Best way to create image effects (bevel etc)

Hello, I'm new to c++ programming but have read a few books on the subject and am starting to get comfortable with the language.

I have an idea on making a game with a random weapon generator in which weapons like swords are drawn randomly as well and would like some advice on the best way to go about this.

Currently I have started using some windows drawing functions (http://msdn.microsoft.com/en-us/library/dd162760(v=vs.85).aspx) and have been able to generate a sword shape with bezier curves.

I'm not sure if this is the best way to go about this though. I would like to anti-alias the edges, draw a bevel on the edge and texture them. I'm having trouble finding information on this as most game programming tutorials go into directX or openGL methods but not on doing something like random image generating.

I know it's possible because there are a ton of image applications out there that have filters like bevel, shading, etc built into them. Does something like photoshop use the windows drawing api or is there a better way? Know of any resources for adding effects like bevels and textures to a shape?

Thanks for any help in pointing me in the right direction :).
I'm new to C++ also, so don't take this to heart or anything.. but maybe I'm not understanding this correctly. You want to basically have a program where it asks the user for a weapon and then will draw a random weapon for them? As in.. I say sword and I get a sword drawn, then you say sword and a different sword will be drawn for you? Sorry, but I'm going to have to say this is IMPOSSIBLE! A computer can essentially only do what it is programmed to do. The only way to go about this would be to have x amount of swords, x amount of guns, and so on and then randomly draw one of the pre-made weapons.
What you want is procedural image generation, and it's usually done for terrain. I don't think it's impossible, but it's probably way out of your league right now. Get familiar with graphics programming first (DirectX, OpenGL or some library like SFML).

TheNoobie wrote:
Sorry, but I'm going to have to say this is IMPOSSIBLE! A computer can essentially only do what it is programmed to do. The only way to go about this would be to have x amount of swords, x amount of guns, and so on and then randomly draw one of the pre-made weapons.

Just because a computer can only do what it's programmed to do, it doesn't mean everything has to be hard coded. As an extreme example, think of Watson. It's programmed to understand humans, which doesn't mean it has every possible human language expression hard coded.
Well even in Watson's case, everything is programmed just in a much more advanced level. He has voice recognition software and uses that to do searches on the HUGE amount of information stored in his memory then uses computer logic to sort the best possible answers. A computer will never be able to think for itself, even if it is programmed to learn from it's mistakes. Maybe I'm wrong, but in my opinion a "machine" thinking for itself won't be possible until if and when biological lifeforms can be "created" by us.
Last edited on
A computer will never be able to think for itself, even if it is programmed to learn from it's mistakes.


Which is different from hard coding everything.
Wow.

Ok a little background on myself might be in order, as I know this is easily possible. I'm not new to programming, just new to c++. I am 35 years old and have been programming since I was 12. I started on the Apple IIgs and worked my way up from BASIC to dabbling in machine code with an assembler. After a few years break I started work doing web programming on windows. I am currently fluent in ASP, ASP.NET, PHP, mysql, all the usual javascript/css stuff, a little bit of server side JAVA, but my main expertise is in AS3 flash programming. I could actually do this sword generator in flash but I'm not looking for a web based game :). Here is an example of a flash site I made a few years ago (AS2) http://thecardchest.com/ . There is a bit of procedural generation going on there too. The card images are loaded from a database and positioned randomly on the shelf with shadowing and envelopes drawn in behind them. Some are randomly tilted etc.

Anyway ha...

I'm not looking for someone to give me code on how to generate the swords. I'm just looking for a best way to go about drawing, adding bevel/shading effects and texturing the images. As in should I be using the windows drawing functions for game programming or is there another way that is usually better to go?

Right now I have a random blade shape drawn using some bezier curves that generates some random curves, serrated edges, etc. I'd like to take that shape, put a beveled edge, some shading, and texturing with it.

I understand this will take some work to accomplish, but I don't want to spend a week working with one API to find out I've wasted my time and should have been using another method. I'll learn all the tricks of C++ eventually I know, but I'd rather not waste time learning what I don't need for my game just yet.

So again, just looking to be pointed in the right direction on this. The random generator thing is irrelevant really. Think of it as just a random shape that needs effects applies. What should I research to accomplish this goal?
Well, you still need to learn some graphics library if you want to draw graphics. The Windows API is not the appropriate tool for the job. You'll have to look into a graphics library like the ones I mentioned. They support pixel and vertex shading and allow you to texturize 3d surfaces (which can be used for 2d programming as well), among many other things. DirectX and OpenGL are more low level and require a bit of deeper graphics programming knowledge to be used well. SFML is simpler (it's a wrapper for OpenGL IIRC) and higher level. DirectX locks you on Windows so you might want to avoid it if you want portability.
Thanks.
I spent a couple weeks learning openGL only to find it is overkill for the job I am trying to do. I'm keeping it a 2d game and in order to draw decent looking curves with opengl you need to work with a lot of points on the polygon. I don't really want users to need a beefed up graphics card in order to run a 2d game. I'll be using opengl to position the swords as textures on quads once I draw them, but in order to use shading etc in opengl I would need to create the images out of points in 3d or do some type of normal mapping.
If I was going to just apply a sort of bump mapping to the images I am still left with the same problem. Drawing the image information to be used as a texture and bump map in the first place so a 3d graphics api really doesn't apply here.

I'm really just looking for the best way to draw bitmap information. I might also want to cross-platform this so using .NET stuff might be to restricted to windows, although I'd be willing to start with a windows only method and go from there. I'd just rather start doing it the right way first, having wasted a lot of time learning openGL only to find it's really only used to draw polygons.
Last edited on
try Allegro.
OpenGL supports 2d surfaces, I believe it's something like "glVertex2f(...)" but don't quote me on that.

As for dynamically creating weapons this can at least be faked. The video game Borderlands is a perfect way to do this. You take PARTS of the weapons and make collections of them. For example you made a sword; a sword has a GRIP, a BLADE, a HANDGUARD, a CROSSGUARD and a POMMEL. You mix and match any permutation of different sets of these components to get different effects\strengths\weaknesses for the weapon. You want more? Then change the color and give it fire abilities. SFML allows you to draw surfaces on any surfaces, not just the rendering context so the hard part is already done for you.

EDIT @ TheNoobie: I am proud to announce that as of 14 months ago, I have created life. You see when a man and a women love eachother...
Last edited on
Topic archived. No new replies allowed.