PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Problems with E2DSurfaceRGBA when EGL_USEGL is defined.

I’m running into a problem when trying to display RGBA surfaces while using OpenGL hardware acceleration. It seems that when hardware acceleration is turned on I can’t blit RGBA surfaces. If I try to blit an RGBA surface to the screen using the following code, BltFast returns E_ERROR:

Code:

display->Perspective2D(m_rgbaSurface.GetWidth(), m_rgbaSurface.GetHeight(), false);
display->buffer.BltFast(0, 0, &m;_rgbaSurface, NULL);


If I try to blit the RGBA surface to an E2DSurface using the following code, BltFast returns E_LOCKFAILED:

Code:

E2DSurface tmpSurf;
if(E_OK == display->CreateSurface(&tmpSurf;, m_rgbaSurface.GetWidth(), m_rgbaSurface.GetHeight()))
{
tmpSurf.BltFast(0, 0, &m;_rgbaSurface, NULL);
}


I am using the following code to create the RGBA Surface:

Code:

E2DSurfaceRGBA m_rgbaSurface;
if(E_OK != display->CreateSurface(&m;_rgbaSurface, "gui_control.png"))
return E_ERROR;

display->UploadTexture(&m;_rgbaSurface);


The above code seems to work fine if I don’t define EGL_USEGL. For my application I’m attempting to render a 3D scene and then overlay a GUI for the user. I need to be able to use RGBA surfaces to create the GUI, but I would also like to take advantage of OpenGL hardware acceleration for the 3D rendering. Is there any way to mix the two? If not, what is the typical approach for creating a 2D GUI to be used in a 3D application?
Hi,

When blitting in OpenGL, blit directly to the display. This is because there is no backbuffer in OpenGL. Other than that, your code looks fine :)
Hi Edge,

Thank you for the quick response. How do you blit an RGBA surface directly to the display in OpenGL? I am able to do this with an E2DSurface by using the ClassEDisplay::BltFast function, however I couldn't find a function in ClassEDisplay that takes an E2DSurfaceRGBA surface as a parameter. I've tried type casting the surface to an E2DSurface and passing it to BltFast, but it didn't display anything. Can this be done through the Edge library, or do I need to do this directly through the OpenGL library?
Hi,

Unfortunately, directly blitting RGBA surfaces is not part of the EDGELIB API at the moment, this will be added in the next release.

In the meantime you can use display->Perspective2D and display->BindTexture to set up your 2D viewport and set the correct texture. Then you can use a 2 textured triangles to 'blit' your HUD 2D pictures.
Hi, Edge, I am having some troubles with this too.

I can't draw an E2DSurface when OpenGL is enabled. It works fine when I am working with __EDGEIDE__ so I don't know if it is posible to draw a simple E2DSurface (not RGBA) in openglMode. This is what I do (I have already checked that loading logo success)

Code:
display->Perspective2D(display->GetWidth(), display->GetHeight());
display->BltFast(0, 0, &logo;, 0);


In case it can be done... if there is no buffer with OpenGL as you say then it is not posible to use display->buffer.BltFast. And, if this is true, ColorKeys won't work because display->BltFast doesn't allow Surface blit flags as param.

If I am right, then all this mean that making a menu for a 3d game using OpenGL is going to be really hard...
Hi Zalo,

It should be possible to blit your (colorkeyed) surfaces through the display in OpenGL. When you have a colorkeyed surface, you need to upload it as RGBA (it's an option of ClassEDisplay::UploadTexture).

Can you post your surface loading code?