Using Multiple Textures
BlitzMax Forums/OpenGL Module/Using Multiple Textures
| ||
I've tried to do a cube with different textures per side. And Im having lots of problems with this. As it works with the one texture, and not with anymore. Thanks for your help, it's much appreciated. How cool Is OpenGL in BMAX! :) THUMBZ! :) |
| ||
Seems to be using the last texture loaded.... brb... |
| ||
don't know but we are currently having texture problems on older Geforce 2 and Voodoo 5 gen cards. We havent posted any bug reports yet since were doing 3D not 2D graphics and have to better determine exactly where the problem is. |
| ||
For me it work perfectly. |
| ||
@Col: I dont see anything, apart from an untextured 6 sided Quad @Extron: You can see the cube with all six different textures (one for each side)? @Evak: I have a Geforce 4 MX card, so if what your saying is true, then I should have no problems at all. @ALL: Is there anything at all wrong with the code, as I cant see any textures at all in it's current state? Thanks |
| ||
I've sussed it. 2 mins and I'll post it up. |
| ||
Ok . Here we go: In the LoadGLTextures() function delete all the glGenTextures..... and place : glGenTextures(5, VarPtr Texture[0]) just after you load in all the textures. Then in the render loop you need to do this: (pseudo code) glBindTexture texture0 glBegin(GL_QUADS) .... .... glEnd glBindTexture texture1 glBegin(GL_QUADS) .... .... glEnd (until last texture) You need to change the texture BEFORE you begin to draw the quads that are going to use that texture. Then change the texture again and draw some more quads and so on.... I'm sure this helps as it sure is helping me to understand OpenGL. I've always tried to learn DirectX on and off over time and never really got that far at all. In fact I've got further in the last 2 days with OpenGL than I ever got with DX!! Have fun. [*******EDITED*******] ps. I used jpegs as I haven't any png's to hand!!!! |
| ||
glGenTextures(6, VarPtr Texture[0]) and/or glGenTextures(1, VarPtr Texture[0]) glGenTextures(1, VarPtr Texture[1]) glGenTextures(1, VarPtr Texture[2]) glGenTextures(1, VarPtr Texture[3]) glGenTextures(1, VarPtr Texture[4]) glGenTextures(1, VarPtr Texture[5]) this two solution are perfectly viable. @Extron: You can see the cube with all six different textures (one for each side)? Yes! |
| ||
Perfectly viable, Yes, but it'll probably wear you fingertips away!! :) I prefer glGenTextures(5,VarPtr Texture[0]) Much less typing!! :) Regards |
| ||
Thank you ever so much dudes, really is top and cool. It really is very much appreciated!! THUMBZ! :) |
| ||
One other question, can the Pixmaps used for loading the textures be freed? Or do they go from memory automatically when FlushMem() is called? |
| ||
It's local to the function and free when you return from this function. But you need to use Flushmem in your main loop, in fact always use Flushmem. |