Blitting onto OpenGL surfaces

Hi!

Is it safe to rely on SDL_BlitSurface() for blitting onto OpenGL surfaces? Are
there any restrictions, particularly regaring the blitting of surfaces with
an alpha channel?

Or should I go the OpenGL way instead and load everything into a texture
first?

Regards,
Gregor

Hi,

if i remember correctly, blitting directly on a screen
that has SDL_OPENGL set was not possible.

I wanted to do that for an overlay help screen, but then
chose to generate a texture and draw that one with
OpenGL functionality (GL_QUAD).

After doing the 3D stuff i used this code to draw the
overlay:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, xwidth, yheight);
gluOrtho2D(0, xwidth, 0, yheight);

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glColor3f(1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, texbase);
glBegin(GL_QUADS);
glTexCoord2d(0, 0);
glVertex2d(0, 0);

glTexCoord2d(1, 0);
glVertex2d(tn, 0);

glTexCoord2d(1, 1);
glVertex2d(tn, tn);

glTexCoord2d(0, 1);
glVertex2d(0, tn);

glEnd();

Hope that’s whatr you wanted.

Regards,
Torsten.> Hi!

Is it safe to rely on SDL_BlitSurface() for blitting onto OpenGL surfaces?
Are there any restrictions, particularly regaring the blitting of surfaces
with an alpha channel?

Or should I go the OpenGL way instead and load everything into a texture
first?

Regards,
Gregor


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

yeah same thing happened to me, it crashed whenever i tried to use sdl to
draw to the screen after bein in GL mode (:

one neat thing though is that you can convert SDL surfaces to GL textures so
if you want to do some sdl stuff you can create a surface, draw to it w/
sdl, convert the surface to a GL texture and draw that using GL.> ----- Original Message -----

From: tmohr@s.netic.de (Torsten Mohr)
To:
Sent: Tuesday, December 30, 2003 11:52 AM
Subject: Re: [SDL] blitting onto OpenGL surfaces

Hi,

if i remember correctly, blitting directly on a screen
that has SDL_OPENGL set was not possible.

I wanted to do that for an overlay help screen, but then
chose to generate a texture and draw that one with
OpenGL functionality (GL_QUAD).

After doing the 3D stuff i used this code to draw the
overlay:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, xwidth, yheight);
gluOrtho2D(0, xwidth, 0, yheight);

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glColor3f(1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, texbase);
glBegin(GL_QUADS);
glTexCoord2d(0, 0);
glVertex2d(0, 0);

glTexCoord2d(1, 0);
glVertex2d(tn, 0);

glTexCoord2d(1, 1);
glVertex2d(tn, tn);

glTexCoord2d(0, 1);
glVertex2d(0, tn);
glEnd();

Hope that’s whatr you wanted.

Regards,
Torsten.

Hi!

Is it safe to rely on SDL_BlitSurface() for blitting onto OpenGL
surfaces?

Are there any restrictions, particularly regaring the blitting of
surfaces

with an alpha channel?

Or should I go the OpenGL way instead and load everything into a texture
first?

Regards,
Gregor


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

NeHe’s SDL Basecode actually blits some 2D images ontop of an OpenGL
surface. It’s not using the textured quads that have already been
mentioned – just straight calls to SDL_BlitSurface and SDL_UpdateRects

It uses colorkeying instead of an alpha channel for transparency, so the
alpha channel might be whats causing the others to experience crashes,
though – I haven’t actually tested it out.

Here’s the link: http://nehe.gamedev.net/files/basecode/nehegl_sdl.zip
The code for the blitting is in app.cpp, in Draw2D(), the last function in
the file.> ----- Original Message -----

From: gregormueckl@gmx.de (Gregor Muckl)
To:
Sent: Tuesday, December 30, 2003 7:14 AM
Subject: [SDL] blitting onto OpenGL surfaces

Hi!

Is it safe to rely on SDL_BlitSurface() for blitting onto OpenGL surfaces?
Are
there any restrictions, particularly regaring the blitting of surfaces
with
an alpha channel?

Or should I go the OpenGL way instead and load everything into a texture
first?

Regards,
Gregor


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.552 / Virus Database: 344 - Release Date: 12/15/2003