Basic OpenGL Question.

What do I put in the Paramaters for the function glUseProgram? My friend directed e toward a tutorial online for learning OpenGL, but this error always occurs, and it does not explain what to put within the paramaters.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdlib.h>
#ifdef __APPLE__
#  include <GLUT/glut.h>
#else
#  include <GL/glut.h>
#endif

int main(){
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);

glUseProgram(theProgram);

glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

glDrawArrays(GL_TRIANGLES, 0, 3);

glDisableVertexAttribArray(0);
glUseProgram(0);

glutSwapBuffers();
}
You have to compile one or more shaders (typically 2 shaders: one vertex and one fragment). Then link the shaders together to form a program.

The GL id number of that linked program is what you pass to glUseProgram.

It's all covered in the tutorial you're referring to. Specifically, here:

http://www.arcsynthesis.org/gltut/Basics/Tut01%20Making%20Shaders.html



Note that you probably should not be copy/pasting code from those samples, but instead should be looking at, compiling, and running the tutorial source code directly. The process for doing that is outlined here:

http://www.arcsynthesis.org/gltut/Building%20the%20Tutorials.html

And the download link for the source to all the tutorial programs is linked to on that page. It can be found here:

https://bitbucket.org/alfonse/gltut/downloads
I did it to test to see if it worked properly, I planned on deleting it afterwards and typing and studying it word for word after. Also thank-you.
Topic archived. No new replies allowed.