Jump to content

  • Log In with Google      Sign In   
  • Create Account


BigEfromTheVillages

Member Since 22 Nov 2013
Offline Last Active Dec 28 2013 05:35 AM
-----

Topics I've Started

How to tell if a 3D point will be hidden

22 December 2013 - 07:46 AM

I want to number vertices of a model only if that vertex will be visible once the complete model is rendered. I need to turn off the depth buffer to insure that the number text will not be obscured by adjacent objects, so i need to know in advance if the position of the vertex is hidden.

  

My plan is to render the model, then go back over each vertex (could be thousands) to see if it is visible, if so, turn off the depth buffer and label the vertex using outlined fonts.

 

Any suggestions on how to accomplish this??

 

Thanks in advance

 


Texture Objects - can't reuse

22 November 2013 - 10:03 AM

I have a routine to apply contours to the surface of quads. Iam using a 1d texture.
 
I create the texture using:

glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glDeleteTextures(1,&contourTextureName);
glGenTextures(1, &contourTextureName);


glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, CONTOUR_TEXTURE_LENGTH, 0,
GL_RGBA, GL_UNSIGNED_BYTE, contourTexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_1D,contourTextureName);

then when rendering the quads i do the following:

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);


glBindTexture(GL_TEXTURE_1D,contourTextureName);


glEnable(GL_TEXTURE_1D);


glBegin(GL_POLYGON);


glTexCoord1f(value[0]); glVertex3f(NX(n1),NY(n1),NZ(n1));
glTexCoord1f(value[1]); glVertex3f(NX(n2),NY(n2),NZ(n2));
glTexCoord1f(value[2]); glVertex3f(NX(n3),NY(n3),NZ(n3));
if(n4 > 0)
glTexCoord1f(value[3]); glVertex3f(NX(n4),NY(n4),NZ(n4));


glEnd();

The texture ends up not being used. However, if i do the following (add the texture creation code each time i need to use it)

	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, CONTOUR_TEXTURE_LENGTH, 0,
		GL_RGBA, GL_UNSIGNED_BYTE, contourTexture);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	glBindTexture(GL_TEXTURE_1D,contourTextureName);

	glEnable(GL_TEXTURE_1D);

	glBegin(GL_POLYGON);

	glTexCoord1f(value[0]); glVertex3f(NX(n1),NY(n1),NZ(n1));
	glTexCoord1f(value[1]); glVertex3f(NX(n2),NY(n2),NZ(n2));
	glTexCoord1f(value[2]); glVertex3f(NX(n3),NY(n3),NZ(n3));
	if(n4 > 0)
		glTexCoord1f(value[3]); glVertex3f(NX(n4),NY(n4),NZ(n4));

	glEnd();

It works fine. This is eating up all sorts of cpu, and i thought i should be able to re-use the texture, what am i doing wrong???

 

 


PARTNERS