mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-18 18:21:13 +00:00
- fixed: FMaterial's tex pointer could be accessed before it was set.
- allow more than two texture units in shaders.
This commit is contained in:
parent
9b8869e78d
commit
c6f4c0b6f0
2 changed files with 9 additions and 3 deletions
|
@ -227,8 +227,14 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
|
|
||||||
glUseProgram(hShader);
|
glUseProgram(hShader);
|
||||||
|
|
||||||
tempindex = glGetUniformLocation(hShader, "texture2");
|
// set up other texture units (if needed by the shader)
|
||||||
if (tempindex > 0) glUniform1i(tempindex, 1);
|
for (int i = 2; i<16; i++)
|
||||||
|
{
|
||||||
|
char stringbuf[20];
|
||||||
|
mysnprintf(stringbuf, 20, "texture%d", i);
|
||||||
|
tempindex = glGetUniformLocation(hShader, stringbuf);
|
||||||
|
if (tempindex > 0) glUniform1i(tempindex, i - 1);
|
||||||
|
}
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
return !!linked;
|
return !!linked;
|
||||||
|
|
|
@ -405,6 +405,7 @@ int FMaterial::mMaxBound;
|
||||||
FMaterial::FMaterial(FTexture * tx, bool expanded)
|
FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
{
|
{
|
||||||
mShaderIndex = 0;
|
mShaderIndex = 0;
|
||||||
|
tex = tx;
|
||||||
|
|
||||||
// TODO: apply custom shader object here
|
// TODO: apply custom shader object here
|
||||||
/* if (tx->CustomShaderDefinition)
|
/* if (tx->CustomShaderDefinition)
|
||||||
|
@ -495,7 +496,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
mMaterials.Push(this);
|
mMaterials.Push(this);
|
||||||
tx->gl_info.Material[expanded] = this;
|
tx->gl_info.Material[expanded] = this;
|
||||||
if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0;
|
if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0;
|
||||||
tex = tx;
|
|
||||||
mExpanded = expanded;
|
mExpanded = expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue