VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c@ 55043

Last change on this file since 55043 was 44196, checked in by vboxsync, 12 years ago

crOpenGL: glGetError fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.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#include "cr_mem.h"
8#include "state.h"
9#include "state/cr_statetypes.h"
10#include "state_internals.h"
11#include "cr_pixeldata.h"
12
13void crStatePolygonInit(CRContext *ctx)
14{
15 CRPolygonState *p = &ctx->polygon;
16 CRStateBits *sb = GetCurrentBits();
17 CRPolygonBits *pb = &(sb->polygon);
18 int i;
19
20 p->polygonSmooth = GL_FALSE;
21 p->polygonOffsetFill = GL_FALSE;
22 p->polygonOffsetLine = GL_FALSE;
23 p->polygonOffsetPoint = GL_FALSE;
24 p->polygonStipple = GL_FALSE;
25 p->cullFace = GL_FALSE;
26 RESET(pb->enable, ctx->bitid);
27
28 p->offsetFactor = 0;
29 p->offsetUnits = 0;
30 RESET(pb->offset, ctx->bitid);
31
32 p->cullFaceMode = GL_BACK;
33 p->frontFace = GL_CCW;
34 p->frontMode = GL_FILL;
35 p->backMode = GL_FILL;
36 RESET(pb->mode, ctx->bitid);
37
38 for (i=0; i<32; i++)
39 p->stipple[i] = 0xFFFFFFFF;
40 RESET(pb->stipple, ctx->bitid);
41
42 RESET(pb->dirty, ctx->bitid);
43}
44
45void STATE_APIENTRY crStateCullFace(GLenum mode)
46{
47 CRContext *g = GetCurrentContext();
48 CRPolygonState *p = &(g->polygon);
49 CRStateBits *sb = GetCurrentBits();
50 CRPolygonBits *pb = &(sb->polygon);
51
52 if (g->current.inBeginEnd)
53 {
54 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
55 "glCullFace called in begin/end");
56 return;
57 }
58
59 FLUSH();
60
61 if (mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK)
62 {
63 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
64 "glCullFace called with bogus mode: 0x%x", mode);
65 return;
66 }
67
68 p->cullFaceMode = mode;
69 DIRTY(pb->mode, g->neg_bitid);
70 DIRTY(pb->dirty, g->neg_bitid);
71}
72
73void STATE_APIENTRY crStateFrontFace (GLenum mode)
74{
75 CRContext *g = GetCurrentContext();
76 CRPolygonState *p = &(g->polygon);
77 CRStateBits *sb = GetCurrentBits();
78 CRPolygonBits *pb = &(sb->polygon);
79
80 if (g->current.inBeginEnd)
81 {
82 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
83 "glFrontFace called in begin/end");
84 return;
85 }
86
87 FLUSH();
88
89 if (mode != GL_CW && mode != GL_CCW)
90 {
91 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
92 "glFrontFace called with bogus mode: 0x%x", mode);
93 return;
94 }
95
96 p->frontFace = mode;
97 DIRTY(pb->mode, g->neg_bitid);
98 DIRTY(pb->dirty, g->neg_bitid);
99}
100
101void STATE_APIENTRY crStatePolygonMode (GLenum face, GLenum mode)
102{
103 CRContext *g = GetCurrentContext();
104 CRPolygonState *p = &(g->polygon);
105 CRStateBits *sb = GetCurrentBits();
106 CRPolygonBits *pb = &(sb->polygon);
107
108 if (g->current.inBeginEnd)
109 {
110 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
111 "glPolygonMode called in begin/end");
112 return;
113 }
114
115 FLUSH();
116
117 if (mode != GL_POINT && mode != GL_LINE && mode != GL_FILL)
118 {
119 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
120 "glPolygonMode called with bogus mode: 0x%x", mode);
121 return;
122 }
123
124 switch (face) {
125 case GL_FRONT:
126 p->frontMode = mode;
127 break;
128 case GL_FRONT_AND_BACK:
129 p->frontMode = mode;
130 case GL_BACK:
131 p->backMode = mode;
132 break;
133 default:
134 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
135 "glPolygonMode called with bogus face: 0x%x", face);
136 return;
137 }
138 DIRTY(pb->mode, g->neg_bitid);
139 DIRTY(pb->dirty, g->neg_bitid);
140}
141
142void STATE_APIENTRY crStatePolygonOffset (GLfloat factor, GLfloat units)
143{
144 CRContext *g = GetCurrentContext();
145 CRPolygonState *p = &(g->polygon);
146 CRStateBits *sb = GetCurrentBits();
147 CRPolygonBits *pb = &(sb->polygon);
148
149 if (g->current.inBeginEnd)
150 {
151 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
152 "glPolygonOffset called in begin/end");
153 return;
154 }
155
156 FLUSH();
157
158 p->offsetFactor = factor;
159 p->offsetUnits = units;
160
161 DIRTY(pb->offset, g->neg_bitid);
162 DIRTY(pb->dirty, g->neg_bitid);
163}
164
165void STATE_APIENTRY crStatePolygonStipple (const GLubyte *p)
166{
167 CRContext *g = GetCurrentContext();
168 CRPolygonState *poly = &(g->polygon);
169 CRStateBits *sb = GetCurrentBits();
170 CRPolygonBits *pb = &(sb->polygon);
171
172 if (g->current.inBeginEnd)
173 {
174 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
175 "glPolygonStipple called in begin/end");
176 return;
177 }
178
179 FLUSH();
180
181 if (!p && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
182 {
183 crDebug("Void pointer passed to PolygonStipple");
184 return;
185 }
186
187 /*@todo track mask if buffer is bound?*/
188 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
189 {
190 crMemcpy((char*)poly->stipple, (char*)p, 128);
191 }
192
193 DIRTY(pb->dirty, g->neg_bitid);
194 DIRTY(pb->stipple, g->neg_bitid);
195}
196
197void STATE_APIENTRY crStateGetPolygonStipple( GLubyte *b )
198{
199 CRContext *g = GetCurrentContext();
200 CRPolygonState *poly = &(g->polygon);
201
202 if (g->current.inBeginEnd)
203 {
204 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
205 "glGetPolygonStipple called in begin/end");
206 return;
207 }
208
209 crMemcpy((char*)b, (char*)poly->stipple, 128);
210}
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