GteGL4Texture1Array.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 length = texture->GetDimension(0);
28  auto const numItems = texture->GetNumItems();
30 
31  Initialize();
32 
33  // Cannot leave this texture bound.
35 
36  // Create a staging texture if requested.
37  CreateStaging();
38 }
39 
40 std::shared_ptr<GEObject> GL4Texture1Array::Create(void*, GraphicsObject const* object)
41 {
42  if (object->GetType() == GT_TEXTURE1_ARRAY)
43  {
44  return std::make_shared<GL4Texture1Array>(
45  static_cast<Texture1Array const*>(object));
46  }
47 
48  LogError("Invalid object type.");
49  return nullptr;
50 }
51 
53 {
54  auto texture = GetTexture();
55 
56  return texture && texture->HasMipmaps() && texture->WantAutogenerateMipmaps();
57 }
58 
59 void GL4Texture1Array::LoadTextureLevel(unsigned int item, unsigned int level, void const* data)
60 {
61  auto texture = GetTexture();
62  if (texture && level < texture->GetNumLevels())
63  {
64  auto const length = texture->GetDimensionFor(level, 0);
65 
66  // For Texture1Array, use the 2D calls where the slice (or item) is
67  // the second dimension. Only updating one slice for the specified
68  // level.
69  glTexSubImage2D(GL_TEXTURE_1D_ARRAY, level, 0, item, length, 1,
71  }
72 }
Texture1Array * GetTexture() const
void APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
Definition: GteOpenGL.cpp:7626
GLuint mExternalType
Definition: GteGL4Texture.h:39
GLint level
Definition: glcorearb.h:103
GL4Texture1Array(Texture1Array const *textureArray)
virtual bool CanAutoGenerateMipmaps() const override
GraphicsObjectType GetType() const
void APIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
Definition: GteOpenGL.cpp:980
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void APIENTRY glBindTexture(GLenum target, GLuint texture)
Definition: GteOpenGL.cpp:967
GLuint mInternalFormat
Definition: GteGL4Texture.h:37
#define LogError(message)
Definition: GteLogger.h:92
GLboolean * data
Definition: glcorearb.h:126
#define GL_TEXTURE_BINDING_1D_ARRAY
Definition: glcorearb.h:1034
GLuint texture
Definition: glcorearb.h:410
void APIENTRY glGenTextures(GLsizei n, GLuint *textures)
Definition: GteOpenGL.cpp:993
unsigned int GetNumItems() const
Definition: GteTexture.h:95
GT_TEXTURE1_ARRAY
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:790
unsigned int GetDimension(int i) const
Definition: GteTexture.h:110
GLuint mExternalFormat
Definition: GteGL4Texture.h:38
void APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)
Definition: GteOpenGL.cpp:954
GLuint object
Definition: glext.h:6426
virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const *data) override
#define GL_TEXTURE_1D_ARRAY
Definition: glcorearb.h:1030


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