hi`
I attached a patch for current SDL CVS that adds some additional
functionality to the OpenGL blitting part.
Okay, I guess I should explain how to use it The flag to pass to
SDL_SetVideoMode is SDL_OPENGLBLIT. It will automagically create an
OpenGL context so there is no need to specify both SDL_OPENGL and
SDL_OPENGLBLIT. There are only two modes for SDL_OPENGLBLIT that donāt
require conversion on the fly. One is the standard 565 16 bit mode and
the other is a 32 bit RGBA mode. In fact the framebuffer will be a
software surface with the appropiate color masks. Keep in mind that the
āframebufferā will only contain stuff that you draw on it and not any
OpenGL magic you do.
Now you can simply use SDL_UpdateRects to draw stuff on the screen. Keep
in mind that the changes wonāt be visible until you call
SDL_GL_SwapBuffers. SDL_UpdateRects doesnāt destroy the order so when
you do some OpenGL stuff, use SDL_UpdateRects to draw a surface and then
use some OpenGL to draw something else it will be in the āmiddleā.
BTW, the code relies on OpenGL 1.2 for GL_UNSIGNED_SHORT_565. This is no
problem on Linux but I donāt know (and care) about which version of
OpenGL comes with MSVCā¦ā
Daniel Vogel
Programmer
Loki Entertainment Software
-------------- next part --------------
Index: src/video/SDL_sysvideo.h
RCS file: /cvs/SDL/src/video/SDL_sysvideo.h,v
retrieving revision 1.6.2.18
diff -r1.6.2.18 SDL_sysvideo.h
172a173
int is_32bit;
Index: src/video/SDL_video.c
===================================================================
RCS file: /cvs/SDL/src/video/SDL_video.c,v
retrieving revision 1.13.2.41
diff -r1.13.2.41 SDL_video.c
596,607c596,625
< // TODO: free Surface
< SDL_VideoSurface = SDL_CreateRGBSurface(
< flags,
< width,
< height,
< 32,
< 0x000000FF,
< 0x0000FF00,
< 0x00FF0000,
< 0xFF000000
< );
< SDL_VideoSurface->flags = flags;
if ( bpp == 16 ) { video->is_32bit = 0; // TODO: free Surface SDL_VideoSurface = SDL_CreateRGBSurface( flags, width, height, 16, 31 << 11, 63 << 5, 31, 0 ); SDL_VideoSurface->flags = flags; } else { video->is_32bit = 1; // TODO: free Surface SDL_VideoSurface = SDL_CreateRGBSurface( flags, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 ); SDL_VideoSurface->flags = flags; }
658,659c676
<
< /* Set the surface completely opaque, by default */
/* Set the surface completely opaque & white by default */
667c684
< GL_RGBA,
video->is_32bit ? GL_RGBA : GL_RGB,
671,672c688,689
< GL_RGBA,
< GL_UNSIGNED_BYTE,
video->is_32bit ? GL_RGBA : GL_RGB, video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
1063c1080
<
1072,1074c1089,1093
< GL_RGBA,
< GL_UNSIGNED_BYTE,
< this->screen->pixels + 4 * update.x + update.y * this->screen->pitch );
this->is_32bit? GL_RGBA : GL_RGB, this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5, this->screen->pixels + this->screen->format->BytesPerPixel * update.x + update.y * this->screen->pitch );
1082c1101
< this->glTexCoord2f( 0.0, update.h / 256.0 );
this->glTexCoord2f( 0.0, update.h / 256.0 );
1107c1126
< this->glPushAttrib(GL_ALL_ATTRIB_BITS); /* TODO: narrow range of what is saved */
this->glPushAttrib( GL_ALL_ATTRIB_BITS ); /* TODO: narrow range of what is saved */
1116c1135
< this->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
this->glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1122c1141
< this->glPixelStorei( GL_UNPACK_ROW_LENGTH, this->screen->pitch / 4 );
this->glPixelStorei( GL_UNPACK_ROW_LENGTH, this->screen->pitch / this->screen->format->BytesPerPixel );