![]() |
VR-Forces Developer's Guide
|
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:

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 |
|
explicit |
Construct with the engine context.
|
virtual |
Destroys the wrapper and releases the owned GL texture handle (if allocated).
|
delete |
|
delete |
|
delete |
|
overridevirtual |
Not supported — DtGlTextureWrapper does not load from files. Always returns false.
Implements makVrv::DtTextureInterface.
|
overridevirtual |
Not supported — DtGlTextureWrapper does not load from files. Always returns false.
Implements makVrv::DtTextureInterface.
|
overridevirtual |
Allocates uninitialised GPU texture storage of the given dimensions. Queues a one-time DtGpuArena op that calls glGenTextures + glTexImage2D(nullptr).
| key | Logical name stored as filename(). |
| width | Texture width in pixels. |
| height | Texture height in pixels. |
Reimplemented from makVrv::DtTextureInterface.
|
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.
|
overridevirtual |
Queue the CPU pixel buffer for upload on the next render frame. Requires that allocateGpuStorage() and setCpuBackingBuffer() have been called.
Reimplemented from makVrv::DtTextureInterface.
|
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.
| x | Left pixel offset of the region. |
| y | Top pixel offset of the region (row 0 = visual top). |
| width | Width of the region in pixels. |
| height | Height of the region in pixels. |
| rgbaPixels | Pointer to width * height * 4 bytes of RGBA data. Copied immediately. |
Reimplemented from makVrv::DtTextureInterface.
|
overridevirtual |
Implements makVrv::DtTextureInterface.
|
overridevirtual |
Implements makVrv::DtTextureInterface.
Not supported for GL-backed textures. No-op.
Implements makVrv::DtTextureInterface.
|
overridevirtual |
Not supported for GL-backed textures (no osg::Image). Always returns false.
Implements makVrv::DtTextureInterface.
|
overridevirtual |
Returns true once the allocation op has run and myGlHandle is non-zero.
Implements makVrv::DtTextureInterface.
|
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.
|
private |
Engine context; not owned.
|
private |
GPU arena; not owned.
|
private |
Logical key set by allocateGpuStorage().
|
private |
Texture width in pixels.
|
private |
Texture height in pixels.
|
private |
Shared GL texture name; zero-initialised until the allocation op runs.
|
private |
Non-owning pointer to the CPU pixel mirror; may be null.
|
private |
Scenegraph face. Declared as osg::Texture2D* here; the concrete type (DtGlOwnedTexture2D) is private to the .cxx to avoid leaking OSG internals.
|
private |
Shared dirty flag for deferred mipmap generation.
|
private |
Persistent mipmap-gen op; registered on the arena.