Skip to content

Commit

Permalink
Debug: Investigating texture bindings during busy progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 27, 2012
1 parent 123b07d commit 0c1ef32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -517,6 +517,17 @@ static void Con_DrawScreenshotBackground(float x, float y, float width, float he
}
}

#ifdef _DEBUG
#define _assertTexture(tex) { \
GLint p; \
glGetIntegerv(GL_TEXTURE_BINDING_2D, &p); \
Sys_GLCheckError(); \
if(p != tex) fprintf(stderr, "tex=%i, got %i at line %i\n", tex, p, __LINE__); \
}
#else
#define _assertTexture(tex)
#endif

/**
* @param 0...1, to indicate how far things have progressed.
*/
Expand Down Expand Up @@ -561,6 +572,7 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)
glEnable(GL_TEXTURE_2D);

GL_BindTextureUnmanaged(texLoading[0], GL_LINEAR);
_assertTexture(texLoading[0]);
glColor4fv(col);
GL_DrawRectf2(x - radius, y - radius, radius*2, radius*2);

Expand All @@ -574,7 +586,9 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)

// Draw a fan.
glColor4f(col[0], col[1], col[2], .5f);
_assertTexture(texLoading[0]);
GL_BindTextureUnmanaged(texLoading[1], GL_LINEAR);
_assertTexture(texLoading[1]);
glBegin(GL_TRIANGLE_FAN);
// Center.
glTexCoord2f(.5f, .5f);
Expand All @@ -587,6 +601,7 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)
glVertex2f(x + cos(angle)*radius*1.05f, y + sin(angle)*radius*1.05f);
}
glEnd();
_assertTexture(texLoading[1]);

glMatrixMode(GL_TEXTURE);
glPopMatrix();
Expand Down
5 changes: 2 additions & 3 deletions doomsday/engine/portable/src/gl_main.c
Expand Up @@ -983,15 +983,14 @@ void GL_SetRawImage(lumpnum_t lumpNum, int wrapS, int wrapT)

void GL_BindTextureUnmanaged(DGLuint glName, int magMode)
{
if(Con_InBusyWorker()) return;
LIBDENG_ASSERT_IN_MAIN_THREAD();

if(glName == 0)
{
GL_SetNoTexture();
return;
}

LIBDENG_ASSERT_IN_MAIN_THREAD();

glBindTexture(GL_TEXTURE_2D, glName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magMode);
if(GL_state.features.texFilterAniso)
Expand Down

0 comments on commit 0c1ef32

Please sign in to comment.