本文整理匯總了Java中javax.media.opengl.GL2.glEnableClientState方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glEnableClientState方法的具體用法?Java GL2.glEnableClientState怎麽用?Java GL2.glEnableClientState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glEnableClientState方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderVA
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void renderVA(DrawContext dc, RectTile tile, int numTextureUnits)
{
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glVertexPointer(3, GL.GL_FLOAT, 0, tile.ri.vertices.rewind());
for (int i = 0; i < numTextureUnits; i++)
{
gl.glClientActiveTexture(GL.GL_TEXTURE0 + i);
gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
Object texCoords = dc.getValue(AVKey.TEXTURE_COORDINATES);
if (texCoords != null && texCoords instanceof DoubleBuffer)
gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, ((DoubleBuffer) texCoords).rewind());
else
gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, tile.ri.texCoords.rewind());
}
gl.glDrawElements(javax.media.opengl.GL.GL_TRIANGLE_STRIP, tile.ri.indices.limit(),
javax.media.opengl.GL.GL_UNSIGNED_INT, tile.ri.indices.rewind());
}
示例2: drawInteriorVertexColorVBO
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawInteriorVertexColorVBO(final DrawContext dc, final int[] vboIds, final PathData pathData) {
final GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
final int vertexStride = pathData.getVertexStride();
// Convert stride from number of elements to number of bytes.
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, vboIds[0]);
{
gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
{
gl.glVertexPointer(3, GL2.GL_FLOAT, 4 * vertexStride, 0);
gl.glColorPointer(4, GL2.GL_FLOAT, 4 * vertexStride, 4 * pathData.getColorOffset());
gl.glDrawArrays(GL2.GL_TRIANGLE_STRIP, 0, pathData.getVertexCount());
}
gl.glDisableClientState(GL2.GL_COLOR_ARRAY);
}
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
}
示例3: beginRendering
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void beginRendering(DrawContext dc)
{
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glPushClientAttrib(GL2.GL_CLIENT_VERTEX_ARRAY_BIT);
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
// Tiles don't push their reference center, they set it, so push the reference center once here so it can be
// restored later, in endRendering.
dc.getView().pushReferenceCenter(dc, Vec4.ZERO);
}
示例4: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGL
* @param polygonMode
* @param sides
*/
public final void draw(final GL2 openGL, final int polygonMode,
final int sides) {
asureIsBuffered(openGL);
openGL.glEnableClientState(GL.GL_ELEMENT_ARRAY_BUFFER);
openGL.glPolygonMode(sides, polygonMode);
openGL.glDrawElements(primitive, getBufferCapacity(),
GL.GL_UNSIGNED_INT, 0);
openGL.glBindBuffer(target(), 0);
}
示例5: drawLine
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGL
* @param lineMode
* @param sides
*/
public final void drawLine(final GL2 openGL, final int lineMode,
final int sides) {
asureIsBuffered(openGL);
openGL.glEnableClientState(GL.GL_ELEMENT_ARRAY_BUFFER);
openGL.glDrawElements(lineMode, getBufferCapacity(),
GL.GL_UNSIGNED_INT, 0);
openGL.glBindBuffer(target(), 0);
}
示例6: startDraw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Must be called at the start of the draw phase, before any of the bodies
* managed by this instance are drawn.
*
* @param gl The instance of GL2 responsible for drawing the bodies.
* @see #endDraw Must be called in conjunction with this method.
*/
public void startDraw(GL2 gl) {
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL2.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
//Use the name under which the data buffer was stored to bind it.
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, dataBufferName);
final int stride = Vertex.NR_VERTEX_ELEMENTS * Vertex.COORD_COUNT * Float.BYTES;
/**
* Tell OpenGL what formats and what stride length to expect when
* extracting vertex coordinate information from the data buffer.
*/
final int positionPointerOffset = 0 * Vertex.COORD_COUNT * Float.BYTES;
gl.glVertexPointer(Vertex.COORD_COUNT, GL2.GL_FLOAT, stride, positionPointerOffset);
/**
* Tell OpenGL what formats, stride length and offset to expect when
* extracting normal information from the data buffer.
*/
final int normalPointerOffset = 1 * Vertex.COORD_COUNT * Float.BYTES;
gl.glNormalPointer(GL2.GL_FLOAT, stride, normalPointerOffset);
/**
* Tell OpenGL what formats, stride length and offset to expect when
* extracting texture information from the data buffer.
*/
final int texturePointerOffset = 2 * Vertex.COORD_COUNT * Float.BYTES;
gl.glTexCoordPointer(Vertex.COORD_COUNT, GL2.GL_FLOAT, stride, texturePointerOffset);
}
示例7: bindVbos
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected boolean bindVbos(DrawContext dc, RectTile tile, int numTextureUnits)
{
int[] verticesVboId = (int[]) dc.getGpuResourceCache().get(tile.ri.vboCacheKey);
if (verticesVboId == null)
{
tile.ri.fillVerticesVBO(dc);
verticesVboId = (int[]) dc.getGpuResourceCache().get(tile.ri.vboCacheKey);
if (verticesVboId == null)
return false;
}
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
// Bind vertices
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, verticesVboId[0]);
gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);
// Bind texture coordinates
if (numTextureUnits > 0)
{
Object texCoordsVboCacheKey = textureCoordVboCacheKeys.get(tile.density);
int[] texCoordsVboId = (int[])
(texCoordsVboCacheKey != null ? dc.getGpuResourceCache().get(texCoordsVboCacheKey) : null);
if (texCoordsVboId == null)
texCoordsVboId = this.fillTextureCoordsVbo(dc, tile.density, tile.ri.texCoords);
for (int i = 0; i < numTextureUnits; i++)
{
gl.glClientActiveTexture(GL2.GL_TEXTURE0 + i);
gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, texCoordsVboId[0]);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);
}
}
// Bind index list
Object indexListVboCacheKey = indexListsVboCacheKeys.get(tile.density);
int[] indexListVboId = (int[])
(indexListVboCacheKey != null ? dc.getGpuResourceCache().get(indexListVboCacheKey) : null);
if (indexListVboId == null)
indexListVboId = this.fillIndexListVbo(dc, tile.density, tile.ri.indices);
if (indexListVboId != null)
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, indexListVboId[0]);
return indexListVboId != null;
}
示例8: setPointer
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
@Override
protected final void setPointer(final GL2 openGl) {
openGl.glEnableClientState(target());
openGl.glColorPointer(dimension, GL2.GL_DOUBLE, NO_STRIDE, getBuffer());
}
示例9: setPointer
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
@Override
protected final void setPointer(final GL2 openGl) {
openGl.glEnableClientState(target());
openGl.glVertexPointer(COORD_3D, GL2.GL_DOUBLE, NO_STRIDE, getBuffer());
}
示例10: paintNormals
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void paintNormals(GL2 gl) {
info.c.assignGl(gl);
Faces faces = info.getModel().getFaces();
List<Vector3f> mesh = info.getModel().getVerts();
List<Vector3f> normals = info.getModel().getNormals();
List<Float> distanceCopy = new ArrayList<>(info.getDistance().size());
for (Float f : info.getDistance()) {
if (!info.isUseRelative()) {
distanceCopy.add(Math.abs(f));
} else {
distanceCopy.add(f);
}
}
float[] color = new float[3];
color[0] = 0.8667f;
color[1] = 0.7176f;
color[2] = 0.6275f;
gl.glPushAttrib(GL_ALL_ATTRIB_BITS);
Vector3f normal;
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
for (int i = 0; i < faces.getNumFaces(); i++) {
int[] facesInd = faces.getFaceVertIdxs(i);
int[] faceNormIndex = faces.getFaceNormalIdxs(i);
gl.glBegin(GL.GL_TRIANGLES);
for (int f = 0; f < facesInd.length; f++) {
if (faceNormIndex[f] != 0) { // if there are normals, render them
normal = normals.get(faceNormIndex[f] - 1);
gl.glNormal3d(normal.getX(), normal.getY(), normal.getZ());
}
float[] ambient = {0.1f, 0.1f, 0.1f, 0.0f};
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, ambient, 0);
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
float[] colorKs = {0, 0, 0, 1.0f};
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorKs, 0);
gl.glVertex3f(mesh.get(facesInd[f] - 1).getX(), mesh.get(facesInd[f] - 1).getY(), mesh.get(facesInd[f] - 1).getZ());
}
gl.glEnd();
}
if (info.getRecompute()) {
recomputeNormals(gl, info, distanceCopy);
info.setRecompute(false);
}
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
info.c.draw();
gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
gl.glPopAttrib();
}
示例11: init
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
if(clContext == null) {
// find gl compatible device
CLDevice[] devices = CLPlatform.getDefault().listCLDevices();
CLDevice device = null;
for (CLDevice d : devices) {
if(d.isGLMemorySharingSupported()) {
device = d;
break;
}
}
if(null==device) {
throw new RuntimeException("couldn't find any CL/GL memory sharing devices ..");
}
// create OpenCL context before creating any OpenGL objects
// you want to share with OpenCL (AMD driver requirement)
clContext = CLGLContext.create(drawable.getContext(), device);
// enable GL error checking using the composable pipeline
drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));
// OpenGL initialization
GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval(1);
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
gl.glGenBuffers(glObjects.length, glObjects, 0);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]);
// gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0);
final int bsz = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT;
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
gl.glBufferData(GL2.GL_ARRAY_BUFFER, bsz, null, GL2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
pushPerspectiveView(gl);
gl.glFinish();
// init OpenCL
initCL(gl, bsz);
// start rendering thread
Animator animator = new Animator(drawable);
animator.start();
}
}
示例12: drawPointsVBO
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws points at this path's specified positions.
* <p/>
* Note: when the draw context is in picking mode, this binds the current GL_ARRAY_BUFFER to 0
* after using the currently bound GL_ARRAY_BUFFER to specify the vertex pointer. This does not
* restore GL_ARRAY_BUFFER to the its previous state. If the caller intends to use that buffer
* after this method returns, the caller must bind the buffer again.
*
* @param dc
* the current draw context.
* @param vboIds
* the ids of this shapes buffers.
* @param pathData
* the current globe-specific path data.
*/
@Override
protected void drawPointsVBO(final DrawContext dc, final int[] vboIds, final PathData pathData) {
final TourTrackConfig config = TourTrackConfigManager.getActiveConfig();
if (config.isShowTrackPosition == false) {
return;
}
final double d = getDistanceMetric(dc, pathData);
if (d > getShowPositionsThreshold()) {
return;
}
final IntBuffer posPoints = pathData.getPositionPoints();
if (posPoints == null || posPoints.limit() < 1) {
return;
}
final boolean useVertexColors = pathData.getTessellatedColors() != null && isShowTrackValueColor_Outline();
final GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
// Convert stride from number of elements to number of bytes.
gl.glVertexPointer(3, GL2.GL_FLOAT, 4 * pathData.getVertexStride(), 0);
if (dc.isPickingMode()) {
gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
gl.glColorPointer(3, GL2.GL_UNSIGNED_BYTE, 0, pickPositionColors);
} else if (useVertexColors) {
// Apply this path's per-position colors if we're in normal rendering mode (not picking) and this path's
// positionColors is non-null. Convert the stride and offset from number of elements to number of bytes.
gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
gl.glColorPointer(4, GL2.GL_FLOAT, 4 * pathData.getVertexStride(), 4 * pathData.getColorOffset());
}
prepareToDrawPoints(dc);
gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, vboIds[2]);
gl.glDrawElements(GL2.GL_POINTS, posPoints.limit(), GL2.GL_UNSIGNED_INT, 0);
// Restore the previous GL point state.
gl.glPointSize(1f);
gl.glDisable(GL2.GL_POINT_SMOOTH);
// Restore the previous GL color array state.
if (dc.isPickingMode() || useVertexColors) {
gl.glDisableClientState(GL2.GL_COLOR_ARRAY);
}
}
示例13: display
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
// ensure pipeline is clean before doing cl work
gl.glFinish();
computeHeightfield();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
usi.interact(gl);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
gl.glVertexPointer(4, GL2.GL_FLOAT, 0, 0);
// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]);
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL2.GL_POINTS, 0, MESH_SIZE * MESH_SIZE);
// gl.glDrawElements(GL2.GL_TRIANGLES, ib.capacity(), GL2.GL_UNSIGNED_INT, 0);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
// gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
}