Game Development Reference
In-Depth Information
GL_BeginRendering : Fires when the rendering starts for each frame of
the game. This function needs to know the left and top XY coordinates
of the screen, plus the width and height of the video, as shown here:
void GL_BeginRendering (int *x, int *y, int *width, int *height)
{
extern cvar_t gl_clear;
*x = *y = 0;
*width = scr_width;
*height = scr_height;
}
Finally, note that GL_EndRendering fires whenever the rendering of a frame of the game
completes. A call to glFlush causes all issued GL commands to be executed as quickly as
they are accepted by the OpenGL pipeline.
void GL_EndRendering (void)
{
glFlush();
}
The brightness of the color palette can be adjusted by altering the values of its RGB pixels.
Because Quake uses a 256 RGB888 palette, the brightness can be increased or decreased
using the formula:
L
[
]
(
)
Pi
()
=
ë
Pi
()
+
1 256
û
gamma
*
255 05
+
. ;(): ,
Pi
0 255
where P(i) represents a pixel in the palette, and gamma is a user parameter read from the
command line with a range from 0 to 1. Note that P(i) must be clamped between 0 and 255,
as shown in Listing 6-11.
Listing 6-11. Brightness Control
static void Check_Gamma (unsigned char *pal)
{
float f, inf;
unsigned char palette[768];
int i;
if ((i = COM_CheckParm("-gamma")) == 0) {
vid_gamma = 0.5; // default to 0.5
} else
vid_gamma = Q_atof(com_argv[i+1]);
for (i=0 ; i<768 ; i++)
{
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
inf = f*255 + 0.5;
Search WWH ::




Custom Search