Advertisement Jump to content

Archived

This topic is now archived and is closed to further replies.

esaint

1D textures and Vertex Arrays problem

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

''kay, so I use vertex arrays and one-dimensional textures to draw an image with the code below:
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);

glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D,texture);
		
glColor3ub(mMaterial.color[0],mMaterial.color[1],mMaterial.color[2]);
	
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(1,GL_FLOAT,0,light_coord);
	
if(mVertex!=NULL)
{
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,0,mVertex);
}
else
{
	glDisableClientState(GL_VERTEX_ARRAY);
}

glDrawElements(GL_TRIANGLES,mFaces*3,GL_UNSIGNED_INT,mFace);

glDisable(GL_TEXTURE_1D);
glPopClientAttrib();
... problem is, the next time I use a similar function to display an model with a 2D texture, like so:
if(mHasTexture)
{
	glEnable(GL_TEXTURE_2D);
	glColor3ub(255,255,255);
	glBindTexture(GL_TEXTURE_2D,mMaterial.texID);
}
else
{
	glDisable(GL_TEXTURE_2D);
	glColor3ub(mMaterial.color[0],mMaterial.color[1],mMaterial.color[2]);
}

if(mHasTexture)
{
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2,GL_FLOAT,0,mTexCoord);
}
else
{
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

if(mVertex!=NULL)
{
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,0,mVertex);
}
else
{
	glDisableClientState(GL_VERTEX_ARRAY);
}
	
glDisableClientState(GL_NORMAL_ARRAY);
glDrawElements(GL_TRIANGLES,mFaces*3,GL_UNSIGNED_INT,mFace);
... That model looks like it''s texture with the one-dimensional texture. Now I''m not sure what I''m doing wrong here, but as I''m not entirely sure what''s going on behind those Client States... If you see anything, please reply.

Share this post


Link to post
Share on other sites
Advertisement
well it could be that you are telling it you are useing 2 dimention Texture Coords

glTexCoordPointer(2,GL_FLOAT,0,mTexCoord);

for 1d it should be

glTexCoordPointer(1,GL_FLOAT,0,mTexCoord);

"I seek knowledge and to help those who also seek it"

Share this post


Link to post
Share on other sites
Ummm, no, as I said, the second one is supposed to be 2D. No worries, though, I figured it out, I just forgot to reset the Active Texture when multi-texturing. Very naughty of me.I''ll quit taking up space now ():-)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!