PDA

View Full Version : why the tree can't be displayed



victorswan
04-23-2003, 04:57 AM
when I create a empty project only displaying tree, the tree can be displayed, but when I put these code into another project with terrain, the tree can not be displayed, I wonder why?
struct plantmodelstruct
{ GLuint masktexture;
GLuint texture;
float sizex;
float sizey;
};
plantmodelstruct plantmodel;
int nPlantList;
void LoadTextu(char *file, GLuint *ptexture)
{
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage, 0, sizeof(void *));
TextureImage[0] = auxDIBImageLoad(file);

glBindTexture(GL_TEXTURE_2D, *ptexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

free(TextureImage[0]->data);
free(TextureImage[0]);

}

void CDrawCulvertView::LoadPlants()
{
plantmodel.sizex = 64;
plantmodel.sizey = 128;
//textures
glGenTextures(1, &plantmodel.masktexture);
glGenTextures(1, &plantmodel.texture);
LoadTextu("texture\\pflmask.bmp", &plantmodel.masktexture);
LoadTextu("texture\\pfl.bmp", &plantmodel.texture);
}

void DrawPlants()
{
nPlantList = ModelPlant();
glPushMatrix();
glTranslatef(0,-50,-300);
glCallList(nPlantList);
glPopMatrix();
}

int ModelPlant()
{
int nModel,j;
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
nModel = glGenLists(1);
glNewList(nModel,GL_COMPILE_AND_EXECUTE);
glColor3f(1, 1, 1);

for(j=0; j<4; j++)
{ //mask
if(j%2 == 0)
{
glBindTexture(GL_TEXTURE_2D, plantmodel.masktexture);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
}
//image
else
{
glBindTexture(GL_TEXTURE_2D, plantmodel.texture);
glBlendFunc(GL_ONE, GL_ONE);
}
if(j==2)
glRotatef(-90, 0, 1, 0);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex3f(-plantmodel.sizex, plantmodel.sizey, 0);
glTexCoord2f(1, 1); glVertex3f(plantmodel.sizex, plantmodel.sizey, 0);
glTexCoord2f(1, 0); glVertex3f(plantmodel.sizex, 0, 0);
glTexCoord2f(0, 0); glVertex3f(-plantmodel.sizex, 0, 0);
glEnd();
}
glEndList();
return nModel;
}

AdrianD
04-23-2003, 05:25 AM
too lazy to debug ? http://www.opengl.org/discussion_boards/ubb/wink.gif
checkout your matrices!

victorswan
04-23-2003, 05:30 AM
I display the terrain with multi-texture, so I wonder wether this is the reason, the matrices are not changed except using gluLookat to locate the eye position

victorswan
04-23-2003, 05:33 AM
I have made a mistake, when I put the tree display code into a project with terrain, the display result is not only not displaying the tree but a black screen

Deiussum
04-23-2003, 06:49 AM
I posted few possible things to look at for your post on this on the beginner board.