ReactOS 0.4.16-dev-92-g0c2cdca
rastpos.h File Reference
#include "types.h"
Include dependency graph for rastpos.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gl_RasterPos4f (GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 
void gl_windowpos (GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
 

Function Documentation

◆ gl_RasterPos4f()

void gl_RasterPos4f ( GLcontext ctx,
GLfloat  x,
GLfloat  y,
GLfloat  z,
GLfloat  w 
)

Definition at line 62 of file rastpos.c.

64{
65 GLfloat v[4], eye[4], clip[4], ndc[3], d;
66
67 ASSIGN_4V( v, x, y, z, w );
68
69 if (ctx->NewModelViewMatrix) {
71 }
72 if (ctx->NewProjectionMatrix) {
74 }
75 if (ctx->NewTextureMatrix) {
77 }
78
79 /* transform v to eye coords: eye = ModelView * v */
80 TRANSFORM_POINT( eye, ctx->ModelViewMatrix, v );
81
82 /* raster color */
83 if (ctx->Light.Enabled) {
84 GLfloat eyenorm[3];
85 TRANSFORM_NORMAL( eyenorm[0], eyenorm[1], eyenorm[2], ctx->Current.Normal,
86 ctx->ModelViewInv );
87 if (ctx->Visual->RGBAflag) {
88 GLubyte color[4];
89 gl_color_shade_vertices( ctx, 0, 1, &eye, &eyenorm, &color );
90 ctx->Current.RasterColor[0] = color[0] * ctx->Visual->InvRedScale;
91 ctx->Current.RasterColor[1] = color[1] * ctx->Visual->InvGreenScale;
92 ctx->Current.RasterColor[2] = color[2] * ctx->Visual->InvBlueScale;
93 ctx->Current.RasterColor[3] = color[3] * ctx->Visual->InvAlphaScale;
94 }
95 else {
96 gl_index_shade_vertices( ctx, 0, 1, &eye, &eyenorm,
97 &ctx->Current.RasterIndex );
98 }
99 }
100 else {
101 /* use current color or index */
102 if (ctx->Visual->RGBAflag) {
103 GLfloat *rc = ctx->Current.RasterColor;
104 rc[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
105 rc[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
106 rc[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
107 rc[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
108 }
109 else {
110 ctx->Current.RasterIndex = ctx->Current.Index;
111 }
112 }
113
114 /* clip to user clipping planes */
115 if (gl_userclip_point(ctx, eye)==0) {
116 ctx->Current.RasterPosValid = GL_FALSE;
117 return;
118 }
119
120 /* compute raster distance */
121 ctx->Current.RasterDistance =
122 GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
123
124 /* apply projection matrix: clip = Proj * eye */
125 TRANSFORM_POINT( clip, ctx->ProjectionMatrix, eye );
126
127 /* clip to view volume */
128 if (gl_viewclip_point( clip )==0) {
129 ctx->Current.RasterPosValid = GL_FALSE;
130 return;
131 }
132
133 /* ndc = clip / W */
134 ASSERT( clip[3]!=0.0 );
135 d = 1.0F / clip[3];
136 ndc[0] = clip[0] * d;
137 ndc[1] = clip[1] * d;
138 ndc[2] = clip[2] * d;
139
140 ctx->Current.RasterPos[0] = ndc[0] * ctx->Viewport.Sx + ctx->Viewport.Tx;
141 ctx->Current.RasterPos[1] = ndc[1] * ctx->Viewport.Sy + ctx->Viewport.Ty;
142 ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport.Sz + ctx->Viewport.Tz)
143 / DEPTH_SCALE;
144 ctx->Current.RasterPos[3] = clip[3];
145 ctx->Current.RasterPosValid = GL_TRUE;
146
147 /* FOG??? */
148
149 if (ctx->Texture.Enabled) {
150 COPY_4V( ctx->Current.RasterTexCoord, ctx->Current.TexCoord );
151 }
152
153 if (ctx->RenderMode==GL_SELECT) {
154 gl_update_hitflag( ctx, ctx->Current.RasterPos[2] );
155 }
156
157}
GLuint gl_userclip_point(GLcontext *ctx, const GLfloat v[])
Definition: clip.c:756
GLuint gl_viewclip_point(const GLfloat v[])
Definition: clip.c:262
#define DEPTH_SCALE
Definition: config.h:146
void gl_analyze_texture_matrix(GLcontext *ctx)
Definition: matrix.c:487
void gl_analyze_modelview_matrix(GLcontext *ctx)
Definition: matrix.c:420
void gl_analyze_projection_matrix(GLcontext *ctx)
Definition: matrix.c:455
void gl_update_hitflag(GLcontext *ctx, GLfloat z)
Definition: feedback.c:240
unsigned char GLubyte
Definition: gl.h:157
#define GL_TRUE
Definition: gl.h:174
float GLfloat
Definition: gl.h:161
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
#define GL_SELECT
Definition: gl.h:389
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_FALSE
Definition: gl.h:173
GLuint color
Definition: glext.h:6243
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874
#define d
Definition: ke_i.h:81
#define ASSIGN_4V(V, V0, V1, V2, V3)
Definition: macros.h:128
#define COPY_4V(DST, SRC)
Definition: macros.h:102
#define GL_SQRT(X)
Definition: mmath.h:63
#define ASSERT(a)
Definition: mode.c:44
void gl_color_shade_vertices(GLcontext *ctx, GLuint side, GLuint n, GLfloat vertex[][4], GLfloat normal[][3], GLubyte color[][4])
Definition: shade.c:94
void gl_index_shade_vertices(GLcontext *ctx, GLuint side, GLuint n, GLfloat vertex[][4], GLfloat normal[][3], GLuint indexResult[])
Definition: shade.c:439
#define TRANSFORM_NORMAL(NX, NY, NZ, N, MAT)
Definition: xform.h:61
#define TRANSFORM_POINT(Q, M, P)
Definition: xform.h:51

Referenced by execute_list(), and init_exec_pointers().

◆ gl_windowpos()

void gl_windowpos ( GLcontext ctx,
GLfloat  x,
GLfloat  y,
GLfloat  z,
GLfloat  w 
)

Definition at line 167 of file rastpos.c.

168{
169 /* set raster position */
170 ctx->Current.RasterPos[0] = x;
171 ctx->Current.RasterPos[1] = y;
172 ctx->Current.RasterPos[2] = CLAMP( z, 0.0F, 1.0F );
173 ctx->Current.RasterPos[3] = w;
174
175 ctx->Current.RasterPosValid = GL_TRUE;
176
177 /* raster color */
178 if (ctx->Light.Enabled) {
179 GLfloat eye[4];
180 GLfloat eyenorm[3];
181 COPY_4V( eye, ctx->Current.RasterPos );
182 if (ctx->NewModelViewMatrix) {
184 }
185 TRANSFORM_NORMAL( eyenorm[0], eyenorm[1], eyenorm[2],
186 ctx->Current.Normal,
187 ctx->ModelViewInv );
188 if (ctx->Visual->RGBAflag) {
189 GLubyte color[4];
190 gl_color_shade_vertices( ctx, 0, 1, &eye, &eyenorm, &color );
191 ASSIGN_4V( ctx->Current.RasterColor,
192 (GLfloat) color[0] * ctx->Visual->InvRedScale,
193 (GLfloat) color[1] * ctx->Visual->InvGreenScale,
194 (GLfloat) color[2] * ctx->Visual->InvBlueScale,
195 (GLfloat) color[3] * ctx->Visual->InvAlphaScale );
196 }
197 else {
198 gl_index_shade_vertices( ctx, 0, 1, &eye, &eyenorm,
199 &ctx->Current.RasterIndex );
200 }
201 }
202 else {
203 /* use current color or index */
204 if (ctx->Visual->RGBAflag) {
205 ASSIGN_4V( ctx->Current.RasterColor,
206 ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale,
207 ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale,
208 ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale,
209 ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale );
210 }
211 else {
212 ctx->Current.RasterIndex = ctx->Current.Index;
213 }
214 }
215
216 ctx->Current.RasterDistance = 0.0;
217
218 if (ctx->Texture.Enabled) {
219 COPY_4V( ctx->Current.RasterTexCoord, ctx->Current.TexCoord );
220 }
221
222 if (ctx->RenderMode==GL_SELECT) {
223 gl_update_hitflag( ctx, ctx->Current.RasterPos[2] );
224 }
225}
#define CLAMP(f, min, max)
Definition: tif_color.c:177