Problems with blitting : test case (fwd)

Hello Sam,

As promised in the loki newsgroup, you'll find two sample case of

blitting failing with two offscreen surfaces.

testGL load an image on a surface A, blit it on another surface B, and
then use B to construct an OpenGL texture. Only Red channel is OK.

showimage loads an image in a surface A, blit it on another B, and
blit B, then A, on the screen. A is correct, not B.

Be aware that I’m having some hardware related problems on my PC
actually (caugh sig 11 when compiling). Maybe the cause of the bug. Tell
me if all is OK for you, even if it would be bad news for my hardware :wink:

                                 Franck.

PS : files in tar archive
Makefile
testgl.c
showimage.c
toto.bmp --> the test image, done with gimp, correctly displayed with
xv.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: test_case_sdl.tar.gz
Type: application/octet-stream
Size: 7213 bytes
Desc:
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20000211/c1765e76/attachment.obj

Oh sh**! Really sorry to disturb the newsgroup…

testGL load an image on a surface A, blit it on another surface B, and
then use B to construct an OpenGL texture. Only Red channel is OK.

You were creating the surface with invalid masks:
B=SDL_CreateRGBSurface(SDL_SWSURFACE,64,64,24,
0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
This should be (RGB):
B=SDL_CreateRGBSurface(SDL_SWSURFACE,64,64,24,
0x00FF0000,0x0000FF00,0x000000FF,0);

OpenGL apparently also provides GL_BGR, which would be suitable for
BMP files as they are loaded.

Also, I think OpenGL naturally uses textures with the (0,0) coordinate
at the lower left. You either need to tell GL that the texture is top-down,
or invert your image before you use it as a texture.

See ya,
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Hello ,

Argh ! thank you Sam, I'm a lamer...

                Franck.

Sam Lantinga wrote:>

testGL load an image on a surface A, blit it on another surface B, and
then use B to construct an OpenGL texture. Only Red channel is OK.

You were creating the surface with invalid masks:
B=SDL_CreateRGBSurface(SDL_SWSURFACE,64,64,24,
0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
This should be (RGB):
B=SDL_CreateRGBSurface(SDL_SWSURFACE,64,64,24,
0x00FF0000,0x0000FF00,0x000000FF,0);