I've been programming some RPG mechanics in C++, relying on the cmd box and therefore being limited to creating roguelike or text adventure games. I'm starting to get the hang of things pretty well, and while even though I'm probably not completely ready for the leap into 'graphical' programming, I'd like to know how I would go about doing it?
I bought "The Red Book", which is an OpenGL book but it mainly focuses on 3D development which I won't touch yet. What I want to know is:
1) How to create a basic window
2) How to draw sprites / hit detection etc.
3) How to differentiate between foreground and background
4) How to implement 'screens' (main menu, map screen, level etc)
5) How to display text, (do you draw from a font.ttf file?)
Note: I'm not asking for answers to the above questions, I'm simply asking what kind of book / guide on the internet I'm looking for in order to start learning these things myself.
Thanks for any replies, you guys are always helpful.
Well there are many libraries out. SFML, OpenGL (Which I recommend), DirectX (Not portable, but good on windows). A guy on YouTube who goes by the name of TheNewBoston, has some excellent tutorials too.
Precious tutorial for the basic concepts of 3D programming on OpenGL. It doesen't comprise shaders 2.0 but I strognly recomendate: http://nehe.gamedev.net/
In both tutorials there is everything from the begining. From setting up OpenGL SDK to your IDE to basic technics.
Disclaimer: OpenGL is multiplatform. You can create 3D programs even on mobile phones with it. DirectX is powerful as well, a little bit more than OpenGL but it works only on windows platforms.
@ResidentBiscuit: I actually watched a few of his videos, they're pretty I great. I've picked up a couple of neat tips from those.
@billythekid I think I'll give that second tutorial a shot, it looks like it covers a lot of basic ground.
Before I'm done, I'll squeeze a couple more answers out of you guys if that's okay.
1) What does 'shaders' mean in relation to OpenGL?
2) I'm wanting to focus solely on 2D programming for now, are these tutorials fine for that or do I need to follow a certain subsection of the library?
Again, thanks for pointing me in the right direction guys.
FWIW, SFML uses OpenGL at its core. If you want to use OpenGL for graphics, I still recommend using SFML because you can use straight OpenGL with it anyway, plus it also makes other things much easier, like window creation/management, texture loading, audio, and input.
:O I might have to actually check out SFML myself. The biggest hurdle for me in getting into graphics, is the whole windows creation. It seems to be this outrageously complicated thing in all libraries. And I'm used to Java for anything GUI related, and making a window (frame in Java), is easier than anything.
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Caption of Window");
// main loop
while (window.IsOpened())
{
sf::Event event;
while (window.PollEvent(event))
{
switch(event.Type)
{
case sf::Event::Closed:
window.Close();
break;
// Handle other events you care about (if any) here
}
}
window.Clear();
// Draw your stuff to the window here
window.Display();
}
return 0;
}
This is about as easy as it can get in C++ and still be reasonably functional.
I'd like to mention that using SFML isn't the same thing as not using OpenGL - as far as I know, SFML allows you to directly use OpenGL in a rather straight forward way. I am not sure how compatible SFML is with modern OpenGL though, which is why I'm still hesistating to use it (I honestly have no wish to go back to glBegin / glEnd or other nonsense like that).
Just pushing this up again: Did some investigation, and apparently SFML works fine with OpenGL 3.x and 4.x (didn't actually try 4.x though, my GPU doesn't support it), however requires the compatibility flag atm. I was told this would change "soon", as in when they are done revamping the graphics package.