Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKaptein

Posted 13 November 2012 - 07:39 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, "in_vertex"); glBindAttribLocation(prog, 1, "in_texture"); break; } // link program glLinkProgram(prog); // check for errors! // bind program, and set some common uniforms glUseProgram(prog); // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you
edit: i see now that you do what is needed, in the loader
but, you can try setting null for length in glShaderSource!
see: http://content.gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example

also, shader source is a glchar ptr ptr
so GLchar* p[1]; p[0] = &shaderSource;
glShaderSource (shader, 1, (glchar**) p, null);

#7Kaptein

Posted 13 November 2012 - 02:39 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, "in_vertex"); glBindAttribLocation(prog, 1, "in_texture"); break; } // link program glLinkProgram(prog); // check for errors! // bind program, and set some common uniforms glUseProgram(prog); // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you
edit: i see now that you do what is needed, in the loader
but, you can try setting null for length in glShaderSource!
see: http://content.gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example

#6Kaptein

Posted 13 November 2012 - 02:29 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, StrPtr("in_vertex")) glBindAttribLocation(prog, 1, StrPtr("in_texture")) break; } // link program glLinkProgram(prog) // check for errors! // bind program, and set some common uniforms glUseProgram(prog) // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you
edit: i see now that you do what is needed, in the loader
but, you can try setting null for length in glShaderSource!
see: http://content.gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example

#5Kaptein

Posted 13 November 2012 - 02:29 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, StrPtr("in_vertex")) glBindAttribLocation(prog, 1, StrPtr("in_texture")) break; } // link program glLinkProgram(prog) // check for errors! // bind program, and set some common uniforms glUseProgram(prog) // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you
edit: i see now that you do what is needed, in the loader
but, you can try setting null for length in glShaderSource!
see: http://content.gpwiki.org/index.php/OpenGL:Codes:Simple_GLSL_example

#4Kaptein

Posted 13 November 2012 - 02:26 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, StrPtr("in_vertex")) glBindAttribLocation(prog, 1, StrPtr("in_texture")) break; } // link program glLinkProgram(prog) // check for errors! // bind program, and set some common uniforms glUseProgram(prog) // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you
edit: i see now that you do what is needed, in the loader
except, i think shader length is also a pointer! perhaps thats where its wrong
try: GLint* lengths[1]; lengths[0] = strlen(...);
glShaderSource(ShaderObj, 1, &p[0], &lengths[0]);

#3Kaptein

Posted 13 November 2012 - 02:22 AM

you need to save the Shader object somehow Posted Image otherwise, the program will be lost
you'll need to link the program together

lets say your function returns 0 if it fails, and non-zero if it returns a valid shader object!
then:
[source lang="cpp"]void CreateShader(file_v, file_f){ GLuint vertex = LoadShader(file_v, GL_VERTEX_SHADER_ARB); GLuint frag = LoadShader(file_f, GL_FRAGMENT_SHADER_ARB); GLuint prog = glCreateProgram(); glAttachShader(vertex); glAttachShader(frag); // bind your attrib locations here, either directly or through another function, but here is an example: switch(prog) { case shaders.dummy: glBindAttribLocation(prog, 0, StrPtr("in_vertex")) glBindAttribLocation(prog, 1, StrPtr("in_texture")) break; } // link program glLinkProgram(prog) // check for errors! // bind program, and set some common uniforms glUseProgram(prog) // set uniform locations here that never changes, either directly or through another function, example: GLint location = glGetUniformLocation(prog, "texture"); if (location+1) glUniform1i(location, 0); // remember to check for glGetError through the whole ordeal! // finally close program glUseProgram(null); }[/source]



note: only an example! i hope this helps you

PARTNERS