Draw a line?

Hi all,

Is there an easy way to draw a line from a point to another point with SDL.
As the LineTo() win32’s function could do ?

Thanx

lawouach at caramail.com

Hi all,

Is there an easy way to draw a line from a point to another point with SDL.
As the LineTo() win32’s function could do ?

SDL doesn't provide any drawing primitives; you have to write your

own. Fortunately, other people have already worked on this. For example,
here’s the SDL Graphics Extension (SGE), which is linked at the SDL
library page:
http://www.etek.chalmers.se/~e8cal1/sge/index.html

Hope this helps...
    -The Mighty Mike Master
    http://tmmm.simplenet.comOn Sat, 11 Mar 2000, Sylvain Hellegouarch wrote:

Hi all,

Is there an easy way to draw a line from a point to another point with SDL.
As the LineTo() win32’s function could do ?

No, but it’s quite easy. I can talk a bit about Bresenham’s algorithm if you
like, or I can direct you to somebody else’s writings.

lawouach at caramail.com

Nicholas

Start looking into using OpenGL. Just set up an Ortho projection and you
can use GL’s line and point calls similarly to how you use to use Win32
calls. If you would like some source code to get you started let me know.

Todd P.

Sylvain Hellegouarch <sylvain.hellegouarch at wanadoo.fr> wrote in message
news:8adfc1$ibu$1 at ftp.lokigames.com

Hi all,

Is there an easy way to draw a line from a point to another point with
SDL.> As the LineTo() win32’s function could do ?

Thanx

lawouach at caramail.com

Start looking into using OpenGL. Just set up an Ortho projection and you
can use GL’s line and point calls similarly to how you use to use Win32
calls. If you would like some source code to get you started let me know.

Aaaie! BAD!

REPEAT AFTER ME: OPENGL IS A 3D API.

DON’T use it for 2D stuff, like lines and polygons. It’s not what it excels
at. You get into convolution, shitty coordinate systems, and trying to force
tiles and sprites into an API designed for textures.

It is a kludge, and a naughty, nasty one at that. Most of the cool things that
you can do in 2D gaming engines can best be accomplished with lots of changing
of blitting surfaces and directly manipulating the target LFB, both of which
you cannot do under OpenGL without hitting VERY unoptimized paths and running
into limitations caused by doing data transfers over the bus.

If you want line code, I will provide it. Anything to stop this abuse
continuing.

Todd P.

Nicholas

vining at pacificcoast.net wrote:

Start looking into using OpenGL. Just set up an Ortho projection and you
can use GL’s line and point calls similarly to how you use to use Win32
calls. If you would like some source code to get you started let me know.

Aaaie! BAD!

REPEAT AFTER ME: OPENGL IS A 3D API.

DON’T use it for 2D stuff, like lines and polygons. It’s not what it excels
at. You get into convolution, shitty coordinate systems, and trying to force
tiles and sprites into an API designed for textures.

It is a kludge, and a naughty, nasty one at that. Most of the cool things that
you can do in 2D gaming engines can best be accomplished with lots of changing
of blitting surfaces and directly manipulating the target LFB, both of which
you cannot do under OpenGL without hitting VERY unoptimized paths and running
into limitations caused by doing data transfers over the bus.

If you want line code, I will provide it. Anything to stop this abuse
continuing.

Hey Nicolas, give it to him straight man. Stop beating about the bush,
that
does no-one any good at all!

(for the humour-impaired :slight_smile:

Simon.

Tank you all !

Sylvain Hellegouarch <sylvain.hellegouarch at wanadoo.fr> a ?crit dans le
message : 8adfc1$ibu$1 at ftp.lokigames.com

Hi all,

Is there an easy way to draw a line from a point to another point with
SDL.> As the LineTo() win32’s function could do ?

Thanx

lawouach at caramail.com

hehe, you’ve got other issues besides using GL Nicholas. The GL pipeline
could care less if you send it a 2D polygon or a 3D polygon… Lines may be
another issue, but unless we have the source who knows… Sylvain is just
trying to get something onto the screen, and using GL is probably the
easiest way to that means. Never once was it mentioned that he wanted 2D
exclusively. I emailed him, he is new to graphics and just wants to get
going, GL is the easiest route for that.

vining at pacificcoast.net wrote:

Start looking into using OpenGL. Just set up an Ortho projection and you
can use GL’s line and point calls similarly to how you use to use Win32
calls. If you would like some source code to get you started let me know.

Aaaie! BAD!

REPEAT AFTER ME: OPENGL IS A 3D API.

Hey Nicolas, give it to him straight man. Stop beating about the bush,
that
does no-one any good at all!

Sorry, but saying OpenGL is a practical 2D solution is like saying DirectPlay
is scaleable network technology. Besides, why incapacitate yourself for a
simple line function?

Lines are easy. Basically you calculate a slope, and draw pixels going down or
across based on whether or not the slope is < 1 or > 1. (so you get a nice
smooth line) Now, you can do some cooler stuff and add a little anti-aliasing,
some drawing modes, …

Cheers,

Nicholas

Sylvain Hellegouarch wrote:

Hi all,

Is there an easy way to draw a line from a point to another point with SDL.
As the LineTo() win32’s function could do ?

I have code to do this. If you’re interested, drop me a private mail.
(I really should get around to cleaning my code up so it’s ready for
public consumption!).–

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman