Help end child hunger

GLSL Tutorial – OpenGL Setup

Prev: Fragment Shader Next: Creating a Shader

This section shows how to load, compile, link, and set the shaders ready for execution. If you’re not ready yet to write your own shaders there are plenty of places to get shaders from the internet, although only a few deal with the latest versions of GLSL. You can also try the examples provided later in this tutorial.

Before we start lets check that at least OpenGL 3.3 is supported. In here, we are going to use GLEW to access this functionality.

#include <GL/glew.h>
#include <GL/glut.h>

void main(int argc, char **argv) {

	glutInit(&argc, argv);

	if (glewIsSupported("GL_VERSION_3_3"))
		printf("Ready for OpenGL 3.3\n");
	else {
		printf("OpenGL 3.3 not supported\n");



As far as OpenGL goes, setting your application is similar to the workflow of writing a C program. Each shader is like a C module, and it must be compiled separately, as in C. The set of compiled shaders, is then linked into a program, exactly as in C.

The figure bellow shows the necessary steps to create  both the individual shaders and the program. In the next subsections these steps are detailed.



Prev: Fragment Shader Next: Creating a Shader

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: