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

The following examples show how to use com.jogamp.opengl.GLAutoDrawable#getUpstreamWidget() . 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: GPUTextRendererListenerBase01.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    super.init(drawable);
    final Object upObj = drawable.getUpstreamWidget();
    if( upObj instanceof Window ) {
        final Window window = (Window) upObj;
        final float[] sDPI = window.getPixelsPerMM(new float[2]);
        sDPI[0] *= 25.4f;
        sDPI[1] *= 25.4f;
        dpiH = sDPI[1];
        System.err.println("Using screen DPI of "+dpiH);
    } else {
        System.err.println("Using default DPI of "+dpiH);
    }
    fontNameBox = font.getMetricBounds(fontName, font.getPixelSize(fontSizeFName, dpiH));
    switchHeadBox();

}
 
Example 2
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 3
Source File: GPURendererListenerBase01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    final Object upObj = drawable.getUpstreamWidget();
    if( upObj instanceof Window ) {
        final Window window = (Window) upObj;
        final float[] sDPI = window.getPixelsPerMM(new float[2]);
        sDPI[0] *= 25.4f;
        sDPI[1] *= 25.4f;
        System.err.println("DPI "+sDPI[0]+" x "+sDPI[1]);

        final float[] hasSurfacePixelScale1 = window.getCurrentSurfaceScale(new float[2]);
        System.err.println("HiDPI PixelScale: "+hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
    }
    autoDrawable = drawable;
    GL2ES2 gl = drawable.getGL().getGL2ES2();
    if(debug) {
        gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ).getGL2ES2();
    }
    if(trace) {
        gl = gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, gl, new Object[] { System.err } ) ).getGL2ES2();
    }
    System.err.println("*** "+gl.getContext().getGLVersion());
    System.err.println("*** GLDebugMessage "+gl.getContext().isGLDebugMessageEnabled());
    MSAATool.dump(drawable);
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    getRenderer().init(gl, renderModes);
}
 
Example 4
Source File: TestTextRendererNEWT00.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
    super.init(drawable);
    drawable.getGL().setSwapInterval(SwapInterval);
    t0 = Platform.currentTimeMillis();

    final Window win = (Window)drawable.getUpstreamWidget();
    final float[] pixelsPerMM = win.getPixelsPerMM(new float[2]);
    final float[] dotsPerInch = new float[] { pixelsPerMM[0]*25.4f, pixelsPerMM[1]*25.4f };
    dpiH = dotsPerInch[1];
    System.err.println(getFontInfo());
    System.err.println("fontSize "+fontSizeFixed+", dotsPerMM "+pixelsPerMM[0]+"x"+pixelsPerMM[1]+", dpi "+dotsPerInch[0]+"x"+dotsPerInch[1]+", pixelSize "+font.getPixelSize(fontSizeFixed, dotsPerInch[1] /* dpi display */));
}