Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoGLImage.h
1#ifndef COIN_SOGLIMAGE_H
2#define COIN_SOGLIMAGE_H
3
4/**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25\**************************************************************************/
26
27// WARNING: This is work in progress. Do not expect this class to have
28// a stable interface over a long period of time. It is installed
29// because we need it in an internal project.
30
31// FIXME: make sure we do a design review for this class for Coin v3.0
32// pederb, 2001-11-28
33
34#include <Inventor/SbBasic.h>
35#include <Inventor/SbVec2s.h>
36#include <Inventor/SbVec3s.h>
37#include <Inventor/SoType.h>
38#include <stddef.h>
39
40class SoGLDisplayList;
41class SoState;
42class SbImage;
43
44class COIN_DLL_API SoGLImage {
45public:
46
47 SoGLImage();
48 virtual void unref(SoState * state = NULL);
49
50 static SoType getClassTypeId(void);
51 virtual SoType getTypeId(void) const ;
52 virtual SbBool isOfType(SoType type) const;
53
54 enum Wrap {
55 REPEAT = 0,
56 CLAMP,
57 CLAMP_TO_EDGE,
58 CLAMP_TO_BORDER
59 };
60
62 IMAGE = 0,
63 SUBIMAGE,
64 MIPMAP
65 };
66
67 typedef SbBool SoGLImageResizeCB(SoState * state,
68 const SbVec3s &newsize,
69 unsigned char * destbuffer,
70 ResizeReason reason,
71 void * closure,
72 class SoGLImage * image);
73
74 void setGLDisplayList(SoGLDisplayList * dl,
75 SoState * state,
76 const Wrap wraps = REPEAT,
77 const Wrap wrapt = REPEAT,
78 const float quality = 0.5f);
79
80 void setPBuffer(SoState * state,
81 void * context,
82 const Wrap wraps = REPEAT,
83 const Wrap wrapt = REPEAT,
84 const float quality = 0.5f);
85
86 void setData(const unsigned char * bytes,
87 const SbVec2s & size,
88 const int numcomponents,
89 const Wrap wraps = REPEAT,
90 const Wrap wrapt = REPEAT,
91 const float quality = 0.5f,
92 const int border = 0,
93 SoState * createinstate = NULL);
94
95 void setData(const unsigned char * bytes,
96 const SbVec3s & size,
97 const int numcomponents,
98 const Wrap wraps = REPEAT,
99 const Wrap wrapt = REPEAT,
100 const Wrap wrapr = REPEAT,
101 const float quality = 0.5f,
102 const int border = 0,
103 SoState * createinstate = NULL);
104
105 virtual void setData(const SbImage * image,
106 const Wrap wraps = REPEAT,
107 const Wrap wrapt = REPEAT,
108 const float quality = 0.5f,
109 const int border = 0,
110 SoState * createinstate = NULL);
111
112 virtual void setData(const SbImage * image,
113 const Wrap wraps,
114 const Wrap wrapt,
115 const Wrap wrapr,
116 const float quality = 0.5f,
117 const int border = 0,
118 SoState * createinstate = NULL);
119
120 // these flags can be used to set texture properties.
121 enum Flags {
122 // mipmap, scaling and filtering settings
123 SCALE_DOWN = 0x0001,
124 NO_MIPMAP = 0x0002,
125 LINEAR_MAG_FILTER = 0x0004,
126 LINEAR_MIN_FILTER = 0x0008,
127 LINEAR_MIPMAP_FILTER = 0x0010,
128
129 // use if you know your image properties.
130 FORCE_TRANSPARENCY_TRUE = 0x0020,
131 FORCE_TRANSPARENCY_FALSE = 0x0040,
132 FORCE_ALPHA_TEST_TRUE = 0x0080,
133 FORCE_ALPHA_TEST_FALSE = 0x0100,
134
135 INVINCIBLE = 0x0200, // never die of old age
136
137 // use GL_NV_texture_rectangle or GL_EXT_texture_rectangle
138 RECTANGLE = 0x0400,
139
140 // Compress texture if available from OpenGL
141 COMPRESSED = 0x0800,
142
143 // use quality value to decide mipmap, filtering and scaling. This
144 // is the default.
145 USE_QUALITY_VALUE = 0X8000
146 };
147
148 void setFlags(const uint32_t flags);
149 uint32_t getFlags(void) const;
150
151 const SbImage * getImage(void) const;
152
153 virtual SoGLDisplayList * getGLDisplayList(SoState * state);
154 SbBool hasTransparency(void) const;
155 SbBool useAlphaTest(void) const;
156 Wrap getWrapS(void) const;
157 Wrap getWrapT(void) const;
158 Wrap getWrapR(void) const;
159
160 float getQuality(void) const;
161 uint32_t getGLImageId(void) const;
162
163protected:
164
165 void incAge(void) const;
166 void resetAge(void) const;
167 virtual void unrefOldDL(SoState * state, const uint32_t maxage);
168 virtual ~SoGLImage();
169
170private:
171
172 class SoGLImageP * pimpl;
173 friend class SoGLImageP;
174 static void cleanupClass(void);
175
176public:
177 // internal methods for texture resource management
178 static void beginFrame(SoState * state);
179 static void tagImage(SoState * state, SoGLImage * image);
180 static void endFrame(SoState * state);
181 static void setDisplayListMaxAge(const uint32_t maxage);
182 static void freeAllImages(SoState * state = NULL);
183
184 void setEndFrameCallback(void (*cb)(void *), void * closure);
185 int getNumFramesSinceUsed(void) const;
186
187public:
188 static void initClass(void);
189 static void setResizeCallback(SoGLImageResizeCB * f, void * closure);
190
191private:
192 static void registerImage(SoGLImage * image);
193 static void unregisterImage(SoGLImage * image);
194};
195
196#endif // !COIN_SOGLIMAGE_H
The SbImage class is an abstract datatype for 2D and 3D images.
Definition SbImage.h:37
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:41
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition SbVec3s.h:39
The SoGLDisplayList class stores and manages OpenGL display lists.
Definition SoGLDisplayList.h:34
The SoGLImage class is used to handle OpenGL 2D/3D textures.
Definition SoGLImage.h:44
ResizeReason
Definition SoGLImage.h:61
Flags
Definition SoGLImage.h:121
Wrap
Definition SoGLImage.h:54
SbBool SoGLImageResizeCB(SoState *state, const SbVec3s &newsize, unsigned char *destbuffer, ResizeReason reason, void *closure, class SoGLImage *image)
Definition SoGLImage.h:67
The SoState class manages the Coin scenegraph traversal state data.
Definition SoState.h:35
The SoType class is the basis for the run-time type system in Coin.
Definition SoType.h:50

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Wed Jul 17 2024 for Coin by Doxygen 1.12.0.