I've tried to texture a tree with a *.bmp image and something I do wrong...Please help me...I have an error : undeclared identifier GL_TEXTURE_3D
void myinit(void);
void CALLBACK display(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void load_texture(const char* s);
float baseRadius = 0.10;
float topRadius = 0.10;
float height = 1.0;
int slices=50, stacks=50;
float pi = 3.14159265358979323846;
GLuint IDtextura;
void load_texture(const char* s)
{
AUX_RGBImageRec *pImagineTextura = auxDIBImageLoad(s);
if(pImagineTextura != NULL )
{
glGenTextures( 1, &IDtextura );
glBindTexture(GL_TEXTURE_3D, IDtextura);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_R开发者_Python百科EPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexImage3D(GL_TEXTURE_3D, 0, 3, pImagineTextura->sizeX, pImagineTextura->sizeY,pImagineTextura->sizeZ,
0, GL_RGB, GL_UNSIGNED_BYTE, pImagineTextura->data);
}
if(pImagineTextura)
{
if(pImagineTextura->data )
free(pImagineTextura->data );
free(pImagineTextura);
}
}
void myinit (void)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_3D);
glShadeModel(GL_FLAT);
}
void CALLBACK display(void)
{
GLUquadricObj* cilindru;
cilindru = gluNewQuadric();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef (0.0, 0.0, -5.0);
const char* sir;
GLuint ID1;
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sir=".\\mm.bmp";
load_texture(sir);
ID1=IDtextura;
glBindTexture( GL_TEXTURE_3D, ID1);
//glBegin(GL_QUADS);
//????
glEnd();
glPushMatrix ();
glRotated (0.0, 1.0, 0.0, 0.0);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING);
glEnable (GL_LIGHTING);
glPopMatrix ();
//tree
glPushMatrix();
glRotatef(90, 1, 0, 0);
gluQuadricDrawStyle(cilindru, GLU_FILL);
gluCylinder(cilindru, baseRadius, topRadius, height, slices,stacks);
glPopMatrix();
..........
A .bmp file is a 2D image... So you don't even have to use GL_TEXTURE_3D.
What you want to do is UV mapping. Texturing a 3D object doesn't require a 3D texture.
Remove glTexImage3D, use glTexImage2D instead. Same thing for glTexCoord3f.
What's more, giving 300 lines of unformatted code without real question (what you want, what you tried, etc) isn't likely to give you an answer ( But it's ok, it's your first time here )
3D textures are part of OpenGL 1.2. On windows, in order to use OpenGL versions higher than 1.1 you need external library such as GLEW or GLee.
精彩评论