VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgTextureWrapper.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 
16 #include <cstdint>
17 #include <vrvCore/DtFileCache.h>
19 
20 #include <osg/Texture>
21 #include <osg/Texture2D>
22 
23 namespace makVrv
24 {
25  class DtOsgFileCache;
28  {
29  public:
31  DtOsgTextureWrapper( DtDe&, osg::Texture* node );
32 
34  virtual ~DtOsgTextureWrapper();
35 
37  DtOsgTextureWrapper() = delete;
38 
40  DtOsgTextureWrapper( const DtOsgTextureWrapper& ) = delete;
41 
43  DtOsgTextureWrapper& operator=( const DtOsgTextureWrapper& ) = delete;
44 
45  public:
49  virtual bool loadTextureFromFile( const std::string& fileName ) override;
50  virtual bool loadTextureFromFile( const std::string& fileName,
51  const DtFileCache::LoadFileOptions& loadFileOptions ) override;
52 
55  virtual void setTexture( const std::string fileName, osg::Texture* texture );
56  virtual osg::Texture* texture() const;
58 
59 
61  virtual bool getStipplePattern(char** stipplePattern) override;
62 
64  virtual bool valid() const override;
65 
66  virtual void releaseGLObjects();
67 
68  virtual void setMinFilter( osg::Texture::FilterMode );
69  virtual osg::Texture::FilterMode minFilter();
70  virtual void setMagFilter( osg::Texture::FilterMode );
71  virtual osg::Texture::FilterMode magFilter();
72  virtual void setWrapModeS( osg::Texture::WrapMode );
73  virtual osg::Texture::WrapMode wrapModeS();
74  virtual void setWrapModeT( osg::Texture::WrapMode );
75  virtual osg::Texture::WrapMode wrapModeT();
76 
80  virtual bool allocateGpuStorage( const std::string& key, int width, int height ) override;
81 
86  virtual void setCpuBackingBuffer( const uint8_t* pixels ) override;
87 
91  virtual bool markCpuBackingBufferDirty() override;
92 
95  unsigned int glHandle( unsigned int contextId = 0 ) const;
96 
99  void imageSize( int& width, int& height ) const;
100 
102  virtual bool loadTexture( const std::string& filename,
103  osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
104  osg::Texture::WrapMode s, osg::Texture::WrapMode t,
105  const DtFileCache::LoadFileOptions& loadFileOptions );
106 
107  virtual float textureWidth() const override;
108  virtual const std::string& filename() const override;
109 
110  virtual void scaleTexture( int w, int h ) override;
111 
113  virtual DtVector4<float> color(unsigned int x, unsigned int y) const override;
114  protected:
117 
118  std::string myFilename;
120  osg::Texture::FilterMode myMinFilter;
122  osg::Texture::FilterMode myMagFilter;
124  osg::Texture::WrapMode myWrapModeS;
126  osg::Texture::WrapMode myWrapModeT;
127 
129 
131 
132  private:
140  {
141  public:
145  CpuBufferLoadCallback( int width, int height );
146 
150  void setCpuBackingBuffer( const uint8_t* pixels );
151 
154  virtual bool textureObjectValid( const osg::Texture2D& texture, osg::State& state ) const override;
155 
158  virtual void load( const osg::Texture2D& texture, osg::State& state ) const override;
159 
163  virtual void subload( const osg::Texture2D& texture, osg::State& state ) const override;
164 
165  private:
166  int myWidth;
167  int myHeight;
168  const uint8_t* myCpuBackingBuffer;
169  };
170 
172  };
173 
176  {
177  // Override to create a DtOsgTextureWrapper
178  virtual DtTextureInterface* create( DtDe& de ) override;
179  };
180 }
int myHeight
Definition: DtOsgTextureWrapper.h:167
Definition: DtTextureInterface.h:109
osg::ref_ptr< CpuBufferLoadCallback > myLoadCallback
Definition: DtOsgTextureWrapper.h:171
DtOsgFileCache * myOsgFileCache
Definition: DtOsgTextureWrapper.h:116
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
const char * filename
Definition: ioapi.h:38
Private callback class that uploads a CPU-backed pixel buffer to the GPU via glTexImage2D when trigge...
Definition: DtOsgTextureWrapper.h:139
Interface for a texture. Used to pass in a texture to vrvGraphics.
Definition: DtTextureInterface.h:26
osg::Texture::FilterMode myMagFilter
Default LINEAR.
Definition: DtOsgTextureWrapper.h:122
Contains makVrv::DtTextureInterface class.
Contains makVrv::DtFileCache class.
The OSG implementation of makVrv::DtOsgFileCache. This will cache files as .ive&#39;s for quicker load ti...
Definition: DtOsgFileCache.h:56
Factory that creates DtOsgTextureWrapper instances via the DtTextureInterfaceCreator plugin mechanism...
Definition: DtOsgTextureWrapper.h:175
DtDe & myDe
Definition: DtOsgTextureWrapper.h:115
osg::ref_ptr< osg::Texture > myTexture
Definition: DtOsgTextureWrapper.h:128
DtSignalConnectionManager myConnectionManager
Definition: DtOsgTextureWrapper.h:130
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
Definition: DtFileCache.h:45
int myWidth
Definition: DtOsgTextureWrapper.h:166
Interface for a texture. Used to pass in a texture to vrvGraphics.
Definition: DtOsgTextureWrapper.h:27
osg::Texture::FilterMode myMinFilter
Default NEAREST.
Definition: DtOsgTextureWrapper.h:120
Base class to provide boost signal/slot management.
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
const uint8_t * myCpuBackingBuffer
Definition: DtOsgTextureWrapper.h:168
osg::Texture::WrapMode myWrapModeT
Default REPEAT.
Definition: DtOsgTextureWrapper.h:126
std::string myFilename
Definition: DtOsgTextureWrapper.h:118
osg::Texture::WrapMode myWrapModeS
Default REPEAT.
Definition: DtOsgTextureWrapper.h:124

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)