Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: IAmAPerson on August 28, 2013, 07:12:02 pm

Title: Graphics in Visual C++ 2012
Post by: IAmAPerson on August 28, 2013, 07:12:02 pm
Hey guys! I've gotten pretty good at C++, and I want to start doing things with graphics. I searched Google for help, but it just returned these old websites that are outdated by about 10 years... Can someone help me? Please do NOT post links to another website, I'd like an explanation please. Also, please include some sample code! I'm hoping to soon be able to make a program to be able to move a ball around the screen. REMEMBER - I am using Visual C++ 2012. Please help me in that language. I know nothing about graphics. All I know about graphics is that it is possible. :banghead:
Title: Re: Graphics in Visual C++ 2012
Post by: Scipi on August 28, 2013, 07:57:06 pm
Graphics using just C++ and OS API's is downright hellish. Personally, I use SFML for all my graphics, audio, networking, and input handling. It's pretty capable, comparable to SDL.

http://www.sfml-dev.org/ (http://www.sfml-dev.org/)

Here's some code to get you started:

http://pastebin.com/UyWeRy4W (http://pastebin.com/UyWeRy4W)

Edit: It may do well to offer a bit of actual explanation of what is going on in the code. Basically, all we are doing is setting up a window, creating a view for that window, as well as a clock for smooth movement and a drawable object.

Then we enter the main loop which reads events, then inputs, then acts on those inputs. Afterwards, we clear the screen, draw everything, then update. that's basically everything going on in your basic graphics program, read, process, output. Or in this case, events, inputs, update, draw.

Edit 2: It should also be noted that Visual C++ 2012, is just C++ compiled using MSVC 2012. It's no different than C++ compiled with, say, GCC, save for little C++0x and no C++14 support and some MSVC features added to it.
Title: Re: Graphics in Visual C++ 2012
Post by: Juju on August 28, 2013, 09:24:54 pm
Depends if you go managed with the .NET framework or not. Personally, I use Visual C# with Windows Forms and it have a nice interface to draw graphics called GDI+, C++ might have the same.
Title: Re: Graphics in Visual C++ 2012
Post by: ruler501 on August 28, 2013, 09:41:47 pm
I would reccomend SDL2 which is a more C/barebones way of graphic programming. There are some good tutorials written for it so I'll just link to those since I don't have the skill to do better.

http://libsdl.org/ download and information

http://lazyfoo.net/tutorials/SDL/index.php tutorial.

Title: Re: Graphics in Visual C++ 2012
Post by: IAmAPerson on August 28, 2013, 10:54:10 pm
Thanks guys!