Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ typedef struct {
#define VectorClear(a) ((a)[0] = (a)[1] = (a)[2] = 0)
#define VectorNegate(a, b) ((b)[0] = -(a)[0], (b)[1] = -(a)[1], (b)[2] = -(a)[2])
#define VectorSet(v, x, y, z) ((v)[0] = (x), (v)[1] = (y), (v)[2] = (z))
#define Vector2Set(v, x, y) ((v)[0] = (x), (v)[1] = (y))
#define Vector2Copy(a, b) ((b)[0] = (a)[0], (b)[1] = (a)[1])

#define Vector4Set(v, x, y, z, w) ((v)[0] = (x), (v)[1] = (y), (v)[2] = (z), (v)[3] = (w))
#define Vector4Copy(a, b) ((b)[0] = (a)[0], (b)[1] = (a)[1], (b)[2] = (a)[2], (b)[3] = (a)[3])

#define Byte4Copy(a, b) ((b)[0] = (a)[0], (b)[1] = (a)[1], (b)[2] = (a)[2], (b)[3] = (a)[3])
Expand Down
1 change: 1 addition & 0 deletions code/renderercommon/qgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern void(APIENTRYP qglUnlockArraysEXT)(void);
#define QGL_1_1_FIXED_FUNCTION_PROCS \
GLE(void, AlphaFunc, GLenum func, GLclampf ref) \
GLE(void, Color4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) \
GLE(void, Color4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) \
GLE(void, ColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
GLE(void, DisableClientState, GLenum cap) \
GLE(void, EnableClientState, GLenum cap) \
Expand Down
112 changes: 88 additions & 24 deletions code/renderergl1/tr_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,46 @@ static void RB_SetGL2D(void) {
backEnd.refdef.floatTime = backEnd.refdef.time * 0.001;
}

/*
================
RB_InstantQuad2
================
*/
void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) {
glIndex_t indexes[6];

qglDisableClientState(GL_COLOR_ARRAY);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);

qglTexCoordPointer(2, GL_FLOAT, 0, texCoords);
qglVertexPointer(3, GL_FLOAT, 16, quadVerts);

indexes[0] = 0;
indexes[1] = 1;
indexes[2] = 2;
indexes[3] = 0;
indexes[4] = 2;
indexes[5] = 3;

R_DrawElements(6, indexes);
}

/*
================
RB_InstantQuad
================
*/
void RB_InstantQuad(vec4_t quadVerts[4]) {
vec2_t texCoords[4] = {
{0, 0},
{1, 0},
{1, 1},
{0, 1}
};

RB_InstantQuad2(quadVerts, texCoords);
}

/*
=============
RE_StretchRaw
Expand Down Expand Up @@ -696,36 +736,62 @@ void RE_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *d

qglColor3f(tr.identityLight, tr.identityLight, tr.identityLight);

qglBegin(GL_QUADS);
qglTexCoord2f(0.5f / cols, 0.5f / rows);
qglVertex2f(x, y);
qglTexCoord2f((cols - 0.5f) / cols, 0.5f / rows);
qglVertex2f(x + w, y);
qglTexCoord2f((cols - 0.5f) / cols, (rows - 0.5f) / rows);
qglVertex2f(x + w, y + h);
qglTexCoord2f(0.5f / cols, (rows - 0.5f) / rows);
qglVertex2f(x, y + h);
qglEnd();
{
vec4_t quadVerts[4];
vec2_t texCoords[4];

Vector4Set(quadVerts[0], x, y, 0.0f, 1.0f);
Vector4Set(quadVerts[1], x + w, y, 0.0f, 1.0f);
Vector4Set(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
Vector4Set(quadVerts[3], x, y + h, 0.0f, 1.0f);

Vector2Set(texCoords[0], 0.5f / cols, 0.5f / rows);
Vector2Set(texCoords[1], (cols - 0.5f) / cols, 0.5f / rows);
Vector2Set(texCoords[2], (cols - 0.5f) / cols, (rows - 0.5f) / rows);
Vector2Set(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows);

RB_InstantQuad2(quadVerts, texCoords);
}
}

void RE_UploadCinematic(int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
byte *buffer;

GL_Bind(tr.scratchImage[client]);

// if the scratchImage isn't in the format we want, specify it as a new texture
if (cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height) {
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

// manually convert RGBA to RGB for OpenGL ES
if (qglesMajorVersion >= 1) {
buffer = ri.Hunk_AllocateTempMemory(3 * cols * rows);

R_ConvertTextureFormat(data, cols, rows, GL_RGB, GL_UNSIGNED_BYTE, buffer);
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, cols, rows, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer);

ri.Hunk_FreeTempMemory(buffer);
} else {
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}

qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glConfig.haveClampToEdge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glConfig.haveClampToEdge ? GL_CLAMP_TO_EDGE : GL_CLAMP);
} else {
if (dirty) {
// otherwise, just subimage upload it so that drivers can tell we are going to be changing
// it and don't try and do a texture compression
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data);
if (qglesMajorVersion >= 1) {
buffer = ri.Hunk_AllocateTempMemory(3 * cols * rows);

R_ConvertTextureFormat(data, cols, rows, GL_RGB, GL_UNSIGNED_BYTE, buffer);
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGB, GL_UNSIGNED_BYTE, buffer);

ri.Hunk_FreeTempMemory(buffer);
} else {
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
}
}
}
Expand Down Expand Up @@ -883,6 +949,7 @@ void RB_ShowImages(void) {
image_t *image;
float x, y, w, h;
int start, end;
vec4_t quadVerts[4];

if (!backEnd.projection2D) {
RB_SetGL2D();
Expand All @@ -909,16 +976,13 @@ void RB_ShowImages(void) {
}

GL_Bind(image);
qglBegin(GL_QUADS);
qglTexCoord2f(0, 0);
qglVertex2f(x, y);
qglTexCoord2f(1, 0);
qglVertex2f(x + w, y);
qglTexCoord2f(1, 1);
qglVertex2f(x + w, y + h);
qglTexCoord2f(0, 1);
qglVertex2f(x, y + h);
qglEnd();

Vector4Set(quadVerts[0], x, y, 0, 1);
Vector4Set(quadVerts[1], x + w, y, 0, 1);
Vector4Set(quadVerts[2], x + w, y + h, 0, 1);
Vector4Set(quadVerts[3], x, y + h, 0, 1);

RB_InstantQuad(quadVerts);
}

qglFinish();
Expand Down
14 changes: 13 additions & 1 deletion code/renderergl1/tr_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ void RE_BeginFrame(stereoFrame_t stereoFrame) {
// do overdraw measurement
//
if (r_measureOverdraw->integer) {
if (glConfig.stencilBits < 4) {
if (qglesMajorVersion >= 1) {
ri.Printf(PRINT_WARNING,
"OpenGL ES does not support reading stencil bits to measure overdraw\n");
ri.Cvar_Set("r_measureOverdraw", "0");
r_measureOverdraw->modified = qfalse;
} else if (glConfig.stencilBits < 4) {
ri.Printf(PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits);
ri.Cvar_Set("r_measureOverdraw", "0");
r_measureOverdraw->modified = qfalse;
Expand Down Expand Up @@ -349,6 +354,13 @@ void RE_BeginFrame(stereoFrame_t stereoFrame) {
ri.Error(ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame);
}
} else {
if (qglesMajorVersion >= 1 && r_anaglyphMode->integer) {
ri.Printf(PRINT_WARNING,
"OpenGL ES does not support drawing to separate buffer for anaglyph mode\n");
ri.Cvar_Set("r_anaglyphMode", "0");
r_anaglyphMode->modified = qfalse;
}

if (r_anaglyphMode->integer) {
if (r_anaglyphMode->modified) {
// clear both, front and backbuffer.
Expand Down
13 changes: 13 additions & 0 deletions code/renderergl1/tr_flares.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,19 @@ void RB_RenderFlares(void) {
return;
}

if (r_flares->modified) {
if (qglesMajorVersion >= 1) {
ri.Printf(PRINT_WARNING,
"OpenGL ES does not support reading depth to determine if flares are visible\n");
ri.Cvar_Set("r_flares", "0");
}
r_flares->modified = qfalse;
}

if (!r_flares->integer) {
return;
}

if (r_flareCoeff->modified) {
R_SetFlareCoeff();
r_flareCoeff->modified = qfalse;
Expand Down
Loading
Loading