GteGL4TextureCube.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);
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> GL4TextureCube::Create(void*, GraphicsObject const* object)
41 {
42  if (object->GetType() == GT_TEXTURE_CUBE)
43  {
44  return std::make_shared<GL4TextureCube>(
45  static_cast<TextureCube 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 GL4TextureCube::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 width = texture->GetDimension(0);
65  auto const height = texture->GetDimension(1);
66 
67  // Each face in the TextureCube has a unique GL target.
68  GLenum targetFace = msCubeFaceTarget[item];
69 
70  glTexSubImage2D(targetFace, level, 0, 0, width, height,
72  }
73 }
virtual bool CanAutoGenerateMipmaps() const override
GLint GLsizei width
Definition: glcorearb.h:98
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
GraphicsObjectType GetType() const
void APIENTRY glDeleteTextures(GLsizei n, const GLuint *textures)
Definition: GteOpenGL.cpp:980
static GLenum const msCubeFaceTarget[6]
GL4TextureCube(TextureCube const *textureArray)
void APIENTRY glBindTexture(GLenum target, GLuint texture)
Definition: GteOpenGL.cpp:967
#define GL_TEXTURE_BINDING_CUBE_MAP
Definition: glcorearb.h:526
unsigned int GLenum
Definition: glcorearb.h:83
GLuint mInternalFormat
Definition: GteGL4Texture.h:37
#define LogError(message)
Definition: GteLogger.h:92
#define GL_TEXTURE_CUBE_MAP
Definition: glcorearb.h:525
GLboolean * data
Definition: glcorearb.h:126
GT_TEXTURE_CUBE
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
GLuint mExternalFormat
Definition: GteGL4Texture.h:38
virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const *data) override
TextureCube * GetTexture() const
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
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)


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