OpenSceneGraph 3.6.5
TextureCubeMap
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_TEXTURECUBEMAP
15#define OSG_TEXTURECUBEMAP 1
16
17#include <osg/Texture>
18
19
20namespace osg {
21
24{
25
26 public :
27
29
32
34
36 virtual int compare(const StateAttribute& rhs) const;
37
38 virtual GLenum getTextureTarget() const { return GL_TEXTURE_CUBE_MAP; }
39
48
50 virtual void setImage(unsigned int face, Image* image);
51
52 template<class T> void setImage(unsigned int face, const ref_ptr<T>& image) { setImage(face, image.get()); }
53
55 virtual Image* getImage(unsigned int face);
56
58 virtual const Image* getImage(unsigned int face) const;
59
61 virtual unsigned int getNumImages() const { return 6; }
62
63
65 virtual bool isDirty(unsigned int contextID) const
66 {
67 return (_images[0].valid() && _images[0]->getModifiedCount()!=_modifiedCount[0][contextID]) ||
68 (_images[1].valid() && _images[1]->getModifiedCount()!=_modifiedCount[1][contextID]) ||
69 (_images[2].valid() && _images[2]->getModifiedCount()!=_modifiedCount[2][contextID]) ||
70 (_images[3].valid() && _images[3]->getModifiedCount()!=_modifiedCount[3][contextID]) ||
71 (_images[4].valid() && _images[4]->getModifiedCount()!=_modifiedCount[4][contextID]) ||
72 (_images[5].valid() && _images[5]->getModifiedCount()!=_modifiedCount[5][contextID]);
73 }
74
75 inline unsigned int& getModifiedCount(unsigned int face,unsigned int contextID) const
76 {
77 // get the modified count for the current contextID.
78 return _modifiedCount[face][contextID];
79 }
80
84 inline void setTextureSize(int width, int height) const
85 {
86 _textureWidth = width;
87 _textureHeight = height;
88 }
89
90 void setTextureWidth(int width) { _textureWidth=width; }
91 void setTextureHeight(int height) { _textureHeight=height; }
92
93 virtual int getTextureWidth() const { return _textureWidth; }
94 virtual int getTextureHeight() const { return _textureHeight; }
95 virtual int getTextureDepth() const { return 1; }
96
98 {
99 public:
100 virtual void load(const TextureCubeMap& texture,State& state) const = 0;
101 virtual void subload(const TextureCubeMap& texture,State& state) const = 0;
102 };
103
105
107
108 const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
109
110
114 void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
115
117 unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
118
126 void copyTexSubImageCubeMap(State& state, int face, int xoffset, int yoffset, int x, int y, int width, int height );
127
128
132 virtual void apply(State& state) const;
133
134 protected :
135
137
138 bool imagesValid() const;
139
140 virtual void computeInternalFormat() const;
141 void allocateMipmap(State& state) const;
142
144
145 // subloaded images can have different texture and image sizes.
147
148 // number of mip map levels the texture has been created with,
149 mutable GLsizei _numMipmapLevels;
150
152
155};
156
157}
158
159#endif
#define GL_TEXTURE_CUBE_MAP
Definition Texture:193
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Implements a simple buffered value for values that need to be buffered on a per graphics context basi...
Definition buffered_value:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Image class for encapsulating the storage texture image data.
Definition Image:179
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Base class for state attributes.
Definition StateAttribute:77
@ TEXTURE
Definition StateAttribute:125
SubloadCallback * getSubloadCallback()
Definition TextureCubeMap:106
unsigned int & getModifiedCount(unsigned int face, unsigned int contextID) const
Definition TextureCubeMap:75
virtual int compare(const StateAttribute &rhs) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
virtual unsigned int getNumImages() const
Get the number of images that can be assigned to the Texture.
Definition TextureCubeMap:61
unsigned int getNumMipmapLevels() const
Get the number of mip map levels the texture has been created with.
Definition TextureCubeMap:117
ImageModifiedCount _modifiedCount[6]
Definition TextureCubeMap:154
void setTextureHeight(int height)
Definition TextureCubeMap:91
virtual int getTextureDepth() const
Definition TextureCubeMap:95
void setTextureSize(int width, int height) const
Set the texture width and height.
Definition TextureCubeMap:84
virtual void setImage(unsigned int face, Image *image)
Set the texture image for specified face.
const SubloadCallback * getSubloadCallback() const
Definition TextureCubeMap:108
virtual void apply(State &state) const
On first apply (unless already compiled), create the mipmapped texture and bind it.
bool imagesValid() const
void setNumMipmapLevels(unsigned int num) const
Set the number of mip map levels the texture has been created with.
Definition TextureCubeMap:114
GLsizei _textureHeight
Definition TextureCubeMap:146
GLsizei _numMipmapLevels
Definition TextureCubeMap:149
virtual int getTextureHeight() const
Definition TextureCubeMap:94
TextureCubeMap(const TextureCubeMap &cm, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
ref_ptr< SubloadCallback > _subloadCallback
Definition TextureCubeMap:151
void allocateMipmap(State &state) const
Allocate mipmap levels of the texture by subsequent calling of glTexImage* function.
void setSubloadCallback(SubloadCallback *cb)
Definition TextureCubeMap:104
virtual void computeInternalFormat() const
void copyTexSubImageCubeMap(State &state, int face, int xoffset, int yoffset, int x, int y, int width, int height)
Copies a two-dimensional texture subimage, as per glCopyTexSubImage2D.
GLsizei _textureWidth
Definition TextureCubeMap:146
virtual GLenum getTextureTarget() const
Definition TextureCubeMap:38
virtual ~TextureCubeMap()
META_StateAttribute(osg, TextureCubeMap, TEXTURE)
virtual bool isDirty(unsigned int contextID) const
return true if the texture image data has been modified and the associated GL texture object needs to...
Definition TextureCubeMap:65
virtual int getTextureWidth() const
Definition TextureCubeMap:93
Face
Definition TextureCubeMap:40
@ POSITIVE_X
Definition TextureCubeMap:41
@ NEGATIVE_Y
Definition TextureCubeMap:44
@ POSITIVE_Y
Definition TextureCubeMap:43
@ NEGATIVE_X
Definition TextureCubeMap:42
@ POSITIVE_Z
Definition TextureCubeMap:45
@ NEGATIVE_Z
Definition TextureCubeMap:46
ref_ptr< Image > _images[6]
Definition TextureCubeMap:143
virtual const Image * getImage(unsigned int face) const
Get the const texture image for specified face.
virtual Image * getImage(unsigned int face)
Get the texture image for specified face.
void setTextureWidth(int width)
Definition TextureCubeMap:90
void setImage(unsigned int face, const ref_ptr< T > &image)
Definition TextureCubeMap:52
buffered_value< unsigned int > ImageModifiedCount
Definition TextureCubeMap:153
Definition TextureCubeMap:98
virtual void subload(const TextureCubeMap &texture, State &state) const =0
virtual void load(const TextureCubeMap &texture, State &state) const =0
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.