PDA

View Full Version : Best way to draw curved lines -dynamic texture or?



Mctittles
04-02-2011, 02:07 PM
Hello. I'm new to c++ and opengl but have experience in quite a few other languages so am trying to jump right in and do something fun.

I'm working only in 2d mode right now and what I'd like to do is write a program that generates random sword images. Currently the algorithm is not what I'm hung up on, but how I should proceed in drawing it.

The problem comes with drawing curves mainly. So if I want to say have it draw random curves on the blade of the sword I'm not sure how to get it to look smooth. As far as I can tell opengl is all polygon based so the only way to achieve a smooth circle is by drawing a lot of points. I'd like to use the generated image as an icon for loot in a game so having a ton of points on it would probably be too much for a simple 2d game.

The other idea I had is to somehow draw the image to memory and apply that as a texture to a quad. This might be what I have to do, however I'd like to be able to apply a texture with opengl to the finished sword shape instead of having to come up with a way to fill in the image myself.

Anyway, what I'm looking for is perhaps someone that can point me in the right direction for what I need to learn to accomplish my goals. Is there a way to draw a 2d sword blade dynamically using opengl or do I need to look at other methods. Or is there a way to apply a texture and perhaps bump mapping to just an area drawn?

Hope this makes sense. Thanks.

Mctittles
04-03-2011, 08:49 AM
After messing around and drawing some curved lines with the opengl API I think I'll be going about it another way. The lines take a lot of points and require anti-aliasing to look good, so it's a little beyond what I think a 2d game should require for resources.

Today I'm going to learn normal c++/windows drawing functions. The plan is to draw the sword I want and apply that as a texture to an opengl 2d rectangle.

I'm still open for advice as it's a wide world of options I'm trying to slim down so I can focus my learning. Right now I'm looking into drawing in windows but even that has a large variety of ways to do it. I'd rather not waste time learning techniques that end up not working so if anyone has some advice in the best direction for drawing in c++ for opengl textures; much appreciated :).