icculus quake2 doxygen  1.0 dev
gl_rmisc.c File Reference
#include "gl_local.h"

Go to the source code of this file.

Classes

struct  _TargaHeader
 

Typedefs

typedef struct _TargaHeader TargaHeader
 

Functions

void R_InitParticleTexture (void)
 
void GL_ScreenShot_f (void)
 
void GL_Strings_f (void)
 
void GL_SetDefaultState (void)
 
void GL_UpdateSwapInterval (void)
 

Variables

byte dottexture [8][8]
 

Typedef Documentation

◆ TargaHeader

typedef struct _TargaHeader TargaHeader

Function Documentation

◆ GL_ScreenShot_f()

void GL_ScreenShot_f ( void  )

Definition at line 100 of file gl_rmisc.c.

101 {
102  byte *buffer;
103  char picname[80];
104  char checkname[MAX_OSPATH];
105  int i, c, temp;
106  FILE *f;
107 
108  // create the scrnshots directory if it doesn't exist
109  Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir());
110  Sys_Mkdir (checkname);
111 
112 //
113 // find a file name to save it to
114 //
115  strcpy(picname,"quake00.tga");
116 
117  for (i=0 ; i<=99 ; i++)
118  {
119  picname[5] = i/10 + '0';
120  picname[6] = i%10 + '0';
121  Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot/%s", ri.FS_Gamedir(), picname);
122  f = fopen (checkname, "rb");
123  if (!f)
124  break; // file doesn't exist
125  fclose (f);
126  }
127  if (i==100)
128  {
129  ri.Con_Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n");
130  return;
131  }
132 
133 
134  buffer = malloc(vid.width*vid.height*3 + 18);
135  memset (buffer, 0, 18);
136  buffer[2] = 2; // uncompressed type
137  buffer[12] = vid.width&255;
138  buffer[13] = vid.width>>8;
139  buffer[14] = vid.height&255;
140  buffer[15] = vid.height>>8;
141  buffer[16] = 24; // pixel size
142 
143  qglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 );
144 
145  // swap rgb to bgr
146  c = 18+vid.width*vid.height*3;
147  for (i=18 ; i<c ; i+=3)
148  {
149  temp = buffer[i];
150  buffer[i] = buffer[i+2];
151  buffer[i+2] = temp;
152  }
153 
154  f = fopen (checkname, "wb");
155  fwrite (buffer, 1, c, f);
156  fclose (f);
157 
158  free (buffer);
159  ri.Con_Printf (PRINT_ALL, "Wrote %s\n", picname);
160 }

Referenced by R_Register().

◆ GL_SetDefaultState()

void GL_SetDefaultState ( void  )

Definition at line 176 of file gl_rmisc.c.

177 {
178  qglClearColor (1,0, 0.5 , 0.5);
179  qglCullFace(GL_FRONT);
180  qglEnable(GL_TEXTURE_2D);
181 
182  qglEnable(GL_ALPHA_TEST);
183  qglAlphaFunc(GL_GREATER, 0.666);
184 
185  qglDisable (GL_DEPTH_TEST);
186  qglDisable (GL_CULL_FACE);
187  qglDisable (GL_BLEND);
188 
189  qglColor4f (1,1,1,1);
190 
191  qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
192  qglShadeModel (GL_FLAT);
193 
197 
198  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
199  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
200 
201  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
202  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
203 
204  qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
205 
206  GL_TexEnv( GL_REPLACE );
207 
208  if ( qglPointParameterfEXT )
209  {
210  float attenuations[3];
211 
212  attenuations[0] = gl_particle_att_a->value;
213  attenuations[1] = gl_particle_att_b->value;
214  attenuations[2] = gl_particle_att_c->value;
215 
216  qglEnable( GL_POINT_SMOOTH );
217  qglPointParameterfEXT( GL_POINT_SIZE_MIN_EXT, gl_particle_min_size->value );
218  qglPointParameterfEXT( GL_POINT_SIZE_MAX_EXT, gl_particle_max_size->value );
219  qglPointParameterfvEXT( GL_DISTANCE_ATTENUATION_EXT, attenuations );
220  }
221 
222  if ( qglColorTableEXT && gl_ext_palettedtexture->value )
223  {
224  qglEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
225 
227  }
228 
230 }

Referenced by R_Init().

◆ GL_Strings_f()

void GL_Strings_f ( void  )

Definition at line 165 of file gl_rmisc.c.

166 {
167  ri.Con_Printf (PRINT_ALL, "GL_VENDOR: %s\n", gl_config.vendor_string );
168  ri.Con_Printf (PRINT_ALL, "GL_RENDERER: %s\n", gl_config.renderer_string );
169  ri.Con_Printf (PRINT_ALL, "GL_VERSION: %s\n", gl_config.version_string );
170  ri.Con_Printf (PRINT_ALL, "GL_EXTENSIONS: %s\n", gl_config.extensions_string );
171 }

Referenced by R_Register().

◆ GL_UpdateSwapInterval()

void GL_UpdateSwapInterval ( void  )

Definition at line 232 of file gl_rmisc.c.

233 {
234  if ( gl_swapinterval->modified )
235  {
236  gl_swapinterval->modified = false;
237 
238  if ( !gl_state.stereo_enabled )
239  {
240 #ifdef _WIN32
241  if ( qwglSwapIntervalEXT )
242  qwglSwapIntervalEXT( gl_swapinterval->value );
243 #endif
244  }
245  }
246 }

Referenced by GL_SetDefaultState(), and R_BeginFrame().

◆ R_InitParticleTexture()

void R_InitParticleTexture ( void  )

Definition at line 41 of file gl_rmisc.c.

42 {
43  int x,y;
44  byte data[8][8][4];
45 
46  //
47  // particle texture
48  //
49  for (x=0 ; x<8 ; x++)
50  {
51  for (y=0 ; y<8 ; y++)
52  {
53  data[y][x][0] = 255;
54  data[y][x][1] = 255;
55  data[y][x][2] = 255;
56  data[y][x][3] = dottexture[x][y]*255;
57  }
58  }
59  r_particletexture = GL_LoadPic ("***particle***", (byte *)data, 8, 8, it_sprite, 32);
60 
61  //
62  // also use this for bad textures, but without alpha
63  //
64  for (x=0 ; x<8 ; x++)
65  {
66  for (y=0 ; y<8 ; y++)
67  {
68  data[y][x][0] = dottexture[x&3][y&3]*255;
69  data[y][x][1] = 0; // dottexture[x&3][y&3]*255;
70  data[y][x][2] = 0; //dottexture[x&3][y&3]*255;
71  data[y][x][3] = 255;
72  }
73  }
74  r_notexture = GL_LoadPic ("***r_notexture***", (byte *)data, 8, 8, it_wall, 32);
75 }

Referenced by R_Init().

Variable Documentation

◆ dottexture

byte dottexture[8][8]
Initial value:
=
{
{0,0,0,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,1,1,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
}

Definition at line 29 of file gl_rmisc.c.

Referenced by R_InitParticleTexture().

it_sprite
@ it_sprite
Definition: r_local.h:59
GL_LoadPic
image_t * GL_LoadPic(char *name, byte *pic, int width, int height, imagetype_t type)
Definition: r_image.c:420
GL_UpdateSwapInterval
void GL_UpdateSwapInterval(void)
Definition: gl_rmisc.c:232
glstate_t::stereo_enabled
qboolean stereo_enabled
Definition: gl_local.h:430
gl_particle_att_c
cvar_t * gl_particle_att_c
Definition: gl_rmain.c:95
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:38
GL_SHARED_TEXTURE_PALETTE_EXT
#define GL_SHARED_TEXTURE_PALETTE_EXT
Definition: qgl.h:464
gl_state
glstate_t gl_state
Definition: gl_rmain.c:36
ri
refimport_t ri
Definition: r_main.c:25
Sys_Mkdir
void Sys_Mkdir(char *path)
Definition: q_shwin.c:135
GL_TextureAlphaMode
void GL_TextureAlphaMode(char *string)
Definition: gl_image.c:254
glconfig_t::extensions_string
const char * extensions_string
Definition: gl_local.h:410
it_wall
@ it_wall
Definition: r_local.h:60
cvar_s::modified
qboolean modified
Definition: q_shared.h:323
GL_TextureMode
void GL_TextureMode(char *string)
Definition: gl_image.c:217
cvar_s::string
char * string
Definition: q_shared.h:320
x
GLint GLenum GLint x
Definition: qgl_win.c:116
viddef_t::width
int width
Definition: vid.h:29
i
int i
Definition: q_shared.c:305
gl_particle_att_a
cvar_t * gl_particle_att_a
Definition: gl_rmain.c:93
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
viddef_t::height
int height
Definition: vid.h:29
GL_TextureSolidMode
void GL_TextureSolidMode(char *string)
Definition: gl_image.c:278
gl_filter_min
int gl_filter_min
Definition: gl_image.c:44
gl_texturemode
cvar_t * gl_texturemode
Definition: gl_rmain.c:128
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:228
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:743
gl_texturealphamode
cvar_t * gl_texturealphamode
Definition: gl_rmain.c:129
cvar_s::value
float value
Definition: q_shared.h:324
r_particletexture
image_t * r_particletexture
Definition: gl_rmain.c:39
MAX_OSPATH
#define MAX_OSPATH
Definition: q_shared.h:74
refimport_t::FS_Gamedir
char *(* FS_Gamedir)(void)
Definition: ref.h:240
dottexture
byte dottexture[8][8]
Definition: gl_rmisc.c:29
GL_SetTexturePalette
void GL_SetTexturePalette(unsigned palette[256])
Definition: gl_image.c:47
gl_filter_max
int gl_filter_max
Definition: gl_image.c:45
glconfig_t::renderer_string
const char * renderer_string
Definition: gl_local.h:407
y
GLint y
Definition: qgl_win.c:115
gl_texturesolidmode
cvar_t * gl_texturesolidmode
Definition: gl_rmain.c:130
gl_particle_max_size
cvar_t * gl_particle_max_size
Definition: gl_rmain.c:91
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
gl_config
glconfig_t gl_config
Definition: gl_rmain.c:35
GL_TexEnv
void GL_TexEnv(GLenum mode)
Definition: gl_image.c:125
gl_ext_palettedtexture
static cvar_t * gl_ext_palettedtexture
Definition: vid_menu.c:37
glconfig_t::vendor_string
const char * vendor_string
Definition: gl_local.h:408
gl_particle_min_size
cvar_t * gl_particle_min_size
Definition: gl_rmain.c:90
gl_swapinterval
cvar_t * gl_swapinterval
Definition: gl_rmain.c:127
glconfig_t::version_string
const char * version_string
Definition: gl_local.h:409
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1236
gl_particle_att_b
cvar_t * gl_particle_att_b
Definition: gl_rmain.c:94
vid
viddef_t vid
Definition: r_main.c:24