How to load texture in OpenGL

BlitzMax Forums/BlitzMax Programming/How to load texture in OpenGL

Sveinung(Posted 2004) [#1]
Can someone please show me an example of how to texture a
OpenGL object. I tryed to look at the MAXCube example, but didnīt
get any wiser :(

Thanks
Sveinung


{cYan|de}(Posted 2004) [#2]
glBindTexture

i think max has some kinda inbuilt shortcut to loading gl textures

bglTexFromPixmap( pixmap:TPixmap,mipmap=True ) Helper function to create a texture from a pixmap

^ im gonna take a guess as i cant actually try it, that you can glbindtexture with the returned int (yay or nay im not sure yet)


marksibly(Posted 2004) [#3]
Yep, that's correct.

Use LoadPixmap to, erm, load a pixmap first.


Sveinung(Posted 2004) [#4]
I have done that, but still no texturemap.

My code look something like this:
tex01 = loadpixmap("rock.png")
glbindtexture(GL_TEXTURE_2D, bgltexfrompixmap(tex01))
glenable GL_TEXTURE_2D

Then I bind this to the quad....
What am I doing wrong?

Regards
Sveinung


{cYan|de}(Posted 2004) [#5]
got your texture coords correct on the quad?


Sveinung(Posted 2004) [#6]
I think so. I have taken the coords from my PureBasic code, works fine there. But I use the command glTexImage2D(GL_TEXTURE_2D, 0, 3, Width, Height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, ImageData+PeekL(ImageData+10)). This is not in my BM code, and I havent found it used in any of the examples. I thought this line was needed, but I'm not sure.

BTW thanks for the help so fare!

regards
Sveinung


marksibly(Posted 2004) [#7]
Looks OK to me. Can you post more code?