View Full Version : Opengl coding

Marc Colomé
07-09-2013, 12:57 PM
When I run a code it has a place where you can render polygons in it.

You can render them using opengl standards or it is different due the windowing aplication (glut, glfw, freeglut.. i use glfw) that i use?

Also can I code programs with glfw in c++

carsten neumann
07-09-2013, 01:46 PM
I'm afraid I don't quite understand what you are asking for, but I think you should read one of the tutorials linked from the wiki (http://www.opengl.org/wiki/Getting_Started#Tutorials_and_How_To_Guides).

OpenGL does not care what windowing toolkit you use, you only need to be able to create an OpenGL context. How the context is created depends on your OS and/or (for a cross platform toolkit) the toolkit.
The default language bindings for OpenGL are for C and those are (as is the case with most C bindings) perfectly fine to use from C++, no additional libraries are needed. Bindings for many other languages exist as well.

Marc Colomé
07-10-2013, 07:24 AM
I just mean that because ALL THE TUTORIALS ARE OUTDATED, they teach you with all versions of GLFW, with GLUT... I just wanted to know if apart of the windows context (that is specific, glfw, glut, freeglut), the rest is OPENGL standard.

Because I want to use GLFW but due that there's no actual GLFW tutorial, I'm lost.

07-10-2013, 09:40 AM
I just wanted to know if apart of the windows context (that is specific, glfw, glut, freeglut), the rest is OPENGL standard.

If you look at a tutorial which uses any of those toolkits, all of the functions which begin with "gl" or "glu" followed by an upper-case letter are part of OpenGL, not the toolkit. Those functions are available and work the same way regardless of the toolkit used. Functions beginning with "glut" or "glfw" are part of the toolkit.

Marc Colomé
07-10-2013, 10:35 AM
Thank you

Do you know any complete working tutorial on the internet? Xoax ones work perfectly but they are very very basic.

what do you think of: http://ogldev.atspace.co.uk/www/tutorial22/tutorial22.html



Marc Colomé
07-10-2013, 10:41 AM
Also which version of GLEW is the one that only requires linking libraries and including headers, the source or the binaries? And If I have a 64bit pc can a 32bit binarie work?

Programming in OpenGl is in C or in C++? If I want to program in C++ what I need to do?

carsten neumann
07-10-2013, 12:39 PM
In order to do OpenGL programming in C++ you need to have some understanding of how (general) programming in C++ works, including how one uses external libraries. I'm not trying to be clever here, graphics programming is a huge topic and without a decent understanding of these basics everything becomes just more confusing.
I'd really recommend working through one of the tutorials linked from the wiki, even if it uses glut (or some other toolkit that is not glfw), because once you've grasped how to do stuff with glut transitioning to glfw is not a huge step (well, your code changes, but the important concepts remain the same). There are tutorials that use C++ and show you the necessary steps (which are basically the same as for C, so using a C based tutorial should also work).

You need a binary version of GLEW so that you can link your application against it. PCs with x86_64 CPUs (64bit) can run 32bit applications. You need to make sure your compiler produces 32bit code if you want to link your application against a 32bit library.

Marc Colomé
07-10-2013, 01:24 PM
Thanks, the tutorial I mentioned uses old OpenGL (GL_TRIANGLES for example): http://ogldev.atspace.co.uk/

Whats wrong if I learn that way?

I can't find any tut more complete than that.


carsten neumann
07-10-2013, 01:45 PM
Uhm, GL_TRIANGLES is part of OpenGL 4.3 core profile, there is nothing old about it (in fact I would guess it is the most commonly used primitive type). The tutorial you linked to also uses buffer objects to store the data for rendering and uses shaders from part 4 forward, so seems to use the current techniques. The wiki page I linked to earlier distinguishes between pre/post OpenGL 3.0 tutorials and I would assume that the post OpenGL 3.0 tutorials all use core profile techniques (and therefore are more or less "modern OpenGL") or at least make it clear when they resort to compatibility profile stuff.

Marc Colomé
07-12-2013, 11:31 AM
I didn't know it! I saw a article saying that they were jurassic coding (literally, it said that). do you think ogldev is a hard/dark tutorial? I understand medium to high c++ but this tutorials are hard to understand (the code and the text).


carsten neumann
07-12-2013, 12:41 PM
Hmm, perhaps the the article was talking about code like this:

glVertex3f(positions[0].x, positions[0].y, positions[0].z);
glVertex3f(positions[1].x, positions[1].y, positions[1].z);
glVertex3f(positions[2].x, positions[2].y, positions[2].z);

A style of specifying vertex data (often called immediate mode) that is not available in the core profile any more. I'm not familiar with that tutorial (or any of them really - I just took a quick glance at it to decide if it uses current techniques or not), so can not really say anything about it's difficulty level or even quality. If you find it hard to follow try one of the others and see if that fits your style of learning better.

Marc Colomé
07-12-2013, 12:54 PM
The problem is that the otheres are no that complete. Thsi tutorial has everything i have to know.

Anyway thank you!