I'm loading a cubemap to create a skybox, everything is fine and the skybox renders properly with a correct texture application.
However, I decided to check my program safety with valgrind, Valgrind gives this error: http://pastebin.com/seqmXjyx
The line 53 in
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, texture.width, texture.height, 0, GL_BGR, GL_UNSIGNED_BYTE, texture.pixels); protoype: void glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
The texture width and height are unsigned int (1024x1024), and the pixels have bmp texture format.
It is correctly parsed for sure (as I said before, everything is rendered correctly, openGL returns no error, I only get this invalid write of 4 from valgrind).
(this invalid write appear every time I load a texture)
So I read the man, and it made me even more confused, this is what I get from it:
GL_INVALID_VALUE is generated if width or height is less than 0 or greater than 2 + GL_MAX_TEXTURE_SIZE, or if either cannot be represented as 2^k +2 (border) for some integer value of k.
glGetError() gives me
GL_NO_ERROR, when I'm sending 1024*1024 as parameters, which is obviously not (2^k + 2)
I also read about the
border parameter, which seems kind of useless for now the openGL I use, but could this be link to this overwrite?
Finally, as I said, everything works properly, but I would definitely like to know where are these invalids writes coming from.
The full project: https://github.com/toss-dev/minetoss