I tried to convert my old openGl code (written in c++) to c, I always encounter this weird warning about an incompatible pointer type when I try to use glCompileShader()
char *buffer = 0;
long length;
FILE *f = fopen(vertexPath, "rb");
if(f) {
fseek(f, 0, SEEK_END);
length = ftell(f);
fseek(f, 0, SEEK_SET);
buffer = malloc(length);
if(buffer) {
fread(buffer, 1, length, f);
}
fclose(f);
}
if(buffer) {
unsigned int vertex;
int success;
vertex = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex, 1, &buffer, NULL);
glCompileShader(vertex);
glGetShaderiv(vertex, GL_COMPILE_STATUS, &success);
if(!success) {
char *infoLog;
infoLog = malloc(512);
glGetShaderInfoLog(vertex, 512, NULL, infoLog);
printf("%s%s", "Error Fragment\n", infoLog);
free(infoLog);
}
}
Here is the warning message that I got:
..\src.\shader.c: In function 'compileShader':
..\src.\shader.c:29:35: warning: passing argument 3 of 'glad_glShaderSource' from
incompatible pointer type [-Wincompatible-pointer-types]
29 | glShaderSource(vertex, 1, &buffer, NULL);
| ^~~~~~~
| |
| char **
..\src.\shader.c:29:35: note: expected 'const GLchar * const*' {aka 'const char *
const*'} but argument is of type 'char **'
I don't know what this warning means, if it is important, or if I can ignore it. Thx 4 helping.