0 (3): error C1013: the function "main" is already defined in 0 (4)

I have this a bit and I can’t understand what is wrong. My shader:

#version 120 attribute vec2 coord2d; void main(void) { gl_Position = vec4(coord2d, 0.0, 1.0); } 

This shader that I know works, but when I try to link the program, I get:

 glLinkProgram:Vertex info ----------- 0(3) : error C1013: function "main" is already defined at 0(4) 

I checked to make sure that viles get into memory correctly and what not. they just compile. it’s a binding step that something went wrong. I do not know that, and for quite some time I hit my head about it. any advice?

Edit:

Here is the code that I use to create the shader. it comes to the conditional, it actually completes the whole execution, but the journal prints what you saw above.

 GLuint updateProg() { prog = glCreateProgram(); if (vs == 0 || fs == 0) return 0; glAttachShader(prog, vs); glAttachShader(prog, fs); int link_ok; glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &link_ok); if (!link_ok) { fprintf(stderr, "glLinkProgram:"); print_log(prog); return 0; } return prog; } 
+4
source share
3 answers

Does the error sound like you're trying to link two copies of a shader? Check the code for creating shader objects, load the code into them and bind them to the program object. That is, double-check all calls to glCreateShader, glShaderSource, glCreateProgram, and glAttachShader to make sure they make sense.

change

You have added code that calls glCreateProgram above, but not code that calls glCreateShader. Your error corresponds to the random (incorrect) passage of GL_VERTEX_SHADER in GL_VERTEX_SHADER for the fragment shader.

+17
source

I had this mistake today. This happened because I copied / pasted too much code. I called glCreateShader (GL_VERTEX_SHADER); for my vertex and fragment shader. They compiled just fine, but they will not be linked because they were both vertex shaders.

+3
source

GLSL is not C or C ++. void cannot be used as a single parameter, as in void main(void) . You want void main() .

The mistake, however, is mysterious.

+1
source

Source: https://habr.com/ru/post/1392294/


All Articles