2D drawing primitives

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?

I have tried to do some SDL_GetWMInfo()/XCreateGC()/XDrawLine() stuff,
but nothing appeared on the screen; I’m must be missing some detail…

@barrett_at_9hells.or

I hate to promote a different library, but Allegro is pretty good at 2D
graphics.
It has many 2d graphics primitives, like line, vline(vertical line),
hline(horz line).
SDL is very very good at many things, however allegro seems to be a little
faster at quick 2d drawing.> ----- Original Message -----

From: barrett@9hells.org ()
To:
Sent: Monday, June 24, 2002 8:04 PM
Subject: [SDL] 2D drawing primitives

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?

I have tried to do some SDL_GetWMInfo()/XCreateGC()/XDrawLine() stuff,
but nothing appeared on the screen; I’m must be missing some detail…

barrett at 9hells.org


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

May I suggest that using OpenGL set up for 2D use is the way to go? It
gives you fast, portable, accelerated graphics using a standard based
library.

	Bob Pendleton

Philip D. Bober wrote:> I hate to promote a different library, but Allegro is pretty good at 2D

graphics.
It has many 2d graphics primitives, like line, vline(vertical line),
hline(horz line).
SDL is very very good at many things, however allegro seems to be a little
faster at quick 2d drawing.

----- Original Message -----
From: <barrett at 9hells.org>
To:
Sent: Monday, June 24, 2002 8:04 PM
Subject: [SDL] 2D drawing primitives

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?

I have tried to do some SDL_GetWMInfo()/XCreateGC()/XDrawLine() stuff,
but nothing appeared on the screen; I’m must be missing some detail…

barrett at 9hells.org


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-----------------------------------------+

  • Bob Pendleton, an experienced C/C++/Java +
  • UNIX/Linux programmer, researcher, and +
  • system architect, is seeking full time, +
  • consulting, or contract employment. +
  • Resume: http://www.jump.net/~bobp +
  • Email: @Bob_Pendleton +
    ±-----------------------------------------+

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

  1. 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.

  2. 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?

“A little”? Does this mean Allegro supports whatever h/w accelerated rendering of primitives there might be, or just that it has a carefully optimized s/w rendering library? (SDL has neither in the core lib, so you can’t really compare either way…)

//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 Mon, 24/06/2002 23:29:43 , Philip D. Bober wrote:

I hate to promote a different library, but Allegro is pretty good at 2D
graphics.
It has many 2d graphics primitives, like line, vline(vertical line),
hline(horz line).
SDL is very very good at many things, however allegro seems to be a little
faster at quick 2d drawing.

Carefully optimized software rendering library, I think.On Tue, Jun 25, 2002 at 05:38:25PM +0200, David Olofson wrote:

“A little”? Does this mean Allegro supports whatever h/w accelerated
rendering of primitives there might be, or just that it has a carefully
optimized s/w rendering library? (SDL has neither in the core lib, so you
can’t really compare either way…)


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

I agree. Go all the way in either direction; full software, or full hardware. Mix only if you really have to - and in that case, I would recommend OpenGL (and procedural textures) just the same.

//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 Tue, 25/06/2002 09:43:12 , Bob Pendleton wrote:

May I suggest that using OpenGL set up for 2D use is the way to go? It
gives you fast, portable, accelerated graphics using a standard based
library.

That’s what I thought.

This suggests SDL lacks a really fast s/w rendering library. I could really use one right now; preferably one that does texture mapped polygons as well - and it would be nice if it supported other targets than SDL as well.

However, for some reason, it feels like there are too many of these libraries already. Most of them seem to be unfinished, too slow, and/or lack too many features - but does it really make sense to start hacking Yet Another 2D Rendering Library to address those issues? Something tells me this is almost as futile as trying to replace GTK+, Qt and co with Yet Another Traditional GUI Toolkit.

Either fix what’s there (merging useful code from various places where applicable), or “invent” some radically different, clearly superior design. (Which doesn’t nescessarilly rule out the reuse of existing and working code.)

//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 Tue, 25/06/2002 11:41:55 , Matthew Miller wrote:

On Tue, Jun 25, 2002 at 05:38:25PM +0200, David Olofson wrote:

“A little”? Does this mean Allegro supports whatever h/w accelerated
rendering of primitives there might be, or just that it has a carefully
optimized s/w rendering library? (SDL has neither in the core lib, so you
can’t really compare either way…)

Carefully optimized software rendering library, I think.