I am very new to OpenGL and am reading about mapping images to textures and came across this API with the following signature:
void glTexImage2D(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type, const GLvoid * data);
Now, I have read many places that graphics hardware works better if things are aligned to 4 byte boundaries. So, I was wondering about the following case where I have a RGB image. So, the format parameter should be GL_RGB. However, to take advantage of this 4 byte alignment I want to keep it internally as GL_RGBA (where the alpha channel is not really used).
Reading the API, I got a bit confused as to whether I need to internally change my image to have this RGBA structure or would just setting the internal format to GL_RGBA and format to GL_RGB suffice?
Another question that I wonder is what if I have grayscale data i.e. just a single channel. Would it also be beneficial to convert that to RGBA structure at the cost of more memory or would I not get a performance hit by keeping it as GL_RED, for example.
Thanks,
Luca