本文整理匯總了Java中javax.media.opengl.GL2.glBegin方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glBegin方法的具體用法?Java GL2.glBegin怎麽用?Java GL2.glBegin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glBegin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderSquare
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public static void renderSquare(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.brighter().getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
for (Geometry temp : geometries) {
gl.glLineWidth(temp == selectedGeometry ? renderWidth * 3 : renderWidth);
Coordinate point = new Coordinate(temp.getCoordinate());
point.x = (point.x - context.getX()) / zoomWidth;
point.y = 1 - (point.y - context.getY()) / zoomHeight;
double rectwidth = 0.01;
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
gl.glVertex2d(point.x - rectwidth, point.y + rectwidth);
gl.glVertex2d(point.x + rectwidth, point.y + rectwidth);
gl.glVertex2d(point.x + rectwidth, point.y - rectwidth);
gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
gl.glEnd();
gl.glFlush();
}
}
示例2: renderCross
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public static void renderCross(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.brighter().getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
if(geometries!=null){
for (Geometry temp : geometries) {
gl.glLineWidth(temp == selectedGeometry ? renderWidth * 2 : renderWidth);
Coordinate point = new Coordinate(temp.getCoordinate());
point.x = (point.x - context.getX()) / zoomWidth;
point.y = 1 - (point.y - context.getY()) / zoomHeight;
double rectwidth = 0.01;
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(point.x - rectwidth, point.y);
gl.glVertex2d(point.x + rectwidth, point.y);
gl.glEnd();
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(point.x, point.y - rectwidth);
gl.glVertex2d(point.x, point.y + rectwidth);
gl.glEnd();
gl.glFlush();
}
}
}
示例3: renderTriangle
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public static void renderTriangle(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float renderWidth,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.brighter().getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
if(geometries!=null){
for (Geometry temp : geometries) {
gl.glLineWidth(temp == selectedGeometry ? renderWidth * 2 : renderWidth);
Coordinate point = new Coordinate(temp.getCoordinate());
point.x = (point.x - context.getX()) / zoomWidth;
point.y = 1 - (point.y - context.getY()) / zoomHeight;
double rectwidth = 0.01;
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
gl.glVertex2d(point.x, point.y + rectwidth);
gl.glVertex2d(point.x + rectwidth, point.y - rectwidth);
gl.glVertex2d(point.x - rectwidth, point.y - rectwidth);
gl.glEnd();
gl.glFlush();
}
}
}
示例4: renderCircle
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public static void renderCircle(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,Geometry selectedGeometry,float size,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.brighter().getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
gl.glBegin(GL.GL_POINTS);
for (int ii=0;ii<geometries.size();ii++) {
Geometry temp =geometries.get(ii);
gl.glLineWidth(temp == selectedGeometry ? size * 2 : size);
gl.glPointSize(temp == selectedGeometry ? size * 2 : size);
Coordinate point = temp.getCoordinate();
double dx=(point.x - context.getX()) / zoomWidth;
double dy=1 - (point.y - context.getY()) / zoomHeight;
for (int i=0; i < 360; i++){
//double angle = 2 * Math.PI * i / 360;
double xx = dx+Math.sin(i)*0.005;
double yy = dy+Math.cos(i)*0.005;
gl.glVertex2d(xx,yy);
}
}
gl.glEnd();
gl.glFlush();
}
示例5: drawPoly
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param gl
* @param cs
* @param width
* @param height
* @param x
* @param y
*/
public static void drawPoly(OpenGLContext context,Coordinate[] cs,float width,float height,int x,int y,float rwidth,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
gl.glLineWidth(rwidth);
gl.glBegin(GL.GL_LINE_STRIP);
// System.out.println("----------------------------------");
for (int p = 0; p < cs.length; p++) {
double vx=(cs[p].x - x) / width;
double vy=1 - (cs[p].y - y) / height;
// System.out.println(vx+" "+vy+",");
gl.glVertex2d(vx,vy);
}
// System.out.println("----------------------------------");
//close polygon
Coordinate point = cs[0];
gl.glVertex2d((point.x - x) / width, 1 - (point.y - y) / height);
gl.glEnd();
gl.glFlush();
}
示例6: drawPoly
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param gl
* @param cs
* @param width
* @param height
* @param x
* @param y
*/
protected void drawPoly(GL2 gl,Coordinate[] cs,float width,float height,int x,int y,float rwidth){
gl.glLineWidth(rwidth);
gl.glBegin(GL.GL_LINE_STRIP);
for (int p = 0; p < cs.length; p++) {
double vx=(cs[p].x - x) / width;
double vy=1 - (cs[p].y - y) / height;
gl.glVertex2d(vx,vy);
}
//close polygon
Coordinate point = cs[0];
gl.glVertex2d((point.x - x) / width, 1 - (point.y - y) / height);
gl.glEnd();
gl.glFlush();
}
示例7: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(OpenGLContext context) {
if (initPosition == null) {
return;
}
int x = context.getX(), y = context.getY();
float zoom = context.getZoom(), width = context.getWidth() * zoom, height = context.getHeight() * zoom;
GL2 gl = context.getGL().getGL2();
gl.glLineWidth(1);
float[] c = Color.GREEN.getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
gl.glBegin(GL.GL_LINE_STRIP);
gl.glVertex2d((initPosition.x - x) / width, 1 - (initPosition.y - y) / height);
if (endPosition == null) {
gl.glVertex2d((imagePosition.x - x) / width, 1 - (imagePosition.y - y) / height);
} else {
gl.glVertex2d((endPosition.x - x) / width, 1 - (endPosition.y - y) / height);
}
gl.glEnd();
gl.glFlush();
}
示例8: drawLine
import javax.media.opengl.GL2; //導入方法依賴的package包/類
protected void drawLine(DrawContext dc, Vec4 screenPoint, Vec4 projectedPoint, DetailedOrderedIcon uIcon) {
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
gl.glLoadIdentity();
double opacity = uIcon.getOpacity();
opacity = Math.min(opacity, .5f);
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glColor4d(.2,.2,.2, opacity);
gl.glBegin(GL.GL_LINES);
gl.glVertex2d(screenPoint.x, screenPoint.y);
gl.glVertex2d(projectedPoint.x, projectedPoint.y);
gl.glEnd();
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glColor4f(1,1,1,1);
}
示例9: glRender
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void glRender(GLRenderContext glc)
{
GL2 gl2 = glc.gl2;
gl2.glBegin(GL2.GL_QUADS);
{
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 1);
gl2.glVertex3f(left, up,0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 0);
gl2.glVertex3f(left, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 0);
gl2.glVertex3f(right, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 1);
gl2.glVertex3f(right, up, 0);
}
gl2.glEnd();
}
示例10: drawTransform
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawTransform(Transform xf) {
GL2 gl = panel.getGL().getGL2();
getWorldToScreenToOut(xf.p, temp);
temp2.setZero();
float k_axisScale = 0.4f;
gl.glBegin(GL2.GL_LINES);
gl.glColor3f(1, 0, 0);
temp2.x = xf.p.x + k_axisScale * xf.q.c;
temp2.y = xf.p.y + k_axisScale * xf.q.s;
getWorldToScreenToOut(temp2, temp2);
gl.glVertex2f(temp.x, temp.y);
gl.glVertex2f(temp2.x, temp2.y);
gl.glColor3f(0, 1, 0);
temp2.x = xf.p.x + -k_axisScale * xf.q.s;
temp2.y = xf.p.y + k_axisScale * xf.q.c;
getWorldToScreenToOut(temp2, temp2);
gl.glVertex2f(temp.x, temp.y);
gl.glVertex2f(temp2.x, temp2.y);
gl.glEnd();
}
示例11: debugRender
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Render a debugging hint for the arcball tool.
*
* @param gl GL class for rendering-
*/
@SuppressWarnings("unused")
public void debugRender(GL2 gl) {
if (!DEBUG || (startcamera == null)) {
return;
}
gl.glLineWidth(3f);
gl.glColor4f(1.f, 0.f, 0.f, .66f);
gl.glBegin(GL.GL_LINES);
gl.glVertex3f(0.f, 0.f, 0.f);
double rot = startangle - startcamera.getRotationZ();
gl.glVertex3f((float) FastMath.cos(rot) * 4.f, (float) -FastMath.sin(rot) * 4.f, 0.f);
gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 0.f);
gl.glVertex3f((float) FastMath.cos(rot) * 1.f, (float) -FastMath.sin(rot) * 1.f, 1.f);
gl.glEnd();
}
示例12: renderContents
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
void renderContents(GL2 gl) {
// Get text bounds.
Rectangle2D bounds = renderer.getBounds(getMessage());
// Render message background:
final float bx1 = .45f * (float) (width - bounds.getWidth());
final float bx2 = .55f * (float) (width + bounds.getWidth());
final float by1 = .45f * (float) (height - bounds.getHeight());
final float by2 = .55f * (float) (height + bounds.getHeight());
gl.glBegin(GL2.GL_QUADS);
gl.glColor4f(0f, 0f, 0f, .75f);
gl.glVertex2f(bx1, by1);
gl.glVertex2f(bx1, by2);
gl.glVertex2f(bx2, by2);
gl.glVertex2f(bx2, by1);
gl.glEnd();
// Render message
renderer.beginRendering(width, height);
renderer.setColor(1f, 1f, 1f, 1f);
renderer.setColor(1f, 1f, 1f, 1f);
renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1);
renderer.endRendering();
}
示例13: drawCircle
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
System.err.println("drawCircle: "+center +", "+radius+", "+color);
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1);
for (int i = 0; i < NUM_CIRCLE_POINTS; i++) {
gl.glVertex3f(x + cx, y + cy, 0);
// apply the rotation matrix
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
gl.glPopMatrix();
}
示例14: paint
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void paint(){
// Compute maximum width of text we're going to draw
TextRenderer textRenderer = new TextRenderer(new Font(Font.SERIF,0 , 18));
int maxTextWidth = (int) textRenderer.getBounds(this.text).getWidth();
maxTextWidth = Math.min(maxTextWidth+10,size.width);
GL2 gl=glContext.getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glPolygonMode (GL2.GL_FRONT, GL2.GL_LINE_STRIP);
gl.glColor3f(0.5f, 0.5f, 0.5f);
gl.glBegin(GL2.GL_LINE_STRIP);
gl.glVertex2i( this.posx,this.posy); //x1,y1
gl.glVertex2i( this.posx+maxTextWidth,this.posy ); //x2,y1
gl.glVertex2i( this.posx+maxTextWidth,this.posy +size.height); //x2,y2
gl.glVertex2i( this.posx,this.posy+size.height); //x1,y2
gl.glVertex2i( this.posx,this.posy);
gl.glEnd( );
GLDrawable draw=gl.getGL().getContext().getGLDrawable();
textRenderer.beginRendering(draw.getWidth(),draw.getHeight());
textRenderer.setColor(Color.WHITE);
textRenderer.setSmoothing(true);
textRenderer.draw(this.text,(int)posx,(int)posy+5); //text and position
textRenderer.flush();
textRenderer.endRendering();
gl.glFlush();
}
示例15: renderPolygons
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public static void renderPolygons(OpenGLContext context,float zoomWidth,float zoomHeight,List<Geometry>geometries,float size,Color color){
GL2 gl = context.getGL().getGL2();
float[] c = color.brighter().getColorComponents(null);
gl.glColor3f(c[0], c[1], c[2]);
gl.glPointSize(size);
gl.glBegin(GL.GL_POINTS);
for (Geometry temp : geometries) {
for (Coordinate point : temp.getCoordinates()) {
gl.glVertex2d((point.x - context.getX()) / zoomWidth, 1 - (point.y - context.getY()) / zoomHeight);
}
}
gl.glEnd();
gl.glFlush();
}