Skip to content

Commit

Permalink
Refactor|Client|GL: Use GL2 filter/wrap identifiers for (tiled) Patch…
Browse files Browse the repository at this point in the history
… drawers
  • Loading branch information
danij-deng committed Nov 9, 2013
1 parent f343501 commit 71b5676
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
10 changes: 10 additions & 0 deletions doomsday/client/include/gl/gl_main.h
Expand Up @@ -142,6 +142,16 @@ void GL_DoUpdate();
*/
void GL_BlendMode(blendmode_t mode);

/**
* Utility for translating to a GL texture filter identifier.
*/
GLenum GL_Filter(de::gl::Filter f);

/**
* Utility for translating to a GL texture wrapping identifier.
*/
GLenum GL_Wrap(de::gl::Wrapping w);

/**
* Initializes the graphics library for refresh. Also called at update.
*/
Expand Down
5 changes: 3 additions & 2 deletions doomsday/client/include/render/r_draw.h
Expand Up @@ -34,11 +34,12 @@ void R_ShutdownViewWindow();
void R_DrawViewBorder();

texturevariantspecification_t &Rend_PatchTextureSpec(int flags = 0,
int wrapS = GL_CLAMP_TO_EDGE, int wrapT = GL_CLAMP_TO_EDGE);
de::gl::Wrapping wrapS = de::gl::ClampToEdge, de::gl::Wrapping wrapT = de::gl::ClampToEdge);

void R_DrawPatch(de::Texture &texture, int x, int y);
void R_DrawPatch(de::Texture &texture, int x, int y, int w, int h, bool useOffsets = true);

void R_DrawPatchTiled(de::Texture &texture, int x, int y, int w, int h, int wrapS, int wrapT);
void R_DrawPatchTiled(de::Texture &texture, int x, int y, int w, int h,
de::gl::Wrapping wrapS, de::gl::Wrapping wrapT);

#endif // LIBDENG_RENDER_MISC_H
12 changes: 6 additions & 6 deletions doomsday/client/src/gl/gl_main.cpp
Expand Up @@ -743,7 +743,7 @@ void GL_BlendMode(blendmode_t mode)
}
}

static GLenum glFilter(gl::Filter f)
GLenum GL_Filter(gl::Filter f)
{
switch(f)
{
Expand All @@ -753,7 +753,7 @@ static GLenum glFilter(gl::Filter f)
return GL_REPEAT;
}

static GLenum glWrap(gl::Wrapping w)
GLenum GL_Wrap(gl::Wrapping w)
{
switch(w)
{
Expand Down Expand Up @@ -818,7 +818,7 @@ void GL_SetMaterialUI2(Material *mat, gl::Wrapping wrapS, gl::Wrapping wrapT)

MaterialVariantSpec const &spec =
App_Materials().variantSpec(UiContext, 0, 1, 0, 0,
glWrap(wrapS), glWrap(wrapT),
GL_Wrap(wrapS), GL_Wrap(wrapT),
0, 1, 0, false, false, false, false);
GL_BindTexture(&mat->prepare(spec).texture(MTU_PRIMARY));
}
Expand Down Expand Up @@ -899,9 +899,9 @@ void GL_BindTextureUnmanaged(GLuint glName, gl::Wrapping wrapS, gl::Wrapping wra
glBindTexture(GL_TEXTURE_2D, glName);
Sys_GLCheckError();

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrap(wrapS));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrap(wrapT));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glFilter(filter));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_Wrap(wrapS));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_Wrap(wrapT));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_Filter(filter));
if(GL_state.features.texFilterAniso)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_GetTexAnisoMul(texAniso));
Expand Down
16 changes: 9 additions & 7 deletions doomsday/client/src/render/r_draw.cpp
Expand Up @@ -128,10 +128,11 @@ void R_ShutdownViewWindow(void)
inited = false;
}

texturevariantspecification_t &Rend_PatchTextureSpec(int flags, int wrapS, int wrapT)
texturevariantspecification_t &Rend_PatchTextureSpec(int flags,
gl::Wrapping wrapS, gl::Wrapping wrapT)
{
return GL_TextureVariantSpec(TC_UI, flags, 0, 0, 0,
wrapS, wrapT, 0, -3, 0,
GL_Wrap(wrapS), GL_Wrap(wrapT), 0, -3, 0,
false, false, false, false);
}

Expand Down Expand Up @@ -165,7 +166,8 @@ void R_DrawPatch(Texture &tex, int x, int y)
R_DrawPatch(tex, x, y, tex.width(), tex.height());
}

void R_DrawPatchTiled(Texture &texture, int x, int y, int w, int h, int wrapS, int wrapT)
void R_DrawPatchTiled(Texture &texture, int x, int y, int w, int h,
gl::Wrapping wrapS, gl::Wrapping wrapT)
{
texturevariantspecification_t const &spec =
Rend_PatchTextureSpec(0 | (texture.isFlagged(Texture::Monochrome) ? TSF_MONOCHROME : 0)
Expand Down Expand Up @@ -234,10 +236,10 @@ void R_DrawViewBorder()
if(border != 0)
{
Textures &textures = App_Textures();
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_TOP]).texture(), vd->window.origin.x, vd->window.origin.y - border, vd->window.size.width, border, GL_REPEAT, GL_CLAMP_TO_EDGE);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_BOTTOM]).texture(), vd->window.origin.x, vd->window.origin.y + vd->window.size.height , vd->window.size.width, border, GL_REPEAT, GL_CLAMP_TO_EDGE);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_LEFT]).texture(), vd->window.origin.x - border, vd->window.origin.y, border, vd->window.size.height, GL_CLAMP_TO_EDGE, GL_REPEAT);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_RIGHT]).texture(), vd->window.origin.x + vd->window.size.width, vd->window.origin.y, border, vd->window.size.height, GL_CLAMP_TO_EDGE, GL_REPEAT);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_TOP]).texture(), vd->window.origin.x, vd->window.origin.y - border, vd->window.size.width, border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_BOTTOM]).texture(), vd->window.origin.x, vd->window.origin.y + vd->window.size.height , vd->window.size.width, border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_LEFT]).texture(), vd->window.origin.x - border, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat);
R_DrawPatchTiled(textures.scheme("Patches").findByUniqueId(borderPatches[BG_RIGHT]).texture(), vd->window.origin.x + vd->window.size.width, vd->window.origin.y, border, vd->window.size.height, gl::ClampToEdge, gl::Repeat);
}

glMatrixMode(GL_TEXTURE);
Expand Down

0 comments on commit 71b5676

Please sign in to comment.