c - Why fragment shader didn't attach? -


i'm pretty new modern opengl (3.0+) , right i'm trying create basic white triangle on black background. i'm on mac os x mavericks 10.9.2, using glfw 3.0.4 create window, glew 1.10.0 load extensions. can find full source code here.

my problem is, fragment shader doesn't want attached program. checked both program (glisprogram()) , shader (glisshader) , both passed. shaders compiling, , program linking..

however code compiles, runs , doesn't throw error, got running window black background without white triangle. here part, think broken somehow (or @ least can find error):

const char* opengl_get_error(void) {     switch (glgeterror())     {         case 0x0500: return "gl_invalid_enum​";         case 0x0501: return "gl_invalid_value​";         case 0x0502: return "gl_invalid_operation​";         case 0x0503: return "gl_stack_overflow​";         case 0x0504: return "gl_stack_underflow​";         case 0x0505: return "gl_out_of_memory​";         case 0x0506: return "gl_invalid_framebuffer_operation​";         case 0x8031: return "gl_table_too_large​";             default: return "gl_no_error";     } }  void check_attached_shaders(gluint program) {     glsizei count = 0;     gluint shaders[] = {0, 0, 0, 0};     glgetattachedshaders(program, 4, &count, shaders);     printf(">>> error: %s\n", opengl_get_error());     printf("\tnumber of shaders: %d\n", count);     (int i=0; < 4; i++) printf("\tshader_id: %d\n", shaders[i]); }  ...      // program id     gluint programid = glcreateprogram();      // attach shaders /* checking: */ check_attached_shaders(programid);     glattachshader(programid, vert_shader); /* checking: */ check_attached_shaders(programid);     glattachshader(programid, frag_shader); /* checking: */ check_attached_shaders(programid);      // link shader program     gllinkprogram(programid);  ... 

and have output:

/* >>> error: gl_no_error     number of shaders: 0     shader_id: 0     shader_id: 0     shader_id: 0     shader_id: 0 >>> error: gl_no_error     number of shaders: 1     shader_id: 1     shader_id: 0     shader_id: 0     shader_id: 0 >>> error: gl_invalid_operation     number of shaders: 1     shader_id: 1     shader_id: 0     shader_id: 0     shader_id: 0 */ 

this vertex shader looks like:

// opengl shading language version 1.5.0 #version 150 core  in vec2 input_position;  void main() {     gl_position = vec4(input_position, 0.f, 1); } 

this how fragment shader looks like:

// opengl shading language version 1.5.0 #version 150 core  out vec4 output_fragment;  void main() {     output_fragment = vec4(1.f, 1.f, 1.f, 1.f); } 

any feedback welcome,

thanks in advance!

as noted in comments, issue in function gluint create_shader_from_file(glchar *path, glenum shader_type) compiled shader source file , returned 0 or 1 indicate failure or success.

the result used shader id.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -