Skip to content

Commit

Permalink
When batching up model drawing, also batch up depth stretching info.
Browse files Browse the repository at this point in the history
Fixes ticket:4366
  • Loading branch information
perim committed Jun 18, 2016
1 parent 04df320 commit 94d0afe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ivis_opengl/piedraw.cpp
Expand Up @@ -135,6 +135,7 @@ typedef struct
PIELIGHT teamcolour;
int flag;
int flag_data;
float stretch;
} SHAPE;

static std::vector<ShadowcastingShape> scshapes;
Expand Down Expand Up @@ -428,6 +429,7 @@ void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colour, int
tshape.teamcolour = teamcolour;
tshape.flag = pieFlag;
tshape.flag_data = pieFlagData;
tshape.stretch = pie_GetShaderStretchDepth();
pie_GetMatrix(&tshape.matrix[0][0]);

if (pieFlag & pie_HEIGHT_SCALED) // construct
Expand Down Expand Up @@ -549,14 +551,18 @@ void pie_RemainingPasses(void)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
for (unsigned i = 0; i < shapes.size(); ++i)
{
pie_SetShaderStretchDepth(shapes[i].stretch);
pie_Draw3DShape2(shapes[i].shape, shapes[i].frame, shapes[i].colour, shapes[i].teamcolour, shapes[i].flag, shapes[i].flag_data, shapes[i].matrix);
pie_SetShaderStretchDepth(0);
}
// Draw translucent models last
// TODO, sort list by Z order to do translucency correctly
GL_DEBUG("Remaining passes - translucent models");
for (unsigned i = 0; i < tshapes.size(); ++i)
{
pie_SetShaderStretchDepth(tshapes[i].stretch);
pie_Draw3DShape2(tshapes[i].shape, tshapes[i].frame, tshapes[i].colour, tshapes[i].teamcolour, tshapes[i].flag, tshapes[i].flag_data, tshapes[i].matrix);
pie_SetShaderStretchDepth(0);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
Expand Down
5 changes: 5 additions & 0 deletions lib/ivis_opengl/piestate.cpp
Expand Up @@ -385,6 +385,11 @@ void pie_SetShaderStretchDepth(float stretch)
shaderStretch = stretch;
}

float pie_GetShaderStretchDepth()
{
return shaderStretch;
}

void pie_ActivateShader(int shaderMode, const iIMDShape *shape, PIELIGHT teamcolour, PIELIGHT colour)
{
int maskpage = shape->tcmaskpage;
Expand Down
1 change: 1 addition & 0 deletions lib/ivis_opengl/piestate.h
Expand Up @@ -90,6 +90,7 @@ GLuint pie_LoadShader(const char *programName, const char *vertexPath, const cha
void pie_ActivateShader(int shaderMode, const iIMDShape *shape, PIELIGHT teamcolour, PIELIGHT colour);
void pie_DeactivateShader();
void pie_SetShaderStretchDepth(float stretch);
float pie_GetShaderStretchDepth();
void pie_SetShaderTime(uint32_t shaderTime);
void pie_SetShaderEcmEffect(bool value);

Expand Down

0 comments on commit 94d0afe

Please sign in to comment.