Surface conversion... which format?

Hello, I’ve been using with a lot of success this code
http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
to provide a crossplatform way to load png images onto a gl texture,
on both powerpc and x86 architectures.
Also on ARM (iOS) the code worked fine using sdl1.3 until revision
5288 in which a ‘format’ flag appearead to SDL_PixelFormat structure.

I naively intialized that flag to 0 and it seemed to work fine
(meaning it had the same behavior of sdl1.2) until 5297, where any
value i put didn’t change the end result: a black screen!
I’ve tried setting different values of SDL_PIXELFORMAT_* and tried the
new SDL_AllocFormat()/SDL_FreeFormat() but with no success!

Can anyone help me? All pngs are 32bit RGBA - what’s the correct value
for the format field?
and why i can’t see any source change in revision 5297 that might cause this?
thanks all
Vittorio

SDL_AllocFormat() should work… can you post your code?On Sat, Mar 12, 2011 at 2:36 PM, Vittorio G. <vitto.giova at yahoo.it> wrote:

Hello, I’ve been using with a lot of success this code
http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
to provide a crossplatform way to load png images onto a gl texture,
on both powerpc and x86 architectures.
Also on ARM (iOS) the code worked fine using sdl1.3 until revision
5288 in which a ‘format’ flag appearead to SDL_PixelFormat structure.

I naively intialized that flag to 0 and it seemed to work fine
(meaning it had the same behavior of sdl1.2) until 5297, where any
value i put didn’t change the end result: a black screen!
I’ve tried setting different values of SDL_PIXELFORMAT_* and tried the
new SDL_AllocFormat()/SDL_FreeFormat() but with no success!

Can anyone help me? All pngs are 32bit RGBA - what’s the correct value
for the format field?
and why i can’t see any source change in revision 5297 that might cause
this?
thanks all
Vittorio


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


-Sam Lantinga, Founder and CEO, Galaxy Gameworks

Sure, but i believe there’s something more than surface conversion problems
right now the code is this, working with sdl up to r5296. here is what
i see http://dl.dropbox.com/u/24468/5296-normal.png

function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
const conversionFormat: TSDL_PixelFormat = (
format: 0;
palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
refcount: 0; next: nil;
var convertedSurf: PSDL_Surface;
begin
if ((tmpsurf^.format^.bitsperpixel = 32) and
(tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
(tmpsurf^.format^.bitsperpixel = 24) then
begin
convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat,
SDL_SWSURFACE);
SDL_FreeSurface(tmpsurf);
exit(convertedSurf);
end;

exit(tmpsurf);

end;

if i use the “correct” code (meaning with a proper pixelformat and
sdl_allocformat) with 5296 i see
http://dl.dropbox.com/u/24468/5296-allocRight.png

function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
var conversionFormat: PSDL_PixelFormat;
var convertedSurf: PSDL_Surface;
begin
if ((tmpsurf^.format^.bitsperpixel = 32) and
(tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
(tmpsurf^.format^.bitsperpixel = 24) then
begin
conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_RGBA8888);
convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, 0);
SDL_FreeFormat(conversionFormat);
SDL_FreeSurface(tmpsurf);
exit(convertedSurf);
end;

exit(tmpsurf);

end;

if i skip conversion at all, i get this with 5296:
http://dl.dropbox.com/u/24468/5296-noconversion.png
As you can see there are some small pixels on the top right which
shouldn’t be there! If i move the mouse/finger they change, as if
they’re correctly interpretating the input, so i’m starting to suspect
that the window dimensions get somehow ignored/destroyed.

Reading the revision commit http://hg.libsdl.org/SDL/rev/5297 i see
that a lot of changes involved with the clipping rect for the opengles
renderer; is it possible that somehow this is related? The test
suitcase at 5297 printed

Platform : All tests successful (2)
SDL_RWops : All tests successful (5)
Rect : All tests successful (1)
Assert Failed!
Blitting blending output not the same (using SDL_BLEND_*).
Test Case 'Blit Blending Tests’
Test Suite 'SDL_Surface’
Last SDL error ''
SDL_Surface : Failed 1 out of 4 testcases!

and then crashed. 5296 and latest revision didn’t crash, but still
failed many tests

I’m ready to carry out all further necessary tests.
VittorioOn Wed, Mar 16, 2011 at 4:04 AM, Sam Lantinga wrote:

SDL_AllocFormat() should work… can you post your code?

On Sat, Mar 12, 2011 at 2:36 PM, Vittorio G. <vitto.giova at yahoo.it> wrote:

Hello, I’ve been using with a lot of success this code
http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
to provide a crossplatform way to load png images onto a gl texture,
on both powerpc and x86 architectures.
Also on ARM (iOS) the code worked fine using sdl1.3 until revision
5288 in which a ‘format’ flag appearead to SDL_PixelFormat structure.

I naively intialized that flag to 0 and it seemed to work fine
(meaning it had the same behavior of sdl1.2) until 5297, where any
value i put didn’t change the end result: a black screen!
I’ve tried setting different values of SDL_PIXELFORMAT_* and tried the
new SDL_AllocFormat()/SDL_FreeFormat() but with no success!

Can anyone help me? All pngs are 32bit RGBA - what’s the correct value
for the format field?
and why i can’t see any source change in revision 5297 that might cause
this?
thanks all
Vittorio


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


? ? -Sam Lantinga, Founder and CEO, Galaxy Gameworks


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