— Fabien Mairesse <fabien.mairesse at barco.com> wrote:
Hello,
I make a 2D application with SDL and Opengl and I
thought naively that I can
blit an hardware surface to the video surface (flags
= OPENGL, not OPENGLBLIT)
using SDL_BlitSurface and avoiding by this way the
opengl pipeline.
I’ve tried and it has not been working. I also read
on the internet that it
can’t work (but no reason was given).
It can’t work because SDL was not programmed to have
it work using the OPENGL flag… the OPENGLBLIT flag
was provided for this functionality. Seperating the
two allows much better preformance (using 3d
acceleration anyways) if just using OpenGL rendering
functions.
So my question is : why?? Why can’t we write
directly the opengl frame buffer by
SDL_BlitSurface?
The problem is the way SDL has to deal with this…
basicly it breaks down into the fact that using SDL
functions directly in conjunction with OpenGL requires
sending lots of data over the graphics pipeline… and
that this could be implemented a lot faster/less
wastefully by using OpenGL for all of it, if you’re
using OpenGL in the first place.
I also read that OPENGLBLIT should not be used.
Reasons: Due to the preformance hit allready
mentioned, and also that it’s mainly meant for
backwards compatability rather than as a feature of
SDL.
It
seems that configured with
OPENGLBLIT, SDL wraps a call to a slow opengl
routine. What is this routine? I
saw glDrawPixels and glWritePixel? Which one of this
routine is wrapped? (I
don’t see any glWritePixel in the opengl reference).
Err, the “slow opengl routine” (I’m assuming you read
this somewhere?) probably refers to having to take the
OpenGL scene from the graphics card, load it into
system memory, add the SDL blits, then send it all
back to the graphics card.
And finally, OPENGLBLIT is recommended to not be
used but on my QNX machine,
with Mesa, the testgl program is faster with
OPENGLBLIT (19fpp) than with
texture (15fpp).
With Mesa, everything is allready in system memory, so
the major preformance hit to/from texture memory isn’t
being incured.
Instead, you have the larger problem of having to
render everything using the CPU instead of the
dedicated hardware of your graphics card (assuming you
have such a card).
I havn’t looked at testgl, so I don’t know why it’s
faster using OPENGLBLIT. I’m guessing it’ll be faster
using textures if you use 3d acceleration. (Again,
clarification: Mesa is completely software based… no
3d acceleration will occur using Mesa).
Could you explain me that? In my case, OPENGLBLIT is
not so much bad, isn’t it?
I don’t know the details of your case… but, for
reasons allready mentioned, you should stay away from
the SDL_OPENGLBLIT flag. Mesa will get slow real fast,
and you’ll take a major preformance hit using
OPENGLBLIT if you use 3d acceleration.
Thanks in advance.
Fabien
-Mike__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com