GteGL4TextureArray.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 
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // Abstract base class, a shim to distinguish between single textures and
20  // texture arrays.
21  virtual ~GL4TextureArray();
22 
23  // Member access.
24  inline TextureArray* GetTexture() const;
25 
26  virtual bool Update() override;
27  virtual bool CopyCpuToGpu() override;
28  virtual bool CopyGpuToCpu() override;
29 
30  bool Update(unsigned int item, unsigned int level);
31  bool CopyCpuToGpu(unsigned int item, unsigned int level);
32  bool CopyGpuToCpu(unsigned int item, unsigned int level);
33  void CopyGpuToGpu(GL4TextureArray* target, unsigned int item, unsigned int level)
34  {
35  (void)target;
36  (void)item;
37  (void)level;
38  LogError("Not yet implemented.");
39  }
40 
41  // Returns true if mipmaps need to be generated.
42  virtual bool CanAutoGenerateMipmaps() const = 0;
43 
44  // Generates mipmaps from level 0 -- only if CanAutoGenerateMipmaps() returns true.
45  virtual bool GenerateMipmaps();
46 
47 protected:
48  // No public construction. Derived classes use this constructor.
49  GL4TextureArray(TextureArray const* gtTexture, GLenum target, GLenum targetBinding);
50 
51  // Only call from derived class constructor after texture storage has been allocated.
52  void Initialize();
53 
54  // Called by Update and CopyCpuToGpu.
55  bool DoCopyCpuToGpu(unsigned int item, unsigned int level);
56 
57  // Should be called in constructor when CopyType is any value bu COPY_NONE.
58  void CreateStaging();
59 
60  // This is called to copy the data from the CPU buffer to the GPU
61  // for the specified level. If a pixel unpack buffer is being used
62  // then data needs to be passed as 0 which is used as an offset.
63  virtual void LoadTextureLevel(unsigned int item, unsigned int level, void const* data) = 0;
64 
65  // Conversions from GTEngine values to GL4 values.
66  static GLenum const msCubeFaceTarget[6];
67 
68 private:
69  // Data associated with each mip level
70  GLuint mLevelPixelUnpackBuffer[Texture::MAX_MIPMAP_LEVELS];
71  GLuint mLevelPixelPackBuffer[Texture::MAX_MIPMAP_LEVELS];
72 };
73 
75 {
76  return static_cast<TextureArray*>(mGTObject);
77 }
78 
79 }
unsigned int GLuint
Definition: glcorearb.h:89
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint level
Definition: glcorearb.h:103
GLenum target
Definition: glcorearb.h:1662
unsigned int GLenum
Definition: glcorearb.h:83
#define LogError(message)
Definition: GteLogger.h:92
void CopyGpuToGpu(GL4TextureArray *target, unsigned int item, unsigned int level)
GLboolean * data
Definition: glcorearb.h:126
TextureArray * GetTexture() const
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


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