本文整理汇总了Java中com.jogamp.opengl.GL2.glVertex2f方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glVertex2f方法的具体用法?Java GL2.glVertex2f怎么用?Java GL2.glVertex2f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glVertex2f方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotateHistogram
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Draw with default width and color
*
* @param gl
* @param width width of annotateHistogram (chip) area in gl pixels
* @param height of annotateHistogram (chip) area in gl pixels
*/
private void annotateHistogram(GL2 gl, int width, int height) { // width and height are of AEchip annotateHistogram size in pixels of chip (not screen pixels)
if (activations == null) {
return;
}
float dx = (float) (width) / (activations.length);
float sy = (float) 0.9f * (height);
// gl.glBegin(GL.GL_LINES);
// gl.glVertex2f(1, 1);
// gl.glVertex2f(width - 1, 1);
// gl.glEnd();
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < activations.length; i++) {
float y = 1 + (sy * activations[i]); // TODO debug hack
float x1 = 1 + (dx * i), x2 = x1 + dx;
gl.glVertex2f(x1, 1);
gl.glVertex2f(x1, y);
gl.glVertex2f(x2, y);
gl.glVertex2f(x2, 1);
}
gl.glEnd();
}
示例2: drawVector
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws an arrow vector using current open gl color
*
* @param gl the opengl context
* @param origX the arrow origin location x
* @param origY the arrow origin location x
* @param headX The x length of arrow
* @param headY the y length of arrow
* @param headlength the length of the arrow tip segments as fraction of entire arrow length, after scaling
* @param scale the scaling used for drawing the arrow
*/
public static void drawVector(GL2 gl, float origX, float origY, float headX, float headY, float headlength, float scale) {
float endx = headX*scale, endy = headY*scale;
float arx = -endx+endy, ary = -endx-endy; // halfway between pointing back to origin
float l = (float)Math.sqrt((arx*arx)+(ary*ary)); // length
arx = (arx/l)*headlength; ary = (ary/l)*headlength; // normalize to headlength
gl.glTranslatef(origX, origY, 0);
gl.glBegin(GL2.GL_LINES);
{
gl.glVertex2f(0,0);
gl.glVertex2f(endx,endy);
// draw arrow (half)
gl.glVertex2f(endx,endy);
gl.glVertex2f(endx+arx, endy+ary);
// other half, 90 degrees
gl.glVertex2f(endx,endy);
gl.glVertex2f(endx+ary, endy-arx);
}
gl.glEnd();
}
示例3: drawHistogram
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public static void drawHistogram(GL2 gl, float[] activations, int width, int height, float lineWidth, Color color) {
if (activations == null) {
return;
}
float[] ca = color.getColorComponents(null);
gl.glPushAttrib(GL2ES3.GL_COLOR | GL.GL_LINE_WIDTH);
gl.glLineWidth(lineWidth);
gl.glColor4fv(ca, 0);
float dx = (float) (width) / (activations.length);
float sy = (float) HISTOGRAM_HEIGHT_FRACTION * (height);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < activations.length; i++) {
float y = 1 + (sy * activations[i]); // TODO debug hack
float x1 = 1 + (dx * i), x2 = x1 + dx;
gl.glVertex2f(x1, 1);
gl.glVertex2f(x1, y);
gl.glVertex2f(x2, y);
gl.glVertex2f(x2, 1);
}
gl.glEnd();
gl.glPopAttrib();
}
示例4: annotateHistogram
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void annotateHistogram (GL2 gl, int width, int height) {
if (this.output == null) {
} else {
float dx = (float) (width)/this.output.length;
float dy = (float) 0.8f * (height);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < this.output.length; i++) {
float tmpOutput = this.output.get(i);
float tmpOutputMax = this.output.max();
float y_end = (float) (1 + (dy*tmpOutput)/tmpOutputMax); // draws the relative activations of the neurons in the layer
float x_start = 1 + (dx * i);
float x_end = x_start + dx;
gl.glVertex2f(x_start, 1);
gl.glVertex2f(x_start, y_end);
gl.glVertex2f(x_end, y_end);
gl.glVertex2f(x_end, 1);
}
gl.glEnd();
}
}
示例5: showActivations
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Annotates the frame with the activations of the softmax layer as a bar
* chart
*
* @param gl
* @param width
* @param height
*/
public void showActivations(GL2 gl, int width, int height) {
if (this.networkOutput == null) {
} else {
float dx = (float) (width) / this.networkOutput.length;
float dy = 0.8f * (height);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < this.networkOutput.length; i++) {
float tmpOutput = this.networkOutput[i];
float tmpOutputMax = RNNfilterExpFeatures.maxValue(this.networkOutput);
float y_end = 1 + ((dy * tmpOutput) / tmpOutputMax); // draws the relative activations of the neurons in
// the layer
float x_start = 1 + (dx * i);
float x_end = x_start + dx;
gl.glVertex2f(x_start, 1);
gl.glVertex2f(x_start, y_end);
gl.glVertex2f(x_end, y_end);
gl.glVertex2f(x_end, 1);
}
gl.glEnd();
}
}
示例6: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
synchronized void draw(GL2 gl, int y) {
int x = 10;
float histBinWidthPix = (float) (chip.getSizeX() - (2 * x)) / histNumBins;
if (proximityDetected) {
gl.glColor3f(1, 0, 0);
} else {
gl.glColor3f(0, 0, 1);
}
gl.glLineWidth(4);
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i < histNumBins; i++) {
float yy = y + (counts[i] * histCountScale);
gl.glVertex2f(x + (i * histBinWidthPix), yy);
gl.glVertex2f(1 + x + (i * histBinWidthPix), yy);
// System.out.print(bins[i]+" ");
}
// System.out.println("");
gl.glEnd();
renderer.begin3DRendering();
String s = String.format("count=%6.1f + %-6.1f mean dt=%6.1f+ %-6.1f ms", meanCount, stdCount, (histBinSizeUs * meanBin) / 1000, (histBinSizeUs * stdBin) / 1000);
final float scale = .2f;
renderer.draw3D(s, x, y - 5, 0, scale);
// Rectangle2D bounds=renderer.getBounds(s);
renderer.end3DRendering();
}
示例7: rect
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void rect(GL2 gl, float x, float y, float w, float h) {
gl.glLineWidth(1f);
gl.glColor3f(1, 1, 1);
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glVertex2f(x, y);
gl.glVertex2f(x + w, y);
gl.glVertex2f(x + w, y + h);
gl.glVertex2f(x, y + h);
gl.glEnd();
}
示例8: arrow
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void arrow(GL2 gl, float x,float y,float ux, float uy){
gl.glColor3f(1,1,1);
gl.glPointSize(5);
gl.glBegin(GL.GL_POINTS);
gl.glVertex3f(x,y,0);
gl.glEnd();
gl.glBegin(GL2.GL_LINES);
float ex=x+vectorLengthScale*MOTION_VECTOR_FACTOR*ux, ey=y+vectorLengthScale*MOTION_VECTOR_FACTOR*uy;
gl.glVertex2f(x,y);
gl.glVertex2f(ex,ey);
gl.glEnd();
}
示例9: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Annotation or drawing method
* @param drawable OpenGL Rendering Object
*/
@Override
public void annotate (GLAutoDrawable drawable) {
if (!isAnnotationEnabled()) {
return;
}
GL2 gl = drawable.getGL().getGL2();
if (gl == null) {
return;
}
// Draw Box around groups
for (int gx=0; gx<numGroupsX; gx++) {
for (int gy=0; gy<numGroupsY; gy++) {
gl.glPushMatrix();
gl.glLineWidth(1f);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glColor3f(1f,0.1f,0.1f);
gl.glVertex2f(xGroupOffset*gx,yGroupOffset*gy);
gl.glVertex2f(xPixels + (xGroupOffset*gx),yGroupOffset*gy);
gl.glVertex2f(xPixels + (xGroupOffset*gx),yPixels + (yGroupOffset*gy));
gl.glVertex2f(xGroupOffset*gx,yPixels + (yGroupOffset*gy));
gl.glEnd();
gl.glPopMatrix();
} // END IF
} // END IF
}
示例10: drawSelection
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawSelection(GL2 gl, Rectangle r, float[] c) {
gl.glPushMatrix();
gl.glColor3fv(c, 0);
gl.glLineWidth(lineWidth);
gl.glTranslatef(-.5f, -.5f, 0);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2f(selection.x, selection.y);
gl.glVertex2f(selection.x + selection.width, selection.y);
gl.glVertex2f(selection.x + selection.width, selection.y + selection.height);
gl.glVertex2f(selection.x, selection.y + selection.height);
gl.glEnd();
gl.glPopMatrix();
}
示例11: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void draw(GLAutoDrawable drawable, GL2 gl, float linewidth) {
// if (getTargetLocation() != null && getTargetLocation().location == null) {
// textRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// textRenderer.draw("Target not visible", chip.getSizeX() / 2, chip.getSizeY() / 2);
// textRenderer.endRendering();
// return;
// }
gl.glPushMatrix();
gl.glTranslatef(location.x, location.y, 0f);
float[] compArray = new float[4];
gl.glColor3fv(targetTypeColors[targetClassID % targetTypeColors.length].getColorComponents(compArray), 0);
// gl.glColor4f(0, 1, 0, .5f);
gl.glLineWidth(linewidth);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2f(-width / 2, -height / 2);
gl.glVertex2f(+width / 2, -height / 2);
gl.glVertex2f(+width / 2, +height / 2);
gl.glVertex2f(-width / 2, +height / 2);
gl.glEnd();
// if (mouseQuad == null) {
// mouseQuad = glu.gluNewQuadric();
// }
// glu.gluQuadricDrawStyle(mouseQuad, GLU.GLU_LINE);
// //glu.gluDisk(mouseQuad, getTargetRadius(), getTargetRadius(), 32, 1);
// int maxDim = Math.max(width, height);
// glu.gluDisk(mouseQuad, maxDim / 2, (maxDim / 2) + 0.1, 32, 1);
//getTargetRadius(), getTargetRadius() + 1, 32, 1);
gl.glPopMatrix();
}
示例12: rect
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void rect(GL2 gl, float x, float y, float w, float h, String txt) {
gl.glPushMatrix();
gl.glTranslatef(-.5f, -.5f, 0);
gl.glLineWidth(2f);
gl.glColor3f(1, 1, 1);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2f(x, y);
gl.glVertex2f(x + w, y);
gl.glVertex2f(x + w, y + h);
gl.glVertex2f(x, y + h);
gl.glEnd();
// label arrays
if (txt != null) {
renderer.begin3DRendering();
renderer.draw3D(txt, x, y, 0, .4f); // x,y,z, scale factor
renderer.end3DRendering();
if(displayIntensity){
exposureRenderer.begin3DRendering();
String frequency = "";
if(frameTime>0){
frequency = "("+((float)1000000/frameTime)+" Hz)";
}
String expC = "";
// if(config.useC.isSet()){
// expC = " ms, exposure 2: "+(float)exposureC/1000;
// }
exposureRenderer.draw3D("exposure 1: "+((float)exposureB/1000)+expC+" ms, frame period: "+((float)frameTime/1000)+" ms "+frequency, x, h, 0, .4f); // x,y,z, scale factor
exposureRenderer.end3DRendering();
}
}
gl.glPopMatrix();
}
示例13: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GLAutoDrawable drawable){
GL2 gl=drawable.getGL().getGL2();
gl.glLineWidth(2.0f);
if(type == 1){
gl.glColor3f(0.9f,0.9f,0.9f);
}else{
gl.glColor3f(0.1f,0.1f,0.1f);
}
//gl.glColor3f(clusterColors[idx][0],clusterColors[idx][1],clusterColors[idx][2]);
gl.glBegin(GL2.GL_LINES);
//System.out.println("Frag "+idx+", Distance: "+getDistance(p1, p2)+", Max: "+minDist);
gl.glVertex2f(line.x1,line.y1);
gl.glVertex2f(line.x2,line.y2);
gl.glEnd();
}
示例14: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws this cluster using OpenGL.
*
* @param drawable area to draw this.
*/
public void draw (GLAutoDrawable drawable){
final float BOX_LINE_WIDTH = 2f; // in chip
final float PATH_POINT_SIZE = 4f;
final float SUPER_POINT_SIZE = 8f;
final float VEL_LINE_WIDTH = 4f;
GL2 gl = drawable.getGL().getGL2();
int x = (int)getLocation().x;
int y = (int)getLocation().y;
// set color and line width of cluster annotation
getColor().getRGBComponents(rgb);
gl.glColor3fv(rgb,0);
gl.glLineWidth(BOX_LINE_WIDTH);
// draw cluster rectangle
drawBox(gl,x,y,(int)maxRadius);
gl.glPointSize(PATH_POINT_SIZE);
ArrayList<ClusterPathPoint> points = getPath();
for ( Point2D.Float p:points ){
gl.glBegin(GL.GL_POINTS);
gl.glVertex2f(p.x,p.y);
gl.glEnd();
}
// now draw velocityPPT vector
if ( showClusterVelocity ){
gl.glLineWidth(VEL_LINE_WIDTH);
gl.glBegin(GL.GL_LINES);
{
gl.glVertex2i(x,y);
gl.glVertex2f(x + (getVelocityPPT().x * VELOCITY_VECTOR_SCALING * velocityVectorScaling),y + (getVelocityPPT().y * VELOCITY_VECTOR_SCALING * velocityVectorScaling));
}
gl.glEnd();
}
// text annoations on clusters, setup
final int font = GLUT.BITMAP_HELVETICA_18;
if(validForOSC){
gl.glColor3f(0,1,0);
}else{
gl.glColor3f(1,1,1);
}
gl.glRasterPos3f(location.x,location.y,0);
// annotate the cluster with hash ID
if ( showClusterNumber ){
chip.getCanvas().getGlut().glutBitmapString(font,String.format("#%d",hashCode()));
}
//annotate the cluster with the velocityPPT in pps
if ( showClusterVelocity ){
Point2D.Float velpps = getVelocityPPS();
chip.getCanvas().getGlut().glutBitmapString(font,String.format("%.0f,%.0f pps",velpps.x,velpps.y));
}
//show superPos
gl.glColor3f(1,0,0);
gl.glPointSize(SUPER_POINT_SIZE);
gl.glBegin(GL.GL_POINTS);
gl.glVertex2f(superPos.x,superPos.y);
gl.glEnd();
}
示例15: displayPixmap
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Displays the pixmap of pixel values.
*
* @param drawable
*/
synchronized private void displayPixmap(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
if (gl == null) {
return;
}
checkGLError(gl, "before pixmap");
final int wi = drawable.getSurfaceWidth(), hi = drawable.getSurfaceHeight();
float scale = 1;
if (fillsVertically) {// tall chip, use chip height
scale = ((float) hi - (2 * borderPixels)) / getSizeY();
} else if (fillsHorizontally) {
scale = ((float) wi - (2 * borderPixels)) / getSizeX();
}
gl.glPixelZoom(scale, scale);
gl.glRasterPos2f(-.5f, -.5f); // to LL corner of chip, but must be inside viewport or else it is ignored, breaks on zoom if (zoom.isZoomEnabled() == false) {
checkPixmapAllocation();
{
try {
pixmap.rewind();
gl.glDrawPixels(sizeX, sizeY, GL.GL_RGB, GL.GL_FLOAT, pixmap);
} catch (IndexOutOfBoundsException e) {
log.warning(e.toString());
}
}
// FloatBuffer minMax=FloatBuffer.allocate(6);
// gl.glGetMinmax(GL.GL_MINMAX, true, GL.GL_RGB, GL.GL_FLOAT, minMax);
// gl.glDisable(GL.GL_MINMAX);
checkGLError(gl, "after rendering image");
// outline frame
gl.glColor4f(0, 0, 1f, 0f);
gl.glLineWidth(1f);
{
gl.glBegin(GL.GL_LINE_LOOP);
final float o = .5f;
final float w = sizeX - 1;
final float h = sizeY - 1;
gl.glVertex2f(-o, -o);
gl.glVertex2f(w + o, -o);
gl.glVertex2f(w + o, h + o);
gl.glVertex2f(-o, h + o);
gl.glEnd();
}
checkGLError(gl, "after rendering frame");
}