2D graphics in C++ - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: 2D graphics in C++ (/thread-4321.html)
2D graphics in C++ - jab630 - Apr 24, 2006 10:08 PM
I need to build a very simple 2D graphics library in C++. All it needs to do is respond to the following list of very simple commands:
CIRCLE(String ID, int x, int y, int radius, int R, int G, int B);
RECTANGLE(String ID, int x, int y, int width, int height, int R, int G, int B);
IMAGE(String ID, String filename, int x, int y, int width, int height);
MOVE(String ID, int x, int y);
RESIZE(String ID, int width, int height);
ROTATE(String ID, int degrees);
Basically, the CIRCLE, RECTANGLE, and IMAGE commands create new graphical elements. The other commands (HIDE, SHOW, MOVE, RESIZE, ROTATE) are applied to existing graphical elements. Then after a sequence of the previous commands, UPDATE is called to show the changes.
I will be sending the above commands to my program in real time over a network from a client program. I have already written the code that listens for these commands over the network, all I need to do now is build the graphics library. Basically what I'm looking for is the C++ equivalent of Java's Swing, except even less since I'm only drawing fullscreen and I don't need GUI widgets or anything. Someone told me SDL was a good choice, so I've gotten everything set up in SDL and can already display images and rectangles, but there seems to be no built-in function for circles. Is there a 2D graphics package that does this?
P.S. I posted the above in the "Tools & Technology" forum and everyone there told me to use OpenGL. OpenGL is not an option. The primary concern is that this be quick and easy to set up and simple enough so that the people who will be using it who have little programming experience (and no OpenGL experience) can easily see what's going on in the code. Thanks in advance.
2D graphics in C++ - akb825 - Apr 24, 2006 11:07 PM
Since everybody there told you to use OpenGL, I think everybody here will tell you to use OpenGL as well. That's generally what you use in SDL. Seriously, somebody even posted the code to do what you want in the first place. You can even use SDL to set up the context, and you can even make a function to set it up the way you know it will always be. You're wasting more time trying to find an alternative to OpenGL and saying that it's difficult (it isn't) than it would take to just use it. I'll just shut up and see what everybody else says, but I think the consensus will remain the same.
2D graphics in C++ - Nick - Apr 24, 2006 11:18 PM
Yeah, considering it's all the same forum, you'll probably see the same people here.
Trust me, just learning the basic OpenGL to implement this yourself would be way easier. Heck if you started today, you could be done (assuming you are a decent learner who knows C++) in a matter of days, if even that long.
If the people using it have little programming experience, why will they care if you use SDL or OpenGL or whatever library for the background of the functions? All they'll see is that list you've provided. You can easily wrap all the functions and initialization into easy functions as well.
I'll reference you to NeHe for some tutorials to get you going. It's a pretty easy API to learn if you just try.
2D graphics in C++ - Taxxodium - Apr 25, 2006 02:25 AM
Don't start a new thread that is exactly the same as your previous one!
Original thread: http://www.idevgames.com/forum/showthread.php?t=12010