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 "state.h"
|
---|
8 | #include "state/cr_statetypes.h"
|
---|
9 | #include "state_internals.h"
|
---|
10 |
|
---|
11 | void crStatePointInit (CRContext *ctx)
|
---|
12 | {
|
---|
13 | CRPointState *p = &ctx->point;
|
---|
14 | CRStateBits *sb = GetCurrentBits();
|
---|
15 | CRPointBits *pb = &(sb->point);
|
---|
16 | int i;
|
---|
17 |
|
---|
18 | p->pointSmooth = GL_FALSE;
|
---|
19 | RESET(pb->enableSmooth, ctx->bitid);
|
---|
20 | p->pointSize = 1.0f;
|
---|
21 | RESET(pb->size, ctx->bitid);
|
---|
22 | #ifdef CR_ARB_point_parameters
|
---|
23 | p->minSize = 0.0f;
|
---|
24 | RESET(pb->minSize, ctx->bitid);
|
---|
25 | p->maxSize = CR_ALIASED_POINT_SIZE_MAX;
|
---|
26 | RESET(pb->maxSize, ctx->bitid);
|
---|
27 | p->fadeThresholdSize = 1.0f;
|
---|
28 | RESET(pb->fadeThresholdSize, ctx->bitid);
|
---|
29 | p->distanceAttenuation[0] = 1.0f;
|
---|
30 | p->distanceAttenuation[1] = 0.0f;
|
---|
31 | p->distanceAttenuation[2] = 0.0f;
|
---|
32 | RESET(pb->distanceAttenuation, ctx->bitid);
|
---|
33 | #endif
|
---|
34 | #ifdef CR_ARB_point_sprite
|
---|
35 | p->pointSprite = GL_FALSE;
|
---|
36 | RESET(pb->enableSprite, ctx->bitid);
|
---|
37 | for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) {
|
---|
38 | p->coordReplacement[i] = GL_FALSE;
|
---|
39 | RESET(pb->coordReplacement[i], ctx->bitid);
|
---|
40 | }
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | p->spriteCoordOrigin = (GLfloat)GL_UPPER_LEFT;
|
---|
44 | RESET(pb->spriteCoordOrigin, ctx->bitid);
|
---|
45 |
|
---|
46 | RESET(pb->dirty, ctx->bitid);
|
---|
47 |
|
---|
48 | /*
|
---|
49 | *p->aliasedpointsizerange_min = c->aliasedpointsizerange_min;
|
---|
50 | *p->aliasedpointsizerange_max = c->aliasedpointsizerange_max;
|
---|
51 | *p->aliasedpointsizegranularity = c->aliasedpointsizegranularity;
|
---|
52 | *p->smoothpointsizerange_min = c->smoothpointsizerange_min;
|
---|
53 | *p->smoothpointsizerange_max = c->smoothpointsizerange_max;
|
---|
54 | *p->smoothpointgranularity = c->smoothpointgranularity;
|
---|
55 | */
|
---|
56 | }
|
---|
57 |
|
---|
58 | void STATE_APIENTRY crStatePointSize(GLfloat size)
|
---|
59 | {
|
---|
60 | CRContext *g = GetCurrentContext();
|
---|
61 | CRPointState *p = &(g->point);
|
---|
62 | CRStateBits *sb = GetCurrentBits();
|
---|
63 | CRPointBits *pb = &(sb->point);
|
---|
64 |
|
---|
65 | if (g->current.inBeginEnd)
|
---|
66 | {
|
---|
67 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointSize called in begin/end");
|
---|
68 | return;
|
---|
69 | }
|
---|
70 |
|
---|
71 | FLUSH();
|
---|
72 |
|
---|
73 | if (size <= 0.0f)
|
---|
74 | {
|
---|
75 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointSize called with size <= 0.0: %f", size);
|
---|
76 | return;
|
---|
77 | }
|
---|
78 |
|
---|
79 | p->pointSize = size;
|
---|
80 | DIRTY(pb->size, g->neg_bitid);
|
---|
81 | DIRTY(pb->dirty, g->neg_bitid);
|
---|
82 | }
|
---|
83 |
|
---|
84 | void STATE_APIENTRY crStatePointParameterfARB(GLenum pname, GLfloat param)
|
---|
85 | {
|
---|
86 | CRContext *g = GetCurrentContext();
|
---|
87 |
|
---|
88 | if (g->current.inBeginEnd)
|
---|
89 | {
|
---|
90 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfARB called in begin/end");
|
---|
91 | return;
|
---|
92 | }
|
---|
93 |
|
---|
94 | FLUSH();
|
---|
95 |
|
---|
96 | crStatePointParameterfvARB(pname, ¶m);
|
---|
97 | }
|
---|
98 |
|
---|
99 | void STATE_APIENTRY crStatePointParameterfvARB(GLenum pname, const GLfloat *params)
|
---|
100 | {
|
---|
101 | CRContext *g = GetCurrentContext();
|
---|
102 | CRPointState *p = &(g->point);
|
---|
103 | CRStateBits *sb = GetCurrentBits();
|
---|
104 | CRPointBits *pb = &(sb->point);
|
---|
105 |
|
---|
106 | if (g->current.inBeginEnd)
|
---|
107 | {
|
---|
108 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfvARB called in begin/end");
|
---|
109 | return;
|
---|
110 | }
|
---|
111 |
|
---|
112 | FLUSH();
|
---|
113 |
|
---|
114 | switch (pname) {
|
---|
115 | case GL_DISTANCE_ATTENUATION_EXT:
|
---|
116 | if (g->extensions.ARB_point_parameters) {
|
---|
117 | p->distanceAttenuation[0] = params[0];
|
---|
118 | p->distanceAttenuation[1] = params[1];
|
---|
119 | p->distanceAttenuation[2] = params[2];
|
---|
120 | DIRTY(pb->distanceAttenuation, g->neg_bitid);
|
---|
121 | }
|
---|
122 | else
|
---|
123 | {
|
---|
124 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
|
---|
125 | return;
|
---|
126 | }
|
---|
127 | break;
|
---|
128 | case GL_POINT_SIZE_MIN_EXT:
|
---|
129 | if (g->extensions.ARB_point_parameters) {
|
---|
130 | if (params[0] < 0.0F) {
|
---|
131 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
|
---|
132 | return;
|
---|
133 | }
|
---|
134 | p->minSize = params[0];
|
---|
135 | DIRTY(pb->minSize, g->neg_bitid);
|
---|
136 | }
|
---|
137 | else
|
---|
138 | {
|
---|
139 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
|
---|
140 | return;
|
---|
141 | }
|
---|
142 | break;
|
---|
143 | case GL_POINT_SIZE_MAX_EXT:
|
---|
144 | if (g->extensions.ARB_point_parameters) {
|
---|
145 | if (params[0] < 0.0F) {
|
---|
146 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
|
---|
147 | return;
|
---|
148 | }
|
---|
149 | p->maxSize = params[0];
|
---|
150 | DIRTY(pb->maxSize, g->neg_bitid);
|
---|
151 | }
|
---|
152 | else
|
---|
153 | {
|
---|
154 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
|
---|
155 | return;
|
---|
156 | }
|
---|
157 | break;
|
---|
158 | case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
|
---|
159 | if (g->extensions.ARB_point_parameters) {
|
---|
160 | if (params[0] < 0.0F) {
|
---|
161 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
|
---|
162 | return;
|
---|
163 | }
|
---|
164 | p->fadeThresholdSize = params[0];
|
---|
165 | DIRTY(pb->fadeThresholdSize, g->neg_bitid);
|
---|
166 | }
|
---|
167 | else
|
---|
168 | {
|
---|
169 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
|
---|
170 | return;
|
---|
171 | }
|
---|
172 | break;
|
---|
173 | case GL_POINT_SPRITE_COORD_ORIGIN:
|
---|
174 | {
|
---|
175 | GLenum enmVal = (GLenum)params[0];
|
---|
176 | if (enmVal != GL_LOWER_LEFT && enmVal != GL_UPPER_LEFT) {
|
---|
177 | crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid GL_POINT_SPRITE_COORD_ORIGIN value: %f", params[0]);
|
---|
178 | return;
|
---|
179 | }
|
---|
180 | p->spriteCoordOrigin = params[0];
|
---|
181 | DIRTY(pb->spriteCoordOrigin, g->neg_bitid);
|
---|
182 | break;
|
---|
183 | }
|
---|
184 | default:
|
---|
185 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
|
---|
186 | return;
|
---|
187 | }
|
---|
188 |
|
---|
189 | DIRTY(pb->dirty, g->neg_bitid);
|
---|
190 | }
|
---|
191 |
|
---|
192 | void STATE_APIENTRY crStatePointParameteri(GLenum pname, GLint param)
|
---|
193 | {
|
---|
194 | GLfloat f_param = (GLfloat) param;
|
---|
195 | crStatePointParameterfvARB( pname, &f_param );
|
---|
196 | }
|
---|
197 |
|
---|
198 | void STATE_APIENTRY crStatePointParameteriv(GLenum pname, const GLint *params)
|
---|
199 | {
|
---|
200 | GLfloat f_param = (GLfloat) (*params);
|
---|
201 | crStatePointParameterfvARB( pname, &f_param );
|
---|
202 | }
|
---|