GteTextureCubeArray.h
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 #pragma once
9 
11 
12 namespace gte
13 {
14 
16 {
17 public:
18  // Construction. Cube maps must be square; the 'length' parameter is the
19  // shared value for width and height of a face. The 'numCubes' is the
20  // number of 6-tuples of cube maps.
21  TextureCubeArray(unsigned int numCubes, DFType format, unsigned int length,
22  bool hasMipmaps = false, bool createStorage = true);
23 
24  // Member access.
25  unsigned int GetNumCubes() const;
26 
27  // The texture width and height are the same value.
28  unsigned int GetLength() const;
29 
30  // Faces for all the of the cubes are stored contiguously in one large array so
31  // GetNumItems() will return a number that is the same as 6*GetNumCubes().
32  // These methods allow mapping between the array itemIndex and the corresponding
33  // (cubeIndex, faceIndex) pair.
34  inline unsigned int GetItemIndexFor(unsigned int cube, unsigned int face) const;
35  inline unsigned int GetCubeIndexFor(unsigned int item) const;
36  inline unsigned int GetFaceIndexFor(unsigned int item) const;
37 
38  // Mipmap information.
39  inline unsigned int GetOffsetFor(unsigned int cube, unsigned int face, unsigned int level) const;
40  inline char const* GetDataFor(unsigned int cube, unsigned int face, unsigned int level) const;
41  inline char* GetDataFor(unsigned int cube, unsigned int face, unsigned int level);
42  template <typename T> inline T const* GetFor(unsigned int cube, unsigned int face, unsigned int level) const;
43  template <typename T> inline T* GetFor(unsigned int cube, unsigned int face, unsigned int level);
44 
45  // Subresource indexing: index = numLevels*item + level
46  // where item = cube*6 + face
47  inline unsigned int GetIndex(unsigned int cube, unsigned int face, unsigned int level) const;
48 
49 private:
50  unsigned int mNumCubes;
51 };
52 
53 inline unsigned int TextureCubeArray::GetItemIndexFor(unsigned int cube, unsigned int face) const
54 {
55  return cube * 6 + face;
56 }
57 
58 inline unsigned int TextureCubeArray::GetCubeIndexFor(unsigned int item) const
59 {
60  return item / 6;
61 }
62 
63 inline unsigned int TextureCubeArray::GetFaceIndexFor(unsigned int item) const
64 {
65  return item % 6;
66 }
67 
68 inline unsigned int TextureCubeArray::GetOffsetFor(unsigned int cube, unsigned int face, unsigned int level) const
69 {
70  return TextureArray::GetOffsetFor(GetItemIndexFor(cube, face), level);
71 }
72 
73 inline char const* TextureCubeArray::GetDataFor(unsigned int cube, unsigned int face, unsigned int level) const
74 {
75  return TextureArray::GetDataFor(GetItemIndexFor(cube, face), level);
76 }
77 
78 inline char* TextureCubeArray::GetDataFor(unsigned int cube, unsigned int face, unsigned int level)
79 {
80  return TextureArray::GetDataFor(GetItemIndexFor(cube, face), level);
81 }
82 
83 template <typename T> inline T
84 const* TextureCubeArray::GetFor(unsigned int cube, unsigned int face, unsigned int level) const
85 {
86  return TextureArray::GetFor<T>(GetItemIndexFor(cube, face), level);
87 }
88 
89 template <typename T> inline
90 T* TextureCubeArray::GetFor(unsigned int cube, unsigned int face, unsigned int level)
91 {
92  return TextureArray::GetFor<T>(GetItemIndexFor(cube, face), level);
93 }
94 
95 }
GLint level
Definition: glcorearb.h:103
T const * GetFor(unsigned int cube, unsigned int face, unsigned int level) const
char const * GetDataFor(unsigned int cube, unsigned int face, unsigned int level) const
char const * GetDataFor(unsigned int item, unsigned int level) const
unsigned int GetCubeIndexFor(unsigned int item) const
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:103
unsigned int GetOffsetFor(unsigned int cube, unsigned int face, unsigned int level) const
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:790
unsigned int GetOffsetFor(unsigned int item, unsigned int level) const
unsigned int GetItemIndexFor(unsigned int cube, unsigned int face) const
unsigned int GetFaceIndexFor(unsigned int item) const
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
GLenum GLuint GLint GLenum face
Definition: glext.h:3311


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