本文整理匯總了Java中javax.media.opengl.GL2.glLineWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glLineWidth方法的具體用法?Java GL2.glLineWidth怎麽用?Java GL2.glLineWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glLineWidth方法的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: 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();
}
示例9: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(OpenGLContext context) {
GL2 gl = context.getGL().getGL2();
gl.glColor3f(1, 1, 1);
gl.glLineWidth(1.0f);
gl.glBegin(GL.GL_LINE_LOOP);
float zoom=context.getZoom();
gl.glVertex2f(context.getX() / (1f*width),1-context.getY() / (1f*height));
gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- context.getY() / (1f*height));
gl.glVertex2f((context.getX() + zoom*context.getWidth()) / width,1- (context.getY() + zoom*context.getHeight()) / height);
gl.glVertex2f(context.getX() / (1f*width),1-(context.getY() + zoom*context.getHeight()) / height);
gl.glEnd();
gl.glFlush();
}
示例10: drawAxis
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawAxis( final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
gl.glLineWidth( (float)config.getRenderingConfig().getThickness() );
gl.glColor3f( config.getRenderingConfig().getColour()[0],
config.getRenderingConfig().getColour()[1],
config.getRenderingConfig().getColour()[2] );
final float n1 = this.calculatePosition( config.getMinValue() ).floatValue();
final float n2 = this.calculatePosition( config.getMaxValue() ).floatValue();
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( n1, zero, zero );
gl.glVertex3f( n2, zero, zero );
}
gl.glEnd();
gl.glPopMatrix();
}
示例11: drawMajorTick
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMajorTick( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
gl.glLineWidth( (float)config.getRenderingConfig().getMajorTickThickness() );
gl.glColor3f( config.getRenderingConfig().getMajorTickColour()[0],
config.getRenderingConfig().getMajorTickColour()[1],
config.getRenderingConfig().getMajorTickColour()[2] );
final float l = (float)config.getRenderingConfig().getMajorTickLength();
final float l2 = -l;
final float ll = this.calculatePosition( location ).floatValue();
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, l, zero );
gl.glVertex3f( ll, l2, zero );
}
gl.glEnd();
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, l );
gl.glVertex3f( ll, zero, l2 );
}
gl.glEnd();
gl.glPopMatrix();
}
示例12: drawMajorTickGridline
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMajorTickGridline( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
gl.glLineWidth( (float)config.getRenderingConfig().getMajorGridThickness() );
gl.glColor3f( config.getRenderingConfig().getMajorGridColour()[0],
config.getRenderingConfig().getMajorGridColour()[1],
config.getRenderingConfig().getMajorGridColour()[2] );
final float ll = this.calculatePosition( location ).floatValue();
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, zero );
gl.glVertex3f( ll, 1, zero );
}
gl.glEnd();
gl.glBegin( GL.GL_LINE_STRIP );
{
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, zero, zero );
gl.glVertex3f( ll, zero, 1*this.gridDirection );
}
gl.glEnd();
gl.glPopMatrix();
}
示例13: drawMinorTick
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void drawMinorTick( final double location, final AxisConfig<float[]> config )
{
final GL2 gl = this.glad.getGL().getGL2();
gl.glPushMatrix();
this.orient( gl );
final float zero = 0.001f;
gl.glBegin( GL.GL_LINE_STRIP );
{
// gl.glEnable( GL2.GL_LINE_STIPPLE );
// gl.glLineStipple( 2, (short) 0x00FF );
gl.glLineWidth( (float)config.getRenderingConfig().getMinorTickThickness() );
gl.glColor3f( config.getRenderingConfig().getMinorTickColour()[0],
config.getRenderingConfig().getMinorTickColour()[1],
config.getRenderingConfig().getMinorTickColour()[2] );
final float l = (float)config.getRenderingConfig().getMinorTickLength();
final float l2 = -l;
final float ll = this.calculatePosition( location ).floatValue();
// We draw in the x axis, so the orientation has to be set appropriately
gl.glVertex3f( ll, l, zero );
gl.glVertex3f( ll, l2, zero );
}
gl.glEnd();
gl.glPopMatrix();
}
示例14: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void render(final DrawContext dc) {
final GL2 gl = dc.getGL().getGL2();
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glDepthFunc(GL.GL_LEQUAL);
gl.glDepthMask(true);
// gl.glDepthMask(false);
// gl.glDepthRange(0.0, 1.0);
try {
dc.getView().pushReferenceCenter(dc, _placePoint); // draw relative to the place point
// Pull the arrow triangles forward just a bit to ensure they show over the terrain.
dc.pushProjectionOffest(0.995);
// final Color color = this.getAttributes().getTextColor();
// final Color color = Color.RED;
final Color color = _lineColor;
gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 0xff);
gl.glLineWidth(1.0f);
// gl.glEnable(GL.GL_LINE_SMOOTH);
// gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
// gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE);
gl.glBegin(GL2.GL_LINE_STRIP);
{
gl.glVertex3d(Vec4.ZERO.x, Vec4.ZERO.y, Vec4.ZERO.z);
gl.glVertex3d(//
_terrainPoint.x - _placePoint.x,
_terrainPoint.y - _placePoint.y,
_terrainPoint.z - _placePoint.z);
}
gl.glEnd();
} finally {
dc.popProjectionOffest();
dc.getView().popReferenceCenter(dc);
}
}
示例15: drawLine_Line
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawLine_Line(final DrawContext dc, final Vec4 annotationPoint) {
// Compute a terrain point if needed.
Vec4 terrainPoint = null;
if (this.altitudeMode != WorldWind.CLAMP_TO_GROUND) {
terrainPoint = dc.computeTerrainPoint(position.getLatitude(), position.getLongitude(), 0);
}
if (terrainPoint == null) {
return;
}
final GL2 gl = dc.getGL().getGL2();
if ((!dc.isDeepPickingEnabled())) {
gl.glEnable(GL.GL_DEPTH_TEST);
}
gl.glDepthFunc(GL.GL_LEQUAL);
// gl.glDepthFunc(GL.GL_GREATER); // draw the part that is behind an intersecting surface
gl.glDepthMask(true);
// gl.glDepthMask(false);
gl.glDepthRange(0.0, 1.0);
try {
dc.getView().pushReferenceCenter(dc, annotationPoint); // draw relative to the place point
//
// !!! THIS CAUSES A stack overflow1283 because there are only 4 available stack entries !!!
//
//
// // Pull the arrow triangles forward just a bit to ensure they show over the terrain.
// dc.pushProjectionOffest(0.95);
final Color color = this.getAttributes().getTextColor();
gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 0xff);
gl.glLineWidth(1.5f);
gl.glHint(GL.GL_LINE_SMOOTH_HINT, Polyline.ANTIALIAS_FASTEST);
gl.glEnable(GL.GL_LINE_SMOOTH);
// System.out.println((UI.timeStampNano() + " [" + getClass().getSimpleName() + "] ")
// + ("\t" + dc.getFrameTimeStamp()));
// GLLogger.logDepth(dc, getClass().getSimpleName());
// TODO remove SYSTEM.OUT.PRINTLN
gl.glBegin(GL2.GL_LINE_STRIP);
{
gl.glVertex3d(Vec4.ZERO.x, Vec4.ZERO.y, Vec4.ZERO.z);
gl.glVertex3d(//
terrainPoint.x - annotationPoint.x,
terrainPoint.y - annotationPoint.y,
terrainPoint.z - annotationPoint.z);
}
gl.glEnd();
// GLLogger.logDepth(dc, "trackpt");
} finally {
// dc.popProjectionOffest();
dc.getView().popReferenceCenter(dc);
}
}