Hy there.
I’am studing computer grafics, and start to learn abou OpenGl.I have to put textures (in bmp file) on a pyramid and i coulden’t do it…I whant to kown if some one is dispose to help me …
tks mates
Hy there.
I’am studing computer grafics, and start to learn abou OpenGl.I have to put textures (in bmp file) on a pyramid and i coulden’t do it…I whant to kown if some one is dispose to help me …
tks mates
Have a read throught this whole thread :
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=255046&fpart=1
an easier way to load bmp file is using ‘auxDIBImageLoad’
notice that the size of the image is better of power of two, you could use ‘gluScaleImage’ to scale your image to a proper size.
before using a texture, you should create a texture object at first. something like this :
glGenTexture( 1, &handle );
active texture target, bind the object, load pixels into buffer, for example :
glEnable( GL_TEXTURE_2D );
glBindBuffer( handle );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
glBindBuffer( 0 );
glDisable( GL_TEXTURE_2D );
use this as a texture
glEnable( GL_TEXTURE_2D );
glBindBuffer( handle );
// set filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
// set wrap mode
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
// draw something …
glBindBuffer( 0 );
glDisable( GL_TEXTURE_2D );
hope this will work:)
tks for all the help, but i whas enable to do it …
i will send my code for you to try…
http://www.megaupload.com/?d=2SUADFHF
by mates
I am sorry that I made a big mistake for binding texture.
there is no ‘glBindBuffer( handle )’ function, so use this instead :
glBindTexture( GL_TEXTURE_2D, handle );
you could visit http://nehe.gamedev.net/ where you could found some tutorials that may be helpful to you.
( maybe lesson 6 : Texture Mapping )