GteGL4Texture2Array.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
9 #include <LowLevel/GteLogger.h>
11 using namespace gte;
12 
14 {
16 }
17 
19  :
21 {
22  // Create a texture structure.
25 
26  // Allocate (immutable) texture storage for all levels.
27  auto const width = texture->GetDimension(0);
28  auto const height = texture->GetDimension(1);
29  auto const numItems = texture->GetNumItems();
31 
32  Initialize();
33 
34  // Cannot leave this texture bound.
36 
37  // Create a staging texture if requested.
38  CreateStaging();
39 }
40 
41 std::shared_ptr<GEObject> GL4Texture2Array::Create(void*, GraphicsObject const* object)
42 {
43  if (object->GetType() == GT_TEXTURE2_ARRAY)
44  {
45  return std::make_shared<GL4Texture2Array>(
46  static_cast<Texture2Array const*>(object));
47  }
48 
49  LogError("Invalid object type.");
50  return nullptr;
51 }
52 
54 {
55  auto texture = GetTexture();
56 
57  return texture && texture->HasMipmaps() && texture->WantAutogenerateMipmaps();
58 }
59 
60 void GL4Texture2Array::LoadTextureLevel(unsigned int item, unsigned int level, void const* data)
61 {
62  auto texture = GetTexture();
63  if (texture && level < texture->GetNumLevels())
64  {
65  auto const width = texture->GetDimensionFor(level, 0);
66  auto const height = texture->GetDimensionFor(level, 1);
67 
68  // For Texture2Array, use the 3D calls where the slice (or item) is the third dimension.
69  // Only updating one slice for the specified level.
70  glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, item, width, height, 1,
72  }
73 }
GLint GLsizei width
Definition: glcorearb.h:98
#define GL_TEXTURE_2D_ARRAY
Definition: glcorearb.h:1032
GLuint mExternalType
Definition: GteGL4Texture.h:39
GLint level
Definition: glcorearb.h:103
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
Definition: GteOpenGL.cpp:7639
GraphicsObjectType GetType() const
void APIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
Definition: GteOpenGL.cpp:980
virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const *data) override
void APIENTRY glBindTexture(GLenum target, GLuint texture)
Definition: GteOpenGL.cpp:967
#define GL_TEXTURE_BINDING_2D_ARRAY
Definition: glcorearb.h:1035
void APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels)
Definition: GteOpenGL.cpp:1078
GLuint mInternalFormat
Definition: GteGL4Texture.h:37
#define LogError(message)
Definition: GteLogger.h:92
GT_TEXTURE2_ARRAY
GLboolean * data
Definition: glcorearb.h:126
GLuint texture
Definition: glcorearb.h:410
void APIENTRY glGenTextures(GLsizei n, GLuint *textures)
Definition: GteOpenGL.cpp:993
GLint GLsizei GLsizei height
Definition: glcorearb.h:98
unsigned int GetNumItems() const
Definition: GteTexture.h:95
unsigned int GetDimension(int i) const
Definition: GteTexture.h:110
GLuint mExternalFormat
Definition: GteGL4Texture.h:38
virtual bool CanAutoGenerateMipmaps() const override
GLuint object
Definition: glext.h:6426
Texture2Array * GetTexture() const
GL4Texture2Array(Texture2Array const *texture)


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00