VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.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: 4.9 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 <stdio.h>
8#include "state.h"
9#include "state/cr_statetypes.h"
10#include "state_internals.h"
11
12void crStateFogInit (CRContext *ctx)
13{
14 CRFogState *f = &ctx->fog;
15 CRStateBits *sb = GetCurrentBits();
16 CRFogBits *fb = &(sb->fog);
17 GLcolorf black = {0.0f, 0.0f, 0.0f, 0.0f};
18
19 f->color = black;
20 RESET(fb->color, ctx->bitid);
21 f->density = 1.0f;
22 RESET(fb->density, ctx->bitid);
23 f->end = 1.0f;
24 RESET(fb->end, ctx->bitid);
25 f->start = 0.0f;
26 RESET(fb->start, ctx->bitid);
27 f->mode = GL_EXP;
28 RESET(fb->mode, ctx->bitid);
29 f->index = 0;
30 RESET(fb->index, ctx->bitid);
31 f->enable = GL_FALSE;
32 RESET(fb->enable, ctx->bitid);
33
34#ifdef CR_NV_fog_distance
35 f->fogDistanceMode = GL_EYE_PLANE_ABSOLUTE_NV;
36 RESET(fb->fogDistanceMode, ctx->bitid);
37#endif
38#ifdef CR_EXT_fog_coord
39 f->fogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
40 RESET(fb->fogCoordinateSource, ctx->bitid);
41#endif
42 RESET(fb->dirty, ctx->bitid);
43}
44
45void STATE_APIENTRY crStateFogf(GLenum pname, GLfloat param)
46{
47 crStateFogfv( pname, &param );
48}
49
50void STATE_APIENTRY crStateFogi(GLenum pname, GLint param)
51{
52 GLfloat f_param = (GLfloat) param;
53 crStateFogfv( pname, &f_param );
54}
55
56void STATE_APIENTRY crStateFogiv(GLenum pname, const GLint *param)
57{
58 GLcolor f_color;
59 GLfloat f_param;
60 switch (pname)
61 {
62 case GL_FOG_MODE:
63 case GL_FOG_DENSITY:
64 case GL_FOG_START:
65 case GL_FOG_END:
66 case GL_FOG_INDEX:
67 f_param = (GLfloat) (*param);
68 crStateFogfv( pname, &f_param );
69 break;
70 case GL_FOG_COLOR:
71 f_color.r = ((GLfloat) param[0]) / ((GLfloat) CR_MAXINT);
72 f_color.g = ((GLfloat) param[1]) / ((GLfloat) CR_MAXINT);
73 f_color.b = ((GLfloat) param[2]) / ((GLfloat) CR_MAXINT);
74 f_color.a = ((GLfloat) param[3]) / ((GLfloat) CR_MAXINT);
75 crStateFogfv( pname, (GLfloat *) &f_color );
76 break;
77#ifdef CR_NV_fog_distance
78 case GL_FOG_DISTANCE_MODE_NV:
79 f_param = (GLfloat) (*param);
80 crStateFogfv( pname, &f_param );
81 break;
82#endif
83#ifdef CR_EXT_fog_coord
84 case GL_FOG_COORDINATE_SOURCE_EXT:
85 f_param = (GLfloat) (*param);
86 crStateFogfv( pname, &f_param );
87 break;
88#endif
89 default:
90 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param);
91 return;
92 }
93}
94
95void STATE_APIENTRY crStateFogfv(GLenum pname, const GLfloat *param)
96{
97 CRContext *g = GetCurrentContext();
98 CRFogState *f = &(g->fog);
99 CRStateBits *sb = GetCurrentBits();
100 CRFogBits *fb = &(sb->fog);
101
102 if (g->current.inBeginEnd)
103 {
104 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glFogfv called in Begin/End");
105 return;
106 }
107
108 FLUSH();
109
110 switch (pname)
111 {
112 case GL_FOG_MODE:
113 {
114 GLenum e = (GLenum) *param;
115 if (e != GL_LINEAR && e != GL_EXP && e != GL_EXP2)
116 {
117 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid param for glFog: %d", e);
118 return;
119 }
120 f->mode = e;
121 DIRTY(fb->mode, g->neg_bitid);
122 }
123 break;
124 case GL_FOG_DENSITY:
125 f->density = *param;
126 if (f->density < 0.0f)
127 {
128 f->density = 0.0f;
129 }
130 DIRTY(fb->density, g->neg_bitid);
131 break;
132 case GL_FOG_START:
133 f->start = *param;
134 DIRTY(fb->start, g->neg_bitid);
135 break;
136 case GL_FOG_END:
137 f->end = *param;
138 DIRTY(fb->end, g->neg_bitid);
139 break;
140 case GL_FOG_INDEX:
141 f->index = (GLint) *param;
142 DIRTY(fb->index, g->neg_bitid);
143 break;
144 case GL_FOG_COLOR:
145 f->color.r = param[0];
146 f->color.g = param[1];
147 f->color.b = param[2];
148 f->color.a = param[3];
149 DIRTY(fb->color, g->neg_bitid);
150 break;
151#ifdef CR_NV_fog_distance
152 case GL_FOG_DISTANCE_MODE_NV:
153 if (g->extensions.NV_fog_distance)
154 {
155 if (param[0] != GL_EYE_RADIAL_NV &&
156 param[0] != GL_EYE_PLANE &&
157 param[0] != GL_EYE_PLANE_ABSOLUTE_NV )
158 {
159 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
160 "Fogfv: GL_FOG_DISTANCE_MODE_NV called with illegal parameter: 0x%x", (GLenum) param[0]);
161 return;
162 }
163 f->fogDistanceMode = (GLenum) param[0];
164 DIRTY(fb->fogDistanceMode, g->neg_bitid);
165 }
166 else
167 {
168 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param);
169 return;
170 }
171 break;
172#endif
173#ifdef CR_EXT_fog_coord
174 case GL_FOG_COORDINATE_SOURCE_EXT:
175 if (g->extensions.EXT_fog_coord)
176 {
177 if ((GLenum) param[0] != GL_FOG_COORDINATE_EXT &&
178 (GLenum) param[0] != GL_FRAGMENT_DEPTH_EXT)
179 {
180 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
181 "Fogfv: GL_FOG_COORDINATE_SOURCE_EXT called with illegal parameter: 0x%x", (GLenum) param[0]);
182 return;
183 }
184 f->fogCoordinateSource = (GLenum) param[0];
185 DIRTY(fb->fogCoordinateSource, g->neg_bitid);
186 }
187 else
188 {
189 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: 0x%x", (GLint) param[0]);
190 return;
191 }
192 break;
193#endif
194 default:
195 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param);
196 return;
197 }
198 DIRTY(fb->dirty, g->neg_bitid);
199}
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