Jump to content
  • Advertisement
Sign in to follow this  
Bobboau

smooth curves

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was thinking about doing an texture tool and one of the thing's I'd need would be a vector drawer. I was thinking it would be really nice to use OGL for drawing polygons, but that would limit me to straight lines, and that would not be very useful. then I remembered OGL has a bunch of features that people who focus on games usually don't know about because virtually no hardware supports them. so I was wondering if anyone knew of a feature that would enable me to make smoothly curved lines and shapes? something like the vector layers in psp/photoshop. it does not need to be widely supported on hardware or supported at all so long as it can be emulated. I know there is a NURBS feature, but is it a totally smooth curve, or is it just a bunch of subdivided lines?

Share this post


Link to post
Share on other sites
Advertisement
I don't know how OpenGL works under the covers, but all curves end up as very small straight lines anyway.

Share this post


Link to post
Share on other sites
Graphics cards are built to work with trianges, so if you want curves you've just got to use enough triangles to make it smooth. I'm pretty sure the NURBS stuff that you mention is just a "tessellator" - it takes input curves and outputs triangles.

There's really nothing wrong with this... If you convert a curve into lots of lines with 1px length, then a rendering of those lines should be indistinguishable from a 'true' rendering of the curve.

However, I recently read about a way to reproduce vector art from bitmap textures, which might be of interest to you if you're only interested in 2D shapes.

Share this post


Link to post
Share on other sites
well like I said, I don't care if it is supported by any hardware. if the NURBS thingy will tessellate to pixel length lines on it's own then that will do for my purposes, but I just don't want to have to worry about if you blow a texture up big enough will it start showing artifacts.

Share this post


Link to post
Share on other sites
You have glu nurbs and gl evaluators. All of them run in software, so all will be available on pretty much all GL implementations.

Share this post


Link to post
Share on other sites
I use Cairo(www.cairographics.org) for vector graphics and text rendering in opengl, its easy to use and fast enough. If the texture isn't too big you can even update it every frame.


cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create(surface);

... draw commands ...

unsigned char * data = cairo_image_surface_get_data(surface);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);


You can also try Anti-Grain, its faster but harder to use. Both libraries create high quality anti-aliased pictures.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!