当前位置: 首页>>代码示例>>Java>>正文


Java GL类代码示例

本文整理汇总了Java中com.jogamp.opengl.GL的典型用法代码示例。如果您正苦于以下问题:Java GL类的具体用法?Java GL怎么用?Java GL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GL类属于com.jogamp.opengl包,在下文中一共展示了GL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void init(GLAutoDrawable drawable) {

	System.out.println("init");

	GL2 gl = getGL().getGL2();

	gl.setSwapInterval(1);
	gl.glShadeModel(GLLightingFunc.GL_FLAT);

	gl.glClearColor(0, 0, 0, 0f);
	gl.glClear(GL.GL_COLOR_BUFFER_BIT);
	gl.glLoadIdentity();

	gl.glRasterPos3f(0, 0, 0);
	gl.glColor3f(1, 1, 1);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:RaceDisplay.java

示例2: init

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void init(GLAutoDrawable drawable) {
    context = drawable.getContext();
    
    GL3 gl = drawable.getGL().getGL3();
    gl.setSwapInterval(0);
    gl.glEnable(GL.GL_DEPTH_TEST);
    
    log.info("GL Vendor: " + gl.glGetString(GL.GL_VENDOR));
    log.info("GL Renderer: " + gl.glGetString(GL.GL_RENDERER));
    log.info("GL Version: " + gl.glGetString(GL.GL_VERSION));
    log.info("GLSL Version: " + gl.glGetString(GL2.GL_SHADING_LANGUAGE_VERSION));
    
    log.debug("Changed context: " + context.getGLVersion());
    ogl.setOgl(gl); 
    
    synchronized (contextWait) {
        contextWait.notify(); 
    }
}
 
开发者ID:HuskyGameDev,项目名称:2017-TeamEngine,代码行数:21,代码来源:Jogl3Window.java

示例3: display

import com.jogamp.opengl.GL; //导入依赖的package包/类
/** Called when the canvas is updated. To update the display, call either
 * <code>repaint()</code> or <code>display()</code>.
 * @param drawable the Open GL context.
 */
@Override
public synchronized void display(GLAutoDrawable drawable) {

	GL2 gl = getGL().getGL2();
	if (reshapePending) {
		reshapePending = false;
		reshape(drawable, 0, 0, getWidth(), getHeight());
	}
	try {
		gl.glClear(GL.GL_COLOR_BUFFER_BIT);
		displayPixmap(drawable);
		drawText(gl);
		gl.glFlush();
	} catch (GLException e) {
		log.warning(e.toString());
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:ImageDisplay.java

示例4: checkGLError

import com.jogamp.opengl.GL; //导入依赖的package包/类
/** Utility method to check for GL errors. Prints stacked up errors up to a limit.
   @param g the GL context
   @param glu the GLU used to obtain the error strings
   @param msg an error message to log to e.g., show the context
 */
private void checkGLError(GL2 g, String msg) {
	int error = g.glGetError();
	int nerrors = 3;
	while ((error != GL.GL_NO_ERROR) && (nerrors-- != 0)) {
		StackTraceElement[] trace = Thread.currentThread().getStackTrace();
		if (trace.length > 1) {
			String className = trace[2].getClassName();
			String methodName = trace[2].getMethodName();
			int lineNumber = trace[2].getLineNumber();
			log.warning("GL error number " + error + " " + glu.gluErrorString(error) + " : " + msg + " at " + className + "." + methodName + " (line " + lineNumber + ")");
		} else {
			log.warning("GL error number " + error + " " + glu.gluErrorString(error) + " : " + msg);
		}
		error = g.glGetError();
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:ImageDisplay.java

示例5: annotate

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void annotate(final GLAutoDrawable drawable) {
	if (!showHotPixels) {
		return;
	}
	final GL2 gl = drawable.getGL().getGL2();
	try {
		gl.glEnable(GL.GL_BLEND);
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
		gl.glBlendEquation(GL.GL_FUNC_ADD);
	}
	catch (final GLException e) {
		e.printStackTrace();
		showHotPixels = false;
	}
	gl.glColor4f(.1f, .1f, 1f, .25f);
	gl.glLineWidth(1f);
	for (final HotPixel p : hotPixelSet) {
		gl.glRectf(p.x - 1, p.y - 1, p.x + 2, p.y + 2);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:HotPixelFilter.java

示例6: drawBox

import com.jogamp.opengl.GL; //导入依赖的package包/类
public static void drawBox(GL2 gl, float centerX, float centerY, float width, float height, float angle) {
    final float r2d = (float) (180 / Math.PI);
    final float w = width/2, h = height/2;
    
    gl.glTranslatef(centerX, centerY, 0);
    if(angle!=0) gl.glRotatef(angle * r2d, 0, 0, 1);

    gl.glBegin(GL.GL_LINE_LOOP);
    {
        gl.glVertex2f(-w, -h);
        gl.glVertex2f(+w, -h);
        gl.glVertex2f(+w, +h);
        gl.glVertex2f(-w, +h);
    }
    gl.glEnd();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:DrawGL.java

示例7: display

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void display(Graphics3D graphics) {
    AWTGraphics3D g = (AWTGraphics3D) graphics;
    view.update(0);

    GL2 gl = g.getGL2();  // get the OpenGL 2 graphics context
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
    gl.glClearColor(1f, 1f, 1f, 1);
    gl.glLoadIdentity();  // reset the model-view matrix

    //Transform by Aim
    g.aimCamera(view.getAim());

    g.setColor(Color.CYAN);

    for (Bone bone : motion.getArmature().getBones()) {
        g.drawLine(bone.getOrigin().getPosition(), bone.getDestination().getPosition());
        g.drawSphere(bone.getOrigin().getPosition(), 0.1);
    }
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:21,代码来源:AnimationJustLoadApplication.java

示例8: annotate

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public synchronized void annotate (GLAutoDrawable drawable){
	if ( !isFilterEnabled() ){
		return;
	}
	super.annotate(drawable);
	final int sx = chip.getSizeX(),  sy = chip.getSizeY();
	final GL2 gl = drawable.getGL().getGL2();
	gl.glLineWidth(2f);
	gl.glColor3f(0,0,1);
	gl.glRasterPos3f(0,sy * getTopLine(),0);
	glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_24,String.format("%d exited",nOut));
	gl.glRasterPos3f(0,sy * getBotLine(),0);
	glut.glutBitmapString(GLUT.BITMAP_TIMES_ROMAN_24,String.format("%d entered",nIn));
	gl.glBegin(GL.GL_LINES);
	gl.glVertex2f(0,sy * getTopLine());
	gl.glVertex2f(sx,sy * getTopLine());
	gl.glVertex2f(0,sy * getBotLine());
	gl.glVertex2f(sx,sy * getBotLine());
	gl.glEnd();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:BeeCounter.java

示例9: drawRay

import com.jogamp.opengl.GL; //导入依赖的package包/类
private void drawRay(GL2 gl, Ray ray) {

        float axisSize = 50;

        Vector3 v = new Vector3(ray.direction);
        v.scl(axisSize);

        //Draw Camera Axis
        if (colide >= 0) {
            gl.glColor3d(1.0, 0.0, 0.0);
        } else {
            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();
    }
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:20,代码来源:StampApplication.java

示例10: init

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void init(Graphics3D graphics) {
	//Init 3d Stuff
	AWTGraphics3D g = (AWTGraphics3D) graphics;
	GL2 gl = g.getGL2(); // get the OpenGL graphics context

	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // set background (clear) color
	gl.glClearDepth(1.0f);      // set clear depth value to farthest
	gl.glEnable(GL.GL_DEPTH_TEST); // enables depth testing
	gl.glDepthFunc(GL.GL_LEQUAL);  // the type of depth test to do
	gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // best perspective correction
	gl.glShadeModel(GL2.GL_SMOOTH); // blends colors nicely, and smoothes out lighting
	
	//Load bunny model
	Model bunnyVBO = MeshLoader.getInstance().loadModel("bunny.obj");
	bunny = new ModelInstance(bunnyVBO);
	bunny.setColor(Color.GHOST_WHITE);
	
	loading = 100;
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:21,代码来源:SimpleMeshExample.java

示例11: toImage

import com.jogamp.opengl.GL; //导入依赖的package包/类
/**
 * Turns gl to BufferedImage with fixed format
 *
 * @param gl
 * @param w
 * @param h
 * @return
 */
protected BufferedImage toImage(GL2 gl, int w, int h) {

    gl.glReadBuffer(GL.GL_FRONT); // or GL.GL_BACK
    ByteBuffer glBB = Buffers.newDirectByteBuffer(4 * w * h);
    gl.glReadPixels(0, 0, w, h, GL2.GL_BGRA, GL.GL_BYTE, glBB);

    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
    int[] bd = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int b = 2 * glBB.get();
            int g = 2 * glBB.get();
            int r = 2 * glBB.get();
            int a = glBB.get(); // not using

            bd[(h - y - 1) * w + x] = (b << 16) | (g << 8) | r | 0xFF000000;
        }
    }

    return bi;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:31,代码来源:AbstractAviWriter.java

示例12: render

import com.jogamp.opengl.GL; //导入依赖的package包/类
private void render(Graphics3D graphics) {
	AWTGraphics3D g = (AWTGraphics3D) graphics;
	// Get the OpenGL graphics context
	GL2 gl = g.getGL2();
	// Clear the color and the depth buffers
	gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
	// Reset the view (x, y, z axes back to normal)
	gl.glLoadIdentity();

	gl.glTranslatef(0.0f, 0.0f, -6.0f); // translate into the screen

	// Draw a triangle
	float sin = (float)Math.sin(angle);
	float cos = (float)Math.cos(angle);
	gl.glBegin(GL.GL_TRIANGLES);
	gl.glColor3f(1.0f, 0.0f, 0.0f);   // Red
	gl.glVertex2d(-cos, -cos);
	gl.glColor3f(0.0f, 1.0f, 0.0f);   // Green
	gl.glVertex2d(0.0f, cos);
	gl.glColor3f(0.0f, 0.0f, 1.0f);   // Blue
	gl.glVertex2d(sin, -sin);
	gl.glEnd();
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:24,代码来源:Example2.java

示例13: init

import com.jogamp.opengl.GL; //导入依赖的package包/类
@Override
public void init(Graphics3D graphics) {
    AWTGraphics3D g = (AWTGraphics3D) graphics;
    view = new FlyView(0, 3.6f, -10);
    view.getAim().setAngleY(180);

    cone = new Cone(6, 6, 3);
    cylinder = new Cylinder(6, 6, 3);
    cylinder.transform.translate(8, 0, 0);

    GL2 gl = g.getGL2(); // get the OpenGL graphics context

    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // set background (clear) color
    gl.glClearDepth(1.0f);      // set clear depth value to farthest
    gl.glEnable(GL.GL_DEPTH_TEST); // enables depth testing
    gl.glDepthFunc(GL.GL_LEQUAL);  // the type of depth test to do
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // best perspective correction
    gl.glShadeModel(GL2.GL_SMOOTH); // blends colors nicely, and smoothes out lighting
}
 
开发者ID:Harium,项目名称:propan-jogl-examples,代码行数:20,代码来源:ConeCollision.java

示例14: annotate

import com.jogamp.opengl.GL; //导入依赖的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 relevant pixels
	gl.glPushMatrix();
	gl.glLineWidth(1f);
	gl.glBegin(GL.GL_LINE_LOOP);
	gl.glColor3f(1f,0.1f,0.1f);
	gl.glVertex2f(xStart-1,yStart-1);
	gl.glVertex2f(xStart+xPixels,yStart-1);
	gl.glVertex2f(xStart+xPixels,yStart+yPixels);
	gl.glVertex2f(xStart-1,yStart+yPixels);
	gl.glEnd();
	gl.glPopMatrix();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:27,代码来源:StdpFeatureLearningI.java

示例15: drawOsculatingCircle

import com.jogamp.opengl.GL; //导入依赖的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();

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:27,代码来源:CurvatureBasedController.java


注:本文中的com.jogamp.opengl.GL类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。