Using Multiple Textures

BlitzMax Forums/OpenGL Module/Using Multiple Textures

Clyde(Posted 2005) [#1]
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! :)


col(Posted 2005) [#2]
Seems to be using the last texture loaded....

brb...


AdrianT(Posted 2005) [#3]
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.


Extron(Posted 2005) [#4]
For me it work perfectly.


Clyde(Posted 2005) [#5]
@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


col(Posted 2005) [#6]
I've sussed it.

2 mins and I'll post it up.


col(Posted 2005) [#7]
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!!!!


Extron(Posted 2005) [#8]
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!


col(Posted 2005) [#9]
Perfectly viable, Yes, but it'll probably wear you fingertips away!! :)

I prefer glGenTextures(5,VarPtr Texture[0])

Much less typing!! :)

Regards


Clyde(Posted 2005) [#10]
Thank you ever so much dudes, really is top and cool.
It really is very much appreciated!!

THUMBZ! :)


Clyde(Posted 2005) [#11]
One other question, can the Pixmaps used for loading the textures be freed?

Or do they go from memory automatically when FlushMem() is called?


Extron(Posted 2005) [#12]
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.