30 #include "../../shared/images.h"
33 {1, 1, 1, 1, 1, 1, 1, 1},
34 {1, 0, 0, 0, 0, 0, 0, 1},
35 {1, 0, 0, 0, 0, 0, 0, 1},
36 {1, 0, 0, 0, 0, 0, 0, 1},
37 {1, 0, 0, 0, 0, 0, 0, 1},
38 {1, 0, 0, 0, 0, 0, 0, 1},
39 {1, 0, 0, 0, 0, 0, 0, 1},
40 {1, 1, 1, 1, 1, 1, 1, 1},
45 #define MISC_TEXTURE_SIZE 16
54 for (x = 0; x < 8; x++) {
55 for (y = 0; y < 8; y++) {
64 data[y][x][0] = rand() % 255;
65 data[y][x][1] = rand() % 255;
66 data[y][x][2] = rand() % 48;
67 data[y][x][3] = rand() % 48;
104 int type, quality = 100;
107 glGetIntegerv(GL_PACK_ALIGNMENT, &rowPack);
108 glPixelStorei(GL_PACK_ALIGNMENT, 1);
138 if (quality > 100 || quality <= 0)
141 Com_Printf(
"Taking JPG screenshot (at %i%% quality)...\n", quality);
148 Com_sprintf(checkName,
sizeof(checkName),
"scrnshot/%s.%s", filename, ext);
151 for (shotNum = 0; shotNum < 1000; shotNum++) {
152 Com_sprintf(checkName,
sizeof(checkName),
"scrnshot/ufo%i%i.%s", shotNum / 10, shotNum % 10, ext);
156 if (shotNum == 1000) {
157 Com_Printf(
"R_ScreenShot_f: screenshot limit (of 1000) exceeded!\n");
166 Com_Printf(
"R_ScreenShot_f: Couldn't create file: %s\n", checkName);
173 Com_Printf(
"R_ScreenShot_f: Could not allocate %i bytes for screenshot!\n", width * height * 3);
178 glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
192 R_WriteJPG(&f, buffer, width, height, quality);
200 glPixelStorei(GL_PACK_ALIGNMENT, rowPack);
205 const char* ext =
nullptr;
222 if (transform !=
nullptr) {
223 glTranslatef(transform[0], transform[1], transform[2]);
226 if (rotate !=
nullptr) {
227 glRotatef(rotate[0], 0, 0, 1);
228 glRotatef(rotate[1], 0, 1, 0);
229 glRotatef(rotate[2], 1, 0, 0);
232 if (scale !=
nullptr) {
233 glScalef(scale[0], scale[1], scale[2]);
258 #define CAPABILITY( X ) {GL_ ## X, # X}
260 const struct {
GLenum idx;
const char* text; } openGLCaps[] = {
289 GLint maxTexUnits = 0;
290 GLint activeTexUnit = 0;
291 GLint activeClientTexUnit = 0;
292 GLint activeTexId = 0;
293 GLfloat texEnvMode = 0;
294 const char* texEnvModeStr =
"UNKNOWN";
297 for (
int i = 0; i <
lengthof(openGLCaps); i++) {
298 if (glIsEnabled(openGLCaps[i].idx)) {
299 Q_strcat(s,
sizeof(s),
"%s ", openGLCaps[i].text);
302 glGetFloatv(GL_CURRENT_COLOR, color);
304 Com_Printf(
"OpenGL enabled caps: %s color %f %f %f %f \n", s, color[0], color[1], color[2], color[3]);
306 glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexUnit);
307 glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &activeClientTexUnit);
309 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTexUnits);
310 for (i = GL_TEXTURE0; i < GL_TEXTURE0 + maxTexUnits; i++) {
312 qglClientActiveTexture(i);
315 if (glIsEnabled (GL_TEXTURE_2D))
316 strcat(s,
"enabled, ");
317 if (glIsEnabled (GL_TEXTURE_COORD_ARRAY))
318 strcat(s,
"with texcoord array, ");
319 if (i == activeTexUnit)
320 strcat(s,
"active, ");
321 if (i == activeClientTexUnit)
322 strcat(s,
"client active, ");
324 glGetIntegerv(GL_TEXTURE_BINDING_2D, &activeTexId);
325 glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvMode);
326 if (fabs(texEnvMode - GL_ADD) < 0.1
f)
327 texEnvModeStr =
"ADD";
328 if (fabs(texEnvMode - GL_MODULATE) < 0.1
f)
329 texEnvModeStr =
"MODULATE";
330 if (fabs(texEnvMode - GL_DECAL) < 0.1
f)
331 texEnvModeStr =
"DECAL";
332 if (fabs(texEnvMode - GL_BLEND) < 0.1
f)
333 texEnvModeStr =
"BLEND";
334 if (fabs(texEnvMode - GL_REPLACE) < 0.1
f)
335 texEnvModeStr =
"REPLACE";
336 if (fabs(texEnvMode - GL_COMBINE) < 0.1
f)
337 texEnvModeStr =
"COMBINE";
339 Com_Printf(
"Texunit: %d texID %d %s texEnv mode %s\n", i - GL_TEXTURE0, activeTexId, s, texEnvModeStr);
342 qglActiveTexture(activeTexUnit);
343 qglClientActiveTexture(activeClientTexUnit);
374 int vertind = 0, coordind = 0, tangind = 0;
385 qglBufferData(GL_ARRAY_BUFFER, vertind *
sizeof(GLfloat), mod->
bsp.
verts, GL_STATIC_DRAW);
389 qglBufferData(GL_ARRAY_BUFFER, coordind *
sizeof(GLfloat), mod->
bsp.
texcoords, GL_STATIC_DRAW);
393 qglBufferData(GL_ARRAY_BUFFER, coordind *
sizeof(GLfloat), mod->
bsp.
lmtexcoords, GL_STATIC_DRAW);
397 qglBufferData(GL_ARRAY_BUFFER, vertind *
sizeof(GLfloat), mod->
bsp.
normals, GL_STATIC_DRAW);
401 qglBufferData(GL_ARRAY_BUFFER, tangind *
sizeof(GLfloat), mod->
bsp.
tangents, GL_STATIC_DRAW);
406 qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
413 qglBindBuffer(GL_ARRAY_BUFFER, 0);
const char * Cmd_Argv(int arg)
Returns a given argument.
cvar_t * r_screenshot_jpeg_quality
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
void R_ShutdownFBObjects(void)
Delete all registered framebuffer and render buffer objects, clear memory.
QGL_EXTERN GLint GLenum type
void R_Transform(const vec3_t transform, const vec3_t rotate, const vec3_t scale)
Perform translate, rotate and scale operations on the current matrix.
void R_ScreenShot_f(void)
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
unsigned int texcoord_buffer
static const vec3_t scale
model_t * r_mapTiles[MAX_MAPTILES]
The world model(s)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const GLenum *typedef GLint
void R_EndBuildingLightmaps(void)
void R_SetDefaultState(void)
image_t * R_LoadImageData(const char *name, const byte *pic, int width, int height, imagetype_t type)
Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it...
local graphics definitions
cvar_t * r_screenshot_format
void Com_Printf(const char *const fmt,...)
void R_WriteJPG(qFILE *f, byte *buffer, int width, int height, int quality)
void R_UpdateDefaultMaterial(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Change listener callback for material value cvars.
void R_CreateSurfaceLightmap(mBspSurface_t *surf)
const GLuint *typedef GLuint *typedef GLenum
void R_InitMiscTexture(void)
const char * FS_Gamedir(void)
Called to find where to write a file (savegames, etc)
glElementIndex_t * indexes
static const byte dummytexture[4]
unsigned int normal_buffer
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void R_InitFBObjects(void)
unsigned int tangent_buffer
void R_ResetArrayState(void)
void R_ShutdownPrograms(void)
#define Q_strcasecmp(a, b)
void R_ScreenShot(int x, int y, int width, int height, const char *filename, const char *ext)
unsigned int vertex_buffer
#define Mem_PoolAllocTypeN(type, n, pool)
unsigned int lmtexcoord_buffer
void R_ReloadImages(void)
void R_PopMatrix(void)
Removes the current matrix from the stack.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
void R_DumpOpenGlState(void)
Dumps OpenGL state for debugging - typically every capability set with glEnable().
void R_FontCleanCache(void)
Clears font cache and frees memory associated with the cache.
void R_WritePNG(qFILE *f, byte *buffer, int width, int height)
void R_ReinitOpenglContext(void)
Re-initializes OpenGL state machine, all textures and renderer variables, this needed when applicatio...
memPool_t * vid_imagePool
GLsizei const GLvoid * data
#define MISC_TEXTURE_SIZE
void R_BeginBuildingLightmaps(void)
void R_PushMatrix(void)
Push a new matrix to the stack.
void R_InitPrograms(void)
unsigned int index_buffer
static const byte gridtexture[8][8]
void R_WriteCompressedTGA(qFILE *f, const byte *buffer, int width, int height)