Skip to main content
GameDev.net gamedev.net
🔒 Locked

Curves/ lines

Started by marthy Feb 19, 2005 at 6:48 PM 1 replies 750+ views
Original Post
marthy
marthy
Hi! Well, I've read few first lessons and I know how to draw triangles, quads etc. But how to draw curves (or lines)? Is there any special way of doing that? When we want to draw a triangle there we write glBegin(GL_TRIANGLE) and what in case curve?
cwhite
cwhite
OpenGL does not support curved surfaces directly. The process of drawing a curved surface in OpenGL is called tesselation. The curved surface needs to be divided down into triangles that are small enough that the overall surface appears curved.

As for lines, just use glBegin(GL_LINE)
iNsAn1tY
iNsAn1tY
Graphically reproducing curves ranges from very simple to very complex, and has little to do with the graphics API that you use, as cwhite notes above. With OpenGL, you can use certain GLU functions to create curves and curved surfaces. Try Google for more information on that. A major drawback with these functions is that they create geometry "on the fly", so you can never really modify or manage it. If you really want to get into the complex realm of curves, you might want to try Piecewise Cubic Bezier Splines (which aren't too difficlut to implement), or NURBS (Non-Rational Uniform B-Splines) (which require a good understanding of mathematics, but are the industry standard for repesenting curved surfaces). The mathematics behind all curve systems can be very complex, but you don't necessarily need to know exactly how they work to use them, just how to apply the theory behind them. Of course, it's always a good idea to throughly understand how something works before you use it, and it might be worth investing some time in studying the theory of these curve systems before you use them if you're planning on using them regularly.

My apologies for any mistakes/general misinformation in the above post; I have had a bit to drink. There might be a few spelling mistakes, too...

EDIT: You can find a very good tutorial on Piecewise Cubic Bezier Splines at www.gametutorials.com. Follow the OpenGL link, then scroll down to the "Bezier Curve" tutorial.

EDIT2:
Quote:
Original post by cwhite
As for lines, just use glBegin(GL_LINE)

Actually, it's glBegin(GL_LINES). If I was drawing a curve, I'd use glBegin(GL_LINE_STRIP), just to save on function calls to glVertex*.

[Edited by - iNsAn1tY on February 19, 2005 9:25:05 PM]
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.