Hi!
SDL is fantastic: I’ve ported my SVGALIB emulator to SDL in just
2 hours (I’m developing an GPL spectrum emulator), but I have
some questions…
I want a function to be executed 50 times per second (it is the
function that updates the keyboard array and screen for my
emulator) and I don’t know how to do this under SDL… ?Must I
use a separate thread with a wait like SDL_Delay into it?
Another question is the “putpixel” example given on the SDL docs.
It is supposed to accept an Uint32 colour, but you must decide
before calling it the format of that colour, so you need extra
code. I’ve done the following, but I don’t know if will work on
all platforms (I think BGR cards will show wrong colours):
learScreen( char color )
{
int y, x;
Uint32 color32;
if ( SDL_MUSTLOCK(video) )
{ if ( SDL_LockSurface(video) < 0 ) exit(1); }
switch(video->format->BytesPerPixel)
{
case 1: color32 = color;
break;
case 2: color32 = ((colores[color][0]/4)<<12) |
((colores[color][1]/4)<<6) | colores[color][2];
break;
case 3: /* 24 BPP NOT SUPPORTED YET!!! */
break;
case 4: color32=(colores[color][0]<<16)|(colores[color][1]<<8)|
(colores[color][2]);
break;
}
for( y=0; y<200; y++ )
for( x=0; x<320; x++ )
{
PutPixel(video,x, y,color32);
}
if ( SDL_MUSTLOCK(video) )
{ SDL_UnlockSurface(video); }
SDL_UpdateRect(video, 0, 0, 0, 0);
}
The putpixel routine is a #define of the putpixel example given
on your source code… I pass it x, y, and the Uint32 color to write.
This code works fine in my computer (surely an RGB card), but
as I don’t have an BGR card, I can’t test it… but surely it will
display wrong colors, right?
How can I fix it?
PS: Yes, I know the above is a really shit of code but I’m
just testing SDL at this moment. And as I’ve said, it’s fantastic :)–
Windows es multitarea real: puede ejecutar 2 bugs simult?neamente.
-----------------------------------------------------
NoP / Compiler – nop @ todolinux.org |
---|
POWERED BY - Linux RedHat 6.0 - Reg. User #74.821 |
http://www.ctv.es/USERS/sromero |
~-----------------------------------------------------~