ReactOS 0.4.15-dev-8241-g63935f8
feedback.c File Reference
#include <assert.h>
#include <stdio.h>
#include "context.h"
#include "feedback.h"
#include "dlist.h"
#include "macros.h"
#include "types.h"
Include dependency graph for feedback.c:

Go to the source code of this file.

Macros

#define FB_3D   0x01
 
#define FB_4D   0x02
 
#define FB_INDEX   0x04
 
#define FB_COLOR   0x08
 
#define FB_TEXTURE   0X10
 
#define WRITE_RECORD(CTX, V)
 

Functions

void gl_FeedbackBuffer (GLcontext *ctx, GLsizei size, GLenum type, GLfloat *buffer)
 
void gl_PassThrough (GLcontext *ctx, GLfloat token)
 
void gl_feedback_vertex (GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w, const GLfloat color[4], GLfloat index, const GLfloat texcoord[4])
 
void gl_SelectBuffer (GLcontext *ctx, GLsizei size, GLuint *buffer)
 
void gl_InitNames (GLcontext *ctx)
 
void gl_update_hitflag (GLcontext *ctx, GLfloat z)
 
static void write_hit_record (GLcontext *ctx)
 
void gl_LoadName (GLcontext *ctx, GLuint name)
 
void gl_PushName (GLcontext *ctx, GLuint name)
 
void gl_PopName (GLcontext *ctx)
 
GLint gl_RenderMode (GLcontext *ctx, GLenum mode)
 

Macro Definition Documentation

◆ FB_3D

#define FB_3D   0x01

Definition at line 79 of file feedback.c.

◆ FB_4D

#define FB_4D   0x02

Definition at line 80 of file feedback.c.

◆ FB_COLOR

#define FB_COLOR   0x08

Definition at line 82 of file feedback.c.

◆ FB_INDEX

#define FB_INDEX   0x04

Definition at line 81 of file feedback.c.

◆ FB_TEXTURE

#define FB_TEXTURE   0X10

Definition at line 83 of file feedback.c.

◆ WRITE_RECORD

#define WRITE_RECORD (   CTX,
  V 
)
Value:
if (CTX->Select.BufferCount < CTX->Select.BufferSize) { \
CTX->Select.Buffer[CTX->Select.BufferCount] = (V); \
} \
CTX->Select.BufferCount++;
#define V(i, a, b, c, d)
Definition: jaricom.c:29

Definition at line 232 of file feedback.c.

Function Documentation

◆ gl_feedback_vertex()

void gl_feedback_vertex ( GLcontext ctx,
GLfloat  x,
GLfloat  y,
GLfloat  z,
GLfloat  w,
const GLfloat  color[4],
GLfloat  index,
const GLfloat  texcoord[4] 
)

Definition at line 161 of file feedback.c.

165{
166 FEEDBACK_TOKEN( ctx, x );
167 FEEDBACK_TOKEN( ctx, y );
168 if (ctx->Feedback.Mask & FB_3D) {
169 FEEDBACK_TOKEN( ctx, z );
170 }
171 if (ctx->Feedback.Mask & FB_4D) {
172 FEEDBACK_TOKEN( ctx, w );
173 }
174 if (ctx->Feedback.Mask & FB_INDEX) {
176 }
177 if (ctx->Feedback.Mask & FB_COLOR) {
178 FEEDBACK_TOKEN( ctx, color[0] );
179 FEEDBACK_TOKEN( ctx, color[1] );
180 FEEDBACK_TOKEN( ctx, color[2] );
181 FEEDBACK_TOKEN( ctx, color[3] );
182 }
183 if (ctx->Feedback.Mask & FB_TEXTURE) {
184 FEEDBACK_TOKEN( ctx, texcoord[0] );
185 FEEDBACK_TOKEN( ctx, texcoord[1] );
186 FEEDBACK_TOKEN( ctx, texcoord[2] );
187 FEEDBACK_TOKEN( ctx, texcoord[3] );
188 }
189}
#define FB_3D
Definition: feedback.c:79
#define FB_TEXTURE
Definition: feedback.c:83
#define FB_COLOR
Definition: feedback.c:82
#define FB_INDEX
Definition: feedback.c:81
#define FB_4D
Definition: feedback.c:80
#define FEEDBACK_TOKEN(CTX, T)
Definition: feedback.h:39
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
GLuint index
Definition: glext.h:6031
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by drawpixels(), feedback_line(), feedback_points(), feedback_triangle(), gl_Bitmap(), and gl_CopyPixels().

◆ gl_FeedbackBuffer()

void gl_FeedbackBuffer ( GLcontext ctx,
GLsizei  size,
GLenum  type,
GLfloat buffer 
)

Definition at line 88 of file feedback.c.

89{
90 if (ctx->RenderMode==GL_FEEDBACK || INSIDE_BEGIN_END(ctx)) {
91 gl_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" );
92 return;
93 }
94
95 if (size<0) {
96 gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" );
97 return;
98 }
99 if (!buffer) {
100 gl_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" );
101 ctx->Feedback.BufferSize = 0;
102 return;
103 }
104
105 switch (type) {
106 case GL_2D:
107 ctx->Feedback.Mask = 0;
108 ctx->Feedback.Type = type;
109 break;
110 case GL_3D:
111 ctx->Feedback.Mask = FB_3D;
112 ctx->Feedback.Type = type;
113 break;
114 case GL_3D_COLOR:
115 ctx->Feedback.Mask = FB_3D
116 | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX);
117 ctx->Feedback.Type = type;
118 break;
120 ctx->Feedback.Mask = FB_3D
121 | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX)
122 | FB_TEXTURE;
123 ctx->Feedback.Type = type;
124 break;
126 ctx->Feedback.Mask = FB_3D | FB_4D
127 | (ctx->Visual->RGBAflag ? FB_COLOR : FB_INDEX)
128 | FB_TEXTURE;
129 ctx->Feedback.Type = type;
130 break;
131 default:
132 ctx->Feedback.Mask = 0;
133 gl_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" );
134 }
135
136 ctx->Feedback.BufferSize = size;
137 ctx->Feedback.Buffer = buffer;
138 ctx->Feedback.Count = 0;
139}
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define GL_INVALID_VALUE
Definition: gl.h:695
#define GL_2D
Definition: gl.h:392
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_INVALID_OPERATION
Definition: gl.h:696
#define GL_3D_COLOR_TEXTURE
Definition: gl.h:395
#define GL_FEEDBACK
Definition: gl.h:387
#define GL_3D
Definition: gl.h:393
#define GL_4D_COLOR_TEXTURE
Definition: gl.h:396
#define GL_3D_COLOR
Definition: gl.h:394
#define GL_INVALID_ENUM
Definition: gl.h:694
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_InitNames()

void gl_InitNames ( GLcontext ctx)

Definition at line 219 of file feedback.c.

220{
221 if (INSIDE_BEGIN_END(ctx)) {
222 gl_error( ctx, GL_INVALID_OPERATION, "glInitNames" );
223 }
224 ctx->Select.NameStackDepth = 0;
225 ctx->Select.HitFlag = GL_FALSE;
226 ctx->Select.HitMinZ = 1.0;
227 ctx->Select.HitMaxZ = 0.0;
228}
#define GL_FALSE
Definition: gl.h:173

Referenced by execute_list(), and init_exec_pointers().

◆ gl_LoadName()

void gl_LoadName ( GLcontext ctx,
GLuint  name 
)

Definition at line 280 of file feedback.c.

281{
282 if (INSIDE_BEGIN_END(ctx)) {
283 gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" );
284 return;
285 }
286 if (ctx->RenderMode!=GL_SELECT) {
287 return;
288 }
289 if (ctx->Select.NameStackDepth==0) {
290 gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" );
291 return;
292 }
293 if (ctx->Select.HitFlag) {
295 }
296 if (ctx->Select.NameStackDepth<MAX_NAME_STACK_DEPTH) {
297 ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name;
298 }
299 else {
300 ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name;
301 }
302}
#define MAX_NAME_STACK_DEPTH
Definition: config.h:109
static void write_hit_record(GLcontext *ctx)
Definition: feedback.c:253
#define GL_SELECT
Definition: gl.h:389
Definition: name.c:39

Referenced by execute_list(), and init_exec_pointers().

◆ gl_PassThrough()

void gl_PassThrough ( GLcontext ctx,
GLfloat  token 
)

Definition at line 143 of file feedback.c.

144{
145 if (INSIDE_BEGIN_END(ctx)) {
146 gl_error( ctx, GL_INVALID_OPERATION, "glPassThrough" );
147 return;
148 }
149
150 if (ctx->RenderMode==GL_FEEDBACK) {
153 }
154}
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
#define GL_PASS_THROUGH_TOKEN
Definition: gl.h:404
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210

Referenced by execute_list(), and init_exec_pointers().

◆ gl_PopName()

void gl_PopName ( GLcontext ctx)

Definition at line 327 of file feedback.c.

328{
329 if (INSIDE_BEGIN_END(ctx)) {
330 gl_error( ctx, GL_INVALID_OPERATION, "glPopName" );
331 return;
332 }
333 if (ctx->RenderMode!=GL_SELECT) {
334 return;
335 }
336 if (ctx->Select.HitFlag) {
338 }
339 if (ctx->Select.NameStackDepth>0) {
340 ctx->Select.NameStackDepth--;
341 }
342 else {
343 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopName" );
344 }
345}
#define GL_STACK_UNDERFLOW
Definition: gl.h:698

Referenced by execute_list(), and init_exec_pointers().

◆ gl_PushName()

void gl_PushName ( GLcontext ctx,
GLuint  name 
)

Definition at line 305 of file feedback.c.

306{
307 if (INSIDE_BEGIN_END(ctx)) {
308 gl_error( ctx, GL_INVALID_OPERATION, "glPushName" );
309 return;
310 }
311 if (ctx->RenderMode!=GL_SELECT) {
312 return;
313 }
314 if (ctx->Select.HitFlag) {
316 }
317 if (ctx->Select.NameStackDepth<MAX_NAME_STACK_DEPTH) {
318 ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name;
319 }
320 else {
321 gl_error( ctx, GL_STACK_OVERFLOW, "glPushName" );
322 }
323}
#define GL_STACK_OVERFLOW
Definition: gl.h:697

Referenced by execute_list(), and init_exec_pointers().

◆ gl_RenderMode()

GLint gl_RenderMode ( GLcontext ctx,
GLenum  mode 
)

Definition at line 358 of file feedback.c.

359{
361
362 if (INSIDE_BEGIN_END(ctx)) {
363 gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
364 }
365
366 switch (ctx->RenderMode) {
367 case GL_RENDER:
368 result = 0;
369 break;
370 case GL_SELECT:
371 if (ctx->Select.HitFlag) {
373 }
374 if (ctx->Select.BufferCount > ctx->Select.BufferSize) {
375 /* overflow */
376#ifdef DEBUG
377 gl_warning(ctx, "Feedback buffer overflow");
378#endif
379 result = -1;
380 }
381 else {
382 result = ctx->Select.Hits;
383 }
384 ctx->Select.BufferCount = 0;
385 ctx->Select.Hits = 0;
386 ctx->Select.NameStackDepth = 0;
387 break;
388 case GL_FEEDBACK:
389 if (ctx->Feedback.Count > ctx->Feedback.BufferSize) {
390 /* overflow */
391 result = -1;
392 }
393 else {
394 result = ctx->Feedback.Count;
395 }
396 ctx->Feedback.Count = 0;
397 break;
398 default:
399 gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
400 return 0;
401 }
402
403 switch (mode) {
404 case GL_RENDER:
405 break;
406 case GL_SELECT:
407 if (ctx->Select.BufferSize==0) {
408 /* haven't called glSelectBuffer yet */
409 gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
410 }
411 break;
412 case GL_FEEDBACK:
413 if (ctx->Feedback.BufferSize==0) {
414 /* haven't called glFeedbackBuffer yet */
415 gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
416 }
417 break;
418 default:
419 gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
420 return 0;
421 }
422
423 ctx->RenderMode = mode;
424 ctx->NewState |= NEW_ALL;
425
426 return result;
427}
void gl_warning(const GLcontext *ctx, const char *s)
Definition: context.c:1406
#define NEW_ALL
Definition: types.h:1236
#define GL_RENDER
Definition: gl.h:388
GLenum mode
Definition: glext.h:6217
GLuint64EXT * result
Definition: glext.h:11304

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_SelectBuffer()

void gl_SelectBuffer ( GLcontext ctx,
GLsizei  size,
GLuint buffer 
)

Definition at line 201 of file feedback.c.

202{
203 if (INSIDE_BEGIN_END(ctx)) {
204 gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" );
205 }
206 if (ctx->RenderMode==GL_SELECT) {
207 gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" );
208 }
209 ctx->Select.Buffer = buffer;
210 ctx->Select.BufferSize = size;
211 ctx->Select.BufferCount = 0;
212
213 ctx->Select.HitFlag = GL_FALSE;
214 ctx->Select.HitMinZ = 1.0;
215 ctx->Select.HitMaxZ = 0.0;
216}

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_update_hitflag()

void gl_update_hitflag ( GLcontext ctx,
GLfloat  z 
)

Definition at line 240 of file feedback.c.

241{
242 ctx->Select.HitFlag = GL_TRUE;
243 if (z < ctx->Select.HitMinZ) {
244 ctx->Select.HitMinZ = z;
245 }
246 if (z > ctx->Select.HitMaxZ) {
247 ctx->Select.HitMaxZ = z;
248 }
249}
#define GL_TRUE
Definition: gl.h:174

Referenced by drawpixels(), gl_CopyPixels(), gl_RasterPos4f(), gl_windowpos(), select_line(), select_points(), and select_triangle().

◆ write_hit_record()

static void write_hit_record ( GLcontext ctx)
static

Definition at line 253 of file feedback.c.

254{
255 GLuint i;
256 GLuint zmin, zmax, zscale = (~0u);
257
258 /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */
259 /* 2^32-1 and round to nearest unsigned integer. */
260
261 assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */
262 zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ);
263 zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ);
264
265 WRITE_RECORD( ctx, ctx->Select.NameStackDepth );
266 WRITE_RECORD( ctx, zmin );
268 for (i=0;i<ctx->Select.NameStackDepth;i++) {
269 WRITE_RECORD( ctx, ctx->Select.NameStack[i] );
270 }
271
272 ctx->Select.Hits++;
273 ctx->Select.HitFlag = GL_FALSE;
274 ctx->Select.HitMinZ = 1.0;
275 ctx->Select.HitMaxZ = -1.0;
276}
#define NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
#define WRITE_RECORD(CTX, V)
Definition: feedback.c:232
unsigned int GLuint
Definition: gl.h:159
GLclampd zmax
Definition: glext.h:10123
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

Referenced by gl_LoadName(), gl_PopName(), gl_PushName(), and gl_RenderMode().