Skip to content

Commit

Permalink
[engine]Issue #115: Some safe check asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Miquel Angel Quinones Garcia committed Feb 19, 2013
1 parent 8712157 commit 7c6453e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
22 changes: 15 additions & 7 deletions IndieLib/common/src/render/opengl/RenderObject2dOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ void OpenGLRender::blitSurface(IND_Surface *pSu) {
if (!_math.cullFrustumBox(mP1, mP2,_frustrumPlanes)) {
_numDiscardedObjects++;
} else {

//Enable texturing
glEnable(GL_TEXTURE_2D);
#ifdef _DEBUG
GLboolean enabled;
glGetBooleanv(GL_TEXTURE_2D,&enabled);
assert(GL_FALSE != enabled); //Should have texturing enabled
#endif

//Surface drawing
glEnableClientState(GL_VERTEX_ARRAY);
Expand Down Expand Up @@ -180,8 +182,11 @@ void OpenGLRender::blitRegionSurface(IND_Surface *pSu,
if (!_math.cullFrustumBox(mP1, mP2, _frustrumPlanes)) {
_numDiscardedObjects++;
} else {
//Enable texturing
glEnable(GL_TEXTURE_2D);
#ifdef _DEBUG
GLboolean enabled;
glGetBooleanv(GL_TEXTURE_2D,&enabled);
assert(GL_FALSE != enabled); //Should have texturing enabled
#endif
//Surface drawing
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Expand Down Expand Up @@ -255,8 +260,11 @@ bool OpenGLRender::blitWrapSurface(IND_Surface *pSu,
if (!_math.cullFrustumBox(mP1, mP2, _frustrumPlanes)) {
_numDiscardedObjects++;
} else {
//Enable texturing
glEnable(GL_TEXTURE_2D);
#ifdef _DEBUG
GLboolean enabled;
glGetBooleanv(GL_TEXTURE_2D,&enabled);
assert(GL_FALSE != enabled); //Should have texturing enabled
#endif
//Surface drawing
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Expand Down
32 changes: 23 additions & 9 deletions IndieLib/common/src/render/opengl/RenderPrimitive2dOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void OpenGLRender::blitPixel(int pX,

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}

void OpenGLRender::blitLine(int pX1,
Expand Down Expand Up @@ -114,7 +117,8 @@ void OpenGLRender::blitLine(int pX1,

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}

void OpenGLRender::blitRectangle(int pX1,
Expand Down Expand Up @@ -156,7 +160,8 @@ void OpenGLRender::blitRectangle(int pX1,

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}

void OpenGLRender::blitFillRectangle(int pX1,
Expand Down Expand Up @@ -197,7 +202,8 @@ void OpenGLRender::blitFillRectangle(int pX1,

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}

void OpenGLRender::blitTriangleList(IND_Point *pTrianglePoints,
Expand Down Expand Up @@ -240,7 +246,8 @@ void OpenGLRender::blitTriangleList(IND_Point *pTrianglePoints,
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}


Expand Down Expand Up @@ -287,7 +294,8 @@ void OpenGLRender::blitColoredTriangle(int pX1,
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
}


Expand Down Expand Up @@ -330,7 +338,8 @@ bool OpenGLRender::blitPoly2d(IND_Point *pPolyPoints,
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
return 1;
}

Expand Down Expand Up @@ -381,7 +390,8 @@ bool OpenGLRender::blitRegularPoly(int pX,
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

//Reenable texturing
glEnable(GL_TEXTURE_2D);
return 1;
}

Expand Down Expand Up @@ -453,7 +463,9 @@ Blits a bounding line
}
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
//Reenable texturing
glEnable(GL_TEXTURE_2D);
}

/*
Expand Down Expand Up @@ -517,7 +529,9 @@ void OpenGLRender::blitCollisionCircle(int pPosX, int pPosY, int pRadius, float
}
#endif
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
//Reenable texturing
glEnable(GL_TEXTURE_2D);

}

Expand Down

0 comments on commit 7c6453e

Please sign in to comment.