GteGL4TextureSingle.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 #include <LowLevel/GteLogger.h>
13 
14 namespace gte
15 {
16 
18 {
19 public:
20  // Abstract base class, a shim to distinguish between single textures and
21  // texture arrays.
22  virtual ~GL4TextureSingle();
23 
24  // Member access.
25  inline TextureSingle* GetTexture() const;
26 
27  virtual bool Update() override;
28  virtual bool CopyCpuToGpu() override;
29  virtual bool CopyGpuToCpu() override;
30 
31  bool Update(unsigned int level);
32  bool CopyCpuToGpu(unsigned int level);
33  bool CopyGpuToCpu(unsigned int level);
34  void CopyGpuToGpu(GL4TextureSingle* texture, unsigned int level)
35  {
36  (void)texture;
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  GL4TextureSingle(TextureSingle 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 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 level, void const* data) = 0;
64 
65 private:
66  // Data associated with each mip level
67  GLuint mLevelPixelUnpackBuffer[Texture::MAX_MIPMAP_LEVELS];
68  GLuint mLevelPixelPackBuffer[Texture::MAX_MIPMAP_LEVELS];
69 };
70 
72 {
73  return static_cast<TextureSingle*>(mGTObject);
74 }
75 
76 }
unsigned int GLuint
Definition: glcorearb.h:89
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint level
Definition: glcorearb.h:103
void CopyGpuToGpu(GL4TextureSingle *texture, unsigned int level)
GLenum target
Definition: glcorearb.h:1662
unsigned int GLenum
Definition: glcorearb.h:83
#define LogError(message)
Definition: GteLogger.h:92
GLboolean * data
Definition: glcorearb.h:126
GLuint texture
Definition: glcorearb.h:410
TextureSingle * 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