Holmes
2006.09.04, 10:32 PM
I'm having some problems with GLSL (getting it working for the first time). Here is some code of mine:
int installShader(char *vertex, char *fragment) {
GLhandleARB vertex_handle, fragment_handle, program_handle; // handles to objects
GLint vertCompiled, fragCompiled; // status values
GLint linked;
const char *c_vert = (const char *)vertex;
const char *c_frag = (const char *)fragment;
vertex_handle = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
fragment_handle = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
program_handle = glCreateProgramObjectARB();
// pass the shaders the souce
glShaderSourceARB(vertex_handle, 1, &c_vert, NULL);
glShaderSourceARB(fragment_handle, 1, &c_frag, NULL);
The program crashes at the line "vertex_handle = glCreateShaderObjectARB ..." I cannot, for the life of me, figure out why. The debugger gives me this:
#0 0x90004910 in szone_malloc
#1 0x90003520 in malloc
#2 0x97bfb294 in operator new
#3 0x97bfbb40 in operator new[]
#4 0x97b84374 in TPoolAllocator::allocate
#5 0x97b84bcc in initializeSymbolTable
#6 0x97b84b1c in generateBuiltInSymbolTable
#7 0x97b848f8 in ShInitialize
#8 0x005c9f34 in glCreateShaderObjectARB_Exec
#9 0x0000ee8c in installShader at ShaderManager.cpp:67
#10 0x0000c900 in Game_Init at game.cpp:58
#11 0x0000b5b4 in initGL at main.cpp:87
Additional, the run log tells me this:
Argonaut2(4843,0xa000ed98) malloc: *** error for object 0x1895a00: incorrect checksum for freed object - object was probably modified after being freed, break at szone_error to debug
Argonaut2(4843,0xa000ed98) malloc: *** set a breakpoint in szone_error to debug"
I have made sure that it is not because of the most typical error I make, which is calling OpenGL functions before the context is set up. Other OpenGL calls are made before glCreateShaderObjectARB and they execute fine, and if I don't load the shader the game loads up and displays some animated ships flying around.
Any ideas?
int installShader(char *vertex, char *fragment) {
GLhandleARB vertex_handle, fragment_handle, program_handle; // handles to objects
GLint vertCompiled, fragCompiled; // status values
GLint linked;
const char *c_vert = (const char *)vertex;
const char *c_frag = (const char *)fragment;
vertex_handle = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
fragment_handle = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
program_handle = glCreateProgramObjectARB();
// pass the shaders the souce
glShaderSourceARB(vertex_handle, 1, &c_vert, NULL);
glShaderSourceARB(fragment_handle, 1, &c_frag, NULL);
The program crashes at the line "vertex_handle = glCreateShaderObjectARB ..." I cannot, for the life of me, figure out why. The debugger gives me this:
#0 0x90004910 in szone_malloc
#1 0x90003520 in malloc
#2 0x97bfb294 in operator new
#3 0x97bfbb40 in operator new[]
#4 0x97b84374 in TPoolAllocator::allocate
#5 0x97b84bcc in initializeSymbolTable
#6 0x97b84b1c in generateBuiltInSymbolTable
#7 0x97b848f8 in ShInitialize
#8 0x005c9f34 in glCreateShaderObjectARB_Exec
#9 0x0000ee8c in installShader at ShaderManager.cpp:67
#10 0x0000c900 in Game_Init at game.cpp:58
#11 0x0000b5b4 in initGL at main.cpp:87
Additional, the run log tells me this:
Argonaut2(4843,0xa000ed98) malloc: *** error for object 0x1895a00: incorrect checksum for freed object - object was probably modified after being freed, break at szone_error to debug
Argonaut2(4843,0xa000ed98) malloc: *** set a breakpoint in szone_error to debug"
I have made sure that it is not because of the most typical error I make, which is calling OpenGL functions before the context is set up. Other OpenGL calls are made before glCreateShaderObjectARB and they execute fine, and if I don't load the shader the game loads up and displays some animated ships flying around.
Any ideas?