I’m working on a game engine, and one of the functions in the Texture class should be to create a blank texture with a specified width, height, and pixel format.
I know how to create the texture and all that, I also know that I can format it using glTexImage2d with null as the data. What annoys me though is that I have to tell openGL the format of my data (even though it’s null) which would mean I have to write a function which converts the PIXEL_INTERNAL_FORMAT enum into a PIXEL_FORMAT and a PIXEL_TYPE.
How can I get opengl to allocate memory only based on the PIXEL_INTERNAL_FORMAT?
PIXEL_FORMATandPIXEL_TYPEaren’t supposed to matchPIXEL_INTERNAL_FORMAT. They’re supposed to describe the data you pass in, so OpenGL can convert it if necessary. When no data is passed in, there will be no conversion.So you can use any legal values for these two parameters, when the data pointer is null (assuming you do not have a VBO bound).