Doublebuffering Access To Front and Backbuffer - SDL Development - Simple Directmedia Layer
Doublebuffering Access To Front and Backbuffer - SDL Development - Simple Directmedia Layer
Hi all,
However, there are cases where I want to write a simple line or other
graphics onto the front buffer directly (to avoid having to flip again). I
set up double buffering (and SDL_HWSURFACE) in the call to SDL_SetVideoMode
(which works), but I can find no way to get a pointer to the frontbuffer
(as SDL_Surface). The SDL_GetVideoSurface() gives me the same pointer as
returned from the SDL_SetVideoMode, which is the backbuffer. Also after
flipping the SDL_GetVideoSurface still returns the same pointer.
I also couldn’t find any relevant info in the last two months of the
mailinglist-archive or the FAQ.
Thanks, Maarten.
M. Egmond wrote:
[…]
I might me missing something, but why not just blit to the back buffer
before flipping?
Regards,–
Ney Andr? de Mello Zunino
M. Egmond wrote:
[…]
I might me missing something, but why not just blit to the back buffer
before flipping?
Regards,
–
Ney Andr? de Mello Zunino
Unless you are always able to run well over 30 fps, the difference between
drawing into the buffer and drawing directly on the screen for things like
text and cursors is very easy to feel, i.e., 33 ms is too much for cursor
movement or keyboard feedback, whereas it is perfectly acceptable for 3D
object rendering.
Combining drawing a sprite, say, into the buffer and drawing the same sprite
directly to the screen at a higher framerate (don’t forget to draw it into
the back buffer first, or it will rip) is a technique I’ve used with success,
and which I consider essential for achieving that smooth, professional feel
for a 3D app, especially an editor.
Run a slow animation, and you will notice that the X cursor already works
this way, though I doubt that’s explicitly part of SDL.
A quick tour of the source suggest SDL doesn’t have an API for this yet.
Technically, it’s not hard, but getting it totally generic and convenient is
hard. My recommendation to the orignal poster: just get the SDL source,
hack it in the way that works for you in your configuration, then post your
hack for discussion.
DanielOn Wednesday 01 January 2003 08:09, Ney Andr? de Mello Zunino wrote:
M. Egmond wrote:
[…]
I might me missing something, but why not just blit to the back buffer
before flipping?
A quick tour of the source suggest SDL doesn’t have an API for this yet.
Technically, it’s not hard, but getting it totally generic and convenient is
hard. My recommendation to the orignal poster: just get the SDL source,
hack it in the way that works for you in your configuration, then post your
hack for discussion.
Thanks for the suggestion. The question about why I didn’t write to the
backbuffer and flip was indeed answered correctly by the other poster: I
don’t want to spend the same time again drawing the complete screen in the
backbuffer. It’s also a bit pragmatic as the current code I have uses
direct frontbuffer writes and it would be a lot of work to get them out.
I’m not sure I’m comfortable enough yet with Linux and X to hack (and
compile) the source code, but I’ll definately have a look as time permits.
Combining drawing a sprite, say, into the buffer and drawing the same sprite
directly to the screen at a higher framerate (don’t forget to draw it into
the back buffer first, or it will rip) is a technique I’ve used with success,
and which I consider essential for achieving that smooth, professional feel
for a 3D app, especially an editor.
Run a slow animation, and you will notice that the X cursor already works
this way, though I doubt that’s explicitly part of SDL.
There are at least three different ways that the X cursor is drawn. Most
of the time (these days) there is hardware cursor support that inserts
the curors pixels into the video output in the video hardware. Sometimes
it is drawn using a real overlay plane. And, a lot of the time it is
drawn using “save unders”. Which means that the pixels under the cursor
are saved and the cursor is drawn directly into the frame buffer. Before
any drawing is done the server puts the pixels back does the drawing,
and then redraws the cursor. It gets more complicated in mulitibuffered
X servers, but I haven’t seen one of those for a long time.
–
±-----------------------------------+