Java Code Examples for com.jogamp.opengl.GL2#glPopName()
The following examples show how to use
com.jogamp.opengl.GL2#glPopName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Spidee.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void render(GL2 gl2) { super.render(gl2); gl2.glPushName(getPickName()); gl2.glPushMatrix(); Vector3d p = getPosition(); gl2.glTranslated(p.x, p.y, p.z); Draw_Head(gl2); Draw_Legs(gl2); Draw_Body(gl2); gl2.glPopMatrix(); gl2.glPopName(); }
Example 2
Source File: DrawingPlugin.java From depan with Apache License 2.0 | 4 votes |
/** * Draw a node. */ @Override public boolean apply(NodeRenderingProperty property) { if (!property.isVisible) { return false; } GL2 gl = scene.gl; gl.glPushMatrix(); gl.glPushName(property.shapeId); // move property.shape.setTranslation(property.positionX * GLConstants.FACTOR, property.positionY * GLConstants.FACTOR, 0f); // scale property.shape.setScale(property.size, property.size * property.ratio, property.size); // fill the shape if (property.isFilled) { gl.glColor4f(property.fillColor.getRed() / 255f, property.fillColor.getGreen() / 255f, property.fillColor.getBlue() / 255f, property.fillColor.getAlpha() / 255f); property.shape.fill(gl); } // draw the border if (property.strokeWidth > 0.0f) { gl.glLineWidth(property.strokeWidth); gl.glColor4f(property.strokeColor.getRed() / 255f, property.strokeColor.getGreen() / 255f, property.strokeColor.getBlue() / 255f, property.strokeColor.getAlpha() / 255f); property.shape.draw(gl); } Rectangle2D bounds = property.shape.getDrawingBounds(); updateDrawingBounds(bounds); // we don't want the label to be clickable, // so we just pop the name before drawing it. gl.glPopName(); // draw the label if (property.isTextVisible) { paintLabel(property); } // draw a little "+" on the top right corner of the node if it has // nodes collapsed under. if (property.hasCollapsedNodeUnder) { double centerX = property.positionX+property.size/2; double centerY = property.positionY+property.size/2; double halfWidth = 0.7; double halfHeight = 4; gl.glBegin(GL2.GL_QUADS); gl.glColor4f(1f, 1f, 1f, 0.5f); // vertical line gl.glVertex2d(centerX - halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY - halfHeight); gl.glVertex2d(centerX - halfWidth, centerY - halfHeight); // left part of horizontal line gl.glVertex2d(centerX - halfHeight, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY - halfWidth); gl.glVertex2d(centerX - halfHeight, centerY - halfWidth); // right part. gl.glVertex2d(centerX + halfWidth, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY - halfWidth); gl.glVertex2d(centerX + halfWidth, centerY - halfWidth); gl.glVertex3d(0, 0, 0); gl.glEnd(); } gl.glPopMatrix(); return true; }
Example 3
Source File: RobotOverlord.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
/** * Use glRenderMode(GL_SELECT) to ray pick the item under the cursor. * https://github.com/sgothel/jogl-demos/blob/master/src/demos/misc/Picking.java * http://web.engr.oregonstate.edu/~mjb/cs553/Handouts/Picking/picking.pdf * @param gl2 the openGL render context */ protected int findItemUnderCursor(GL2 gl2) { // select buffer IntBuffer pickBuffer = Buffers.newDirectIntBuffer(SELECT_BUFFER_SIZE); // set up the buffer that will hold the names found under the cursor in furthest to closest. gl2.glSelectBuffer(SELECT_BUFFER_SIZE, pickBuffer); // change the render mode gl2.glRenderMode( GL2.GL_SELECT ); // wipe the select buffer gl2.glInitNames(); viewport.renderPick(gl2,pickX,pickY); gl2.glPushName(0); // render in selection mode, without advancing time in the simulation. scene.render(gl2); gl2.glPopName(); gl2.glFlush(); // get the picking results and return the render mode to the default int hits = gl2.glRenderMode( GL2.GL_RENDER ); boolean verbose=false; if(verbose) Log.message("\n"+hits+" PICKS @ "+pickX+","+pickY); float z1,z2; float zMinBest = Float.MAX_VALUE; int i, j, index=0, nameCount, pickName=0, bestPickName=0; for(i=0;i<hits;++i) { nameCount=pickBuffer.get(index++); z1 = (float) (pickBuffer.get(index++) & 0xffffffffL) / (float)0x7fffffff; z2 = (float) (pickBuffer.get(index++) & 0xffffffffL) / (float)0x7fffffff; if(verbose) { Log.message(" names="+nameCount+" zMin="+z1+" zMax="+z2); } String add=": "; for(j=0;j<nameCount;++j) { pickName = pickBuffer.get(index++); if(verbose) { Log.message(add+pickName); add=", "; } } if(nameCount>0) { //pickName = pickBuffer.get(index++); if(verbose) Log.message(add+" BEST="+pickName); if(zMinBest > z1) { zMinBest = z1; bestPickName = pickName; } } } return bestPickName; }