Hemu:
Actually i wanted to ask
Is there any function in SDL using which i can create SDL_Surface from
backbuffer?
Donny Viszneki:
You’ll want to use SDL_CreateRGBSurface and then blit screen to the new
surface.
Hemu:
For time being i am doing pixel manipulation in backbuffer and at the
time of
flipping the surface, I set the pixel data from backbuffer to
SDL_Surface.
Donny Viszneki:
What does “I set the pixel data from backbuffer to SDL_Surface” mean
exactly?
Hemu:
I am copying pixel data from BackBuffer class to SDL_surface.
Hemu:
It works fine except the images are not displayed in there original
color.
I tried to set RGB mask, loss and shift values but no luck.
I need help in understanding the usage and importance of these values
and how
they affect the image.
Donny Viszneki:
This actually has given me a great idea for you! It should be possible
to use SDL_DisplayFormat! Here is its description from the man page:
This function takes a surface and copies it to a new surface
of the pixel format and colors of the video framebuffer, suitable
for fast blitting onto the display surface.
SDL_DisplayFormat returns a pointer to a newly created surface, so you
won’t have to call CreateRGBSurface (although it probably uses this
internally, but that doesn’t really matter now does it?)
I would also like to ask why you think you must create a copy of the
back buffer to do pixel operations on it. Do you realize that at any
given time in a double buffered SDL application, screen->pixels points
to the back buffer?
Hope you find this useful.
Hemu:
I already written lot of code for drawing line,circle, rectangle etc.
I don’t want to do it again for SDL. So what i am trying to do is, use the
existing code and while blitting, set the data from my backbuffer functionality
to SDL_Surface and let SDL handle displaying.
I got the solution. After a bit debugging, i found that the true color format
i was using was different from that of used by SDL.
So now what i am doing is, I am setting a true color format used by SDL in my
backbuffer class just after creating a object of backbuffer.
Yes, information you given is really very helpfull.
Thanks a lot for replying to my post.
Hemu