SoGLImage(3)
๐ธ NAME ๐ธ
SoGLImage โ the class that handles OpenGL 2D/3D textures. This is a Coin manual page, bestie. ๐
โจ SYNOPSIS โจ
okay so here's the include, exactly:
#include <include/Inventor/misc/SoGLImage.h>
Inherited by SoGLBigImage, and SoGLCubeMapImage.
๐ Public Types ๐
enum Wrapโ{ REPEAT = 0, CLAMP, CLAMP_TO_EDGE, CLAMP_TO_BORDER }enum ResizeReasonโ{ IMAGE = 0, SUBIMAGE, MIPMAP }enum Flagsโ{ SCALE_DOWN = 0x0001, NO_MIPMAP = 0x0002, LINEAR_MAG_FILTER = 0x0004, LINEAR_MIN_FILTER = 0x0008, LINEAR_MIPMAP_FILTER = 0x0010, FORCE_TRANSPARENCY_TRUE = 0x0020, FORCE_TRANSPARENCY_FALSE = 0x0040, FORCE_ALPHA_TEST_TRUE = 0x0080, FORCE_ALPHA_TEST_FALSE = 0x0100, INVINCIBLE = 0x0200, RECTANGLE = 0x0400, COMPRESSED = 0x0800, USE_QUALITY_VALUE = 0X8000 }typedef SbBool SoGLImageResizeCB(SoState *state, const SbVec3s &newsize, unsigned char *destbuffer, ResizeReason reason, void *closure, class SoGLImage *image)โ image resize callback type. Full deets are down below, bestie. ๐
๐ Public Member Functions ๐
here's the whole roster, exact, no cap:
SoGLImage ()
virtual void unref (SoState *state=NULL)
virtual SoType getTypeId (void) const
virtual SbBool isOfType (SoType type) const
void setGLDisplayList (SoGLDisplayList *dl, SoState *state, const Wrap wraps=REPEAT, const Wrap wrapt=REPEAT, const float quality=0.5f)
void setPBuffer (SoState *state, void *context, const Wrap wraps=REPEAT, const Wrap wrapt=REPEAT, const float quality=0.5f)
void setData (const unsigned char *bytes, const SbVec2s &size, const int numcomponents, const Wrap wraps=REPEAT, const Wrap wrapt=REPEAT, const float quality=0.5f, const int border=0, SoState *createinstate=NULL)
void setData (const unsigned char *bytes, const SbVec3s &size, const int numcomponents, const Wrap wraps=REPEAT, const Wrap wrapt=REPEAT, const Wrap wrapr=REPEAT, const float quality=0.5f, const int border=0, SoState *createinstate=NULL)
virtual void setData (const SbImage *image, const Wrap wraps=REPEAT, const Wrap wrapt=REPEAT, const float quality=0.5f, const int border=0, SoState *createinstate=NULL)
virtual void setData (const SbImage *image, const Wrap wraps, const Wrap wrapt, const Wrap wrapr, const float quality=0.5f, const int border=0, SoState *createinstate=NULL)
void setFlags (const uint32_t flags)
uint32_t getFlags (void) const
const SbImage * getImage (void) const
virtual SoGLDisplayList * getGLDisplayList (SoState *state)
SbBool hasTransparency (void) const
SbBool useAlphaTest (void) const
Wrap getWrapS (void) const
Wrap getWrapT (void) const
Wrap getWrapR (void) const
float getQuality (void) const
uint32_t getGLImageId (void) const
void setEndFrameCallback (void(*cb)(void *), void *closure)
int getNumFramesSinceUsed (void) const
๐ Static Public Member Functions ๐
static SoType getClassTypeId (void)
static void beginFrame (SoState *state)
static void tagImage (SoState *state, SoGLImage *image)
static void endFrame (SoState *state)
static void setDisplayListMaxAge (const uint32_t maxage)
static void freeAllImages (SoState *state=NULL)
static void initClass (void)
static void setResizeCallback (SoGLImageResizeCB *f, void *closure)
๐ Protected Member Functions ๐
void incAge (void) const
void resetAge (void) const
virtual void unrefOldDL (SoState *state, const uint32_t maxage)
virtual ~SoGLImage ()
๐ Detailed Description ๐
okay so the tea: SoGLImage is used to handle OpenGL 2D/3D textures. ๐
A number of environment variables can be set to control how textures are created. This is useful to tune Coin to fit your system. E.g. if you are running on a laptop, it might be a good idea to disable linear filtering and mipmaps. ๐ปโจ
COIN_TEX2_LINEAR_LIMITโ Linear filtering is enabled ifComplexity::textureQualityis greater or equal to this value. Default value is0.2. ๐COIN_TEX2_MIPMAP_LIMITโ Mipmaps are created iftextureQualityis greater or equal to this value. Default value is0.5. ๐COIN_TEX2_LINEAR_MIPMAP_LIMITโ Linear filtering between mipmap levels is enabled iftextureQualityis greater or equal to this value. Default value is0.8. โจCOIN_TEX2_SCALEUP_LIMITโ Textures with width or height not equal to a power of two will always be scaled up iftextureQualityis greater or equal to this value. Default value is0.7. IftextureQualityis lower than this value, and the width or height is larger than256pixels, the texture is only scaled up if it is relatively close to the next power of two size. This could save a lot of texture memory. ๐ฅCOIN_TEX2_USE_GLTEXSUBIMAGEโ When set, and when the new texture data have the same attributes as the old data,glTexSubImage()will be used to copy new data into the texture instead of recreating the texture. This is not enabled by default, since it seems to trigger a bug in the Linux nVidia drivers. It just happens in some unreproduceable cases. It could be a bug in ourglTexSubImage()code, of course. :) ๐COIN_TEX2_USE_SGIS_GENERATE_MIPMAPโ When set, use theGL_SGIS_generate_mipmapextension (if available) to generate mipmaps, otherwise use a fast internal routine to generate them. Use ofGL_SGIS_generate_mipmapis not enabled by default since we suspect some ATi drivers have problems with this extension. ๐ญCOIN_ENABLE_CONFORMANT_GL_CLAMPโ When set,GL_CLAMPwill be used whenSoGLImage::CLAMPis specified as the texture wrap mode. By defaultGL_CLAMP_TO_EDGEis used, since this is usually what people want. Seehttp://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007306.htmlfor a discussion regardingGL_CLAMPandGL_CLAMP_TO_EDGE. ๐ฆCOIN_TEX2_ANISOTROPIC_LIMITโ Anisotropic filtering is enabled for textures when the texture quality is higher than this value. Default value is0.85. ๐
๐จ Be aware that this class is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
๐ Member Typedef Documentation ๐
typedef SbBool SoGLImage::SoGLImageResizeCB(...)
typedef SbBool SoGLImage::SoGLImageResizeCB(SoState *state, const SbVec3s
&newsize, unsigned char *destbuffer, ResizeReason reason, void *closure,
class SoGLImage *image)
Image resize callback type. If registered using setResizeCallback(), this function will be called whenever Coin needs to resize an image. The function will be called both for 2D and 3D images. ๐ผ๏ธโจ
stateis the current state at the time of resizing.newsizeis the requested new image size. Note that the z size of a 2D image is0.destbufferis a preallocated buffer big enough to hold the pixels for the resized image. The # of bytes per pixel is the same as for the original image.reasonis a hint about why the image is resized. At the moment, onlyIMAGEis supported.imageis the original image.
Return value: TRUE if the resize has been resized, FALSE if not. If FALSE is returned, Coin will resize the image instead.
๐ฎ Member Enumeration Documentation ๐ฎ
enum SoGLImage::Wrap
Used to specify how texture coordinates < 0.0 and > 1.0 should be handled. It can either be repeated (REPEAT), clamped (CLAMP) or clamped to edge (CLAMP_TO_EDGE), which is useful when tiling textures. Since 2002-11-18, CLAMP will be treated as CLAMP_TO_EDGE. The environment variable COIN_ENABLE_CONFORMANT_GL_CLAMP can be used to override this behaviour.
enum SoGLImage::ResizeReason
Sent as a parameter to SoGLImageResizeCB as a hint to why an image is being resized. IMAGE means that a whole image is being initially resized (e.g. a texture image). SUBIMAGE and MIPMAP are not in use and reserved for future use.
enum SoGLImage::Flags
Can be used to tune/optimize the GL texture handling. Normally the texture quality will be used to decide scaling and filtering, and the image data will be scanned to decide if the image is (partially) transparent, and if the texture can be rendered using the cheaper alpha test instead of blending if it does contain transparency. If you know the contents of your texture image, or if you have special requirements on how the texture should be rendered, you can set the flags using the SoGLImage::setFlags() method.
๐งธ Constructor & Destructor Documentation ๐งธ
SoGLImage::SoGLImage (void )
Constructor. ๐
SoGLImage::~SoGLImage () [protected], [virtual]
Destructor. ๐
๐ Member Function Documentation ๐
okay bestie, this is the big one โ every single method, no skips, no shortcuts. buckle up. ๐
โจ void SoGLImage::unref(SoState * state = NULL) โ virtual
So this class has a private destructor because the devs want you to hand over the current GL state when you're deleting the image. why? so the GL texture objects get freed as soon as possible, no lingering ghosts. if you pass NULL to this method, those GL texture objects won't be deleted until the next time a GLRenderAction is applied in the image's cache context(s). ๐
Reimplemented inSoGLBigImage, andSoGLCubeMapImage.
SoType SoGLImage::getClassTypeId(void) โ static
This static method returns the SoType object associated with objects of this class. that's it, that's the whole vibe. โจ
SoType SoGLImage::getTypeId(void) const โ virtual
Returns the type identification of an object derived from a class inheriting SoGLImage. this is the runtime type checking + "downward" casting girly. ๐
Reimplemented inSoGLBigImage, andSoGLCubeMapImage.
SbBool SoGLImage::isOfType(SoType type) const โ virtual
Returns TRUE if the type of this object is either of the same type or inherited from type. also used for runtime type checking and "downward" casting. ๐โโ๏ธ
void SoGLImage::setGLDisplayList(SoGLDisplayList * dl, SoState * state, const Wrap wraps = REPEAT, const Wrap wrapt = REPEAT, const float quality = 0.5f)
Can be used for creating a custom OpenGL texture inside an SoGLImage instance. iconic behaviour, honestly. ๐
Example use โ and yes bestie, this one creates a depth texture:
SoGLDisplayList * depthmap = new SoGLDisplayList(state, SoGLDisplayList::TEXTURE_OBJECT);
depthmap->ref();
depthmap->open(state);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, //
GL_DEPTH_COMPONENT24 size[0], size[1], 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
depthmap->close(state);
SoGLImage * image = new SoGLImage;
image->setGLDisplayList(depthmap, state);
Since: Coin 2.5 โจ
void SoGLImage::setPBuffer(SoState * state, void * pbuffer, const Wrap wraps = REPEAT, const Wrap wrapt = REPEAT, const float quality = 0.5f)
Sets the pbuffer for this texture. Experimental code, use with care. ๐จ like, don't be shocked if it's a lil chaotic.
void SoGLImage::setData(const unsigned char * bytes, const SbVec2s & size, const int numcomponents, const Wrap wraps = REPEAT, const Wrap wrapt = REPEAT, const float quality = 0.5f, const int border = 0, SoState * createinstate = NULL)
2D setData() wrapper. You supply raw data, size and numcomponents instead of an SbImage. It creates a temporary image, then calls the read setData().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void SoGLImage::setData(const unsigned char * bytes, const SbVec3s & size, const int numcomponents, const Wrap wraps = REPEAT, const Wrap wrapt = REPEAT, const Wrap wrapr = REPEAT, const float quality = 0.5f, const int border = 0, SoState * createinstate = NULL)
3D setData() wrapper. You supply raw data, size and numcomponents instead of an SbImage. It creates a temporary image, then calls the read setData().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void SoGLImage::setData(const SbImage * image, const Wrap wraps = REPEAT, const Wrap wrapt = REPEAT, const float quality = 0.5f, const int border = 0, SoState * createinstate = NULL) โ virtual
Convenience 2D wrapper function around the 3D setData().
Reimplemented inSoGLBigImage, andSoGLCubeMapImage.
void SoGLImage::setData(const SbImage * image, const Wrap wraps, const Wrap wrapt, const Wrap wrapr, const float quality = 0.5f, const int border = 0, SoState * createinstate = NULL) โ virtual
Sets the data for this GL image. Should only be called when one of the parameters have changed, since this will cause the GL texture object to be recreated. Caller is responsible for sending legal wrap values. CLAMP_TO_EDGE is only supported on OpenGL v1.2 implementations, and as an extension on some earlier SGI implementations (GL_SGIS_texture_edge_clamp).
For now, if quality > 0.5 when created, we create mipmaps, otherwise a regular texture is created. Be aware, if you for instance create a texture with texture quality 0.4, and then later try to apply the texture with a texture quality greater than 0.5, the texture object will be recreated as a mipmap texture object. This will happen only once though, of course. ๐
If border != 0, the OpenGL texture will be created with this border size. Be aware that this might be extremely slow on most PC hardware. ๐
Normally, the OpenGL texture object isn't created until the first time it is needed, but if createinstate is != NULL, the texture object is created immediately. This is useful if you use a temporary buffer to hold the texture data. Be careful when using this feature, since the texture data might be needed at a later stage (for instance to create a texture object for another context). It will not be possible to create texture objects for other cache contexts when createinstate is != NULL.
Also if createinstate is supplied, and all the attributes are the same as the current data in the image, glTexSubImage() will be used to insert the image data instead of creating a new texture object. This is much faster on most OpenGL drivers, and is very useful, for instance when doing animated textures. ๐ฅ
If you supply NULL for image, the instance will be reset, causing all display lists and memory to be freed.
Reimplemented inSoGLBigImage, andSoGLCubeMapImage.
void SoGLImage::setFlags(const uint32_t flags)
Sets flags to control how the texture is handled/initialized.
uint32_t SoGLImage::getFlags(void) const
Returns the flags.
See also: setFlags()
const SbImage * SoGLImage::getImage(void) const
Returns a pointer to the image data.
SoGLDisplayList * SoGLImage::getGLDisplayList(SoState * state) โ virtual
Returns or creates a SoGLDisplayList to be used for rendering. Returns NULL if no SoGLDisplayList could be created.
Reimplemented inSoGLBigImage, andSoGLCubeMapImage.
SbBool SoGLImage::hasTransparency(void) const
Returns TRUE if this texture has some pixels with alpha value != 255. ๐
SbBool SoGLImage::useAlphaTest(void) const
Returns TRUE if this image has some alpha value != 255, and all these values are 0. If this is the case, alpha test can be used to render this texture instead of for instance blending, which is usually slower and might yield z-buffer artifacts. ๐ซถ
SoGLImage::Wrap SoGLImage::getWrapS(void) const
Returns the wrap strategy for the S (horizontal) direction.
SoGLImage::Wrap SoGLImage::getWrapT(void) const
Returns the wrap strategy for the T (vertical) direction.
SoGLImage::Wrap SoGLImage::getWrapR(void) const
Returns the wrap strategy for the R (depth) direction.
float SoGLImage::getQuality(void) const
Returns the texture quality for this texture image.
Since: Coin 2.5 โจ
uint32_t SoGLImage::getGLImageId(void) const
Returns an unique id for this GL image. This id can be used to test for changes in an SoGLImage's internal data. ๐
void SoGLImage::unrefOldDL(SoState * state, const uint32_t maxage) โ protected, virtual
Virtual method that will be called once each frame. The method should unref display lists that have an age bigger or equal to maxage, and increment the age for other display lists.
Reimplemented in SoGLBigImage.
void SoGLImage::beginFrame(SoState * state) โ static
When doing texture resource control, call this method before rendering the scene, typically in the viewer's actualRedraw(). state should be your SoGLRenderAction state.
See also:endFrame(),tagImage(),setDisplayListMaxAge()
void SoGLImage::tagImage(SoState * state, SoGLImage * image) โ static
Should be called when a texture image is used. In Coin this is handled by SoGLTextureImageElement, but if you use an SoGLImage on your own, you should call this method to avoid that the display list is deleted too soon. state should be your SoGLRenderAction state, image the image you are about to use/have used.
void SoGLImage::endFrame(SoState * state) โ static
Should be called after your scene is rendered. Old display lists will be deleted when you call this method. state should be your SoGLRenderAction state.
See also:beginFrame(),tagImage(),setDisplayListMaxAge()
void SoGLImage::setDisplayListMaxAge(const uint32_t maxage) โ static
Set the maximum age for a texture object/display list. The age of an image is the number of frames since it has been used. Default maximum age is 60.
void SoGLImage::freeAllImages(SoState * state = NULL) โ static
Free all GL images currently used. This can be used to help the operating system and/or OpenGL driver's resource handling. If you know you're not going to render for a while, maybe you're switching to a different application or something, calling this method could be a good idea since it will release all the texture memory used by your application. ๐งนโจ
void SoGLImage::initClass(void) โ static
This static method initializes static data for the SoGLImage class.
void SoGLImage::setResizeCallback(SoGLImageResizeCB * f, void * closure) โ static
Sets a custom image resize function.
Since: Coin 2.5 โจ
๐ Author ๐
Generated automatically by Doxygen for Coin from the source code. (yes bestie, the robots wrote this one, we just gave it the โจauraโจ)
and that's a wrap on SoGLImage(3), bestie! this page is Version 4.0.10, stamped Thu Jun 25 2026 00:00:00. go forth and texture-slay, no cap. ๐
๐๐ฆ๐
๐ฆ where this page comes from
- fedora 43: Coin4-devel 4.0.10-1.fc43 ยท BSD-3-Clause AND GPL-3.0-or-later
- fedora 43: Coin4-devel 4.0.10-1.fc43 ยท BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 ยท BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 ยท BSD-3-Clause AND GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms