Problem is that the relation between SDL’s software rendering and h/w accelerated lines is pretty much like that between SDL and OpenGL; they don’t really mix.
In both cases, consider a situation where you’re doing h/w accelerated rendering directly into the display buffer. Meanwhile, SDL and/or the underlying API (or driver) doesn’t provide a way for SDL (ie the CPU) to access the framebuffer directly.
The only ways you could possibly support software rendering through SDL (with the current API, at least) in that situation is
-
blit the contents of the whole frame buffer into the shadow
buffer before doing the software rendering; then blit the
result back into the frame buffer.
-
Add an alpha channel or colorkey to the shadow buffer, and
blit it “on top” of the frame buffer. (This is what
SDL_OPENGLBLIT does.)
Both alternatives would “work”, but they practically eliminates any benefits of using h/w acceleration in the first place.
There are effective ways of mixing software and h/w accelerated rendering, but they don’t really mix with the way most applications use the current SDL API. You have to start thinking about SDL surfaces as OpenGL textures on a “remote” piece of hardware. That is, it may be expensive to write to surfaces, and even more expensive to read from them.
I would say it’s a good idea to design that way anyway in most cases (part because of the h/w acceleration trend, and part because it applies to s/w rendering with SDL’s RLE acceleration), but it doesn’t really work for every SDL application.
//David
.---------------------------------------
| David Olofson
| Programmer
david.olofson at reologica.se
|
Address: |
REOLOGICA Instruments AB |
Scheelev?gen 30 |
223 63 LUND |
Sweden |
--------------------------------------- |
Phone: 046-12 77 60 |
Fax: 046-12 50 57 |
Mobil: |
E-mail: david.olofson at reologica.se
|
WWW: http://www.reologica.se
|
|
`-----> We Make Rheology RealOn 25/06/2002 00:04:05 , barrett at 9hells.org wrote:
I am looking for a way to use native 2D graphic primitives (basically
XDrawLine for X11 and LineTo for W32 GDI) to get hardware acceleration.
I am developing a vector-graphics based RTS game, and that means thousands
of lines per frame. Actually I’m using SGE, but it’s wasting too much
CPU just to draw lines.
Browsing the archive I found that this was discussed two years ago:
http://www.libsdl.org/pipermail/sdl/2000-July/029187.html
[How do I use XDrawLine() on the SDL window in my program?]
Mattias Engdegard proposed (SDL_GetParam()) solution is fine,
but was I really want is a set of 2D drawing routines for SDL.
( like SDL_DrawLine(surface, x0, y0, x1, y1, color); )
Any chance of this to be implemented in SDL?
Or can someone help me to create a separate library for that?