VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGlTextureWrapper.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 #include <vrvCore/DtFileCache.h>
16 
17 #include <vrvMath/DtVector4.h>
18 
19 #include <atomic>
20 #include <cstdint>
21 #include <memory>
22 #include <string>
23 
24 #include <osg/Texture2D>
25 
26 #include <GL/gl.h>
27 
28 namespace makVrv
29 {
30  class DtDe;
31  class DtGpuArena;
32  class DtMipmapGenerateOp;
47  {
48  public:
50  explicit DtGlTextureWrapper( DtDe& de );
51 
53  virtual ~DtGlTextureWrapper();
54 
55  DtGlTextureWrapper() = delete;
56  DtGlTextureWrapper( const DtGlTextureWrapper& ) = delete;
57  DtGlTextureWrapper& operator=( const DtGlTextureWrapper& ) = delete;
58 
59 
60  // -----------------------------------------------------------------------
61 
63  virtual bool loadTextureFromFile( const std::string& fileName ) override;
64 
66  virtual bool loadTextureFromFile( const std::string& fileName,
67  const DtFileCache::LoadFileOptions& loadFileOptions ) override;
68 
75  virtual bool allocateGpuStorage( const std::string& key, int width, int height ) override;
76 
79  virtual void setCpuBackingBuffer( const uint8_t* pixels ) override;
80 
84  virtual bool markCpuBackingBufferDirty() override;
85 
96  virtual bool enqueueSubRegion( int x, int y, int width, int height,
97  const uint8_t* rgbaPixels ) override;
98 
100  virtual const std::string& filename() const override;
102  virtual float textureWidth() const override;
103 
105  virtual void scaleTexture( int w, int h ) override;
106 
108  virtual bool getStipplePattern( char** stipplePattern ) override;
109 
111  virtual bool valid() const override;
112 
114  virtual DtVector4<float> color( unsigned int x, unsigned int y ) const override;
115 
116  // -----------------------------------------------------------------------
117  // Additional API
118  // -----------------------------------------------------------------------
119 
122  osg::Texture* texture() const;
123 
125  GLuint glHandle() const;
126 
127  private:
130  std::string myFilename;
131  int myWidth;
132  int myHeight;
133  std::shared_ptr<GLuint> myGlHandle;
134  const uint8_t* myCpuBackingBuffer;
135 
139 
140  std::shared_ptr<std::atomic<bool>> myMipmapDirty;
141  std::unique_ptr<DtMipmapGenerateOp> myMipmapOp;
142  };
143 
147  {
148  public:
152  virtual DtTextureInterface* create( DtDe& de ) override;
153  };
154 }
Definition: DtTextureInterface.h:109
Factory that creates DtGlTextureWrapper instances. Registered by vrvOsg at startup via DtTextureInter...
Definition: DtGlTextureWrapper.h:146
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
const char * filename
Definition: ioapi.h:38
int myWidth
Texture width in pixels.
Definition: DtGlTextureWrapper.h:131
DtTextureInterface implementation that owns a raw GLuint texture handle.
Definition: DtGlTextureWrapper.h:46
std::unique_ptr< DtMipmapGenerateOp > myMipmapOp
Persistent mipmap-gen op; registered on the arena.
Definition: DtGlTextureWrapper.h:141
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
Interface for a texture. Used to pass in a texture to vrvGraphics.
Definition: DtTextureInterface.h:26
DtDe & myDe
Engine context; not owned.
Definition: DtGlTextureWrapper.h:128
4 dimensional vector
Contains makVrv::DtTextureInterface class.
std::shared_ptr< std::atomic< bool > > myMipmapDirty
Shared dirty flag for deferred mipmap generation.
Definition: DtGlTextureWrapper.h:140
Contains makVrv::DtFileCache class.
const uint8_t * myCpuBackingBuffer
Non-owning pointer to the CPU pixel mirror; may be null.
Definition: DtGlTextureWrapper.h:134
osg::ref_ptr< osg::Texture2D > myOsgTexture
Scenegraph face. Declared as osg::Texture2D* here; the concrete type (DtGlOwnedTexture2D) is private ...
Definition: DtGlTextureWrapper.h:138
Definition: DtFileCache.h:45
Top-level pre-draw osg::Operation registered on the OSG viewer that coordinates all GPU work requirin...
Definition: DtGpuArena.h:79
std::string myFilename
Logical key set by allocateGpuStorage().
Definition: DtGlTextureWrapper.h:130
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
int myHeight
Texture height in pixels.
Definition: DtGlTextureWrapper.h:132
std::shared_ptr< GLuint > myGlHandle
Shared GL texture name; zero-initialised until the allocation op runs.
Definition: DtGlTextureWrapper.h:133
DtGpuArena * myGpuArena
GPU arena; not owned.
Definition: DtGlTextureWrapper.h:129

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)