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_GLSTATE_H
|
---|
8 | #define CR_GLSTATE_H
|
---|
9 |
|
---|
10 | /* Forward declaration since some of the state/cr_*.h files need the CRContext type */
|
---|
11 | struct CRContext;
|
---|
12 | typedef struct CRContext CRContext;
|
---|
13 |
|
---|
14 | #include "cr_version.h"
|
---|
15 |
|
---|
16 | #include "state/cr_buffer.h"
|
---|
17 | #include "state/cr_bufferobject.h"
|
---|
18 | #include "state/cr_client.h"
|
---|
19 | #include "state/cr_current.h"
|
---|
20 | #include "state/cr_evaluators.h"
|
---|
21 | #include "state/cr_feedback.h"
|
---|
22 | #include "state/cr_fog.h"
|
---|
23 | #include "state/cr_hint.h"
|
---|
24 | #include "state/cr_lighting.h"
|
---|
25 | #include "state/cr_limits.h"
|
---|
26 | #include "state/cr_line.h"
|
---|
27 | #include "state/cr_lists.h"
|
---|
28 | #include "state/cr_multisample.h"
|
---|
29 | #include "state/cr_occlude.h"
|
---|
30 | #include "state/cr_pixel.h"
|
---|
31 | #include "state/cr_point.h"
|
---|
32 | #include "state/cr_polygon.h"
|
---|
33 | #include "state/cr_program.h"
|
---|
34 | #include "state/cr_regcombiner.h"
|
---|
35 | #include "state/cr_stencil.h"
|
---|
36 | #include "state/cr_texture.h"
|
---|
37 | #include "state/cr_transform.h"
|
---|
38 | #include "state/cr_viewport.h"
|
---|
39 | #include "state/cr_attrib.h"
|
---|
40 | #include "state/cr_framebuffer.h"
|
---|
41 | #include "state/cr_glsl.h"
|
---|
42 |
|
---|
43 | #include "state/cr_statefuncs.h"
|
---|
44 | #include "state/cr_stateerror.h"
|
---|
45 |
|
---|
46 | #include "spu_dispatch_table.h"
|
---|
47 |
|
---|
48 | #include <iprt/cdefs.h>
|
---|
49 |
|
---|
50 | #ifndef IN_GUEST
|
---|
51 | #include <VBox/ssm.h>
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #define CR_MAX_EXTENTS 256
|
---|
55 |
|
---|
56 | #ifdef __cplusplus
|
---|
57 | extern "C" {
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Bit vectors describing GL state
|
---|
62 | */
|
---|
63 | typedef struct {
|
---|
64 | CRAttribBits attrib;
|
---|
65 | CRBufferBits buffer;
|
---|
66 | #ifdef CR_ARB_vertex_buffer_object
|
---|
67 | CRBufferObjectBits bufferobject;
|
---|
68 | #endif
|
---|
69 | CRClientBits client;
|
---|
70 | CRCurrentBits current;
|
---|
71 | CREvaluatorBits eval;
|
---|
72 | CRFeedbackBits feedback;
|
---|
73 | CRFogBits fog;
|
---|
74 | CRHintBits hint;
|
---|
75 | CRLightingBits lighting;
|
---|
76 | CRLineBits line;
|
---|
77 | CRListsBits lists;
|
---|
78 | CRMultisampleBits multisample;
|
---|
79 | #if CR_ARB_occlusion_query
|
---|
80 | CROcclusionBits occlusion;
|
---|
81 | #endif
|
---|
82 | CRPixelBits pixel;
|
---|
83 | CRPointBits point;
|
---|
84 | CRPolygonBits polygon;
|
---|
85 | CRProgramBits program;
|
---|
86 | CRRegCombinerBits regcombiner;
|
---|
87 | CRSelectionBits selection;
|
---|
88 | CRStencilBits stencil;
|
---|
89 | CRTextureBits texture;
|
---|
90 | CRTransformBits transform;
|
---|
91 | CRViewportBits viewport;
|
---|
92 | } CRStateBits;
|
---|
93 |
|
---|
94 | typedef void (*CRStateFlushFunc)( void *arg );
|
---|
95 |
|
---|
96 |
|
---|
97 | typedef struct _CRSharedState {
|
---|
98 | CRHashTable *textureTable; /* all texture objects */
|
---|
99 | CRHashTable *dlistTable; /* all display lists */
|
---|
100 | GLint refCount;
|
---|
101 | } CRSharedState;
|
---|
102 |
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Chromium version of the state variables in OpenGL
|
---|
106 | */
|
---|
107 | struct CRContext {
|
---|
108 | int id;
|
---|
109 | CRbitvalue bitid[CR_MAX_BITARRAY];
|
---|
110 | CRbitvalue neg_bitid[CR_MAX_BITARRAY];
|
---|
111 |
|
---|
112 | CRSharedState *shared;
|
---|
113 |
|
---|
114 | GLenum renderMode;
|
---|
115 |
|
---|
116 | GLenum error;
|
---|
117 |
|
---|
118 | CRStateFlushFunc flush_func;
|
---|
119 | void *flush_arg;
|
---|
120 |
|
---|
121 | CRAttribState attrib;
|
---|
122 | CRBufferState buffer;
|
---|
123 | #ifdef CR_ARB_vertex_buffer_object
|
---|
124 | CRBufferObjectState bufferobject;
|
---|
125 | #endif
|
---|
126 | CRClientState client;
|
---|
127 | CRCurrentState current;
|
---|
128 | CREvaluatorState eval;
|
---|
129 | CRExtensionState extensions;
|
---|
130 | CRFeedbackState feedback;
|
---|
131 | CRFogState fog;
|
---|
132 | CRHintState hint;
|
---|
133 | CRLightingState lighting;
|
---|
134 | CRLimitsState limits;
|
---|
135 | CRLineState line;
|
---|
136 | CRListsState lists;
|
---|
137 | CRMultisampleState multisample;
|
---|
138 | #if CR_ARB_occlusion_query
|
---|
139 | CROcclusionState occlusion;
|
---|
140 | #endif
|
---|
141 | CRPixelState pixel;
|
---|
142 | CRPointState point;
|
---|
143 | CRPolygonState polygon;
|
---|
144 | CRProgramState program;
|
---|
145 | CRRegCombinerState regcombiner;
|
---|
146 | CRSelectionState selection;
|
---|
147 | CRStencilState stencil;
|
---|
148 | CRTextureState texture;
|
---|
149 | CRTransformState transform;
|
---|
150 | CRViewportState viewport;
|
---|
151 |
|
---|
152 | #ifdef CR_EXT_framebuffer_object
|
---|
153 | CRFramebufferObjectState framebufferobject;
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
157 | CRGLSLState glsl;
|
---|
158 | #endif
|
---|
159 |
|
---|
160 | /*@todo add back buffer, depth and fbos and move out of here*/
|
---|
161 | GLvoid *pImage; /*stored front buffer image*/
|
---|
162 |
|
---|
163 | /** For buffering vertices for selection/feedback */
|
---|
164 | /*@{*/
|
---|
165 | GLuint vCount;
|
---|
166 | CRVertex vBuffer[4];
|
---|
167 | GLboolean lineReset;
|
---|
168 | GLboolean lineLoop;
|
---|
169 | /*@}*/
|
---|
170 | };
|
---|
171 |
|
---|
172 |
|
---|
173 | DECLEXPORT(void) crStateInit(void);
|
---|
174 | DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
|
---|
175 | DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
|
---|
176 | DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
|
---|
177 | DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
|
---|
178 | DECLEXPORT(CRContext *) crStateGetCurrent(void);
|
---|
179 | DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
|
---|
180 |
|
---|
181 | DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
|
---|
182 | DECLEXPORT(void) crStateFlushArg( void *arg );
|
---|
183 | DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
|
---|
184 | DECLEXPORT(void) crStateUpdateColorBits( void );
|
---|
185 |
|
---|
186 | DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
|
---|
187 | DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
|
---|
188 |
|
---|
189 | DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
|
---|
190 |
|
---|
191 | DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
|
---|
192 | DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
|
---|
193 |
|
---|
194 | #ifndef IN_GUEST
|
---|
195 | DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
|
---|
196 | DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, PSSMHANDLE pSSM);
|
---|
197 | #endif
|
---|
198 |
|
---|
199 |
|
---|
200 | /* XXX move these! */
|
---|
201 |
|
---|
202 | DECLEXPORT(void) STATE_APIENTRY
|
---|
203 | crStateChromiumParameteriCR( GLenum target, GLint value );
|
---|
204 |
|
---|
205 | DECLEXPORT(void) STATE_APIENTRY
|
---|
206 | crStateChromiumParameterfCR( GLenum target, GLfloat value );
|
---|
207 |
|
---|
208 | DECLEXPORT(void) STATE_APIENTRY
|
---|
209 | crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
|
---|
210 |
|
---|
211 | DECLEXPORT(void) STATE_APIENTRY
|
---|
212 | crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
|
---|
213 | GLsizei count, GLvoid *values );
|
---|
214 |
|
---|
215 | DECLEXPORT(void) STATE_APIENTRY
|
---|
216 | crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
217 | GLenum format, GLenum type, GLvoid *pixels );
|
---|
218 |
|
---|
219 | #ifdef __cplusplus
|
---|
220 | }
|
---|
221 | #endif
|
---|
222 |
|
---|
223 | #endif /* CR_GLSTATE_H */
|
---|