SDL_MapRGB in OpenGL Mode

Hi All :slight_smile:

Just wondering if my code is wonky or if when running in OpenGL mode,

SDL_SetVideoMode(scr_width, scr_height, 0, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|
SDL_HWPALETTE);

I no longer have access to things like SDL_MapRGB…?

Maybe my code porting needs some work, but if anyone could clarify…?

Thanks,

Steve

Stephen Sweeney a ?crit :

Hi All :slight_smile:

Just wondering if my code is wonky or if when running in OpenGL mode,

SDL_SetVideoMode(scr_width, scr_height, 0, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|
SDL_HWPALETTE);

Two things :

  • there is no palette in OpenGL mode
  • to use OpenGL double buffering you should use SDL_GL_SetAttribute(
    SDL_GL_DOUBLEBUFFER, 1 );

I no longer have access to things like SDL_MapRGB…?

SDL_MapRGB is not available with OpenGL. In fact, all OpenGL functions
dealing with pixel formats allow multiple input formats, so you’ll
probably find one that suits your needs.

Stephane

Two things :

  • there is no palette in OpenGL mode
  • to use OpenGL double buffering you should use SDL_GL_SetAttribute(
    SDL_GL_DOUBLEBUFFER, 1 );

Righto… :slight_smile:

I no longer have access to things like SDL_MapRGB…?

SDL_MapRGB is not available with OpenGL. In fact, all OpenGL functions
dealing with pixel formats allow multiple input formats, so you’ll
probably find one that suits your needs.

Aw, man… So I’ll have to reimplement all my widget drawing routines in
OpenGL instead…? :frowning: I really didn’t fancy messing around with view port
sizes and stuff like that… Grrrrrrrrr oh well :(On Tuesday 12 Jul 2005 22:54, Stephane Marchesin wrote:

I no longer have access to things like SDL_MapRGB…?

SDL_MapRGB is not available with OpenGL. In fact, all OpenGL functions
dealing with pixel formats allow multiple input formats, so you’ll
probably find one that suits your needs.

AFAIK, the normal SDL routines are still available, but you cannot
call anything that draws directly to the screen.
you can still load bitmaps as SDL_Surfacess, then use that
gl_texture_making_function
with the correct pixel format( as is described somewhere in the
SDL_Surface struct )
and with the pixels pointer being surface->pixels.

using glBegin( GL_QUADS ) and 2d vertex positions, you might
( depending on what exactly you are up to ) be able to
" reimplement all my widget drawing routines "
with only minor modifications

" I really didn’t fancy messing around with view port sizes"

don’t you only have to do that once?
that was the least of my problems when i used opengl

Nah… if you want to render to a texture you have a adjust the port size,
bind a texture and then render to it… I’ve made some progress with it, but
now everything is upside down(!!) Hmmm… anyway, this is moving off topic so
I’ll keep working on it…

Cheers, guys :)On Wednesday 13 Jul 2005 20:51, Brian Barrett wrote:

" I really didn’t fancy messing around with view port sizes"

don’t you only have to do that once?
that was the least of my problems when i used opengl

OpenGL coordinates and SDL coordinates are different. SDL is upper left
(0,0) where OGL is lower left (0,0); Reverse the y portion to correct
the upside down behaviour.

HTH,
Richard

Stephen Sweeney wrote:>On Wednesday 13 Jul 2005 20:51, Brian Barrett wrote:

" I really didn’t fancy messing around with view port sizes"

don’t you only have to do that once?
that was the least of my problems when i used opengl

Nah… if you want to render to a texture you have a adjust the port size,
bind a texture and then render to it… I’ve made some progress with it, but
now everything is upside down(!!) Hmmm… anyway, this is moving off topic so
I’ll keep working on it…

Cheers, guys :slight_smile:


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