Hello Again !!!
I have another little problem with graphics (all SDL )
First, three questions:
When you alloc a new suface, does it has all pointers allocated or
you must alloc it? (Ex. new_suface->pixels)
And when it is allocated, it points directly to the video mem or
not… (If the answer is yes, then I can modify the content
directly - framebuffer - with lock or unlock if necesary, correct?)
If the screen has different pixel format SDL does conversion, but
when and how, because now I use the imlib lib so it can
do some of the transformations. Is this correct too?
Can I handle a 24 bit surface with a screen depth of 32 copying a 24
bit pix on the 24 bit surface and waiting that it will show in the 32
bit screen?
(long, long question, sorry)
And then my program…
I breaks with a video memory protecting message when I try to put
the raw pix on the surface…
The init
screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);
// The main surface (others for double and
// triple buffer)
if ( screen == NULL ) {
cout << stderr << "No puedo inicializar el modo grafico: " <<
SDL_GetError(); // Can’t init
return;
}
if ( SDL_MUSTLOCK(screen) )
cout << “Debe ser bloqueada”; // -> This happen
else
cout << “No debe ser bloqueada”;
cout << flush;
and the conflict:
disp=XOpenDisplay(NULL);
/* Immediately afterwards Intitialise Imlib */
ID=Imlib_init(disp);
im=Imlib_load_image(ID,“Graficos/Portada.png”); //the pix
Imlib_render(ID,im,800,600);
//This convert it to 24 bit per pixel, OK?
cout << “\n Graficos/Portada.png abierto con exit y es png” <<
fflush; // Ack message
SDL_LockSurface(Main_status.screen); // Is this correct?
Main_status is a object that has the screen pointer
// of the
initialization
nueva_sur = SDL_AllocSurface
(SDL_SWSURFACE,800,600,24,0xFF0000,0xFF00,0xFF,0); // 24 bit surf
memmove(Main_status.screen->pixels,im->rgb_data,80060024);
// move the data
// With 24 bits on the screen surface happens the same
//SDL_BlitSurface(nueva_sur,NULL,Main_status.screen,NULL);
SDL_Delay(5000);
SDL_UnlockSurface(Main_status.screen);
SDL_FreeSurface(nueva_sur);
cout << "\n OK : " << fflush;
Thats all
Hope someone can help me…