SDL / OpenGL

Hi all,

Suppose I want to create an SDL/OpenGL game, and I’d like to have nice menus, HUDs, scores and all the rest of it. I’ve heard that setting up an OpenGL context prevents the usage of SDL as a blitter (and thus any derivated library like SFont).
Any solutions or good URLs on this topic ?

Thanks

Hi Julien,

If it’s just about nice font rendering (2D/3D) you want to have look at
OGLFT: http://oglft.sourceforge.net (use the svn trunk!)

It acts as an interface between OpenGL and Freetype, hence makes TTF
fonts available to your app. I also tried FTGL but found OGLFT to be the
better solution for my purposes. Some other alternatives can be found
here: http://www.opengl.org/resources/features/fontsurvey

This way you should be able to come up with a nice HUD…

Cheers,

Oliver

julien CLEMENT wrote:> Hi all,

Suppose I want to create an SDL/OpenGL game, and I’d like to have nice menus, HUDs, scores and all the rest of it. I’ve heard that setting up an OpenGL context prevents the usage of SDL as a blitter (and thus any derivated library like SFont).
Any solutions or good URLs on this topic ?

Thanks



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You heard wrong, you need to read up on the concept of a context in OpenGL.

Bob PendletonOn Tue, Oct 7, 2008 at 2:22 AM, julien CLEMENT wrote:

Hi all,

Suppose I want to create an SDL/OpenGL game, and I’d like to have nice
menus, HUDs, scores and all the rest of it. I’ve heard that setting up an
OpenGL context prevents the usage of SDL as a blitter (and thus any
derivated library like SFont).
Any solutions or good URLs on this topic ?

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

±-------------------------------------+

Hi again,

I may have been unclear. I set up an OpenGL context and use opengl to render 3D objects. Many forums confirm that in open gl mode (if I may call it this way), it’s not possible anymore to use SDL for blitting.
Any other advice to confirm or reject this ?

By the way, thank you Oliver for the links.

Cheers

— En date de?: Mer 8.10.08, Bob Pendleton a ?crit?:de: Bob Pendleton
Objet: Re: [SDL] SDL / OpenGL
?: @Julien_Clement1, “A list for developers using the SDL library. (includes SDL-announce)”
Date: Mercredi 8 Octobre 2008, 21h43

On Tue, Oct 7, 2008 at 2:22 AM, julien CLEMENT <@Julien_Clement1> wrote:

Hi all,

Suppose I want to create an SDL/OpenGL game, and I’d like to have nice
menus, HUDs, scores and all the rest of it. I’ve heard that setting up
an
OpenGL context prevents the usage of SDL as a blitter (and thus any
derivated library like SFont).
Any solutions or good URLs on this topic ?

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You heard wrong, you need to read up on the concept of a context in OpenGL.

Bob Pendleton

±-------------------------------------+

Hi.

You cannot blit to the screen, no. But if you are careful to only use
software surfaces or the surface returned by SDL_SetVideoMode() (even
implicity: e.g. SDL_DisplayFormat()), you can still blit between
surfaces you load or create.

For example, you could SDL_LoadBMP() an image, change the format to
match an internal OpenGL format, and use glTexImage2D() to use the raw
pixel data for a texture.

If SFont can make surfaces, you can make textures from those surfaces
and then draw it by setting up an orthographic projection and
disabling depth buffer reads.

Alternatively, I’m sure you can find libraries for OpenGL to handle
text or GUIs or whatever =).

HTH,
Brian.On Thu, Oct 9, 2008 at 7:57 AM, julien CLEMENT wrote:

Hi again,

I may have been unclear. I set up an OpenGL context and use opengl to
render 3D objects
. Many forums confirm that in open gl mode (if I may call
it this way), it’s not possible anymore to use SDL for blitting.
Any other advice to confirm or reject this ?

Hi Brian ,

Hi.

You cannot blit to the screen, no. But if you are careful to only use
software surfaces or the surface returned by SDL_SetVideoMode() (even
implicity: e.g. SDL_DisplayFormat()), you can still blit between
surfaces you load or create.

For example, you could SDL_LoadBMP() an image, change the format to
match an internal OpenGL format, and use glTexImage2D() to use the raw
pixel data for a texture.

If SFont can make surfaces, you can make textures from those surfaces
and then draw it by setting up an orthographic projection and
disabling depth buffer reads.

Alternatively, I’m sure you can find libraries for OpenGL to handle
text or GUIs or whatever =).

I also wanted to be able to write text in SDL and I ended up writing
a class just for that by going through forums,mailing lists and finding
about freefonts and SDL_font.
Is there something widely used,maybe a framework that is based on SDL
and already knows these(the basics I mean) ?
Otherwise I will have to write my own wrappers(which of course I will if
somebody hasn’t done it yet).

HTH,
Brian.

Hi again,

I may have been unclear. I set up an OpenGL context and use opengl to
render 3D objects
. Many forums confirm that in open gl mode (if I may call
it this way), it’s not possible anymore to use SDL for blitting.
Any other advice to confirm or reject this ?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Best regards,
StefanOn Thu, Oct 09, 2008 at 11:23:10AM +0100, Brian wrote:

On Thu, Oct 9, 2008 at 7:57 AM, julien CLEMENT wrote:

Stefan Petrea
homepage : http://perlhobby.googlecode.com/
mobile phone : +40732070179

Hi again,

I may have been unclear. I set up an OpenGL context and use opengl to
render 3D objects
. Many forums confirm that in open gl mode (if I may call
it this way), it’s not possible anymore to use SDL for blitting.
Any other advice to confirm or reject this ?

Yes, I can do that for you. SDL has two distinct ways of accessing the
screen. It can treat it as a dumb frame buffer or it can use OpenGL.
They are exclusive. You can either access the screen using OpenGL or
by using SDL blits, but not both. That has nothing to do with setting
up an OpenGL context for 3D rendering. It only depends on how you set
up the screen when you first init it.

Even if you are using OpenGL to access the screen you can still use
SDL blits for manipulating images in memory and for converting images
for use as OpenGL textures. And, remember that OpenGL is perfectly
happy to do 2D rendering as well as 3D rendering. Once you have an
image in memory you can make it into an OpenGL texture and draw
textured polygons to accomplish the same things you would do with SDL
blits. Only now you can do them in 3D.

The easiest way to draw nice text in SDL/OpenGL is to use SDL_ttf to
create images of each character, up load the characters as textures,
and then draw the images to the screen using textured rectangles. If
you look back through the archive you’ll find a C++ class I posted a
while back (maybe a couple of years ago) that implements that
strategy.

Bob PendletonOn Thu, Oct 9, 2008 at 1:57 AM, julien CLEMENT wrote:

By the way, thank you Oliver for the links.

Cheers

— En date de : Mer 8.10.08, Bob Pendleton <@Bob_Pendleton> a ?crit :

De: Bob Pendleton <@Bob_Pendleton>
Objet: Re: [SDL] SDL / OpenGL
?: clementj2005 at yahoo.fr, “A list for developers using the SDL library.
(includes SDL-announce)”
Date: Mercredi 8 Octobre 2008, 21h43

On Tue, Oct 7, 2008 at 2:22 AM, julien CLEMENT wrote:

Hi all,

Suppose I want to create an SDL/OpenGL game, and I’d like to have nice
menus, HUDs, scores and all the rest of it. I’ve heard that setting up
an
OpenGL context prevents the usage of SDL as a blitter (and thus any
derivated library like SFont).
Any solutions or good URLs on this topic ?

Thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You heard wrong, you need to read up on the concept of a context in OpenGL.

Bob Pendleton

±-------------------------------------+


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

±-------------------------------------+

OpenGL is doing nice things for 2D rendering, too, so maybe you should
also use it for HUDs and menus. As for font drawing, OGLFT and FTGL
have already been mentioned, and you may also try GLC for a nice
GL-like API.

Cheers,
Alex