question

FaclonDev-8283 avatar image
0 Votes"
FaclonDev-8283 asked Viorel-1 edited

OpenGL ERROR E0310

default argument of type "const char " is incompatible with parameter of type "char "

My Code:

Shader(char* vertexFile, char* fragmentFile, char* geometryFile = "")
{
GLuint vertexShader = 0;
GLuint geometryShader = 0;
GLuint fragmentShader = 0;


     vertexShader = loadShader(GL_VERTEX_SHADER, vertexFile);
        
     if(geometryFile != "")
     geometryShader = loadShader(GL_GEOMETRY_SHADER, geometryFile);
    
     fragmentShader = loadShader(GL_FRAGMENT_SHADER, fragmentFile);
    
     this->linkProgram(vertexShader, geometryShader, fragmentShader);


     //END
     glDeleteShader(vertexShader);
     glDeleteShader(geometryShader);
     glDeleteShader(fragmentShader);
    
     glUseProgram(0);
    
 }

I had the same code on my other project and I had no errors with it

c++
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

On which line of code that you've shown do you get that error?

0 Votes 0 ·

@FaclonDev-8283

According to the issue, It is related to OpenGL. I suggest you could post the issue to the OpenGL forum: Khronos Forums.


0 Votes 0 ·

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

I think that you must change the definition of default argument:

Shader(char* vertexFile, char* fragmentFile, const char* geometryFile = "")

This maybe requires corresponding changes to other functions. It is probably a good idea to use const if geometryFile is a read-only string. Check if const can be added to other parameters too.

By the way, instead of 'if(geometryFile != "")', which is not always correct, you can write 'if(*geometryFile)' or 'if(strlen(geometryFile) != 0)'.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.