本文整理匯總了Java中javax.media.opengl.GL2.GL_POLYGON屬性的典型用法代碼示例。如果您正苦於以下問題:Java GL2.GL_POLYGON屬性的具體用法?Java GL2.GL_POLYGON怎麽用?Java GL2.GL_POLYGON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.GL_POLYGON屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderFace
void renderFace(int i, GL2 gl, int curDistanceAttrib, List<Float> dist) {
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);
Vector3f vert, norm;
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());
}
gl.glVertexAttrib1f(curDistanceAttrib,dist.get(vertIdxs[f] - 1));
vert = verts.get(vertIdxs[f] - 1); // render the vertices
gl.glVertex3d(vert.getX(), vert.getY(), vert.getZ());
}
gl.glEnd();
}
示例2: build
/**
* Create a SimpleBody from the previously given definition.
*
* @return A new SimpleBody.
*/
public SimpleBody build() {
/**
* Tell Assembler to compile all the surfaces and then retrieve the
* necessary values.
*/
assembler.compileSurfaceCompilation();
//Buffer containing all Vertextdata off all previously added shapes.
//The data in in the format: vertexX, vertexY, vertexZ, normalX, normalY, normalZ.
final FloatBuffer dataBuffer = assembler.getDataBuffer();
/**
* List of index buffers. Each index buffer belongs to a shape and
* consists of pointers to vertices in the data buffer.
*/
final List<IntBuffer> indicesBufferList = assembler.getIndicesBuffers();
/**
* List of boolean flags. Runs parallel to the indicesBufferList and is
* true if the shape is a polygon, false if it's a QuadStrip.
*/
final List<Boolean> surfaceTypeList = assembler.getSurfaceTypeList();
final List<ImplementedTexture> textureList = assembler.getTextureList();
final int[] indexBufferNames = bmInitialiser.addData(dataBuffer, indicesBufferList);
final SimpleBody simpleBody = new SimpleBody();
for (int i = 0; i < indexBufferNames.length; i++) {
final int shapeMode = surfaceTypeList.get(i) ? GL2.GL_POLYGON : GL2.GL_QUAD_STRIP;
final ImplementedTexture texture = textureList.get(i);
final Shape shape = new Shape(indexBufferNames[i], indicesBufferList.get(i).capacity(), shapeMode).setTexture(texture);
if (texture != null) {
texturedShapes.add(shape);
}
simpleBody.addShape(shape);
}
return simpleBody;
}
示例3: build
public SimpleBody build(List<Vertex> trackDescription) {
assembler.calculateTrack(trackDescription, laneWidth, laneCount, trackHeight, closedTrack, textureTop, textureBottom, textureSide);
/**
* Buffer containing all vertex data from all previously added shapes.
* The data in in the format: vertexX, vertexY, vertexZ, normalX,
* normalY, normalZ.
*/
final FloatBuffer dataBuffer = assembler.getDataBuffer();
/**
* List of index buffers. Each index buffer belongs to a shape and
* consists of pointers to vertices in the data buffer.
*/
final List<IntBuffer> indicesBufferList = assembler.getIndicesBuffers();
/**
* List of boolean flags. Runs parallel to the indicesBufferList and is
* true if the shape is a polygon, false if it's a QuadStrip.
*/
final List<Boolean> surfaceTypeList = assembler.getSurfaceTypeList();
final List<ImplementedTexture> textureList = assembler.getTextureList();
final int[] indexBufferNames = bmInitialiser.addData(dataBuffer, indicesBufferList);
/**
* Create the SimpleBody that represents this RaceTrack.
*/
final SimpleBody simpleBody = new SimpleBody();
for (int i = 0; i < indexBufferNames.length; i++) {
final int shapeMode = surfaceTypeList.get(i) ? GL2.GL_POLYGON : GL2.GL_QUAD_STRIP;
final ImplementedTexture texture = textureList.get(i);
simpleBody.addShape(new Shape(indexBufferNames[i], indicesBufferList.get(i).capacity(), shapeMode).setTexture(texture));
}
return simpleBody;
}