mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Make sure to bind to the renderer FBO when drawing
This commit is contained in:
parent
a32a9e8ae8
commit
31278fba92
1 changed files with 272 additions and 256 deletions
|
@ -32,16 +32,16 @@ Draw_SetColor
|
||||||
*/
|
*/
|
||||||
void Draw_SetColor(const vec4_t rgba) {
|
void Draw_SetColor(const vec4_t rgba) {
|
||||||
#if 1
|
#if 1
|
||||||
if (!rgba) {
|
if (!rgba) {
|
||||||
rgba = r_colorWhite;
|
rgba = r_colorWhite;
|
||||||
}
|
}
|
||||||
|
|
||||||
backEnd.color2D[0] = (byte)(rgba[0] * tr.identityLightByte);
|
backEnd.color2D[0] = (byte)(rgba[0] * tr.identityLightByte);
|
||||||
backEnd.color2D[1] = (byte)(rgba[1] * tr.identityLightByte);
|
backEnd.color2D[1] = (byte)(rgba[1] * tr.identityLightByte);
|
||||||
backEnd.color2D[2] = (byte)(rgba[2] * tr.identityLightByte);
|
backEnd.color2D[2] = (byte)(rgba[2] * tr.identityLightByte);
|
||||||
backEnd.color2D[3] = (byte)(rgba[3] * 255.0);
|
backEnd.color2D[3] = (byte)(rgba[3] * 255.0);
|
||||||
#else
|
#else
|
||||||
RE_SetColor(rgba);
|
RE_SetColor(rgba);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,45 +52,45 @@ Draw_StretchPic
|
||||||
*/
|
*/
|
||||||
void Draw_StretchPic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader) {
|
void Draw_StretchPic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader) {
|
||||||
#if 1
|
#if 1
|
||||||
shader_t* shader;
|
shader_t* shader;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
if (glRefConfig.framebufferObject)
|
if (glRefConfig.framebufferObject)
|
||||||
FBO_Bind(tr.renderFbo);
|
FBO_Bind(tr.renderFbo);
|
||||||
|
|
||||||
if (hShader) {
|
if (hShader) {
|
||||||
shader = R_GetShaderByHandle(hShader);
|
shader = R_GetShaderByHandle(hShader);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shader = tr.defaultShader;
|
shader = tr.defaultShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w <= 0) {
|
if (w <= 0) {
|
||||||
w = shader->stages[0]->bundle[0].image[0]->width;
|
w = shader->stages[0]->bundle[0].image[0]->width;
|
||||||
h = shader->stages[0]->bundle[0].image[0]->height;
|
h = shader->stages[0]->bundle[0].image[0]->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the pic
|
// draw the pic
|
||||||
RB_BeginSurface(shader, 0, 0);
|
RB_BeginSurface(shader, 0, 0);
|
||||||
|
|
||||||
RB_Color4bv(backEnd.color2D);
|
RB_Color4bv(backEnd.color2D);
|
||||||
|
|
||||||
RB_Texcoord2f(s1, t1);
|
RB_Texcoord2f(s1, t1);
|
||||||
RB_Vertex2f(x, y);
|
RB_Vertex2f(x, y);
|
||||||
|
|
||||||
RB_Texcoord2f(s2, t1);
|
RB_Texcoord2f(s2, t1);
|
||||||
RB_Vertex2f(x + w, y);
|
RB_Vertex2f(x + w, y);
|
||||||
|
|
||||||
RB_Texcoord2f(s1, t2);
|
RB_Texcoord2f(s1, t2);
|
||||||
RB_Vertex2f(x, y + h);
|
RB_Vertex2f(x, y + h);
|
||||||
|
|
||||||
RB_Texcoord2f(s2, t2);
|
RB_Texcoord2f(s2, t2);
|
||||||
RB_Vertex2f(x + w, y + h);
|
RB_Vertex2f(x + w, y + h);
|
||||||
|
|
||||||
RB_StreamEnd();
|
RB_StreamEnd();
|
||||||
#else
|
#else
|
||||||
RE_StretchPic(x, y, w, h, s1, t1, s2, t2, hShader);
|
RE_StretchPic(x, y, w, h, s1, t1, s2, t2, hShader);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,49 +100,52 @@ Draw_StretchPic2
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Draw_StretchPic2(float x, float y, float w, float h, float s1, float t1, float s2, float t2, float sx, float sy, qhandle_t hShader) {
|
void Draw_StretchPic2(float x, float y, float w, float h, float s1, float t1, float s2, float t2, float sx, float sy, qhandle_t hShader) {
|
||||||
shader_t* shader;
|
shader_t* shader;
|
||||||
float halfWidth, halfHeight;
|
float halfWidth, halfHeight;
|
||||||
float scaledWidth1, scaledHeight1;
|
float scaledWidth1, scaledHeight1;
|
||||||
float scaledWidth2, scaledHeight2;
|
float scaledWidth2, scaledHeight2;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
if (hShader) {
|
if (glRefConfig.framebufferObject)
|
||||||
shader = R_GetShaderByHandle(hShader);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
|
||||||
else {
|
|
||||||
shader = tr.defaultShader;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w <= 0) {
|
if (hShader) {
|
||||||
w = shader->stages[0]->bundle[0].image[0]->width;
|
shader = R_GetShaderByHandle(hShader);
|
||||||
h = shader->stages[0]->bundle[0].image[0]->height;
|
}
|
||||||
}
|
else {
|
||||||
|
shader = tr.defaultShader;
|
||||||
|
}
|
||||||
|
|
||||||
halfWidth = w * 0.5f;
|
if (w <= 0) {
|
||||||
halfHeight = h * 0.5f;
|
w = shader->stages[0]->bundle[0].image[0]->width;
|
||||||
scaledWidth1 = halfWidth * sy;
|
h = shader->stages[0]->bundle[0].image[0]->height;
|
||||||
scaledHeight1 = halfHeight * sx;
|
}
|
||||||
scaledWidth2 = halfWidth * sx;
|
|
||||||
scaledHeight2 = halfHeight * sy;
|
halfWidth = w * 0.5f;
|
||||||
|
halfHeight = h * 0.5f;
|
||||||
|
scaledWidth1 = halfWidth * sy;
|
||||||
|
scaledHeight1 = halfHeight * sx;
|
||||||
|
scaledWidth2 = halfWidth * sx;
|
||||||
|
scaledHeight2 = halfHeight * sy;
|
||||||
|
|
||||||
// draw the pic
|
// draw the pic
|
||||||
RB_Color4bv(backEnd.color2D);
|
RB_Color4bv(backEnd.color2D);
|
||||||
RB_BeginSurface(shader, 0, 0);
|
RB_BeginSurface(shader, 0, 0);
|
||||||
|
|
||||||
RB_Texcoord2f(s1, t1);
|
RB_Texcoord2f(s1, t1);
|
||||||
RB_Vertex3f(x + halfWidth - (scaledWidth2 + -scaledHeight2), y + halfWidth - scaledHeight1 - scaledWidth1, 0);
|
RB_Vertex3f(x + halfWidth - (scaledWidth2 + -scaledHeight2), y + halfWidth - scaledHeight1 - scaledWidth1, 0);
|
||||||
|
|
||||||
RB_Texcoord2f(t2, t1);
|
RB_Texcoord2f(t2, t1);
|
||||||
RB_Vertex3f(scaledWidth2 - -scaledHeight2 + x + halfWidth, scaledWidth1 - scaledHeight1 + y + halfWidth, 0);
|
RB_Vertex3f(scaledWidth2 - -scaledHeight2 + x + halfWidth, scaledWidth1 - scaledHeight1 + y + halfWidth, 0);
|
||||||
|
|
||||||
RB_Texcoord2f(s1, s2);
|
RB_Texcoord2f(s1, s2);
|
||||||
RB_Vertex3f(x+ halfWidth - (scaledWidth2 + scaledHeight2), scaledHeight1 - scaledWidth1 + y + halfWidth, 0);
|
RB_Vertex3f(x+ halfWidth - (scaledWidth2 + scaledHeight2), scaledHeight1 - scaledWidth1 + y + halfWidth, 0);
|
||||||
|
|
||||||
RB_Texcoord2f(t2, s2);
|
RB_Texcoord2f(t2, s2);
|
||||||
RB_Vertex3f(scaledWidth2 - scaledHeight2 + x + halfWidth, scaledWidth1 + scaledHeight1 + y + halfWidth, 0);
|
RB_Vertex3f(scaledWidth2 - scaledHeight2 + x + halfWidth, scaledWidth1 + scaledHeight1 + y + halfWidth, 0);
|
||||||
|
|
||||||
RB_StreamEnd();
|
RB_StreamEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,44 +155,47 @@ Draw_TilePic
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Draw_TilePic(float x, float y, float w, float h, qhandle_t hShader) {
|
void Draw_TilePic(float x, float y, float w, float h, qhandle_t hShader) {
|
||||||
shader_t* shader;
|
shader_t* shader;
|
||||||
float picw, pich;
|
float picw, pich;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
if (hShader) {
|
if (glRefConfig.framebufferObject)
|
||||||
shader = R_GetShaderByHandle(hShader);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
|
||||||
else {
|
|
||||||
shader = tr.defaultShader;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w <= 0) {
|
if (hShader) {
|
||||||
w = shader->stages[0]->bundle[0].image[0]->width;
|
shader = R_GetShaderByHandle(hShader);
|
||||||
h = shader->stages[0]->bundle[0].image[0]->height;
|
}
|
||||||
}
|
else {
|
||||||
|
shader = tr.defaultShader;
|
||||||
|
}
|
||||||
|
|
||||||
picw = shader->stages[0]->bundle[0].image[0]->uploadWidth;
|
if (w <= 0) {
|
||||||
pich = shader->stages[0]->bundle[0].image[0]->uploadHeight;
|
w = shader->stages[0]->bundle[0].image[0]->width;
|
||||||
|
h = shader->stages[0]->bundle[0].image[0]->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
picw = shader->stages[0]->bundle[0].image[0]->uploadWidth;
|
||||||
|
pich = shader->stages[0]->bundle[0].image[0]->uploadHeight;
|
||||||
|
|
||||||
// draw the pic
|
// draw the pic
|
||||||
RB_Color4bv(backEnd.color2D);
|
RB_Color4bv(backEnd.color2D);
|
||||||
|
|
||||||
RB_StreamBegin(shader);
|
RB_StreamBegin(shader);
|
||||||
|
|
||||||
RB_Texcoord2f(x / picw, y / pich);
|
RB_Texcoord2f(x / picw, y / pich);
|
||||||
RB_Vertex2f(x, y);
|
RB_Vertex2f(x, y);
|
||||||
|
|
||||||
RB_Texcoord2f((x + w) / picw, y / pich);
|
RB_Texcoord2f((x + w) / picw, y / pich);
|
||||||
RB_Vertex2f(x + w, y);
|
RB_Vertex2f(x + w, y);
|
||||||
|
|
||||||
RB_Texcoord2f(x / picw, (y + h) / pich);
|
RB_Texcoord2f(x / picw, (y + h) / pich);
|
||||||
RB_Vertex2f(x, y + h);
|
RB_Vertex2f(x, y + h);
|
||||||
|
|
||||||
RB_Texcoord2f((x + w) / picw, (y + h) / pich);
|
RB_Texcoord2f((x + w) / picw, (y + h) / pich);
|
||||||
RB_Vertex2f(x + w, y + h);
|
RB_Vertex2f(x + w, y + h);
|
||||||
|
|
||||||
RB_StreamEnd();
|
RB_StreamEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -198,44 +204,47 @@ Draw_TilePicOffset
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Draw_TilePicOffset(float x, float y, float w, float h, qhandle_t hShader, int offsetX, int offsetY) {
|
void Draw_TilePicOffset(float x, float y, float w, float h, qhandle_t hShader, int offsetX, int offsetY) {
|
||||||
shader_t* shader;
|
shader_t* shader;
|
||||||
float picw, pich;
|
float picw, pich;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
if (hShader) {
|
if (glRefConfig.framebufferObject)
|
||||||
shader = R_GetShaderByHandle(hShader);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
|
||||||
else {
|
|
||||||
shader = tr.defaultShader;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w <= 0) {
|
if (hShader) {
|
||||||
w = shader->stages[0]->bundle[0].image[0]->width;
|
shader = R_GetShaderByHandle(hShader);
|
||||||
h = shader->stages[0]->bundle[0].image[0]->height;
|
}
|
||||||
}
|
else {
|
||||||
|
shader = tr.defaultShader;
|
||||||
|
}
|
||||||
|
|
||||||
picw = shader->stages[0]->bundle[0].image[0]->uploadWidth;
|
if (w <= 0) {
|
||||||
pich = shader->stages[0]->bundle[0].image[0]->uploadHeight;
|
w = shader->stages[0]->bundle[0].image[0]->width;
|
||||||
|
h = shader->stages[0]->bundle[0].image[0]->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
picw = shader->stages[0]->bundle[0].image[0]->uploadWidth;
|
||||||
|
pich = shader->stages[0]->bundle[0].image[0]->uploadHeight;
|
||||||
|
|
||||||
// draw the pic
|
// draw the pic
|
||||||
RB_Color4bv(backEnd.color2D);
|
RB_Color4bv(backEnd.color2D);
|
||||||
|
|
||||||
RB_StreamBegin(shader);
|
RB_StreamBegin(shader);
|
||||||
|
|
||||||
RB_Texcoord2f(x / picw, y / pich);
|
RB_Texcoord2f(x / picw, y / pich);
|
||||||
RB_Vertex2f(x + offsetX, y + offsetY);
|
RB_Vertex2f(x + offsetX, y + offsetY);
|
||||||
|
|
||||||
RB_Texcoord2f((x + w) / picw, y / pich);
|
RB_Texcoord2f((x + w) / picw, y / pich);
|
||||||
RB_Vertex2f(x + offsetX + w, y + offsetY);
|
RB_Vertex2f(x + offsetX + w, y + offsetY);
|
||||||
|
|
||||||
RB_Texcoord2f(x / picw, (y + h) / pich);
|
RB_Texcoord2f(x / picw, (y + h) / pich);
|
||||||
RB_Vertex2f(x + offsetX, y + offsetY + h);
|
RB_Vertex2f(x + offsetX, y + offsetY + h);
|
||||||
|
|
||||||
RB_Texcoord2f((x + w) / picw, (y + h) / pich);
|
RB_Texcoord2f((x + w) / picw, (y + h) / pich);
|
||||||
RB_Vertex2f(x + offsetX + w, y + offsetY + h);
|
RB_Vertex2f(x + offsetX + w, y + offsetY + h);
|
||||||
|
|
||||||
RB_StreamEnd();
|
RB_StreamEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -244,29 +253,32 @@ Draw_TrianglePic
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Draw_TrianglePic(const vec2_t vPoints[3], const vec2_t vTexCoords[3], qhandle_t hShader) {
|
void Draw_TrianglePic(const vec2_t vPoints[3], const vec2_t vTexCoords[3], qhandle_t hShader) {
|
||||||
int i;
|
int i;
|
||||||
shader_t* shader;
|
shader_t* shader;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
if (hShader) {
|
if (glRefConfig.framebufferObject)
|
||||||
shader = R_GetShaderByHandle(hShader);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
|
||||||
else {
|
if (hShader) {
|
||||||
shader = tr.defaultShader;
|
shader = R_GetShaderByHandle(hShader);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
shader = tr.defaultShader;
|
||||||
|
}
|
||||||
|
|
||||||
// draw the pic
|
// draw the pic
|
||||||
RB_Color4bv(backEnd.color2D);
|
RB_Color4bv(backEnd.color2D);
|
||||||
|
|
||||||
RB_BeginSurface(shader, 0, 0);
|
RB_BeginSurface(shader, 0, 0);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
RB_Texcoord2f(vTexCoords[i][0], vTexCoords[i][1]);
|
RB_Texcoord2f(vTexCoords[i][0], vTexCoords[i][1]);
|
||||||
RB_Vertex2f(vPoints[i][0], vPoints[i][1]);
|
RB_Vertex2f(vPoints[i][0], vPoints[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_StreamEnd();
|
RB_StreamEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -275,59 +287,59 @@ RE_DrawBackground_TexSubImage
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void RE_DrawBackground_TexSubImage(int cols, int rows, int bgr, byte* data) {
|
void RE_DrawBackground_TexSubImage(int cols, int rows, int bgr, byte* data) {
|
||||||
// FIXME: unimplemented (GL2)
|
// FIXME: unimplemented (GL2)
|
||||||
#if 0
|
#if 0
|
||||||
GLenum format;
|
GLenum format;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
w = glConfig.vidWidth;
|
w = glConfig.vidWidth;
|
||||||
h = glConfig.vidHeight;
|
h = glConfig.vidHeight;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
qglFinish();
|
qglFinish();
|
||||||
|
|
||||||
if (bgr) {
|
if (bgr) {
|
||||||
format = GL_BGR_EXT;
|
format = GL_BGR_EXT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
format = GL_RGB;
|
format = GL_RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_Bind(tr.scratchImage);
|
GL_Bind(tr.scratchImage);
|
||||||
|
|
||||||
if (cols == tr.scratchImage->width && rows == tr.scratchImage->height && format == tr.scratchImage->internalFormat)
|
if (cols == tr.scratchImage->width && rows == tr.scratchImage->height && format == tr.scratchImage->internalFormat)
|
||||||
{
|
{
|
||||||
qglTexSubImage2D(3553, 0, 0, 0, cols, rows, format, 5121, data);
|
qglTexSubImage2D(3553, 0, 0, 0, cols, rows, format, 5121, data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tr.scratchImage->uploadWidth = cols;
|
tr.scratchImage->uploadWidth = cols;
|
||||||
tr.scratchImage->uploadHeight = rows;
|
tr.scratchImage->uploadHeight = rows;
|
||||||
tr.scratchImage->internalFormat = format;
|
tr.scratchImage->internalFormat = format;
|
||||||
qglTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, format, 5121, data);
|
qglTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, format, 5121, data);
|
||||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 9729.0);
|
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 9729.0);
|
||||||
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 9729.0);
|
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 9729.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
qglDisable(GL_CULL_FACE);
|
qglDisable(GL_CULL_FACE);
|
||||||
qglDisable(GL_DEPTH_TEST);
|
qglDisable(GL_DEPTH_TEST);
|
||||||
qglEnable(GL_TEXTURE_2D);
|
qglEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
qglBegin(GL_QUADS);
|
qglBegin(GL_QUADS);
|
||||||
|
|
||||||
qglTexCoord2f(0.5 / (GLfloat)cols, ((GLfloat)rows - 0.5) / rows);
|
qglTexCoord2f(0.5 / (GLfloat)cols, ((GLfloat)rows - 0.5) / rows);
|
||||||
qglVertex2f(0, 0);
|
qglVertex2f(0, 0);
|
||||||
|
|
||||||
qglTexCoord2f(((GLfloat)cols - 0.5) / cols, ((GLfloat)rows - 0.5) / rows);
|
qglTexCoord2f(((GLfloat)cols - 0.5) / cols, ((GLfloat)rows - 0.5) / rows);
|
||||||
qglVertex2f(w, 0);
|
qglVertex2f(w, 0);
|
||||||
|
|
||||||
qglTexCoord2f(((GLfloat)cols - 0.5) / cols, 0.5 / (GLfloat)rows);
|
qglTexCoord2f(((GLfloat)cols - 0.5) / cols, 0.5 / (GLfloat)rows);
|
||||||
qglVertex2f(w, h);
|
qglVertex2f(w, h);
|
||||||
|
|
||||||
qglTexCoord2f(0.5 / (GLfloat)rows, 0.5 / (GLfloat)rows);
|
qglTexCoord2f(0.5 / (GLfloat)rows, 0.5 / (GLfloat)rows);
|
||||||
qglVertex2f(0, h);
|
qglVertex2f(0, h);
|
||||||
|
|
||||||
qglEnd();
|
qglEnd();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,22 +351,22 @@ RE_DrawBackground_DrawPixels
|
||||||
void RE_DrawBackground_DrawPixels(int cols, int rows, int bgr, byte* data) {
|
void RE_DrawBackground_DrawPixels(int cols, int rows, int bgr, byte* data) {
|
||||||
// FIXME: unimplemented (GL2)
|
// FIXME: unimplemented (GL2)
|
||||||
#if 0
|
#if 0
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
GL_State(0);
|
GL_State(0);
|
||||||
qglDisable(GL_TEXTURE_2D);
|
qglDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
qglPixelZoom(glConfig.vidWidth / rows, glConfig.vidHeight / cols);
|
qglPixelZoom(glConfig.vidWidth / rows, glConfig.vidHeight / cols);
|
||||||
|
|
||||||
if (bgr) {
|
if (bgr) {
|
||||||
qglDrawPixels(cols, rows, GL_BGR, GL_UNSIGNED_BYTE, data);
|
qglDrawPixels(cols, rows, GL_BGR, GL_UNSIGNED_BYTE, data);
|
||||||
} else {
|
} else {
|
||||||
qglDrawPixels(cols, rows, GL_RGB, GL_UNSIGNED_BYTE, data);
|
qglDrawPixels(cols, rows, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
qglPixelZoom(1.0, 1.0);
|
qglPixelZoom(1.0, 1.0);
|
||||||
|
|
||||||
qglEnable(GL_TEXTURE_2D);
|
qglEnable(GL_TEXTURE_2D);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,37 +378,37 @@ AddBox
|
||||||
void AddBox(float x, float y, float w, float h) {
|
void AddBox(float x, float y, float w, float h) {
|
||||||
vec4_t quadVerts[4];
|
vec4_t quadVerts[4];
|
||||||
vec2_t texCoords[4];
|
vec2_t texCoords[4];
|
||||||
vec4_t color;
|
vec4_t color;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
|
GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
|
||||||
GL_State(GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE);
|
GL_State(GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE);
|
||||||
|
|
||||||
if (glRefConfig.framebufferObject)
|
if (glRefConfig.framebufferObject)
|
||||||
{
|
{
|
||||||
FBO_Bind(tr.renderFbo);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
color[0] = backEnd.color2D[0] / 255.0;
|
color[0] = backEnd.color2D[0] / 255.0;
|
||||||
color[1] = backEnd.color2D[1] / 255.0;
|
color[1] = backEnd.color2D[1] / 255.0;
|
||||||
color[2] = backEnd.color2D[2] / 255.0;
|
color[2] = backEnd.color2D[2] / 255.0;
|
||||||
color[3] = backEnd.color2D[3] / 255.0;
|
color[3] = backEnd.color2D[3] / 255.0;
|
||||||
|
|
||||||
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
|
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
|
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
|
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
|
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
|
||||||
|
|
||||||
VectorSet2(texCoords[0], 0.0f, 0.0f);
|
VectorSet2(texCoords[0], 0.0f, 0.0f);
|
||||||
VectorSet2(texCoords[1], 1.0f, 0.0f);
|
VectorSet2(texCoords[1], 1.0f, 0.0f);
|
||||||
VectorSet2(texCoords[2], 1.0f, 1.0f);
|
VectorSet2(texCoords[2], 1.0f, 1.0f);
|
||||||
VectorSet2(texCoords[3], 0.0f, 1.0f);
|
VectorSet2(texCoords[3], 0.0f, 1.0f);
|
||||||
|
|
||||||
GLSL_BindProgram(&tr.textureColorShader);
|
GLSL_BindProgram(&tr.textureColorShader);
|
||||||
|
|
||||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color);
|
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color);
|
||||||
|
|
||||||
RB_InstantQuad2(quadVerts, texCoords);
|
RB_InstantQuad2(quadVerts, texCoords);
|
||||||
}
|
}
|
||||||
|
@ -409,37 +421,37 @@ DrawBox
|
||||||
void DrawBox(float x, float y, float w, float h) {
|
void DrawBox(float x, float y, float w, float h) {
|
||||||
vec4_t quadVerts[4];
|
vec4_t quadVerts[4];
|
||||||
vec2_t texCoords[4];
|
vec2_t texCoords[4];
|
||||||
vec4_t color;
|
vec4_t color;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
|
GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
|
||||||
GL_State(GLS_DEPTHTEST_DISABLE | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA);
|
GL_State(GLS_DEPTHTEST_DISABLE | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA);
|
||||||
|
|
||||||
if (glRefConfig.framebufferObject)
|
if (glRefConfig.framebufferObject)
|
||||||
{
|
{
|
||||||
FBO_Bind(tr.renderFbo);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
color[0] = backEnd.color2D[0] / 255.0;
|
color[0] = backEnd.color2D[0] / 255.0;
|
||||||
color[1] = backEnd.color2D[1] / 255.0;
|
color[1] = backEnd.color2D[1] / 255.0;
|
||||||
color[2] = backEnd.color2D[2] / 255.0;
|
color[2] = backEnd.color2D[2] / 255.0;
|
||||||
color[3] = backEnd.color2D[3] / 255.0;
|
color[3] = backEnd.color2D[3] / 255.0;
|
||||||
|
|
||||||
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
|
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
|
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
|
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
|
||||||
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
|
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
|
||||||
|
|
||||||
VectorSet2(texCoords[0], 0.0f, 0.0f);
|
VectorSet2(texCoords[0], 0.0f, 0.0f);
|
||||||
VectorSet2(texCoords[1], 1.0f, 0.0f);
|
VectorSet2(texCoords[1], 1.0f, 0.0f);
|
||||||
VectorSet2(texCoords[2], 1.0f, 1.0f);
|
VectorSet2(texCoords[2], 1.0f, 1.0f);
|
||||||
VectorSet2(texCoords[3], 0.0f, 1.0f);
|
VectorSet2(texCoords[3], 0.0f, 1.0f);
|
||||||
|
|
||||||
GLSL_BindProgram(&tr.textureColorShader);
|
GLSL_BindProgram(&tr.textureColorShader);
|
||||||
|
|
||||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color);
|
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color);
|
||||||
|
|
||||||
RB_InstantQuad2(quadVerts, texCoords);
|
RB_InstantQuad2(quadVerts, texCoords);
|
||||||
}
|
}
|
||||||
|
@ -452,30 +464,30 @@ DrawLineLoop
|
||||||
void DrawLineLoop(const vec2_t* points, int count, int stipple_factor, int stipple_mask) {
|
void DrawLineLoop(const vec2_t* points, int count, int stipple_factor, int stipple_mask) {
|
||||||
// FIXME: unimplemented (GL2)
|
// FIXME: unimplemented (GL2)
|
||||||
#if 0
|
#if 0
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
|
|
||||||
qglDisable(GL_TEXTURE_2D);
|
qglDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (stipple_factor) {
|
if (stipple_factor) {
|
||||||
qglEnable(GL_LINE_STIPPLE);
|
qglEnable(GL_LINE_STIPPLE);
|
||||||
qglLineStipple(stipple_factor, stipple_mask);
|
qglLineStipple(stipple_factor, stipple_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
qglBegin(GL_LINE_LOOP);
|
qglBegin(GL_LINE_LOOP);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
qglVertex2f(points[i][0], points[i][1]);
|
qglVertex2f(points[i][0], points[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
qglEnd();
|
qglEnd();
|
||||||
|
|
||||||
qglEnable(GL_TEXTURE_2D);
|
qglEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (stipple_factor) {
|
if (stipple_factor) {
|
||||||
qglDisable(GL_LINE_STIPPLE);
|
qglDisable(GL_LINE_STIPPLE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,27 +497,31 @@ Set2DWindow
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Set2DWindow(int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f) {
|
void Set2DWindow(int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f) {
|
||||||
mat4_t matrix;
|
mat4_t matrix;
|
||||||
|
|
||||||
R_IssuePendingRenderCommands();
|
R_IssuePendingRenderCommands();
|
||||||
qglViewport(x, y, w, h);
|
|
||||||
qglScissor(x, y, w, h);
|
backEnd.projection2D = qtrue;
|
||||||
|
backEnd.last2DFBO = glState.currentFBO;
|
||||||
|
|
||||||
|
qglViewport(x, y, w, h);
|
||||||
|
qglScissor(x, y, w, h);
|
||||||
|
|
||||||
Mat4Ortho(left, right, bottom, top, n, f, matrix);
|
Mat4Ortho(left, right, bottom, top, n, f, matrix);
|
||||||
GL_SetProjectionMatrix(matrix);
|
GL_SetProjectionMatrix(matrix);
|
||||||
Mat4Identity(matrix);
|
Mat4Identity(matrix);
|
||||||
GL_SetModelviewMatrix(matrix);
|
GL_SetModelviewMatrix(matrix);
|
||||||
|
|
||||||
GL_State(GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
|
GL_State(GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
GL_Cull(CT_TWO_SIDED);
|
GL_Cull(CT_TWO_SIDED);
|
||||||
|
|
||||||
if (!backEnd.projection2D)
|
if (!backEnd.projection2D)
|
||||||
{
|
{
|
||||||
backEnd.refdef.time = ri.Milliseconds();
|
backEnd.refdef.time = ri.Milliseconds();
|
||||||
backEnd.projection2D = qtrue;
|
backEnd.projection2D = qtrue;
|
||||||
backEnd.refdef.floatTime = backEnd.refdef.time / 1000.0;
|
backEnd.refdef.floatTime = backEnd.refdef.time / 1000.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -514,6 +530,6 @@ RE_Scissor
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void RE_Scissor(int x, int y, int width, int height) {
|
void RE_Scissor(int x, int y, int width, int height) {
|
||||||
qglEnable(GL_SCISSOR_TEST);
|
qglEnable(GL_SCISSOR_TEST);
|
||||||
qglScissor(x, y, width, height);
|
qglScissor(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue