com.jogamp.opengl.GLAutoDrawable Java Examples

The following examples show how to use com.jogamp.opengl.GLAutoDrawable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Renderer.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
@Override
public void init(GLAutoDrawable drawable) {
	synchronized (rendererLock) {
		// Per window initialization
		if (USE_DEBUG_GL) {
			drawable.setGL(new DebugGL4bc((GL4bc)drawable.getGL().getGL2GL3()));
		}

		GL2GL3 gl = drawable.getGL().getGL2GL3();

		initSurfaceState(gl);

		gl.glEnable(GL.GL_MULTISAMPLE);


	}
}
 
Example #2
Source File: J3DCube.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

    final GL2 gl = drawable.getGL().getGL2();
    if (height <= 0) {
        height = 1;
    }

    final float h = (float) width / (float) height;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45.0f, h, 1.0, 20.0);
    glu.gluLookAt(0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
}
 
Example #3
Source File: GraphDisplayer.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable, Matrix44f pMatrix) {

    // Draw the graph texture to the screen
    final GL3 gl = drawable.getGL().getGL3();
    gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, 0);
    gl.glActiveTexture(GL3.GL_TEXTURE0);
    gl.glBindTexture(GL3.GL_TEXTURE_2D, graphColorTextureName[0]);
    gl.glActiveTexture(GL3.GL_TEXTURE0 + 1);
    gl.glBindTexture(GL3.GL_TEXTURE_2D, graphDepthTextureName[0]);
    gl.glUseProgram(graphTextureShader);
    gl.glUniform1i(graphColorTextureShaderLocation, 0);
    gl.glUniform1i(graphDepthTextureShaderLocation, 1);
    bindShaderLocations(gl);
    gl.glDisable(GL3.GL_DEPTH_TEST);
    graphTextureBatch.draw(gl);
    gl.glEnable(GL3.GL_DEPTH_TEST);
}
 
Example #4
Source File: Rhombus.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

    // TODO Auto-generated method stub final
    GL2 gl = drawable.getGL().getGL2();
    if (height  <= 0)
        height = 1;

    final float h = (float) width / (float) height;
    gl.glViewport(3, 6, width, height);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45.0f, h, 1.0, 20.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
}
 
Example #5
Source File: Renderer.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
@Override
public void dispose(GLAutoDrawable drawable) {
	synchronized (rendererLock) {

		GL2GL3 gl = drawable.getGL().getGL2GL3();

		ArrayList<Integer> vaoArray = window.getVAOs();

		int[] vaos = new int[vaoArray.size()];
		int index = 0;
		for (int vao : vaoArray) {
			vaos[index++] = vao;
		}
		if (vaos.length > 0) {
			gl.glDeleteVertexArrays(vaos.length, vaos, 0);
		}
	}
}
 
Example #6
Source File: GPURegionGLListener01.java    From jogl-samples with MIT License 6 votes vote down vote up
public void display(final GLAutoDrawable drawable) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    final RegionRenderer regionRenderer = getRenderer();
    final PMVMatrix pmv = regionRenderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(getXTran(), getYTran(), getZTran());
    pmv.glRotatef(getAngle(), 0, 1, 0);
    if( weight != regionRenderer.getRenderState().getWeight() ) {
        regionRenderer.getRenderState().setWeight(weight);
    }
    region.draw(gl, regionRenderer, getSampleCount());
}
 
Example #7
Source File: JCudaDriverVolumeRendererJOGL.java    From jcuda-samples with MIT License 6 votes vote down vote up
/**
 * Set up a default view for the given GLAutoDrawable
 * 
 * @param drawable The GLAutoDrawable to set the view for
 */
private void setupView(GLAutoDrawable drawable)
{
    GL2 gl = drawable.getGL().getGL2();

    int w = drawable.getSurfaceWidth();
    int h = drawable.getSurfaceHeight();
    gl.glViewport(0, 0, w, h);

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
}
 
Example #8
Source File: TextRendererGLELBase.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    if( null == this.rs ) {
        exclusivePMVMatrix = null == sharedPMVMatrix;
        this.rs = RenderState.createRenderState(SVertex.factory(), sharedPMVMatrix);
    }
    this.renderer = RegionRenderer.create(rs, enableCallback, disableCallback);
    rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
    this.textRenderUtil = new TextRegionUtil(renderModes);
    final GL2ES2 gl = drawable.getGL().getGL2ES2();
    renderer.init(gl, renderModes);
    rs.setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
    renderer.enable(gl, false);

    final Object upObj = drawable.getUpstreamWidget();
    if( upObj instanceof Window ) {
        final float[] pixelsPerMM = ((Window)upObj).getPixelsPerMM(new float[2]);
        dpiH = pixelsPerMM[1]*25.4f;
    }
}
 
Example #9
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void init(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();
    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClearDepth(1.0f);
    gl.glEnable(GL2.GL_DEPTH_TEST);
    gl.glDepthFunc(GL2.GL_LEQUAL);
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
    gl.glEnable(GL2.GL_TEXTURE_2D);
    
    try {
        File im = new File("D:\\Temp\\image\\lenna.jpg ");
        //File im = new File("D:\\Temp\\Map\\GLOBALeb3colshade.jpg");
        BufferedImage image = ImageIO.read(im);
        Texture t = AWTTextureIO.newTexture(gl.getGLProfile(), image, true);
        //Texture t = TextureIO.newTexture(im, true);
        texture = t.getTextureObject(gl);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: CubeTexture.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();                       // Reset The View
    gl.glTranslatef(0f, 0f, -5.0f);
    gl.glRotatef(xrot, 1.0f, 1.0f, 1.0f);
    gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
    
    //drawImage(gl);
    this.drawBoxGridsTicksLabels(gl);        
    drawImage(gl);
    
    gl.glFlush();
    //change the speeds here  
    xrot += .1f;
    yrot += .1f;
    zrot += .1f;
}
 
Example #11
Source File: DelaunayTriangulationExample.java    From delaunay-triangulator with MIT License 6 votes vote down vote up
public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glDisable(GL.GL_CULL_FACE);
    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glClearColor(COLOR_BACKGROUND.getRed() / 255.0f, COLOR_BACKGROUND.getGreen() / 255.0f,
            COLOR_BACKGROUND.getBlue() / 255.0f, 1);
    gl.glClearDepth(1.0f);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LEQUAL);
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

    gl.setSwapInterval(1);
    gl.glDisable(GL2.GL_CULL_FACE);

    delaunayTriangulator = new DelaunayTriangulator(pointSet);
}
 
Example #12
Source File: JOGLRenderer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings ("restriction")
@Override
public void reshape(final GLAutoDrawable drawable, final int arg1, final int arg2, final int w, final int h) {
	int width = w, height = h;
	// See #2628 and https://github.com/sgothel/jogl/commit/ca7f0fb61b0a608b6e684a5bbde71f6ecb6e3fe0
	width = scaleDownIfMac(width);
	height = scaleDownIfMac(height);
	if (width <= 0 || height <= 0) { return; }
	if (openGL.getViewWidth() == width && openGL.getViewHeight() == height) { return; }
	// DEBUG.OUT("Reshaped to " + width + " x " + height);
	// DEBUG.OUT("Zoom size: " + DPIUtil.getDeviceZoom());
	// DEBUG.OUT("AutoScale down = ", false);
	// DEBUG.OUT(DPIUtil.autoScaleDown(new int[] { width, height }));
	// DEBUG.OUT("Size of window:" + ((GLCanvas) drawable).getClientArea());
	final GL2 gl = drawable.getContext().getGL().getGL2();
	keystoneHelper.reshape(width, height);
	openGL.reshape(gl, width, height);
	sceneHelper.reshape(width, height);
	surface.updateDisplay(true);
}
 
Example #13
Source File: FPSRenderable.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    final GL3 gl = drawable.getGL().getGL3();

    try {
        fpsBatcher.createShader(gl);
        fpsBatcher.createBatch(null).run(gl);
    } catch (final IOException | RenderException ex) {
        // If we get here, a shader didn't compile. This obviously shouldn't happen in production;
        // our shaders are static and read from built-in resource files (it happens a lot in
        // development when we edit a shader, but that's OK). Since at least one shader is null,
        // there will be subsequent NullPointerExceptions, but there's nothing we can do about that.
        // Without shaders, we're dead in the water anyway.
        final String msg
                = "This error may have occurred because your video card and/or driver is\n"
                + "incompatible with CONSTELLATION.\n\n"
                + "Please inform CONSTELLATION support, including the text of this message.\n\n"
                + ex.getMessage();
        Logger.getLogger(GraphRenderable.class
                .getName()).log(Level.SEVERE, msg, ex);
        final InfoTextPanel itp = new InfoTextPanel(msg);
        final NotifyDescriptor.Message nd = new NotifyDescriptor.Message(itp,
                NotifyDescriptor.ERROR_MESSAGE);
        nd.setTitle("Shader Error");
        DialogDisplayer.getDefault().notify(nd);
    }
}
 
Example #14
Source File: BasicLine1.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    final GL2 gl = drawable.getGL().getGL2();
    gl.glViewport(0, 0, width, height);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrthof(-2f, 2f, -2f, 2f, 0.0f, 1.0f);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
}
 
Example #15
Source File: TestTextRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void init(final GLAutoDrawable drawable) {
    super.init(drawable);

    final GL2ES2 gl = drawable.getGL().getGL2ES2();
    gl.setSwapInterval(1);
    gl.glEnable(GL.GL_DEPTH_TEST);

    final RenderState rs = getRenderer().getRenderState();
    rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
}
 
Example #16
Source File: JOGLRenderer.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
	WorkbenchHelper.asyncRun(() -> canvas.setVisible(visible));
	openGL.setGL2(drawable.getGL().getGL2());
	cameraHelper.initialize();
	openGL.initializeGLStates(data.getBackgroundColor());
	lightHelper.initialize();
	// We mark the renderer as inited
	inited = true;
}
 
Example #17
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
public void pickShape(final int glWinX, final int glWinY, final float[] objPos, final UIShape[] shape, final Runnable runnable) {
    if( null == cDrawable ) {
        return;
    }
    cDrawable.invoke(false, new GLRunnable() {
        @Override
        public boolean run(final GLAutoDrawable drawable) {
            shape[0] = pickShapeImpl(glWinX, glWinY, objPos);
            if( null != shape[0] ) {
                runnable.run();
            }
            return true;
        } } );
}
 
Example #18
Source File: GraphRenderable.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void update(GLAutoDrawable drawable) {
    final GL3 gl = drawable.getGL().getGL3();
    skipRedraw = false;
    if (parent.isUpdating()) {
        final List<GLRenderableUpdateTask> tasks = new ArrayList<>();
        if (taskQueue.isEmpty()) {
            skipRedraw = true;
        }
        taskQueue.drainTo(tasks);
        tasks.forEach(task -> {
            task.run(gl);
        });
    }
}
 
Example #19
Source File: PlanesRenderable.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void display(final GLAutoDrawable drawable, final Matrix44f mvpMatrix) {
    if (planeBatch.isDrawable()) {
        final GL3 gl = drawable.getGL().getGL3();

        gl.glActiveTexture(GL3.GL_TEXTURE0 + TextureUnits.PLANES);
        gl.glBindTexture(GL3.GL_TEXTURE_2D_ARRAY, textureName);

        gl.glUseProgram(shader);
        gl.glUniformMatrix4fv(shaderMVPMatrix, 1, false, mvpMatrix.a, 0);
        gl.glUniform1i(shaderImages, TextureUnits.PLANES);
        planeBatch.draw(gl);
    }
}
 
Example #20
Source File: GPUTextGLListener0A.java    From jogl-samples with MIT License 5 votes vote down vote up
public void dispose(final GLAutoDrawable drawable) {
    if(drawable instanceof GLWindow) {
        final GLWindow glw = (GLWindow) drawable;
        detachInputListenerFrom(glw);
    }
    super.dispose(drawable);
}
 
Example #21
Source File: PlanesRenderable.java    From constellation with Apache License 2.0 5 votes vote down vote up
public void setVisiblePlanes(final GLAutoDrawable drawable, final BitSet visibleLayers) {

        if (planeBatch.isDrawable()) {
            final GL3 gl = drawable.getGL().getGL3();
            // Map the buffer range.
            gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, planeBatch.getBufferName(planeInfoTarget));
            final ByteBuffer bbuf = gl.glMapBuffer(GL3.GL_ARRAY_BUFFER, GL3.GL_READ_WRITE);
            final FloatBuffer fbuf = bbuf.order(ByteOrder.nativeOrder()).asFloatBuffer();

            // Update the visibility flag for the layers.
            // See createScene().
            // Each plane has six data entries; each data entry is four floats;
            // visibility is in the first entry.
            final int verticesPerPlane = 24;
            final int nVertices = fbuf.limit() / verticesPerPlane;
            for (int i = 0; i < nVertices; i++) {
                final int base = i * verticesPerPlane;

                fbuf.put(base + 2, visibleLayers.get(i) ? 1f : 0f);
                fbuf.put(base + verticesPerPlane / 2 + 2, visibleLayers.get(i) ? 1f : 0f);
            }

            // Unmap the buffer range.
            gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER);
            gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
        }
    }
 
Example #22
Source File: PlanesRenderable.java    From constellation with Apache License 2.0 5 votes vote down vote up
public BitSet getVisiblePlanes(final GLAutoDrawable drawable) {

        final BitSet visiblePlanes = new BitSet();

        if (planeBatch.isDrawable()) {
            final GL3 gl = drawable.getGL().getGL3();
            // Map the buffer range.
            gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, planeBatch.getBufferName(planeInfoTarget));
            final ByteBuffer bbuf = gl.glMapBuffer(GL3.GL_ARRAY_BUFFER, GL3.GL_READ_ONLY);
            final FloatBuffer fbuf = bbuf.order(ByteOrder.nativeOrder()).asFloatBuffer();

            // Get the visibility flag for the planes.
            // Each plane has six dataA entries, each dataA entry is four floats, making 24 vertices per plane.
            // We'll just look at the visibility for the first vertex in each plane (offset 2), since each vertex has the same visibility.
            final int verticesPerPlane = 24;
            final int nPlanes = fbuf.limit() / verticesPerPlane;
            for (int i = 0; i < nPlanes; i++) {
                final int base = i * verticesPerPlane;
                final float vis = fbuf.get(base + 2);
                if (vis > 0) {
                    visiblePlanes.set(i);
                }
            }

            // Unmap the buffer range.
            gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER);
            gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
        }

        return visiblePlanes;
    }
 
Example #23
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void dispose(final GLAutoDrawable drawable) {
    System.err.println("SceneUIController: dispose");
    final GL2ES2 gl = drawable.getGL().getGL2ES2();
    for(int i=0; i<shapes.size(); i++) {
        shapes.get(i).destroy(gl, renderer);
    }
    shapes.clear();
    cDrawable = null;
}
 
Example #24
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
public void windowToShapeCoords(final UIShape activeShape, final int glWinX, final int glWinY, final float[] objPos, final Runnable runnable) {
    if( null == cDrawable || null == activeShape ) {
        return;
    }
    cDrawable.invoke(false, new GLRunnable() {
        @Override
        public boolean run(final GLAutoDrawable drawable) {
            if( windowToShapeCoordsImpl(activeShape, glWinX, glWinY, objPos) ) {
                runnable.run();
            }
            return true;
        } } );
}
 
Example #25
Source File: Renderer.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width,
		int height) {

	//_window.resized(width, height);
	Camera cam = cameras.get(window.getWindowID());
	cam.setAspectRatio((double) width / (double) height);
}
 
Example #26
Source File: UIListenerBase01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void reshape(final GLAutoDrawable drawable, final int xstart, final int ystart, final int width, final int height) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glViewport(xstart, ystart, width, height);
    rRenderer.reshapePerspective(45.0f, width, height, 0.1f, 7000.0f);
    dumpMatrix();
}
 
Example #27
Source File: SWTGLAnimator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method uncaughtException()
 * 
 * @see com.jogamp.opengl.GLAnimatorControl.UncaughtExceptionHandler#uncaughtException(com.jogamp.opengl.GLAnimatorControl,
 *      com.jogamp.opengl.GLAutoDrawable, java.lang.Throwable)
 */
@Override
public void uncaughtException(final GLAnimatorControl animator, final GLAutoDrawable drawable,
		final Throwable cause) {
	DEBUG.ERR("Uncaught exception in animator & drawable:");
	cause.printStackTrace();

}
 
Example #28
Source File: MSAATool.java    From jogl-samples with MIT License 5 votes vote down vote up
public static void dump(final GLAutoDrawable drawable) {
    final float[] vf = new float[] { 0f };
    final byte[] vb = new byte[] { 0 };
    final int[] vi = new int[] { 0, 0 };

    System.out.println("GL MSAA SETUP:");
    final GL2ES2 gl = drawable.getGL().getGL2ES2();
    final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
    System.out.println("  Caps realised "+caps);
    System.out.println("  Caps sample buffers "+caps.getSampleBuffers()+", samples "+caps.getNumSamples());

    System.out.println("  GL MULTISAMPLE "+glIsEnabled(gl, GL.GL_MULTISAMPLE));
    // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB
    gl.glGetIntegerv(GL.GL_SAMPLE_BUFFERS, vi, 0);
    // samples min 0
    gl.glGetIntegerv(GL.GL_SAMPLES, vi, 1);
    System.out.println("  GL SAMPLE_BUFFERS "+vi[0]+", SAMPLES "+vi[1]);

    System.out.println("GL CSAA SETUP:");
    // default FALSE
    System.out.println("  GL SAMPLE COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_COVERAGE));
    // default FALSE
    System.out.println("  GL SAMPLE_ALPHA_TO_COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_ALPHA_TO_COVERAGE));
    // default FALSE
    System.out.println("  GL SAMPLE_ALPHA_TO_ONE "+glIsEnabled(gl, GL.GL_SAMPLE_ALPHA_TO_ONE));
    // default FALSE, value 1, invert false
    gl.glGetFloatv(GL.GL_SAMPLE_COVERAGE_VALUE, vf, 0);
    gl.glGetBooleanv(GL.GL_SAMPLE_COVERAGE_INVERT, vb, 0);
    System.out.println("  GL SAMPLE_COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_COVERAGE) +
                          ": SAMPLE_COVERAGE_VALUE "+vf[0]+
                          ", SAMPLE_COVERAGE_INVERT "+vb[0]);
    dumpBlend(gl);
}
 
Example #29
Source File: Tessellation.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluOrtho2D(0.0, (double) w, 0.0, (double) h);
}
 
Example #30
Source File: J3DBasic.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void display(GLAutoDrawable drawable) {

    final GL2 gl = drawable.getGL().getGL2();
    gl.glTranslatef(0f, 0f, -3f);
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, 0);
    gl.glVertex3f(0f, 1f, 0);
    gl.glEnd();

    //3D  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, -2f);
    gl.glVertex3f(0f, 1f, -2f);
    gl.glEnd();

    //top  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(-1f, 0f, 0);
    gl.glVertex3f(-1f, 0f, -2f);
    gl.glEnd();

    //bottom  
    gl.glBegin(GL2.GL_LINES);
    gl.glVertex3f(0f, 1f, 0);
    gl.glVertex3f(0f, 1f, -2f);
    gl.glEnd();
}