| Callum5042 (125) | |||||
|
I got a function that reads the bitmap data and then I want to use the bitmap to texture a rectangle, but I can't get the texture to show. Anyone know what wrong?
Loads bitmap
| |||||
|
|
|||||
| Disch (8340) | |
|
Two things I notice: 1) OpenGL textures must be a power of 2 size 2) You probably should be enabling 2D textures before attempting to create/load one, but I don't know if that will matter. | |
|
|
|
| Callum5042 (125) | |
|
I'm loading a bitmap which is 64x64, so that power of 2? And tried enabling 2D textures before and still just displaying a black rectangle | |
|
|
|
| qwe40954 (1) | |
| according to my experience,after you set the texture parameter ,you should bind it again. | |
|
|
|
| Ogoyant (48) | |||||
Since you define LoadBMP as GLuint LoadBMP(const char *fileName), it should return texture; upon completion. I looked at a few examples and glTexParameteri() calls are made before the call to glTexImage2D(), which is usually made last. I don't know if that could be an issue. Also, I see you do not make any call to glTexEnvf(). Try making the calls in this order:
| |||||
|
Last edited on
|
|||||
| Callum5042 (125) | |
|
Thanks Ogoyant, it loads now :) But there is one more issue, it not really a problem just a bit annoying. Because how Bitmaps work it loads the image a bit mirror, I changed the colour from RGB to BGR but is there a way to make the image load so it doesn't have it mirror? | |
|
|
|
| Disch (8340) | |
|
Bitmaps are [usually] stored upside-down (bottom row first). OpenGL expects them to be top row first. Only way to fix is to flip the rows upon loading. I just went through all this with someone else recently. Here's the thread: http://cplusplus.com/forum/windows/78897/ | |
|
|
|