OpenGL drawing invisible in release mode(when _DEBUG is defined)
I ported my Opengl project from Qt to MFC with success.. only in debug mode.
Everything works great in debug mode.
It even works in release mode, as long as _DEBUG is defined. If it's not, every OpenGL function get called, but without result on the screen.
I use no assert function anywhere in the code. I use Glew to get OpenGL function pointers.
Here is the (slow) OpenGL function, even if I don't think it will really help:
void COpenGLView::Render()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
for(u32 i = 0; i < 144; ++i)
{
for(u32 j = 0; j < 160; ++j)
{
switch( lcd_[(i * 160)+j] & 0x3 )
{
case WHITE: glColor3f(0.75f,1.0f,0.75f); break;
case LIGHT_GREY: glColor3f(0.50f, 0.80f, 0.50f); break;
case DARK_GREY: glColor3f(0.25f,0.60f,0.25f); break;
case BLACK: glColor3f(0.0f,0.0f,0.0f); break;
开发者_开发知识库 }
glVertex2d(j,i);
glVertex2d(j,i + 1);
glVertex2d(j + 1,i + 1);
glVertex2d(j + 1,i);
}
}
glEnd();
FinishRender();
}
So the main problem is: There is nothing OpenGL-related on the screen if _DEBUG is not defined!
Anyone know where do this problem come from?
This is most likely caused by the wrong use of MFC. In case you are not using #ifdef _DEBUG or ASSERT() anywhere in your code, it is still possible it is used in some macros defined by the MFC. MFC is quite heavy on macros that just call some WinAPI function, and those macros may very well contain some #ifdefs themselves.
But regardless, MFC and OpenGL should be very simple to mix. Just post your OpenGL initialization code to see if we can work it out.
精彩评论