VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h@ 28739

Last change on this file since 28739 was 27091, checked in by vboxsync, 15 years ago

crOpenGL: add GL_ARB_pixel_buffer_object support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_STATE_TEXTURE_H
8#define CR_STATE_TEXTURE_H
9
10#include "cr_hash.h"
11#include "state/cr_statetypes.h"
12#include "state/cr_limits.h"
13
14#include <iprt/cdefs.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/* Tells state tracker to rely on diff_api to store/load texture images
21 * and avoid host memory allocation.
22 */
23#define CR_STATE_NO_TEXTURE_IMAGE_STORE
24
25#if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
26#error CR_ARB_pixel_buffer_object not supported without CR_STATE_NO_TEXTURE_IMAGE_STORE
27#endif
28
29#define CR_MAX_MIPMAP_LEVELS 20
30
31typedef struct {
32 GLubyte redbits;
33 GLubyte greenbits;
34 GLubyte bluebits;
35 GLubyte alphabits;
36 GLubyte luminancebits;
37 GLubyte intensitybits;
38 GLubyte indexbits;
39} CRTextureFormat;
40
41typedef struct {
42 GLubyte *img;
43 int bytes;
44 GLint width; /* width, height, depth includes the border */
45 GLint height;
46 GLint depth;
47 GLint internalFormat;
48 GLint border;
49 GLenum format;
50 GLenum type;
51 int bytesPerPixel;
52#if CR_ARB_texture_compression
53 GLboolean compressed;
54#endif
55 GLboolean generateMipmap;
56 const CRTextureFormat *texFormat;
57
58 CRbitvalue dirty[CR_MAX_BITARRAY];
59} CRTextureLevel;
60
61typedef struct {
62 GLenum target;
63 GLuint name;
64
65 /* The mipmap levels */
66 CRTextureLevel *level[6]; /* 6 cube faces */
67
68 GLcolorf borderColor;
69 GLenum minFilter, magFilter;
70 GLenum wrapS, wrapT;
71#ifdef CR_OPENGL_VERSION_1_2
72 GLenum wrapR;
73 GLfloat priority;
74 GLfloat minLod;
75 GLfloat maxLod;
76 GLint baseLevel;
77 GLint maxLevel;
78#endif
79#ifdef CR_EXT_texture_filter_anisotropic
80 GLfloat maxAnisotropy;
81#endif
82#ifdef CR_ARB_depth_texture
83 GLenum depthMode;
84#endif
85#ifdef CR_ARB_shadow
86 GLenum compareMode;
87 GLenum compareFunc;
88#endif
89#ifdef CR_ARB_shadow_ambient
90 GLfloat compareFailValue;
91#endif
92#ifdef CR_SGIS_generate_mipmap
93 GLboolean generateMipmap;
94#endif
95 CRbitvalue dirty[CR_MAX_BITARRAY];
96 CRbitvalue imageBit[CR_MAX_BITARRAY];
97 CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
98} CRTextureObj;
99
100typedef struct {
101 CRbitvalue dirty[CR_MAX_BITARRAY];
102 CRbitvalue enable[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
103 CRbitvalue current[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
104 CRbitvalue objGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
105 CRbitvalue eyeGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
106 CRbitvalue genMode[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
107 /* XXX someday create more bits for texture env state */
108 CRbitvalue envBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
109} CRTextureBits;
110
111typedef struct {
112 /* Current texture objects (in terms of glBindTexture and glActiveTexture) */
113 CRTextureObj *currentTexture1D;
114 CRTextureObj *currentTexture2D;
115 CRTextureObj *currentTexture3D;
116#ifdef CR_ARB_texture_cube_map
117 CRTextureObj *currentTextureCubeMap;
118#endif
119#ifdef CR_NV_texture_rectangle
120 CRTextureObj *currentTextureRect;
121#endif
122
123 GLboolean enabled1D;
124 GLboolean enabled2D;
125 GLboolean enabled3D;
126#ifdef CR_ARB_texture_cube_map
127 GLboolean enabledCubeMap;
128#endif
129#ifdef CR_NV_texture_rectangle
130 GLboolean enabledRect;
131#endif
132#ifdef CR_EXT_texture_lod_bias
133 GLfloat lodBias;
134#endif
135
136 GLenum envMode;
137 GLcolorf envColor;
138
139 /* GL_ARB_texture_env_combine */
140 GLenum combineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
141 GLenum combineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
142 GLenum combineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
143 GLenum combineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
144 GLenum combineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
145 GLenum combineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
146 GLfloat combineScaleRGB; /* 1 or 2 or 4 */
147 GLfloat combineScaleA; /* 1 or 2 or 4 */
148
149 GLtexcoordb textureGen;
150 GLvectorf objSCoeff;
151 GLvectorf objTCoeff;
152 GLvectorf objRCoeff;
153 GLvectorf objQCoeff;
154 GLvectorf eyeSCoeff;
155 GLvectorf eyeTCoeff;
156 GLvectorf eyeRCoeff;
157 GLvectorf eyeQCoeff;
158 GLtexcoorde gen;
159
160 /* These are only used for glPush/PopAttrib */
161 CRTextureObj Saved1D;
162 CRTextureObj Saved2D;
163 CRTextureObj Saved3D;
164#ifdef CR_ARB_texture_cube_map
165 CRTextureObj SavedCubeMap;
166#endif
167#ifdef CR_NV_texture_rectangle
168 CRTextureObj SavedRect;
169#endif
170} CRTextureUnit;
171
172typedef struct {
173 /* Default texture objects (name = 0) */
174 CRTextureObj base1D;
175 CRTextureObj base2D;
176 CRTextureObj base3D;
177#ifdef CR_ARB_texture_cube_map
178 CRTextureObj baseCubeMap;
179#endif
180#ifdef CR_NV_texture_rectangle
181 CRTextureObj baseRect;
182#endif
183
184 /* Proxy texture objects */
185 CRTextureObj proxy1D;
186 CRTextureObj proxy2D;
187 CRTextureObj proxy3D;
188#ifdef CR_ARB_texture_cube_map
189 CRTextureObj proxyCubeMap;
190#endif
191#ifdef CR_NV_texture_rectangle
192 CRTextureObj proxyRect;
193#endif
194
195 GLuint curTextureUnit; /* GL_ACTIVE_TEXTURE */
196
197 GLint maxLevel; /* number of mipmap levels possible: [0..max] */
198 GLint max3DLevel;
199 GLint maxCubeMapLevel;
200 GLint maxRectLevel;
201
202 GLboolean broadcastTextures; /*@todo what is it for?*/
203
204 /* Indicates that we have to resend texture data to GPU on first glMakeCurrent call with owning context */
205 GLboolean bResyncNeeded;
206
207 /* Per-texture unit state: */
208 CRTextureUnit unit[CR_MAX_TEXTURE_UNITS];
209} CRTextureState;
210
211DECLEXPORT(void) crStateTextureInit(CRContext *ctx);
212DECLEXPORT(void) crStateTextureDestroy(CRContext *ctx);
213DECLEXPORT(void) crStateTextureFree(CRContext *ctx);
214
215DECLEXPORT(void) crStateTextureInitTexture(GLuint name);
216DECLEXPORT(CRTextureObj *) crStateTextureAllocate(GLuint name);
217 /*void crStateTextureDelete(GLuint name);*/
218DECLEXPORT(CRTextureObj *) crStateTextureGet(GLenum target, GLuint textureid);
219DECLEXPORT(int) crStateTextureGetSize(GLenum target, GLenum level);
220DECLEXPORT(const GLvoid *) crStateTextureGetData(GLenum target, GLenum level);
221
222DECLEXPORT(int) crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit);
223
224DECLEXPORT(void) crStateTextureDiff(CRTextureBits *t, CRbitvalue *bitID,
225 CRContext *fromCtx, CRContext *toCtx);
226DECLEXPORT(void) crStateTextureSwitch(CRTextureBits *t, CRbitvalue *bitID,
227 CRContext *fromCtx, CRContext *toCtx);
228
229DECLEXPORT(void) crStateTextureObjectDiff(CRContext *fromCtx,
230 const CRbitvalue *bitID,
231 const CRbitvalue *nbitID,
232 CRTextureObj *tobj, GLboolean alwaysDirty);
233
234DECLEXPORT(void) crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate );
235
236DECLEXPORT(void) crStateDeleteTextureObjectData(CRTextureObj *tobj);
237DECLEXPORT(void) crStateDeleteTextureObject(CRTextureObj *tobj);
238
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif /* CR_STATE_TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette