mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-24 12:51:09 +00:00
- route texture binding through the renderstate class for better control. Currently it's just a direct passthrough but this will change.
This commit is contained in:
parent
d5633701b4
commit
4bb320a27c
16 changed files with 37 additions and 35 deletions
|
@ -303,7 +303,7 @@ void FDMDModel::RenderFrame(FTexture * skin, int frameno, int frameno2, double i
|
|||
|
||||
FMaterial * tex = FMaterial::ValidateTexture(skin, false);
|
||||
|
||||
tex->Bind(CLAMP_NONE, translation, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false);
|
||||
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mModelVBO->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex, inter);
|
||||
|
|
|
@ -267,7 +267,7 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i
|
|||
|
||||
FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin, false);
|
||||
|
||||
tex->Bind(CLAMP_NONE, translation, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false);
|
||||
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mModelVBO->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, inter);
|
||||
|
|
|
@ -417,7 +417,7 @@ int FVoxelModel::FindFrame(const char * name)
|
|||
void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation)
|
||||
{
|
||||
FMaterial * tex = FMaterial::ValidateTexture(skin, false);
|
||||
tex->Bind(CLAMP_NOFILTER, translation, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false);
|
||||
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mModelVBO->SetupFrame(vindex, vindex, 0.f);
|
||||
|
|
|
@ -329,7 +329,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms)
|
|||
}
|
||||
}
|
||||
gl_SetRenderStyle(parms.style, !parms.masked, false);
|
||||
gltex->Bind(CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha));
|
||||
gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha));
|
||||
|
||||
u1 = gltex->GetUL();
|
||||
v1 = gltex->GetVT();
|
||||
|
@ -339,7 +339,7 @@ void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms)
|
|||
}
|
||||
else
|
||||
{
|
||||
gltex->Bind(CLAMP_XY_NOMIP, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, 0, -1, false);
|
||||
u1 = 0.f;
|
||||
v1 = 1.f;
|
||||
u2 = 1.f;
|
||||
|
@ -493,7 +493,7 @@ void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture *
|
|||
|
||||
if (!gltexture) return;
|
||||
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
// scaling is not used here.
|
||||
if (!local_origin)
|
||||
|
@ -586,7 +586,7 @@ void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoint
|
|||
|
||||
gl_SetColor(lightlevel, 0, cm, 1.f);
|
||||
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
int i;
|
||||
float rot = float(rotation * M_PI / float(1u << 31));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "gl/system/gl_interface.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_matrix.h"
|
||||
#include "gl/textures/gl_material.h"
|
||||
#include "c_cvars.h"
|
||||
#include "r_defs.h"
|
||||
|
||||
|
@ -97,10 +98,11 @@ public:
|
|||
|
||||
void Reset();
|
||||
|
||||
void SetShader(int shaderindex, float warptime)
|
||||
void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader, bool alphatexture)
|
||||
{
|
||||
mEffectState = shaderindex;
|
||||
mShaderTimer = warptime;
|
||||
mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex;
|
||||
mShaderTimer = mat->tex->gl_info.shaderspeed;
|
||||
mat->Bind(clampmode, translation, alphatexture);
|
||||
}
|
||||
|
||||
void Apply();
|
||||
|
|
|
@ -319,7 +319,7 @@ void GLWall::DrawDecal(DBaseDecal *decal)
|
|||
|
||||
|
||||
gl_SetRenderStyle(decal->RenderStyle, false, false);
|
||||
tex->Bind(CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha));
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha));
|
||||
|
||||
|
||||
// If srcalpha is one it looks better with a higher alpha threshold
|
||||
|
|
|
@ -1097,7 +1097,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo
|
|||
int rel = getExtraLight();
|
||||
gl_SetColor(lightlevel, rel, Colormap, 1.0f);
|
||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
float fviewx = FIXED2FLOAT(viewx);
|
||||
float fviewy = FIXED2FLOAT(viewy);
|
||||
|
|
|
@ -341,7 +341,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG
|
|||
case GLPASS_ALL:
|
||||
gl_SetColor(lightlevel, rel, Colormap,1.0f);
|
||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
gl_SetPlaneTextureRotation(&plane, gltexture);
|
||||
DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false);
|
||||
gl_RenderState.EnableTextureMatrix(false);
|
||||
|
@ -367,7 +367,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG
|
|||
}
|
||||
else
|
||||
{
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
gl_SetPlaneTextureRotation(&plane, gltexture);
|
||||
DrawSubsectors(pass, true, true);
|
||||
gl_RenderState.EnableTextureMatrix(false);
|
||||
|
|
|
@ -1011,7 +1011,7 @@ void GLHorizonPortal::DrawContents()
|
|||
}
|
||||
|
||||
|
||||
gltexture->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
gl_SetPlaneTextureRotation(sp, gltexture);
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||
|
|
|
@ -1119,7 +1119,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in
|
|||
if (!usefb)
|
||||
{
|
||||
glFlush();
|
||||
gltex->Bind(0, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltex, 0, 0, -1, false);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -268,7 +268,7 @@ void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, in
|
|||
|
||||
if (tex)
|
||||
{
|
||||
tex->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_NONE, 0, -1, false);
|
||||
texw = tex->TextureWidth();
|
||||
texh = tex->TextureHeight();
|
||||
gl_RenderState.EnableModelMatrix(true);
|
||||
|
@ -333,7 +333,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// north
|
||||
tex = FMaterial::ValidateTexture(sb->faces[0], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
@ -349,7 +349,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// east
|
||||
tex = FMaterial::ValidateTexture(sb->faces[1], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
@ -365,7 +365,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// south
|
||||
tex = FMaterial::ValidateTexture(sb->faces[2], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
@ -381,7 +381,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// west
|
||||
tex = FMaterial::ValidateTexture(sb->faces[3], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
@ -425,7 +425,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// top
|
||||
tex = FMaterial::ValidateTexture(sb->faces[faces], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
@ -441,7 +441,7 @@ static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool
|
|||
|
||||
// bottom
|
||||
tex = FMaterial::ValidateTexture(sb->faces[faces+1], false);
|
||||
tex->Bind(CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false);
|
||||
gl_RenderState.Apply();
|
||||
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
|
|
|
@ -214,7 +214,7 @@ void GLSprite::Draw(int pass)
|
|||
gl_RenderState.SetFog(0, 0);
|
||||
}
|
||||
|
||||
if (gltexture) gltexture->Bind(CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha));
|
||||
if (gltexture) gl_RenderState.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha));
|
||||
else if (!modelframe) gl_RenderState.EnableTexture(false);
|
||||
|
||||
if (!modelframe)
|
||||
|
|
|
@ -274,7 +274,7 @@ void GLWall::RenderMirrorSurface()
|
|||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false);
|
||||
pat->Bind(CLAMP_NONE, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
flags &= ~GLWF_GLOW;
|
||||
RenderWall(RWF_BLANK);
|
||||
|
@ -326,7 +326,7 @@ void GLWall::RenderTranslucentWall()
|
|||
if (gltexture)
|
||||
{
|
||||
gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW));
|
||||
gltexture->Bind(flags & 3, 0, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false);
|
||||
extra = getExtraLight();
|
||||
}
|
||||
else
|
||||
|
@ -390,7 +390,7 @@ void GLWall::Draw(int pass)
|
|||
else gl_SetFog(255, 0, NULL, false);
|
||||
|
||||
gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW));
|
||||
gltexture->Bind(flags & 3, false, -1, false);
|
||||
gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false);
|
||||
RenderWall(RWF_TEXTURED|RWF_GLOW);
|
||||
gl_RenderState.EnableGlow(false);
|
||||
break;
|
||||
|
|
|
@ -96,7 +96,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed
|
|||
FMaterial * tex = FMaterial::ValidateTexture(lump, true, false);
|
||||
if (!tex) return;
|
||||
|
||||
tex->Bind(CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture);
|
||||
gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture);
|
||||
|
||||
int vw = viewwidth;
|
||||
int vh = viewheight;
|
||||
|
|
|
@ -616,11 +616,9 @@ static int lastclamp;
|
|||
static int lasttrans;
|
||||
static bool lastalpha;
|
||||
|
||||
void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool alphatexture)
|
||||
{
|
||||
int shaderindex = overrideshader >= 0? overrideshader : mShaderIndex;
|
||||
gl_RenderState.SetShader(shaderindex, tex->gl_info.shaderspeed);
|
||||
|
||||
void FMaterial::Bind(int clampmode, int translation, bool alphatexture)
|
||||
{
|
||||
// avoid rebinding the same texture multiple times.
|
||||
if (this == last && lastclamp == clampmode && translation == lasttrans && lastalpha == alphatexture) return;
|
||||
last = this;
|
||||
|
@ -636,7 +634,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool al
|
|||
else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
|
||||
|
||||
const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, alphatexture, allowhires? tex:NULL);
|
||||
if (gltexture != NULL && shaderindex > 0 && overrideshader == -1)
|
||||
if (gltexture != NULL)
|
||||
{
|
||||
for(unsigned i=0;i<mTextureLayers.Size();i++)
|
||||
{
|
||||
|
@ -671,7 +669,7 @@ void FMaterial::Bind(int clampmode, int translation, int overrideshader, bool al
|
|||
//===========================================================================
|
||||
void FMaterial::Precache()
|
||||
{
|
||||
Bind(0, 0, 0, false);
|
||||
Bind(0, 0, false);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -93,6 +93,8 @@ public:
|
|||
|
||||
class FMaterial
|
||||
{
|
||||
friend class FRenderState;
|
||||
|
||||
struct FTextureLayer
|
||||
{
|
||||
FTexture *texture;
|
||||
|
@ -137,7 +139,7 @@ public:
|
|||
}
|
||||
|
||||
//void Bind(int clamp = 0, int translation = 0, int overrideshader = 0, bool alphatexture = false);
|
||||
void Bind(int clamp, int translation, int overrideshader, bool alphatexture);
|
||||
void Bind(int clamp, int translation, bool alphatexture);
|
||||
|
||||
unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true) const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue