Hello everyone! In developing my current project I want to have the ability to draw 2D bitmap images directly to the screen, while also drawing a 3D image / scene at the same time.
I have a basic Bitmap class that helps me load the image resource and draw it, and it displays 2D images on the screen perfectly as long as I’m not doing any drawing with OpenGL at the same time. If I do both, however, the 2D image winds up flickering. Obviously not a desirable effect.
I figure this is probably because OpenGL is drawing to and swapping buffers, but I can’t figure out how to overcome this. For clarity, I’ve included my drawing method which is responsible for drawing to my screen.
Is there some extra work I need to be doing to overcome this, or should I be taking a different approach altogether? Thanks a lot for the help in advance.
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>
void Draw(HDC hDC)
{
//OpenGL drawing
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//Make and draw a reference object
glColor3f(0.8f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(0.0f, 0.75f, 0.0f);
glBegin(GL_QUADS);
glVertex3f(_squareX, _squareY, _squareZ); //Bottom-left vertex
glVertex3f(_squareX + _squareSize, _squareY, _squareZ); //Bottom-right vertex
glVertex3f(_squareX + _squareSize, _squareY + _squareSize, _squareZ); //Top-Right Vertex
glVertex3f(_squareX, _squareY + _squareSize, _squareZ); //Top-left vertex.
glEnd();
glPopMatrix();
SwapBuffers(hDC);
//2D bitmap drawing
_myBitmap->Draw(hDC, 0, 0);
}
[/QUOTE]</div>