PDA

View Full Version : 1D texture mapping



beachboy1976
07-05-2002, 07:43 AM
I am working on terrain project. I want to use 1D texture to color the land and ocean. However, the problems I am having are that there are only two colors on screen instead of multiple colors. For example, based on the depth of ocean, some part of ocean should be "white blue" color instead of ocean blue colors. The foreshore should be green color instead of "Brown" color like land. I tried to use mipmapping to handle it. It wasn't working. I am attaching my code here. Please let me know what I did wrong.
Thanks

/////////////////////////////////////////////////////////////////////////
GLfloat params[4] = {0.0,0.0,1,0.3};
// GLfloat params[4] = {0.0,0.0,1,.58f};
GLubyte stripe[4][3];
GLubyte stripe1[4][3];

////////////////////////////////////////////////
//stripe data
stripe[0][0] = 0x00;
stripe[0][1] = 0x00;
stripe[0][2] = 0xff;

stripe[1][0] = 0x00;
stripe[1][1] = 0x00;
stripe[1][2] = 0xff;

//Ground
stripe[2][0] = 0xAC;
stripe[2][1] = 0x95;
stripe[2][2] = 0x13;

stripe[3][0] = 0xff;
stripe[3][1] = 0x00;
stripe[3][2] = 0xff;


////////////////////////////////////////////////////
//stripe1 data

//white
stripe[3][0] = 0xB6;
stripe[3][1] = 0xB6;
stripe[3][2] = 0xB6;

//light green
stripe[0][0] = 0x00;
stripe[0][1] = 0xc6;
stripe[0][2] = 0x63;

//black
stripe[1][0] = 0x00;
stripe[1][1] = 0x00;
stripe[1][2] = 0xff;

//Ground
stripe[2][0] = 0xAC;
stripe[2][1] = 0x95;
stripe[2][2] = 0x13;

/////////////////////////////////////////////////////////

glTexImage1D(GL_TEXTURE_1D,0,3,4,0,GL_RGB,GL_UNSIG NED_BYTE,stripe);
glTexImage1D(GL_TEXTURE_1D,1,3,4,0,GL_RGB,GL_UNSIG NED_BYTE,stripe1);

glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);

glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER,GL_NEAREST );
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );

glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEA R);
glTexGenfv(GL_S,GL_OBJECT_PLANE,params);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

glEnable(GL_TEXTURE_GEN_S);