Improved code for loading and linking shaders

dev
Tomasz Kapuściński 2021-06-16 01:40:52 +02:00
parent fe02cf3e4b
commit 704e3f2f0d
2 changed files with 8 additions and 5 deletions

View File

@ -471,9 +471,12 @@ GLint LoadShader(GLint type, const char* filename)
return 0;
}
GLchar source[65536];
GLchar *sources[] = { source };
int length = PHYSFS_read(file, source, 1, 65536);
size_t len = PHYSFS_fileLength(file);
std::vector<GLchar> source(len + 1);
GLchar *sources[] = { source.data() };
size_t length = PHYSFS_read(file, source.data(), 1, len);
source[length] = '\0';
PHYSFS_close(file);
@ -503,7 +506,7 @@ GLint LoadShader(GLint type, const char* filename)
return shader;
}
GLint LinkProgram(int count, GLint shaders[])
GLint LinkProgram(int count, const GLint* shaders)
{
GLint program = glCreateProgram();

View File

@ -99,7 +99,7 @@ std::string GetLastShaderError();
GLint LoadShader(GLint type, const char* filename);
GLint LinkProgram(int count, GLint shaders[]);
GLint LinkProgram(int count, const GLint* shaders);
// TODO: Moved this here temporarily only to remove code duplication in CGLDeviceXX
struct PreparedTextureData