本文整理匯總了Java中javax.media.opengl.GL2.glTexCoord2d方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glTexCoord2d方法的具體用法?Java GL2.glTexCoord2d怎麽用?Java GL2.glTexCoord2d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glTexCoord2d方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawCorners
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCorners(GL2 gl, Map<String, Vertex> map) {
Vertex rightBottom = map.get("rightBottom");
Vertex leftBottom = map.get("leftBottom");
Vertex rightTop = map.get("rightTop");
Vertex leftTop = map.get("leftTop");
TextureCoords textureCoords = texture.getImageTexCoords();
float leftTex = textureCoords.left();
float rightTex = textureCoords.right();
float topTex = textureCoords.top();
float bottomTex = textureCoords.bottom();
gl.glPushMatrix();
gl.glBegin(GL_TRIANGLE_STRIP);
gl.glTexCoord2d(rightTex, bottomTex);
gl.glVertex3f(rightBottom.getPositionX(), rightBottom.getPositionY(),
rightBottom.getPositionZ());
gl.glTexCoord2d(rightTex, topTex);
gl.glVertex3f(rightTop.getPositionX(), rightTop.getPositionY(), rightTop.getPositionZ());
gl.glTexCoord2d(leftTex, bottomTex);
gl.glVertex3f(leftBottom.getPositionX(), leftBottom.getPositionY(), leftBottom.getPositionZ());
gl.glTexCoord2d(leftTex, topTex);
gl.glVertex3f(leftTop.getPositionX(), leftTop.getPositionY(), leftTop.getPositionZ());
gl.glEnd();
gl.glPopMatrix();
}
示例2: renderFace
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Renter face
*
* @param i index of face
* @param flipTexCoords true if the tex coords need flipping
* @param gl
*/
public void renderFace(int i, boolean flipTexCoords, GL2 gl) /* Render the ith face by getting the vertex, normal, and tex
coord indicies for face i. Use those indicies to access the
actual vertex, normal, and tex coord data, and render the face.
Each face uses 3 array of indicies; one for the vertex
indicies, one for the normal indicies, and one for the tex
coord indicies.
If the model doesn't use normals or tex coords then the indicies
arrays will contain 0's.
If the tex coords need flipping then the t-values are changed.
*/ {
if (i >= facesVertIdxs.size()) {
return;
}
int[] vertIdxs = facesVertIdxs.get(i);
// get the vertex indicies for face i
int polytype;
if (vertIdxs.length == 3) {
polytype = GL2.GL_TRIANGLES;
} else if (vertIdxs.length == 4) {
polytype = GL2.GL_QUADS;
} else {
polytype = GL2.GL_POLYGON;
}
gl.glBegin(polytype);
// get the normal and tex coords indicies for face i
int[] normIdxs = facesNormIdxs.get(i);
int[] texIdxs = facesTexIdxs.get(i);
/* render the normals, tex coords, and vertices for face i
by accessing them using their indicies */
Vector3f vert, norm, texCoord;
double yTC;
for (int f = 0; f < vertIdxs.length; f++) {
if (normIdxs[f] != 0) { // if there are normals, render them
norm = normals.get(normIdxs[f] - 1);
gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ());
}
if (texIdxs[f] != 0) {
// if there are tex coords, render them
texCoord = texCoords.get(texIdxs[f] - 1);
yTC = texCoord.getY();
if (flipTexCoords) {
yTC = 1.0f - yTC;
}
if (texCoord.getZ() == DUMMY_Z_TC) {
gl.glTexCoord2d(texCoord.getX(), yTC);
} else {
gl.glTexCoord3d(texCoord.getX(), yTC, texCoord.getZ());
}
/*
System.out.print("Tex index: " + (texIdxs[f]) + ": ");
System.out.println("Tex coord: " + df.format(texCoord.getX()) + ", " +
df.format( yTC ) + ", " +
df.format( texCoord.getZ() ));
*/
}
vert = verts.get(vertIdxs[f] - 1); // render the vertices
// System.out.println(vertIdxs[f] - 1 + " " + verts.get(vertIdxs[f] - 1).length());
gl.glVertex3d(vert.getX(), vert.getY(), vert.getZ());
}
gl.glEnd();
}