Navigation Menu

Skip to content

Commit

Permalink
opengl: Don't assert if vs_flip_loc == -1.
Browse files Browse the repository at this point in the history
This can be -1 if the GLSL compiler removed it, or if you bound a program
without a vertex shader at all.
  • Loading branch information
icculus committed Oct 14, 2020
1 parent 2009682 commit 7cc0e89
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions mojoshader_opengl.c
Expand Up @@ -2927,18 +2927,19 @@ void MOJOSHADER_glProgramViewportInfo(int viewportW, int viewportH,
} // if

#ifdef MOJOSHADER_FLIP_RENDERTARGET
assert(ctx->bound_program->vs_flip_loc != -1);

/* Some compilers require that vpFlip be a float value, rather than int.
* However, there's no real reason for it to be a float in the API, so we
* do a cast in here. That's not so bad, right...?
* -flibit
*/
const int flip = renderTargetBound ? -1 : 1;
if (flip != ctx->bound_program->current_flip)
{
ctx->glUniform1f(ctx->bound_program->vs_flip_loc, (float) flip);
ctx->bound_program->current_flip = flip;
if (ctx->bound_program->vs_flip_loc != -1)
{
/* Some compilers require that vpFlip be a float value, rather than int.
* However, there's no real reason for it to be a float in the API, so we
* do a cast in here. That's not so bad, right...?
* -flibit
*/
const int flip = renderTargetBound ? -1 : 1;
if (flip != ctx->bound_program->current_flip)
{
ctx->glUniform1f(ctx->bound_program->vs_flip_loc, (float) flip);
ctx->bound_program->current_flip = flip;
} // if
} // if
#endif
} // MOJOSHADER_glViewportInfo
Expand Down

0 comments on commit 7cc0e89

Please sign in to comment.