1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
//------------ texture
//
int textureID[1];
int texture_w = 4, texture_h = 4;
unsigned char* texture_data = NULL;
loadTextureData(texture_data);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glGenTextures ( 1, textureID );
glBindTexture ( GL_TEXTURE_2D, textureID[0] );
int bpp = 3;
glTexImage2D ( GL_TEXTURE_2D, 0, bpp==3 ? GL_RGB : GL_RGBA, texture_w, texture_h, 0, bpp==3 ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, texture_data);
//glTexEnvx ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(float), vertices );
// How to setup the parameters?
//=======================
// draw texture here
//=======================
free(texture_data); // Free The Image Structure
glDeleteTextures(1, textureID); |
Partager