opengl-tutorials icon indicating copy to clipboard operation
opengl-tutorials copied to clipboard

compileErrors() doesn't work as intended

Open YourAverageFTCPerson opened this issue 1 year ago • 2 comments

// Checks if the different Shaders have compiled properly
void Shader::compileErrors(unsigned int shader /* Sidenote: shouldn't this be GLuint for maximum generality? */, const char* type)
{
	// ...
	if (type != "PROGRAM") // This is never true because const char* is not std::string and this simply compares the memory addresses. If you want to check to see if the values aren't the same use strcmp(type, program) != 0 in <cstring>
	{
		// ...
	}
	else
	{
		// ...
	}
}

YourAverageFTCPerson avatar Jan 27 '24 18:01 YourAverageFTCPerson

My personal fix for this was to change the comparison to if (shader != ID), which I think is overall better than making it actually compare the string properly. Could also rename the variables and add a comment to make the comparison more clear.

PhoenixWhitefire avatar Jan 14 '25 04:01 PhoenixWhitefire

i guess author abandon this... i come here to wrote this issue, and also seen it

CharaVerKys avatar Jan 29 '25 13:01 CharaVerKys