VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
makVrv::DtGlTextureWrapper Class Reference

DtTextureInterface implementation that owns a raw GLuint texture handle.

The wrapper owns the GLuint for its lifetime; the associated osg::Texture2D is a binding-only scenegraph face and never receives pixel data through OSG. All GPU uploads are enqueued through DtGpuArena, which bypasses OSG's State attribute-caching layer. Use glHandle() to access the raw name and texture() to attach the face to an OSG StateSet.

Typical usage:

  1. allocateGpuStorage(key, width, height) – queues glGenTextures + glTexImage2D(nullptr)
  2. setCpuBackingBuffer(pixels) – stores non-owning pointer to CPU mirror
  3. markCpuBackingBufferDirty() – queues glTexImage2D(pixels) for next pre-draw
  4. texture() – returns osg::Texture2D for stateset attachment
Inheritance diagram for makVrv::DtGlTextureWrapper:
Inheritance graph
[legend]

Public Member Functions

 DtGlTextureWrapper (DtDe &de)
 
virtual ~DtGlTextureWrapper ()
 
 DtGlTextureWrapper ()=delete
 
 DtGlTextureWrapper (const DtGlTextureWrapper &)=delete
 
DtGlTextureWrapper & operator= (const DtGlTextureWrapper &)=delete
 
virtual bool loadTextureFromFile (const std::string &fileName) override
 
virtual bool loadTextureFromFile (const std::string &fileName, const DtFileCache::LoadFileOptions &loadFileOptions) override
 
virtual bool allocateGpuStorage (const std::string &key, int width, int height) override
 
virtual void setCpuBackingBuffer (const uint8_t *pixels) override
 
virtual bool markCpuBackingBufferDirty () override
 
virtual bool enqueueSubRegion (int x, int y, int width, int height, const uint8_t *rgbaPixels) override
 
virtual const std::string & filename () const override
 
virtual float textureWidth () const override
 
virtual void scaleTexture (int w, int h) override
 
virtual bool getStipplePattern (char **stipplePattern) override
 
virtual bool valid () const override
 
virtual DtVector4< float > color (unsigned int x, unsigned int y) const override
 
osg::Texture * texture () const
 
GLuint glHandle () const
 
- Public Member Functions inherited from makVrv::DtTextureInterface
 DtTextureInterface ()
 
virtual ~DtTextureInterface ()
 
 DtTextureInterface (const DtTextureInterface &)=delete
 
DtTextureInterface & operator= (const DtTextureInterface &)=delete
 

Private Attributes

DtDe & myDe
 
DtGpuArena * myGpuArena
 
std::string myFilename
 
int myWidth
 
int myHeight
 
std::shared_ptr< GLuint > myGlHandle
 
const uint8_t * myCpuBackingBuffer
 
osg::ref_ptr< osg::Texture2D > myOsgTexture
 
std::shared_ptr< std::atomic
< bool > > 
myMipmapDirty
 
std::unique_ptr
< DtMipmapGenerateOp > 
myMipmapOp
 

Constructor & Destructor Documentation

makVrv::DtGlTextureWrapper::DtGlTextureWrapper ( DtDe &  de)
explicit

Construct with the engine context.

virtual makVrv::DtGlTextureWrapper::~DtGlTextureWrapper ( )
virtual

Destroys the wrapper and releases the owned GL texture handle (if allocated).

makVrv::DtGlTextureWrapper::DtGlTextureWrapper ( )
delete
makVrv::DtGlTextureWrapper::DtGlTextureWrapper ( const DtGlTextureWrapper &  )
delete

Member Function Documentation

DtGlTextureWrapper& makVrv::DtGlTextureWrapper::operator= ( const DtGlTextureWrapper &  )
delete
virtual bool makVrv::DtGlTextureWrapper::loadTextureFromFile ( const std::string &  fileName)
overridevirtual

Not supported — DtGlTextureWrapper does not load from files. Always returns false.

Implements makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::loadTextureFromFile ( const std::string &  fileName,
const DtFileCache::LoadFileOptions &  loadFileOptions 
)
overridevirtual

Not supported — DtGlTextureWrapper does not load from files. Always returns false.

Implements makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::allocateGpuStorage ( const std::string &  key,
int  width,
int  height 
)
overridevirtual

Allocates uninitialised GPU texture storage of the given dimensions. Queues a one-time DtGpuArena op that calls glGenTextures + glTexImage2D(nullptr).

Parameters
keyLogical name stored as filename().
widthTexture width in pixels.
heightTexture height in pixels.
Returns
True if the op was queued (always true when gpuArena() is available).

Reimplemented from makVrv::DtTextureInterface.

virtual void makVrv::DtGlTextureWrapper::setCpuBackingBuffer ( const uint8_t *  pixels)
overridevirtual

Attach a CPU pixel buffer. Caller retains ownership; pointer must remain valid for the lifetime of this texture. No-op if already set.

Reimplemented from makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::markCpuBackingBufferDirty ( )
overridevirtual

Queue the CPU pixel buffer for upload on the next render frame. Requires that allocateGpuStorage() and setCpuBackingBuffer() have been called.

Returns
True if the upload op was queued.

Reimplemented from makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::enqueueSubRegion ( int  x,
int  y,
int  width,
int  height,
const uint8_t *  rgbaPixels 
)
overridevirtual

Queue a sub-region upload for the next render frame.

Copies rgbaPixels immediately so the caller may reuse its buffer after return. Requires that allocateGpuStorage() has been called.

Parameters
xLeft pixel offset of the region.
yTop pixel offset of the region (row 0 = visual top).
widthWidth of the region in pixels.
heightHeight of the region in pixels.
rgbaPixelsPointer to width * height * 4 bytes of RGBA data. Copied immediately.
Returns
True if the upload was queued successfully.

Reimplemented from makVrv::DtTextureInterface.

virtual const std::string& makVrv::DtGlTextureWrapper::filename ( ) const
overridevirtual
Returns
The logical key string set by allocateGpuStorage(), or empty if not yet allocated.

Implements makVrv::DtTextureInterface.

virtual float makVrv::DtGlTextureWrapper::textureWidth ( ) const
overridevirtual
Returns
Width of the allocated texture in pixels, or 0 if not yet allocated.

Implements makVrv::DtTextureInterface.

virtual void makVrv::DtGlTextureWrapper::scaleTexture ( int  w,
int  h 
)
overridevirtual

Not supported for GL-backed textures. No-op.

Implements makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::getStipplePattern ( char **  stipplePattern)
overridevirtual

Not supported for GL-backed textures (no osg::Image). Always returns false.

Implements makVrv::DtTextureInterface.

virtual bool makVrv::DtGlTextureWrapper::valid ( ) const
overridevirtual

Returns true once the allocation op has run and myGlHandle is non-zero.

Implements makVrv::DtTextureInterface.

virtual DtVector4<float> makVrv::DtGlTextureWrapper::color ( unsigned int  x,
unsigned int  y 
) const
overridevirtual

Not supported — no CPU-side pixel read-back. Returns {0,0,0,0}.

Implements makVrv::DtTextureInterface.

osg::Texture* makVrv::DtGlTextureWrapper::texture ( ) const

Returns the osg::Texture2D scenegraph face for attachment to a StateSet. The texture binds correctly once the arena has allocated the GL handle.

GLuint makVrv::DtGlTextureWrapper::glHandle ( ) const

Returns the raw GL texture handle. 0 until the allocation op has run.

Member Data Documentation

DtDe& makVrv::DtGlTextureWrapper::myDe
private

Engine context; not owned.

DtGpuArena* makVrv::DtGlTextureWrapper::myGpuArena
private

GPU arena; not owned.

std::string makVrv::DtGlTextureWrapper::myFilename
private

Logical key set by allocateGpuStorage().

int makVrv::DtGlTextureWrapper::myWidth
private

Texture width in pixels.

int makVrv::DtGlTextureWrapper::myHeight
private

Texture height in pixels.

std::shared_ptr<GLuint> makVrv::DtGlTextureWrapper::myGlHandle
private

Shared GL texture name; zero-initialised until the allocation op runs.

const uint8_t* makVrv::DtGlTextureWrapper::myCpuBackingBuffer
private

Non-owning pointer to the CPU pixel mirror; may be null.

osg::ref_ptr<osg::Texture2D> makVrv::DtGlTextureWrapper::myOsgTexture
private

Scenegraph face. Declared as osg::Texture2D* here; the concrete type (DtGlOwnedTexture2D) is private to the .cxx to avoid leaking OSG internals.

std::shared_ptr<std::atomic<bool> > makVrv::DtGlTextureWrapper::myMipmapDirty
private

Shared dirty flag for deferred mipmap generation.

std::unique_ptr<DtMipmapGenerateOp> makVrv::DtGlTextureWrapper::myMipmapOp
private

Persistent mipmap-gen op; registered on the arena.


The documentation for this class was generated from the following file:

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)