VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h@ 28800

Last change on this file since 28800 was 25303, checked in by vboxsync, 15 years ago

crOpenGL: properly restore context states after snapshot loading

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.1 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_GLSTATE_H
8#define CR_GLSTATE_H
9
10/* Forward declaration since some of the state/cr_*.h files need the CRContext type */
11struct CRContext;
12typedef 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
57extern "C" {
58#endif
59
60/**
61 * Bit vectors describing GL state
62 */
63typedef 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
94typedef void (*CRStateFlushFunc)( void *arg );
95
96
97typedef 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 */
107struct 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
173DECLEXPORT(void) crStateInit(void);
174DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
175DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
176DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
177DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
178DECLEXPORT(CRContext *) crStateGetCurrent(void);
179DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
180
181DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
182DECLEXPORT(void) crStateFlushArg( void *arg );
183DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
184DECLEXPORT(void) crStateUpdateColorBits( void );
185
186DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
187DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
188
189DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
190
191DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
192DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
193
194#ifndef IN_GUEST
195DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
196DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, PSSMHANDLE pSSM);
197#endif
198
199
200 /* XXX move these! */
201
202DECLEXPORT(void) STATE_APIENTRY
203crStateChromiumParameteriCR( GLenum target, GLint value );
204
205DECLEXPORT(void) STATE_APIENTRY
206crStateChromiumParameterfCR( GLenum target, GLfloat value );
207
208DECLEXPORT(void) STATE_APIENTRY
209crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
210
211DECLEXPORT(void) STATE_APIENTRY
212crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
213 GLsizei count, GLvoid *values );
214
215DECLEXPORT(void) STATE_APIENTRY
216crStateReadPixels( 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 */
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