So I have recently started to learn C++ and I have got all of the basics down (Arrays, Variables, Constants, Strings, Operators, Expressions, Statements, Loops, and Functions w/ Parameters). Probably some stuff that I haven't learned here and there but I have the general gist of it.
I have programmed the usual stuff any beginner would program, like a text-based calculator and RPG. I wish to try making more of my own projects, but my capabilities are very limited without knowing how to program graphics.
I am only around a fourth of the way through a beginner-advanced level book, so I am wondering if I should start learning OpenGL to aid my programming. Should I finish the book first, or begin to learn OpenGL within the next couple of days?
And if anybody thinks I should use a different graphics language, please feel free to tell me about it. I would appreciate one with intermediate difficulty and very good graphics capabilities.
Modern OpenGL is somewhat tricky if you've never done any graphics programming before. I'd highly recommend you use an intermediate library that wraps around it with a simpler interface before you start.
I often recommend SFML as such a library. It's very easy to learn and use, and you could easily pick it up now if you know enough to make a simple console-based RPG already.
Some alternatives to SFML are SDL (use version 2.x please -- 1.x is horrendously outdated) and Allegro.
Avoid any OpenGL tutorial that tells you to use glMatrixMode, glLoadIdentity, glVertex3f, etc functions as those have been deprecated for some time, so those tutorials are very old.
Yeah, I meant linking up the SFML include and lib files with my compiler (Visual Studio Express 2012). Just wanted to know so I might remember to change my project properties when I start my next project. I know you have to write out #include <headerFile> in every program. Thanks for the help! Having a bit of trouble getting SFML to work properly though. Keep getting error codes whenever I compile. Fix one, another pops up. Happens pretty much every time I try something new.
You get errors when you compile SFML (like the actual lib)? Or you get errors when you compile something that uses SFML?
You should not be getting errors when compiling SFML. It should work as downloaded... you shouldn't have to fix anything.
So I'm assuming you mean the latter... in that you're trying to write a program that uses SFML but you are getting errors. I might be able to help with those errors. Can you post them and the related code?
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
error LNK1120: 2 unresolved externals
The first two statements were in the main.obj file and the last one was just my project's executable. I have no idea why these errors are popping up because I watched a youtube video on how to link SFML libraries and headers and also read the tutorial on the SFML website for Visual Studio. The source code is the test code that SFML used on their tutorial page to check if SFML was properly linked.
Might do that in the future if I get really lazy to where I just want to copy and paste
Well it's not "lazy", it's "sensible". Making programming easier isn't necessarily a sign of laziness.
There's never a time where you'd want to include a header and not link to the library. So why put yourself through 2 steps?
With the number of SFML projects I make (for testing or for whatever else), I save a lot of time not having to dink around with that. Just a simple #include <sfml.h> and I get all of it. One step, nice and easy.
But for now I'll stick with changing the project properties.
That's fine. It's just a tip. Use it (or don't) at your discretion.
I saw that that tutorial was for 3D-games, is there something similar for 2D-games?
Just use that one. If you understand 3D, you understand 2D.
Besides... OpenGL is a 3D graphics library, because all modern graphics hardware is designed around 3D.
2D graphics are the exact same concept... only you give all your triangles the same Z coordinate (to put them on a 2D plane) and you use an Orthogonal projection (which that tutorial discusses).