GteGL4Texture3.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 depth = texture->GetDimension(2);
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> GL4Texture3::Create(void*, GraphicsObject const* object)
42 {
43  if (object->GetType() == GT_TEXTURE3)
44  {
45  return std::make_shared<GL4Texture3>(
46  static_cast<Texture3 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 GL4Texture3::LoadTextureLevel(unsigned int level, void const* data)
61 {
62  auto texture = GetTexture();
63  if (texture && level < texture->GetNumLevels())
64  {
65  auto width = texture->GetDimensionFor(level, 0);
66  auto height = texture->GetDimensionFor(level, 1);
67  auto depth = texture->GetDimensionFor(level, 2);
68 
69  glTexSubImage3D(GL_TEXTURE_3D, level, 0, 0, 0, width, height, depth,
71  }
72 }
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
GLint GLsizei width
Definition: glcorearb.h:98
GL4Texture3(Texture3 const *texture)
#define GL_TEXTURE_3D
Definition: glcorearb.h:444
GLuint mExternalType
Definition: GteGL4Texture.h:39
GLint level
Definition: glcorearb.h:103
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
#define GL_TEXTURE_BINDING_3D
Definition: glcorearb.h:439
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:471
void APIENTRY glBindTexture(GLenum target, GLuint texture)
Definition: GteOpenGL.cpp:967
Texture3 * GetTexture() const
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
GLboolean * data
Definition: glcorearb.h:126
virtual void LoadTextureLevel(unsigned int level, void const *data) override
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 GetDimension(int i) const
Definition: GteTexture.h:110
virtual bool CanAutoGenerateMipmaps() const override
GLuint mExternalFormat
Definition: GteGL4Texture.h:38
GT_TEXTURE3
GLuint object
Definition: glext.h:6426
virtual ~GL4Texture3()


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