Java Code Examples for com.jogamp.opengl.GLAutoDrawable#getSurfaceWidth()

The following examples show how to use com.jogamp.opengl.GLAutoDrawable#getSurfaceWidth() . 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: 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 2
Source File: NBodyVisualizer.java    From gpu-nbody with MIT License 5 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(final GLAutoDrawable drawable) {
	final GL3 gl = (GL3) drawable.getGL();

	gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());

	final float aspect = (float) drawable.getSurfaceWidth() / drawable.getSurfaceHeight();
	projectionMatrix = perspective(50, aspect, 0.1f, 400.0f);
}
 
Example 3
Source File: JCudaDriverSimpleJOGL.java    From jcuda-samples with MIT License 5 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)
{
    GL3 gl = drawable.getGL().getGL3();
    int w = drawable.getSurfaceWidth();
    int h = drawable.getSurfaceHeight();
    gl.glViewport(0, 0, w, h);
    simpleInteraction.updateProjectionMatrix(w, h);
}
 
Example 4
Source File: GPUUISceneGLListener0A.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
public void display(final GLAutoDrawable drawable) {
    // System.err.println("GPUUISceneGLListener0A: display");
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    if(null == labels[currentText]) {
        final float pixelSizeFixed = fontSizeFixedPVP * drawable.getSurfaceHeight();
        final float dyTop = drawable.getSurfaceHeight() - 2f*jogampLabel.getLineHeight();
        final float dxMiddle = drawable.getSurfaceWidth() * relMiddle;
        labels[currentText] = new Label(renderer.getRenderState().getVertexFactory(), renderModes, font, pixelSizeFixed, strings[currentText]);
        labels[currentText].setColor(0.1f, 0.1f, 0.1f, 1.0f);
        labels[currentText].setEnabled(enableOthers);
        labels[currentText].translate(dxMiddle,
                                      dyTop - 1.5f * jogampLabel.getLineHeight()
                                            - 1.5f * truePtSizeLabel.getLineHeight(), 0f);
        labels[currentText].addMouseListener(dragZoomRotateListener);
        sceneUIController.addShape(labels[currentText]);
        System.err.println("Label["+currentText+"] CTOR: "+labels[currentText]);
        System.err.println("Label["+currentText+"] CTOR: "+Arrays.toString(labels[currentText].getTranslate()));
    }
    if( fpsLabel.isEnabled() ) {
        final float lfps, tfps, td;
        final GLAnimatorControl animator = drawable.getAnimator();
        if( null != animator ) {
            lfps = animator.getLastFPS();
            tfps = animator.getTotalFPS();
            td = animator.getTotalFPSDuration()/1000f;
        } else {
            lfps = 0f;
            tfps = 0f;
            td = 0f;
        }
        final String modeS = Region.getRenderModeString(renderModes);
        final String text;
        if( null == actionText ) {
            final String timePrec = gl.isGLES() ? "4.0" : "4.1";
            text = String.format("%03.1f/%03.1f fps, v-sync %d, dpi %.1f, fontSize %.1f, %s-samples %d, q %d, td %"+timePrec+"f, blend %b, alpha %d, msaa %d",
                lfps, tfps, gl.getSwapInterval(), dpiH, fontSizeFixedPVP, modeS, sceneUIController.getSampleCount(), fpsLabel.getQuality(), td,
                renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED),
                drawable.getChosenGLCapabilities().getAlphaBits(),
                drawable.getChosenGLCapabilities().getNumSamples());
        } else {
            text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize %.1f, %s",
                lfps, tfps, gl.getSwapInterval(), fontSizeFixedPVP, actionText);
        }
        fpsLabel.setText(text);
    }
    sceneUIController.display(drawable);
}