Page 1 of 1

Blitting a surface on top of another (OpenGL)

PostPosted: Jul 9, 2009 @ 7:22pm
by Nacho84
Hi! I need to add detail to an existing 2D surface by blitting another surface on top of it. Up to this point, I haven't been using OpenGL and managed to get good results by calling the BltFast method from the destination surface.

I've now changed my code to make use of OpenGL (I'm working on Windows) but, unfortunately, the BltFast() method I use to compose the surface is returning E_LOCKFAILED and I don't know how to solve it.

I'm attaching a Visual Studio solution with a very simple example so that you can try it out and tell me what's missing. The call to BltFast that is failing is located in the line 194 of main.cpp

Many thanks!

--Nacho

PostPosted: Jul 14, 2009 @ 10:39am
by edge

PostPosted: Jul 20, 2009 @ 12:02am
by Nacho84

PostPosted: Jul 27, 2009 @ 12:49pm
by edge
Hi Nacho,

The rectangle isn't filled because the E_RGBX macro doesn't specify opacity information. The correct way is to use E_RGBA, for example: E_RGBA(255, 0, 0, 255) for a red color.

Unfortunately it isn't possible to draw rectangles and lines easily. At the moment, the best way to do this is to use an E3DSurface object containing your rectangle, or use OpenGL directly.

PostPosted: Aug 4, 2009 @ 2:25am
by Nacho84
Hi edge,

Many thanks for your reply! The filled rectangle worked great. I'll see if I can implement the non-filled rectangle using OpenGL during the weekend.

--Nacho

PostPosted: Aug 10, 2009 @ 3:07am
by Nacho84

PostPosted: Aug 11, 2009 @ 10:23am
by edge
Hi Nacho,

The lines are probably green because texturing is still enabled. Also, did you know you can't use glBegin/End calls on many mobile devices?

To fix this you need to call glDisable(GL_TEXTURE2D) and disable some OpenGL client states: texture coordinate, color and normal arrays.