You are not logged in.

#1 2015-02-16 19:34:35

pappix
Member
Registered: 2013-06-10
Posts: 24

Getting started using c++ and Opengl

Hi all,
I hope this is the right section to post this question. I am trying to getting started in developing little games in C++ usign Opengl. I have tryed to look for some documentation and understand how to set up my dev environment. I am a little bit confused on wich version of OpenGl to install and whether or not I need to support it installing particular drivers.
This are the information on my VGA controller obtained typing "lspci -v"

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller])
        Subsystem: Dell Device 0571
        Flags: bus master, fast devsel, latency 0, IRQ 35
        Memory at f2400000 (64-bit, non-prefetchable) [size=4M]
        Memory at e0000000 (64-bit, prefetchable) [size=256M]
        I/O ports at 5000 [size=64]
        Expansion ROM at <unassigned> [disabled]
        Capabilities: <access denied>
        Kernel driver in use: i915
        Kernel modules: i915


01:00.0 VGA compatible controller: NVIDIA Corporation GF116M [GeForce GT 555M/635M] (rev a1) (prog-if 00 [VGA controller])
        Subsystem: Dell GeForce GT 555M
        Flags: bus master, fast devsel, latency 0, IRQ 39
        Memory at f0000000 (32-bit, non-prefetchable) [size=32M]
        Memory at c0000000 (64-bit, prefetchable) [size=256M]
        Memory at d0000000 (64-bit, prefetchable) [size=64M]
        I/O ports at 4000 [size=128]
        Expansion ROM at f2000000 [disabled] [size=512K]
        Capabilities: <access denied>
        Kernel driver in use: nouveau
        Kernel modules: nouveau

Any help is much appreciated!

Offline

#2 2015-02-17 09:02:35

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: Getting started using c++ and Opengl

Not sure I understand what you're trying to do/install and why based on your post. But since it sounds like you're trying to jump right into the middle of it and I "got started using c++ and opengl" without having any clue of anything a week or so ago, here's some random stuff that would have saved me a lot of time:

- I don't think nouveau is so great for opengl - you're probably better of using the proprietary nvidia driver (which isn't great for development, but still, better / necessary). You seem to be on a laptop? Then you might need one of those bumblebee / optimus things which makes the situation a lot worse. I never had to use those things, but based on various random posts I came across while I was breaking & fixing my own opengl stuff, everything seems to be even more confusing & glitchy/breaky for the people who have to use it on TOP of the whole rest. You might waste a lot of time looking for errors in your code when there are none and it's really just that optimus/bumblebee thing messing stuff up. Which is TERRIBLE if you're just getting started, so you probably should think about using a different machine with a "real / normal" graphics card for this until you have seen "how opengl is supposed to behave" without this additional source of messy breakage.
- New to c++ and confused with including / linking etc? If so: Try cmake (google "findpackage.cmake" for whatever you need, look at some cmakelist.txt's for programs similar to what you want to write) - that might get you started a lot faster while you're still not sure what you need/want and enables you to learn the boring stuff piece by piece when you really need it (as opposed to all in one giant boring heap before you can even try anything fun).
- Kdevelop (or any IDE that has some support for cmake + GOOD syntax completion) also helps a LOT in the beginning.
- For a start, you just need a modern opengl context. The rest  (glew, glut, opengl, etc) will probably somehow fall into place once you made your choice there and just start with that. SFML is probably the most comfortable to offer an opengl context for a beginner (SDL can be a bit stubborn if you're as clueless as I was. I also tried several others and they all seemed rather "brittle", leading to confusing results if you try to use them while not having much of a clue yet).
- If you already know some C++/opengl, "those pesky :: 's" don't confuse you as much as they did me when I took a first look, and you don't necessarily want to try doing everything very lowlvl (write your own shader class etc) at first until you understand stuff, you can also try to use qt5's opengl context from the start (I'm switching to it now that I need a GUI in addition to raw opengl).
- After you manage to draw some obsolete opengl stuff (glbegin() tutorials are everywhere) to confirm that you managed to create your gl context, it probably makes sense to forget about "glbegin" again right away and focus on ShaderProgram/VAO/VBO. It might make sense to to create + render a VAO manually first to get a better understanding of what they are/do... but on the other hand, you can also safe a lot of time if you use premade ShaderProgram/VAO/VBO classes (I think qt5 has all of those) instead right away.
- At the point you manage to get a VAO rendered in your context, you probably won't rely on finding information specific to your framework (p.E.: linux/qt/nvidia stuff/sfml) so heavily any more and can look for general opengl / VAO / VBO / Open Shader Language stuff - which is all over the place and easy to find.
- Limiting your googling to THE LAST YEAR when you look for opengl/c++ stuff might get you a lot less confusing / obsolete results.

Good luck!

Last edited by whoops (2015-02-17 09:07:16)

Offline

#3 2015-02-17 18:47:03

pappix
Member
Registered: 2013-06-10
Posts: 24

Re: Getting started using c++ and Opengl

Hi woops, thanks for the reply.
I am quite proficient in C++ (used at school/university + 3 years working on platforms for great companies ); however even if at work I use C++ for almost anything, I never really used it for graphics.
I am really looking for a way to get started, I mean: what kind of dev packages to install on my machine. It would be useful of course to understand also what libraries need to be linked to my code,
I plan to start with simple make files to understand how it works, and than I plan to write some python to make the whole thing work with "scons" which is what I am currently using for my personal projects.
Another big question mark is if it is worth to start by using a framework like "SDL", I know is great for portability, and I wonder if it might be able to deal for me with the VGA drivers issue you mentioned before. The only concern about "SDL" is that I am not sure is a good way to start for someone (me) that doesn't know anything about OpenGl.
I will keep digging on the web, and if someone in the meanwhile can point me to some resource to help my research I will appreciate that.
Thanks again for the nice reply!

Offline

#4 2015-02-17 20:15:57

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: Getting started using c++ and Opengl

Dev packages should already be installed or get installed with GLFW/SFML/SDL.

For all of those, you probably need glew and freeglut and a gl implementation (that comes with the graphics driver; in your case probably nvidia-libgl). All of those are in the repos / in packages with exactly those names (or something close). You could do it with glew and X11 only, but that's not really worth the trouble as far as I can tell - the amount of work / learning that SFML & CO (partly glew/glut already, too) keep away from you seems mostly to be a hopeless mess of irrelevant / version / OS / display server / driver dependant stuff half of which might be obsolete by the time you sorted it all out.

SFML is still probably a good choice - it only has semi-highlvl support for some 2d stuff which is good for initial testing, but if you need anything real or 3d then you can / have to implement that on a low level. GLFW seemed even a bit lighter. But even with qt you need to do most of the lowlvl stuff yourself (it helps a bit with shader programs, but when it comes to the rest, it mostly gets in the way, as far as I can tell by now). All of the above are VERY far away from full fledged rendering engines like ogre / irrlicht & co (also in the repo, in case you decide you'd rather have some "easier" eye-candy at some point during a particularity nasty battle with the GPU's compiler).

In the end, it doesn't really seem to matter much where you start, as long as you get that opengl context, where you can do your "glBindBuffer stuff". It all leads into sort of the same direction and having to learn OpenGL is practically impossible to miss on the way.

This is where I got my opengl context:
http://www.sfml-dev.org/tutorials/2.0/window-opengl.php
If you want to use python, this might do:
http://pyopengl.sourceforge.net/context … der_1.html
But SDL should work just as well. Once you have yours (no matter from where), you can jump to framework-independent stuff like:
http://en.wikipedia.org/wiki/Vertex_Buffer_Object
http://en.wikipedia.org/wiki/OpenGL_Shading_Language
( There are some surprisingly good and up to date code examples with explanations spread all over wikipedia - I almost couldn't believe it )

Last edited by whoops (2015-02-17 20:18:27)

Offline

#5 2015-02-17 20:28:22

pappix
Member
Registered: 2013-06-10
Posts: 24

Re: Getting started using c++ and Opengl

Great Woops, you have been really helpfull, I will start getting my hands dirty by setting up the opengl context!
Thanks!

Offline

Board footer

Powered by FluxBB