strattonbrazil
11-10-2008, 07:52 AM
I have setup the usual code for setting up a GLSL program, but after error checking and not getting errors, glUseProgram doesn't change the program. I'm wondering if the glGetShaderInfoLog and glGetProgramInfoLog don't turn up any errors after being setup, what else can you debug to see why glUseProgram doesn't start the program?
Here's my setup code:
const GLsizei maxLength = 1000;
GLsizei log_length;
GLchar log[maxLength];
// allocate the shaders
GLuint v = glCreateShader(GL_VERTEX_SHADER);
GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
GLint length[1];
const GLchar* source[1];
// create vertex shader
source[0] = v_source;
length[0] = strlen(source[0]);
glShaderSource(v, 1, source, length);
glCompileShader(v);
// check vertex compilation
glGetShaderInfoLog(v, maxLength, &log_length, log);
std::cout << log;
// create fragment shader
source[0] = f_source;
length[0] = strlen(source[0]);
glShaderSource(f, 1, source, length);
glCompileShader(f);
// check fragment compilation
glGetShaderInfoLog(f, maxLength, &log_length, log);
std::cout << log;
program = glCreateProgram();
glAttachShader(program, v);
glAttachShader(program, f);
glLinkProgram(program);
glGetProgramInfoLog(program, maxLength, &log_length, log);
std::cout << log;
glValidateProgram(program);
glGetProgramInfoLog(program, maxLength, &log_length, log);
std::cout << log;
cout << "Created program" << endl;
Here's my setup code:
const GLsizei maxLength = 1000;
GLsizei log_length;
GLchar log[maxLength];
// allocate the shaders
GLuint v = glCreateShader(GL_VERTEX_SHADER);
GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
GLint length[1];
const GLchar* source[1];
// create vertex shader
source[0] = v_source;
length[0] = strlen(source[0]);
glShaderSource(v, 1, source, length);
glCompileShader(v);
// check vertex compilation
glGetShaderInfoLog(v, maxLength, &log_length, log);
std::cout << log;
// create fragment shader
source[0] = f_source;
length[0] = strlen(source[0]);
glShaderSource(f, 1, source, length);
glCompileShader(f);
// check fragment compilation
glGetShaderInfoLog(f, maxLength, &log_length, log);
std::cout << log;
program = glCreateProgram();
glAttachShader(program, v);
glAttachShader(program, f);
glLinkProgram(program);
glGetProgramInfoLog(program, maxLength, &log_length, log);
std::cout << log;
glValidateProgram(program);
glGetProgramInfoLog(program, maxLength, &log_length, log);
std::cout << log;
cout << "Created program" << endl;