I initialize video mode with SDL_OPENGLBLIT and OpenGL
doublebuffer. Then I load surface by IMG_Load and call
SDL_BlitSurface and SDL_GL_SwapBuffers:
MySurface = IMG_Load (“My.jpg”);
^^^^^^^^^
Did you check the return?
SDL_BlitSurface (MySurface, 0, screen, &MyRect);
^^^
I would recommend using NULL here, as a picky compiler would treat 0
as an integer and give you an annoying warning about turning integers
into pointers. (Standard C headers usually define NULL to (void *)0.)
SDL_GL_SwapBuffers ();
But surface doesn’t blit… Where is error?
I could keep guessing, but it’d be easier if you posted a slightly
more complete minimal example that demonstrates the problem. There
are so many ways to get even five lines of code wrong…
BTW, I’d also recommend that you try glSDL(/wrapper) or using OpenGL
directly, dependin on what you’re doing. SDL_OPENGLBLIT is a rather
ineffective last resort hack, which pumps all graphics through a
256x256 texture. With glSDL or native OpenGL, you can load the image
into one (or more, if it’s big) textures and then just keep those on
the 3D card (no constant uploading) until you’re done.
The glSDL wrapper can be found here;
http://olofson.net/mixed.html
…and allows you to make your SDL 2D code use OpenGL “properly” by
tweaking two lines of code, adding a .c file to the
makefile/project/whatever and recompiling.
(Uhm, there was a version 0.7 coming… Let’s just say I had some
trouble getting it right, and now I’m hacking work related stuff
around the clock. I’ll try and make some time for my SDL related
projects one of these days.)
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Friday 23 January 2004 15.52, ALakazam (Skidanov Alexander) wrote: