Advertisement

Loading/using textures

Started by October 28, 2004 04:58 AM
0 comments, last by Enigma 20 years, 4 months ago
Can someone explain what all these functions do? TextureImage[0]=LoadBMP("Picture.bmp"); glGenTextures(3, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); I guess first one loads bitmap from disk, and last one copies texture to video/system memory for texture usage... But what other two do??? In directx all I had to do is: ;) Texture tex = TextureLoad.FromFile(dev, "Picture.bmp"); And how do I specify to which memory I want to put texture into (video/system/managed)?
Bulma
Standard OpenGL uses a C interface, which means it has no builtin notion of objects. Instead OpenGL uses a number of other systems to emulate objects. For textures it uses a "texture id" to reference a texture "object". The line glGenTextures(3, &texture[0]); allocates ids for 3 textures, and would probably be equivalent to Texture textures[3]; in DirectX. The line glBindTexture(GL_TEXTURE_2D, texture[0]); tells OpenGL that future operations should operate on texture[0], until we tell it otherwise.

There is no way in OpenGL to assign a texture directly to video or system RAM. OpenGL handles texture for you and will move them about as necessary. You can use the glPrioritizeTextures command to help ensure certain textures remain in video RAM.

Enigma

This topic is closed to new replies.

Advertisement