Potential problem with OpenGL error message
Closed this issue · 2 comments
I have created a Visual Studio fork of this repository and encountered an error with OpenGL. The emulator will fail if there is no error message. I have added a fix to my fork.
https://github.com/mkwong98/gbe-plus/commit/8b63ca2bcca1ff7644eaabd918919f0028ff8572
I'm not sure why your fork doesn't have this problem, but you may want to apply the fix to yours too to prevent potential error in the future.
Hmm... now that I look at all of that code, it would be pretty bad if log_length
is set to zero!
That would result in undefined behavior when trying to access vs_error
, fs_error
, and program_error
, as those vectors are initialized with the size of log_length
. Since it's undefined behavior, the results are probably compiler specific, so I would imagine Visual Studio is less tolerant with this error than g++ is. Since I compile on both Windows and Linux with g++, I guess I never came across this problem. Thanks for catching this!
You might want to expand your if
statement a bit more to cover more than just the cout
statements, since those vectors are accessed as a parameter by glGetShaderInfoLog()
if(log_length)
{
std::vector<char> vs_error(log_length);
glGetShaderInfoLog(vertex_shader_id, log_length, NULL, &vs_error[0]);
//Print any error messages from compiling vertex shader
std::cout<<"OGL::Vertex Shader Error Message Log: " << &vs_error[0] << "\n";
}
I'll make these changes in master soon, sometime later today when I push the last 3 weeks of commits I've been sitting on. Thanks again!