VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_point.c@ 36300

Last change on this file since 36300 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 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 "state.h"
8#include "state/cr_statetypes.h"
9#include "state_internals.h"
10
11void 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 RESET(pb->dirty, ctx->bitid);
44
45 /*
46 *p->aliasedpointsizerange_min = c->aliasedpointsizerange_min;
47 *p->aliasedpointsizerange_max = c->aliasedpointsizerange_max;
48 *p->aliasedpointsizegranularity = c->aliasedpointsizegranularity;
49 *p->smoothpointsizerange_min = c->smoothpointsizerange_min;
50 *p->smoothpointsizerange_max = c->smoothpointsizerange_max;
51 *p->smoothpointgranularity = c->smoothpointgranularity;
52 */
53}
54
55void STATE_APIENTRY crStatePointSize(GLfloat size)
56{
57 CRContext *g = GetCurrentContext();
58 CRPointState *p = &(g->point);
59 CRStateBits *sb = GetCurrentBits();
60 CRPointBits *pb = &(sb->point);
61
62 if (g->current.inBeginEnd)
63 {
64 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointSize called in begin/end");
65 return;
66 }
67
68 FLUSH();
69
70 if (size <= 0.0f)
71 {
72 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointSize called with size <= 0.0: %f", size);
73 return;
74 }
75
76 p->pointSize = size;
77 DIRTY(pb->size, g->neg_bitid);
78 DIRTY(pb->dirty, g->neg_bitid);
79}
80
81void STATE_APIENTRY crStatePointParameterfARB(GLenum pname, GLfloat param)
82{
83 CRContext *g = GetCurrentContext();
84
85 if (g->current.inBeginEnd)
86 {
87 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfARB called in begin/end");
88 return;
89 }
90
91 FLUSH();
92
93 crStatePointParameterfvARB(pname, &param);
94}
95
96void STATE_APIENTRY crStatePointParameterfvARB(GLenum pname, const GLfloat *params)
97{
98 CRContext *g = GetCurrentContext();
99 CRPointState *p = &(g->point);
100 CRStateBits *sb = GetCurrentBits();
101 CRPointBits *pb = &(sb->point);
102
103 if (g->current.inBeginEnd)
104 {
105 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfvARB called in begin/end");
106 return;
107 }
108
109 FLUSH();
110
111 switch (pname) {
112 case GL_DISTANCE_ATTENUATION_EXT:
113 if (g->extensions.ARB_point_parameters) {
114 p->distanceAttenuation[0] = params[0];
115 p->distanceAttenuation[1] = params[1];
116 p->distanceAttenuation[2] = params[2];
117 DIRTY(pb->distanceAttenuation, g->neg_bitid);
118 }
119 else
120 {
121 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
122 return;
123 }
124 break;
125 case GL_POINT_SIZE_MIN_EXT:
126 if (g->extensions.ARB_point_parameters) {
127 if (params[0] < 0.0F) {
128 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
129 return;
130 }
131 p->minSize = params[0];
132 DIRTY(pb->minSize, g->neg_bitid);
133 }
134 else
135 {
136 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
137 return;
138 }
139 break;
140 case GL_POINT_SIZE_MAX_EXT:
141 if (g->extensions.ARB_point_parameters) {
142 if (params[0] < 0.0F) {
143 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
144 return;
145 }
146 p->maxSize = params[0];
147 DIRTY(pb->maxSize, g->neg_bitid);
148 }
149 else
150 {
151 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
152 return;
153 }
154 break;
155 case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
156 if (g->extensions.ARB_point_parameters) {
157 if (params[0] < 0.0F) {
158 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]);
159 return;
160 }
161 p->fadeThresholdSize = params[0];
162 DIRTY(pb->fadeThresholdSize, g->neg_bitid);
163 }
164 else
165 {
166 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
167 return;
168 }
169 break;
170 default:
171 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname);
172 return;
173 }
174
175 DIRTY(pb->dirty, g->neg_bitid);
176}
177
178void STATE_APIENTRY crStatePointParameteri(GLenum pname, GLint param)
179{
180 GLfloat f_param = (GLfloat) param;
181 crStatePointParameterfvARB( pname, &f_param );
182}
183
184void STATE_APIENTRY crStatePointParameteriv(GLenum pname, const GLint *params)
185{
186 GLfloat f_param = (GLfloat) (*params);
187 crStatePointParameterfvARB( pname, &f_param );
188}
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