VirtualBox

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

Last change on this file since 71930 was 69392, checked in by vboxsync, 7 years ago

GuestHost/OpenGL: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
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 RT_FALL_THRU();
131 case GL_BACK:
132 p->backMode = mode;
133 break;
134 default:
135 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
136 "glPolygonMode called with bogus face: 0x%x", face);
137 return;
138 }
139 DIRTY(pb->mode, g->neg_bitid);
140 DIRTY(pb->dirty, g->neg_bitid);
141}
142
143void STATE_APIENTRY crStatePolygonOffset (GLfloat factor, GLfloat units)
144{
145 CRContext *g = GetCurrentContext();
146 CRPolygonState *p = &(g->polygon);
147 CRStateBits *sb = GetCurrentBits();
148 CRPolygonBits *pb = &(sb->polygon);
149
150 if (g->current.inBeginEnd)
151 {
152 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
153 "glPolygonOffset called in begin/end");
154 return;
155 }
156
157 FLUSH();
158
159 p->offsetFactor = factor;
160 p->offsetUnits = units;
161
162 DIRTY(pb->offset, g->neg_bitid);
163 DIRTY(pb->dirty, g->neg_bitid);
164}
165
166void STATE_APIENTRY crStatePolygonStipple (const GLubyte *p)
167{
168 CRContext *g = GetCurrentContext();
169 CRPolygonState *poly = &(g->polygon);
170 CRStateBits *sb = GetCurrentBits();
171 CRPolygonBits *pb = &(sb->polygon);
172
173 if (g->current.inBeginEnd)
174 {
175 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
176 "glPolygonStipple called in begin/end");
177 return;
178 }
179
180 FLUSH();
181
182 if (!p && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
183 {
184 crDebug("Void pointer passed to PolygonStipple");
185 return;
186 }
187
188 /** @todo track mask if buffer is bound?*/
189 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
190 {
191 crMemcpy((char*)poly->stipple, (char*)p, 128);
192 }
193
194 DIRTY(pb->dirty, g->neg_bitid);
195 DIRTY(pb->stipple, g->neg_bitid);
196}
197
198void STATE_APIENTRY crStateGetPolygonStipple( GLubyte *b )
199{
200 CRContext *g = GetCurrentContext();
201 CRPolygonState *poly = &(g->polygon);
202
203 if (g->current.inBeginEnd)
204 {
205 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
206 "glGetPolygonStipple called in begin/end");
207 return;
208 }
209
210 crMemcpy((char*)b, (char*)poly->stipple, 128);
211}
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