Talk:OpenGL Programming/Modern OpenGL Introduction

"the vec4 takes our x and y coordinates, then 0 for the z coordinate. The last one, 1.0, is for opacity, in this case no transparency."

[x:y:z:w] are homogeneous coordinates, w is not an alpha coordinate

94.189.188.203 (discuss) 08:04, 5 September 2011 (UTC) ivan


 * Duh! Thanks for pinpointing this out :) Beuc (discuss • contribs) 17:59, 5 September 2011 (UTC)


 * No problem :) Thanks for these articles, I'm pondering to use them while teaching my class :) --94.189.188.203 (discuss) 08:45, 8 September 2011 (UTC) ivan

Third global variable?
In the "Pass the triangle vertices to the vertex shader" section, it says "let's create a third global variable". I could only find one previous global variable, for a total of two, and the code compiles and runs with only two global variables. Should there be a third somewhere?Ericgribkoff (discuss • contribs) 23:05, 20 November 2011 (UTC)

Glut and glutMainLoop that never returns
Hi.

When practicing this tutorial I stumbled against Glut's "bad habit" of never returning from glutMainLoop, hence not being able to actually free resources. I learned that freeglut offers a way to escape this behaviour by activating this option:

glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

glutSetOption itself is declared in GL/freeglut_ext.h

Is this worth to mention in the tutorial? I can add the paragraph, if needed

ciao!

Dario

--79.54.88.56 (discuss) 22:32, 4 December 2011 (UTC)

I think this should be mentioned. Is there a solution for 'pure' GLUT? --Maxiantor (discuss • contribs) 14:18, 22 March 2013 (UTC)

Editing code style.
I edited a bit the C examples, using a different code style and probably adding some comments in the first code.

It's probably not all people could understand the use of GLUT either the use of some tricks should be avoided (like declaring a void receiving function without writing a void on it). --The Fantasy Club (discuss • contribs) 09:16, 17 April 2012 (UTC)

The example downloadable in github, are with a cpp extension
But the code seams pure c.

WHy !!!!???

Except that, amazing tutorial.


 * I started with pure C examples, but switched to C++ later so I could use GLM.
 * The tutorials are now more C++-ish :) Beuc (discuss • contribs) 18:40, 18 August 2015 (UTC)

Program does not behave on my Ubuntu
The blue triangle does not show-up on my Glut window, instead I see a slice of screen capture of my current desktop state. Does anybody know why? I'm using Ubuntu 14.04.

Thanks for the tutorial.

Solution/Workaround for ubuntu
You have to add an idle callback

void onIdle { glutPostRedisplay; }

and when you set the glut callback: glutIdleFunc(onIdle);

or simply add an environment variable to ignore the vertical sync.: vblank_mode=0 ./triangle but this have the side effect to remove the 60fps limits.

I think the display manager vertical synchronisation is interfering with glut.

rafirafi.


 * I moved the tutorials to SDL2, let me know if that helps :) Beuc (discuss • contribs) 18:40, 18 August 2015 (UTC)

These tutorials are not very good
They are just like the NeHe tutorials in that they never explain the actual concepts or how the stuff actually works. They just walk you through some sample code with pointless explanations here and there like "this if statement makes sure we only go ahead if the init function returned true".

Can't recommend at all.--79.201.255.6 (discuss) 19:51, 10 January 2015 (UTC)


 * I avoided stuffing all the OpenGL theory in the readers' head even before the coding starts. Instead the first tutorials quickly give you a working playground, so you can start experimenting. The theory comes in later tutorials. Beuc (discuss • contribs) 18:40, 18 August 2015 (UTC)

GLES troubles
I am able to compile the code on a mobile platform (dev board). But it renders in software while es2gears and glmark2-es2 run with hardware acceleration. ldd triangle gives a line: libGL.so.1 => /usr/lib/arm-linux-gnueabihf/mesa/libGL.so.1 (0xb6d1d000) is mesa compiled wrong in my distro? or is this line wrong?

truncation from double to GLfloat
From GLfloat triangle_vertices[] = { 0.0, 0.8,    -0.8, -0.8,     0.8, -0.8,  }; To  GLfloat triangle_vertices[] = { 0.0f, 0.8f, -0.8f, -0.8f, 0.8f, -0.8f, };

I also enjoy these tutorials! Great job very good for reference! Btw if you don't like these tutorials and think they are not teaching the concept. That might be because you are writing the code and not playing with it! break it! add things ! do whatever ! don't mindlessly type it.

Linking fragment and vertex shaders to the same program
Can anyone confirm that linking the fragment and vertex shaders to the same program will actually successfully link (as described in the &ldquo;GLSL program&rdquo; section)? A driver bug was causing code of my own to fail when it should have worked, which resulted in my ending up here. When I saw that both shaders were being linked to the same program in this tutorial, I tried doing so myself hoping that this would fix my issue, but OpenGL just threw an error. (At least on my machine, anyway; I'm using GL_VERSION string "4.4.13283 Core Profile Forward-Compatible Context 14.501.1003.0", ATI Radeon HD 5670.) It would seem logical that OpenGL should throw an error, |the documentation for glLinkProgram states,

"&ldquo;glLinkProgram links the program object specified by program. If any shader objects of type GL_VERTEX_SHADER are attached to program, they will be used to create an executable that will run on the programmable vertex processor. If any shader objects of type GL_GEOMETRY_SHADER are attached to program, they will be used to create an executable that will run on the programmable geometry processor. If any shader objects of type GL_FRAGMENT_SHADER are attached to program, they will be used to create an executable that will run on the programmable fragment processor.&rdquo;"

So it seems entirely illogical to me that both shaders should or could be linked to the same program, but perhaps there's buggy drivers lying around that (perhaps) don't complain when the user tries to do this. I suspect that perhaps when attempting this, certain drivers may just fall back on compatibility profile shaders instead.

&mdash; Velociostrich (discuss • contribs) 03:13, 22 June 2015 (UTC)


 * I'm not sure to understand. A GLSL (2.0) program is composed of a vertex shader and a fragment shader, otherwise that's not a complete program. Beuc (discuss • contribs) 18:40, 18 August 2015 (UTC)