If I am writing my own function to check shader compile errors, or do anything that interacts with the OpenGL API but ultimately returns as a result of my application code, should I use the C++ void or GLvoid?
I.E.
GLvoid Shader::check_compile_errors(GLuint ComputeShader, std::string type)
{
const GLint log_length{ 1024 };
GLchar info_log[log_length];
GLint success;
if (type == "PROGRAM")
{
glGetProgramiv(ComputeShader, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(ComputeShader, log_length, nullptr, info_log);
std::cout << "ERROR::PROGRAM_LINKING_ERROR of type: " << type << "\n" << info_log << "\n ---- " << std::endl;
}
}
// Here the return is implicitly void, but from C++ not OpenGL!
}
I realize here that GLvoid is typedef'd to void but I am wondering if there is any case where using the GL types could cause issues when it it is not explictly clear that the values are coming from OpenGL.
Another example would be writing an image to a file (from glReadPixels). If I am setting fields in the header which normally takes things in the form unsigned char should I change that to a GLuchar?
GLvoidand only use GLtypes when talking to OpenGL. If you need fixed bitdepth integers in your code that does not talk to OpenGL usecstdint? – Startec Nov 12 '17 at 02:32GLvoid? – Startec Nov 12 '17 at 02:37GLuinthas a meaning that is distinct from the fundamental typeunsigned int.GLvoidis no different fromvoid. – Nicol Bolas Nov 12 '17 at 02:47typedef unsigned int GLuint;andtypedef void GLvoid;so how isGLvoidno different butGLuintis? – Startec Nov 13 '17 at 20:16GLuintbased on the platform(s) they work on.GLvoidwill always be defined asvoid. – Nicol Bolas Nov 13 '17 at 20:18GLuintmakes sense, because you communicate that value to the GL, you either put it into a GL function or it's returned from a GL function. But thatGLvoidfunction is your function, a C++ function that doesn't return anything anyway, let alone a GL value, you don't goreturn glWhatever(...);, since you don't return anything.voidis just not a meaningful data type, whose representation would have any relevance, because it has none. – Christian Rau Nov 15 '17 at 10:58