Skip to content

Commit

Permalink
Changed: Do not set the texture wrap properties of the currently boun…
Browse files Browse the repository at this point in the history
…d texture in drawConsoleBackground we have no idea which texture (if any) is. Console background drawing should be redesigned to happen entirely game-side if it needs this flexibility or simply allow the game to specify a Material and let the engine handle drawing.

Fixed GL filtering artefacts on the viewwindow border due to border-clamping.
  • Loading branch information
danij-deng committed May 6, 2010
1 parent 0d20b33 commit d165ed8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
4 changes: 4 additions & 0 deletions doomsday/engine/portable/src/dgl_draw.c
Expand Up @@ -549,6 +549,10 @@ void DGL_DrawRect(float x, float y, float w, float h, float r, float g,

void DGL_DrawRectTiled(float x, float y, float w, float h, int tw, int th)
{
// Make sure the current texture will be tiled.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

GL_DrawRectTiled(x, y, w, h, tw, th);
}

Expand Down
4 changes: 0 additions & 4 deletions doomsday/engine/portable/src/gl_draw.c
Expand Up @@ -271,10 +271,6 @@ void GL_DrawRect(float x, float y, float w, float h, float r, float g,

void GL_DrawRectTiled(float x, float y, float w, float h, int tw, int th)
{
// Make sure the current texture will be tiled.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(x, y);
Expand Down
18 changes: 13 additions & 5 deletions doomsday/engine/portable/src/r_draw.c
Expand Up @@ -109,17 +109,25 @@ static void drawPatch(lumpnum_t lump, int x, int y, int w, int h)
{
patchtex_t* p = R_GetPatchTex(lump);
assert(p);

glBindTexture(GL_TEXTURE_2D, GL_PreparePatch(p));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glmode[texMagMode]);

GL_DrawRect(x, y, w, h, 1, 1, 1, 1);
}

static void drawPatchTiled(lumpnum_t lump, int x, int y, int w, int h)
static void drawPatchTiled(lumpnum_t lump, int x, int y, int w, int h, GLint wrapS, GLint wrapT)
{
patchtex_t* p = R_GetPatchTex(lump);
assert(p);

glBindTexture(GL_TEXTURE_2D, GL_PreparePatch(p));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glmode[texMagMode]);

GL_DrawRectTiled(x, y, w, h, p->width, p->height);
}

Expand Down Expand Up @@ -167,10 +175,10 @@ void R_DrawViewBorder(void)

if(border != 0)
{
drawPatchTiled(borderPatchLumps[BG_TOP], viewwindowx, viewwindowy - border, viewwidth, border);
drawPatchTiled(borderPatchLumps[BG_BOTTOM], viewwindowx, viewwindowy + viewheight , viewwidth, border);
drawPatchTiled(borderPatchLumps[BG_LEFT], viewwindowx - border, viewwindowy, border, viewheight);
drawPatchTiled(borderPatchLumps[BG_RIGHT], viewwindowx + viewwidth, viewwindowy, border, viewheight);
drawPatchTiled(borderPatchLumps[BG_TOP], viewwindowx, viewwindowy - border, viewwidth, border, GL_REPEAT, GL_CLAMP_TO_EDGE);
drawPatchTiled(borderPatchLumps[BG_BOTTOM], viewwindowx, viewwindowy + viewheight , viewwidth, border, GL_REPEAT, GL_CLAMP_TO_EDGE);
drawPatchTiled(borderPatchLumps[BG_LEFT], viewwindowx - border, viewwindowy, border, viewheight, GL_CLAMP_TO_EDGE, GL_REPEAT);
drawPatchTiled(borderPatchLumps[BG_RIGHT], viewwindowx + viewwidth, viewwindowy, border, viewheight, GL_CLAMP_TO_EDGE, GL_REPEAT);
}

glMatrixMode(GL_TEXTURE);
Expand Down
10 changes: 10 additions & 0 deletions doomsday/engine/portable/src/rend_console.c
Expand Up @@ -491,6 +491,16 @@ static void drawConsoleBackground(int x, int y, int w, int h, float gtosMulY,
glTranslatef(2 * sin(funnyAng / 4), 2 * cos(funnyAng / 4), 0);
glRotatef(funnyAng * 3, 0, 0, 1);

/**
* Make sure the current texture will be tiled.
* Do NOT do this here. We have no idea what the current texture may be.
* Instead simply assume that it has been suitably configured for tiling.
* \fixme Refactor the way console background is drawn (do it entirely
* engine-side or game-side).
*/
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

GL_DrawRectTiled(x, y, w, h, bgX, bgY);

glMatrixMode(GL_TEXTURE);
Expand Down

0 comments on commit d165ed8

Please sign in to comment.