本文整理汇总了Java中com.jogamp.opengl.GL2.glBegin方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glBegin方法的具体用法?Java GL2.glBegin怎么用?Java GL2.glBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glBegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawMouseJoint
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders a MouseJoint to the given graphics object.
*
* @param gl the OpenGL graphics files
* @param joint the joint
* @param invdt the inverse of the delta time of the last world step
*/
public static final void drawMouseJoint(GL2 gl, PinJoint joint, double invdt) {
// set the color
gl.glColor4f(0.0f, 0.0f, 0.0f, 0.8f);
// draw the anchor point
Vector2 anchor = joint.getAnchor2();
RenderUtilities.fillRectangleFromCenter(gl, anchor.x, anchor.y, 0.05, 0.05);
// draw the target point
Vector2 target = joint.getTarget();
RenderUtilities.fillRectangleFromCenter(gl, target.x, target.y, 0.05, 0.05);
// draw a line connecting them
// make the line color a function of stress (black to red)
// getProperty the inverse delta time
double maxForce = joint.getMaximumForce();
double force = joint.getReactionForce(invdt).getMagnitude();
double red = force / maxForce;
red *= 1.10;
red = Interval.clamp(red, 0.0, 1.0);
// set the color
gl.glColor4f((float) red, 0.0f, 0.0f, 0.8f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(anchor.x, anchor.y);
gl.glVertex2d(target.x, target.y);
gl.glEnd();
}
示例2: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
if (!isFilterEnabled()) {
return;
}
final float LINE_WIDTH = 5f; // in pixels
GL2 gl = drawable.getGL().getGL2(); // when we getString this we are already set up with scale 1=1 pixel, at LL corner
gl.glLineWidth(LINE_WIDTH);
double thetaRad = getThetaRad();
double cosTheta = Math.cos(thetaRad);
double sinTheta = Math.sin(thetaRad);
gl.glColor3f(0, 0, 1);
gl.glBegin(GL.GL_LINES);
if ((thetaRad > (Math.PI / 4)) && (thetaRad < ((3 * Math.PI) / 4))) {
gl.glVertex2d(0, yFromX(0, cosTheta, sinTheta));
gl.glVertex2d(sx2 * 2, yFromX(sx2 * 2, cosTheta, sinTheta));
} else {
gl.glVertex2d(xFromY(0, cosTheta, sinTheta), 0);
gl.glVertex2d(xFromY(sy2 * 2, cosTheta, sinTheta), sy2 * 2);
}
gl.glEnd();
}
示例3: drawRectangleFromCenter
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Draws an outline of a rectangle from the center using the given height and width.
*
* @param gl the OpenGL files
* @param cx the x coordinate of the center
* @param cy the y coordinate of the center
* @param w the width
* @param h the height
* @param points true if points should be drawn
*/
public static final void drawRectangleFromCenter(GL2 gl, double cx, double cy, double w, double h, boolean points) {
double w2 = w * 0.5;
double h2 = h * 0.5;
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2d(cx - w2, cy + h2);
gl.glVertex2d(cx + w2, cy + h2);
gl.glVertex2d(cx + w2, cy - h2);
gl.glVertex2d(cx - w2, cy - h2);
gl.glEnd();
if (points) {
gl.glBegin(GL.GL_POINTS);
gl.glVertex2d(cx - w2, cy + h2);
gl.glVertex2d(cx + w2, cy + h2);
gl.glVertex2d(cx + w2, cy - h2);
gl.glVertex2d(cx - w2, cy - h2);
gl.glEnd();
}
}
示例4: drawOsculatingCircle
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws the osculating circle of the track at the current car position */
private void drawOsculatingCircle(GL2 gl, Point2D p, double radius, Point2D center) {
radius = Math.abs(radius);
gl.glLineWidth(1.0f);
// Draw line to connect center of circle and car
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(p.getX(), p.getY());
gl.glVertex2d(center.getX(), center.getY());
gl.glEnd();
// Draw circle
gl.glColor3f(1.0f, 0.0f, 1.0f);
gl.glBegin(GL.GL_LINE_LOOP);
for (int i=0; i<60; i++) {
gl.glVertex2d(center.getX()+(radius*Math.cos((6.0*i*Math.PI)/180.0)),
center.getY()+(radius*Math.sin((6.0*i*Math.PI)/180.0)));
}
gl.glEnd();
// gl.glLoadIdentity();
}
示例5: drawRopeJoint
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Renders a RopeJoint to the given graphics object.
*
* @param gl the OpenGL graphics files
* @param joint the joint
*/
public static final void drawRopeJoint(GL2 gl, RopeJoint joint) {
Vector2 v1 = joint.getAnchor1();
Vector2 v2 = joint.getAnchor2();
// set the color to be mostly transparent
gl.glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
// emulate a line stroke of arbitrary width without cap/join
// getProperty the tangent vector
Vector2 t = v1.to(v2);
t.normalize();
t.left();
t.multiply(0.05);
// save the original stroke
gl.glBegin(GL2.GL_QUADS);
gl.glVertex2d(v1.x - t.x, v1.y - t.y);
gl.glVertex2d(v1.x + t.x, v1.y + t.y);
gl.glVertex2d(v2.x + t.x, v2.y + t.y);
gl.glVertex2d(v2.x - t.x, v2.y - t.y);
gl.glEnd();
}
示例6: drawRay
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawRay(GL2 gl, Ray ray) {
float axisSize = 50;
Vector3 v = new Vector3(ray.direction);
v.scl(axisSize);
//Draw Camera Axis
gl.glColor3d(0.0, 0.0, 1.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(view.getX(), 1, view.getZ());
gl.glVertex3d(view.getX()+v.x, view.getY()+v.y, view.getZ()+v.z);
gl.glEnd();
}
示例7: 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();
}
示例8: render
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void render(GL2 gl)
{
if(pos == null || v == null)
return;
gl.glColor3d(Shoot.r.nextDouble(), Shoot.r.nextDouble(), Shoot.r.nextDouble());
gl.glBegin(GL2.GL_LINES);
gl.glVertex3d(pos.x, pos.y, 0);
Vector pos2 = pos.add(v);
gl.glVertex3d(pos2.x, pos2.y, 0);
gl.glEnd();
}
示例9: render
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void render(GL2 gl)
{
gl.glColor3d(Math.random()*0.25 +0.75, Math.random()*0.75, 0);
gl.glBegin(GL2.GL_LINES);
gl.glNormal3d(0, 0, 1);
gl.glVertex3d(pos.x, pos.y, 0);
Vector pos2 = pos.add(v);
gl.glVertex3d(pos2.x, pos2.y, 0);
gl.glEnd();
}
示例10: drawRay
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public static void drawRay(GL2 gl, Ray ray, FlyView view, float size) {
Vector3 v = new Vector3(ray.direction);
v.scl(size);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(view.getX(), view.getY()-0.1, view.getZ());
gl.glVertex3d(view.getX()+v.x, view.getY()+v.y, view.getZ()+v.z);
gl.glEnd();
}
示例11: fillRectangleFromCenter
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* Fills the rectangle from the center using the given height and width.
*
* @param gl the OpenGL files
* @param cx the x coordinate of the center
* @param cy the y coordinate of the center
* @param w the width
* @param h the height
*/
public static final void fillRectangleFromCenter(GL2 gl, double cx, double cy, double w, double h) {
double w2 = w * 0.5;
double h2 = h * 0.5;
gl.glBegin(GL2.GL_QUADS);
gl.glVertex2d(cx - w2, cy + h2);
gl.glVertex2d(cx + w2, cy + h2);
gl.glVertex2d(cx + w2, cy - h2);
gl.glVertex2d(cx - w2, cy - h2);
gl.glEnd();
}
示例12: drawAxis
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawAxis(GL2 gl) {
double axisSize = 100;
//Draw Axis
gl.glLineWidth(2.5f);
//Draw X Axis
gl.glColor3d(1.0, 0.0, 0.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(axisSize, 0, 0);
gl.glEnd();
//Draw Y Axis
gl.glColor3d(0.0, 1.0, 0.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(0, axisSize, 0);
gl.glEnd();
//Draw Z Axis
gl.glColor3d(0.0, 0.0, 1.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(0, 0, axisSize);
gl.glEnd();
}
示例13: drawAxis
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void drawAxis(GL2 gl){
double axisSize = 100;
//Draw Axis
gl.glLineWidth(2.5f);
//Draw X Axis
gl.glColor3d(1.0, 0.0, 0.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(axisSize, 0, 0);
gl.glEnd();
//Draw Y Axis
gl.glColor3d(0.0, 1.0, 0.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(0, axisSize, 0);
gl.glEnd();
//Draw Z Axis
gl.glColor3d(0.0, 0.0, 1.0);
gl.glBegin(GL.GL_LINES);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(0, 0, axisSize);
gl.glEnd();
}
示例14: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Called after events are rendered. Here we just render something to show the mean location.
*
* @param drawable the open GL surface.
*/
@Override
public void annotate(GLAutoDrawable drawable) { // called after events are rendered
GL2 gl = drawable.getGL().getGL2(); // get the openGL context
gl.glColor4f(1.0f, 1.0f, 0.0f, 0.1f); // choose RGB color and alpha<1 so we can see through the square
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2f(xmean - xstd, ymean - ystd);
gl.glVertex2f(xmean + xstd, ymean - ystd);
gl.glVertex2f(xmean + xstd, ymean + ystd);
gl.glVertex2f(xmean - xstd, ymean + ystd);
gl.glVertex2f(xmean - xstd, ymean - ystd);
gl.glEnd();
//gl.glRectf(xmean - xstd, ymean - ystd, xmean + xstd, ymean + ystd); // draw a little rectangle over the mean location
}
示例15: 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
}