ReactOS 0.4.15-dev-7705-g2320c37
misc.h File Reference
#include "types.h"
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gl_ClearIndex (GLcontext *ctx, GLfloat c)
 
void gl_ClearColor (GLcontext *ctx, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 
void gl_Clear (GLcontext *ctx, GLbitfield mask)
 
const GLubytegl_GetString (GLcontext *ctx, GLenum name)
 
void gl_Finish (GLcontext *ctx)
 
void gl_Flush (GLcontext *ctx)
 
void gl_Hint (GLcontext *ctx, GLenum target, GLenum mode)
 
void gl_DrawBuffer (GLcontext *ctx, GLenum mode)
 
void gl_ReadBuffer (GLcontext *ctx, GLenum mode)
 

Function Documentation

◆ gl_Clear()

void gl_Clear ( GLcontext ctx,
GLbitfield  mask 
)

Definition at line 260 of file misc.c.

261{
262#ifdef PROFILE
263 GLdouble t0 = gl_time();
264#endif
265
266 if (INSIDE_BEGIN_END(ctx)) {
267 gl_error( ctx, GL_INVALID_OPERATION, "glClear" );
268 return;
269 }
270
271 if (ctx->RenderMode==GL_RENDER) {
272 if (ctx->NewState) {
274 }
275
276 /* See if we can call device driver function to clear both the
277 * color and depth buffers.
278 */
279 if (ctx->Driver.ClearColorAndDepth &&
281 GLint x = ctx->Buffer->Xmin;
282 GLint y = ctx->Buffer->Ymin;
283 GLint height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1;
284 GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1;
285 (*ctx->Driver.ClearColorAndDepth)( ctx, !ctx->Scissor.Enabled,
286 x, y, width, height );
287 if (ctx->RasterMask & FRONT_AND_BACK_BIT) {
288 /*** Also clear the back buffer ***/
289 (*ctx->Driver.SetBuffer)( ctx, GL_BACK );
290 (*ctx->Driver.ClearColorAndDepth)( ctx, !ctx->Scissor.Enabled,
291 x, y, width, height );
292 (*ctx->Driver.SetBuffer)( ctx, GL_FRONT );
293 }
294 }
295 else {
296 /* normal procedure for clearing buffers */
298 if (mask & GL_DEPTH_BUFFER_BIT) (*ctx->Driver.ClearDepthBuffer)(ctx);
301 }
302
303#ifdef PROFILE
304 ctx->ClearTime += gl_time() - t0;
305 ctx->ClearCount++;
306#endif
307 }
308}
void gl_clear_accum_buffer(GLcontext *ctx)
Definition: accum.c:287
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
void gl_update_state(GLcontext *ctx)
Definition: context.c:1749
static void clear_color_buffers(GLcontext *ctx)
Definition: misc.c:222
#define FRONT_AND_BACK_BIT
Definition: types.h:1225
#define GL_RENDER
Definition: gl.h:388
#define GL_ACCUM_BUFFER_BIT
Definition: gl.h:711
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
double GLdouble
Definition: gl.h:163
#define GL_INVALID_OPERATION
Definition: gl.h:696
#define GL_BACK
Definition: gl.h:271
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_STENCIL_BUFFER_BIT
Definition: gl.h:712
int GLint
Definition: gl.h:156
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_FRONT
Definition: gl.h:270
#define GL_DEPTH_BUFFER_BIT
Definition: gl.h:710
GLenum GLint GLuint mask
Definition: glext.h:6028
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
void gl_clear_stencil_buffer(GLcontext *ctx)
Definition: stencil.c:1001

Referenced by execute_list(), and init_exec_pointers().

◆ gl_ClearColor()

void gl_ClearColor ( GLcontext ctx,
GLclampf  red,
GLclampf  green,
GLclampf  blue,
GLclampf  alpha 
)

Definition at line 132 of file misc.c.

134{
135 if (INSIDE_BEGIN_END(ctx)) {
136 gl_error( ctx, GL_INVALID_OPERATION, "glClearColor" );
137 return;
138 }
139
140 ctx->Color.ClearColor[0] = CLAMP( red, 0.0F, 1.0F );
141 ctx->Color.ClearColor[1] = CLAMP( green, 0.0F, 1.0F );
142 ctx->Color.ClearColor[2] = CLAMP( blue, 0.0F, 1.0F );
143 ctx->Color.ClearColor[3] = CLAMP( alpha, 0.0F, 1.0F );
144
145 if (ctx->Visual->RGBAflag) {
146 GLubyte r = (GLint) (ctx->Color.ClearColor[0] * ctx->Visual->RedScale);
147 GLubyte g = (GLint) (ctx->Color.ClearColor[1] * ctx->Visual->GreenScale);
148 GLubyte b = (GLint) (ctx->Color.ClearColor[2] * ctx->Visual->BlueScale);
149 GLubyte a = (GLint) (ctx->Color.ClearColor[3] * ctx->Visual->AlphaScale);
150 (*ctx->Driver.ClearColor)( ctx, r, g, b, a );
151 }
152}
unsigned char GLubyte
Definition: gl.h:157
GLclampf green
Definition: gl.h:1740
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLclampf GLclampf blue
Definition: gl.h:1740
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define red
Definition: linetest.c:67
#define CLAMP(f, min, max)
Definition: tif_color.c:177

Referenced by execute_list(), and init_exec_pointers().

◆ gl_ClearIndex()

void gl_ClearIndex ( GLcontext ctx,
GLfloat  c 
)

Definition at line 117 of file misc.c.

118{
119 if (INSIDE_BEGIN_END(ctx)) {
120 gl_error( ctx, GL_INVALID_OPERATION, "glClearIndex" );
121 return;
122 }
123 ctx->Color.ClearIndex = (GLuint) c;
124 if (!ctx->Visual->RGBAflag) {
125 /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
126 (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex );
127 }
128}
unsigned int GLuint
Definition: gl.h:159
const GLubyte * c
Definition: glext.h:8905

Referenced by execute_list(), and init_exec_pointers().

◆ gl_DrawBuffer()

void gl_DrawBuffer ( GLcontext ctx,
GLenum  mode 
)

Definition at line 408 of file misc.c.

409{
410 if (INSIDE_BEGIN_END(ctx)) {
411 gl_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
412 return;
413 }
414 switch (mode) {
415 case GL_FRONT:
416 case GL_FRONT_LEFT:
418 if ( (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ) == GL_FALSE ) {
419 gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" );
420 return;
421 }
422 ctx->Color.DrawBuffer = mode;
423 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
424 ctx->NewState |= NEW_RASTER_OPS;
425 break;
426 case GL_BACK:
427 case GL_BACK_LEFT:
428 if ( (*ctx->Driver.SetBuffer)( ctx, GL_BACK ) == GL_FALSE) {
429 gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" );
430 return;
431 }
432 ctx->Color.DrawBuffer = mode;
433 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
434 ctx->NewState |= NEW_RASTER_OPS;
435 break;
436 case GL_NONE:
437 ctx->Color.DrawBuffer = mode;
438 ctx->Buffer->Alpha = NULL;
439 ctx->NewState |= NEW_RASTER_OPS;
440 break;
441 case GL_FRONT_RIGHT:
442 case GL_BACK_RIGHT:
443 case GL_LEFT:
444 case GL_RIGHT:
445 case GL_AUX0:
446 gl_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
447 break;
448 default:
449 gl_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" );
450 }
451}
#define NULL
Definition: types.h:112
#define NEW_RASTER_OPS
Definition: types.h:1233
#define GL_NONE
Definition: gl.h:465
#define GL_LEFT
Definition: gl.h:466
#define GL_FRONT_AND_BACK
Definition: gl.h:336
#define GL_FRONT_RIGHT
Definition: gl.h:472
#define GL_FRONT_LEFT
Definition: gl.h:471
#define GL_BACK_LEFT
Definition: gl.h:473
#define GL_AUX0
Definition: gl.h:475
#define GL_RIGHT
Definition: gl.h:467
#define GL_FALSE
Definition: gl.h:173
#define GL_INVALID_ENUM
Definition: gl.h:694
#define GL_BACK_RIGHT
Definition: gl.h:474
GLenum mode
Definition: glext.h:6217

Referenced by execute_list(), gl_PopAttrib(), and init_exec_pointers().

◆ gl_Finish()

void gl_Finish ( GLcontext ctx)

Definition at line 346 of file misc.c.

347{
348 /* Don't compile into display list */
349 if (INSIDE_BEGIN_END(ctx)) {
350 gl_error( ctx, GL_INVALID_OPERATION, "glFinish" );
351 return;
352 }
353 if (ctx->Driver.Finish) {
354 (*ctx->Driver.Finish)( ctx );
355 }
356}

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_Flush()

void gl_Flush ( GLcontext ctx)

Definition at line 360 of file misc.c.

361{
362 /* Don't compile into display list */
363 if (INSIDE_BEGIN_END(ctx)) {
364 gl_error( ctx, GL_INVALID_OPERATION, "glFlush" );
365 return;
366 }
367 if (ctx->Driver.Flush) {
368 (*ctx->Driver.Flush)( ctx );
369 }
370}

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_GetString()

const GLubyte * gl_GetString ( GLcontext ctx,
GLenum  name 
)

Definition at line 312 of file misc.c.

313{
314 static char renderer[1000];
315 static char *vendor = "Brian Paul & ReactOS Developers";
316 static char *version = "1.1.0";
317 static char *extensions = "GL_EXT_paletted_texture GL_EXT_bgra GL_WIN_swap_hint";
318
319 if (INSIDE_BEGIN_END(ctx)) {
320 gl_error( ctx, GL_INVALID_OPERATION, "glGetString" );
321 return (GLubyte *) 0;
322 }
323
324 switch (name) {
325 case GL_VENDOR:
326 return (GLubyte *) vendor;
327 case GL_RENDERER:
328 strcpy(renderer, "Mesa");
329 if (ctx->Driver.RendererString) {
330 strcat(renderer, " ");
331 strcat(renderer, (*ctx->Driver.RendererString)());
332 }
333 return (GLubyte *) renderer;
334 case GL_VERSION:
335 return (GLubyte *) version;
336 case GL_EXTENSIONS:
337 return (GLubyte *) extensions;
338 default:
339 gl_error( ctx, GL_INVALID_ENUM, "glGetString" );
340 return (GLubyte *) 0;
341 }
342}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
const WCHAR * vendor
Definition: db.cpp:872
static const WCHAR version[]
Definition: asmname.c:66
#define GL_VERSION
Definition: gl.h:689
#define GL_EXTENSIONS
Definition: gl.h:690
#define GL_RENDERER
Definition: gl.h:688
#define GL_VENDOR
Definition: gl.h:687
Definition: name.c:39

Referenced by init_dlist_pointers(), and init_exec_pointers().

◆ gl_Hint()

void gl_Hint ( GLcontext ctx,
GLenum  target,
GLenum  mode 
)

Definition at line 374 of file misc.c.

375{
376 if (INSIDE_BEGIN_END(ctx)) {
377 gl_error( ctx, GL_INVALID_OPERATION, "glHint" );
378 return;
379 }
381 gl_error( ctx, GL_INVALID_ENUM, "glHint(mode)" );
382 return;
383 }
384 switch (target) {
385 case GL_FOG_HINT:
386 ctx->Hint.Fog = mode;
387 break;
389 ctx->Hint.LineSmooth = mode;
390 break;
392 ctx->Hint.PerspectiveCorrection = mode;
393 break;
395 ctx->Hint.PointSmooth = mode;
396 break;
398 ctx->Hint.PolygonSmooth = mode;
399 break;
400 default:
401 gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
402 }
403 ctx->NewState |= NEW_ALL; /* just to be safe */
404}
#define NEW_ALL
Definition: types.h:1236
#define GL_FASTEST
Definition: gl.h:584
#define GL_POINT_SMOOTH_HINT
Definition: gl.h:579
#define GL_NICEST
Definition: gl.h:585
#define GL_FOG_HINT
Definition: gl.h:582
#define GL_DONT_CARE
Definition: gl.h:583
#define GL_LINE_SMOOTH_HINT
Definition: gl.h:580
#define GL_PERSPECTIVE_CORRECTION_HINT
Definition: gl.h:578
#define GL_POLYGON_SMOOTH_HINT
Definition: gl.h:581
GLenum target
Definition: glext.h:7315

Referenced by execute_list(), and init_exec_pointers().

◆ gl_ReadBuffer()

void gl_ReadBuffer ( GLcontext ctx,
GLenum  mode 
)

Definition at line 455 of file misc.c.

456{
457 if (INSIDE_BEGIN_END(ctx)) {
458 gl_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
459 return;
460 }
461 switch (mode) {
462 case GL_FRONT:
463 case GL_FRONT_LEFT:
464 if ( (*ctx->Driver.SetBuffer)( ctx, GL_FRONT ) == GL_FALSE) {
465 gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" );
466 return;
467 }
468 ctx->Pixel.ReadBuffer = mode;
469 ctx->Buffer->Alpha = ctx->Buffer->FrontAlpha;
470 ctx->NewState |= NEW_RASTER_OPS;
471 break;
472 case GL_BACK:
473 case GL_BACK_LEFT:
474 if ( (*ctx->Driver.SetBuffer)( ctx, GL_BACK ) == GL_FALSE) {
475 gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" );
476 return;
477 }
478 ctx->Pixel.ReadBuffer = mode;
479 ctx->Buffer->Alpha = ctx->Buffer->BackAlpha;
480 ctx->NewState |= NEW_RASTER_OPS;
481 break;
482 case GL_FRONT_RIGHT:
483 case GL_BACK_RIGHT:
484 case GL_LEFT:
485 case GL_RIGHT:
486 case GL_AUX0:
487 gl_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
488 break;
489 default:
490 gl_error( ctx, GL_INVALID_ENUM, "glReadBuffer" );
491 }
492
493 /* Remember, the draw buffer is the default state */
494 (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DrawBuffer );
495}

Referenced by execute_list(), and init_exec_pointers().