String getFontInfo() { final float unitsPerEM_Inv = font.getMetrics().getScale(1f); final float unitsPerEM = 1f / unitsPerEM_Inv; return String.format( "Font %s%n %s%nunitsPerEM %f (upem)", font.getFullFamilyName(null).toString(), font.getName(Font.NAME_UNIQUNAME), unitsPerEM); }
@Override public void init(GLAutoDrawable drawable) { super.init(drawable); drawable.getGL().setSwapInterval(SwapInterval); t0 = Platform.currentTimeMillis(); final Window win = (Window) drawable.getUpstreamWidget(); final MonitorDevice monitor = win.getMainMonitor(); final float[] pixelsPerMM = new float[2]; monitor.getPixelsPerMM(pixelsPerMM); 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 */)); }
@Override public void display(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 GLAnimatorControl anim = drawable.getAnimator(); final float lfps = null != anim ? anim.getLastFPS() : 0f; final float tfps = null != anim ? anim.getTotalFPS() : 0f; // Note: MODELVIEW is from [ 0 .. height ] final long t1 = Platform.currentTimeMillis(); // final float fontSize = TestTextRendererNEWT00.fontSize; fontSizeAnim += fontSizeDelta; if (fontSizeMin >= fontSizeAnim || fontSizeAnim >= fontSizeMax) { fontSizeDelta *= -1f; } final float pixelSize = font.getPixelSize(fontSizeFixed, dpiH); final float pixelSizeAnim = font.getPixelSize(fontSizeAnim, dpiH); final String modeS = Region.getRenderModeString(renderModes); if (false) { // renderString(drawable, font, pixelSize, "I - / H P 7 0", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "A M > } ] ", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "M", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "0 6 9 a b O Q A M > } ] ", 0, 0, 0, 0, -1000f, // true); // renderString(drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, // true); // renderString(drawable, font, pixelSize, textX2, 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000f, regionFPS); // // no-cache final String text1 = lfps + " / " + tfps + " fps, vsync " + gl.getSwapInterval() + ", elapsed " + (t1 - t0) / 1000.0 + " s, fontSize " + fontSizeFixed + ", msaa " + drawable.getChosenGLCapabilities().getNumSamples() + ", " + modeS + "-samples " + vbaaSampleCount[0]; renderString(drawable, font, pixelSize, text1, 0, 0, 0, 0, -1000, regionFPS); // no-cache } else { final String text1 = String.format( "%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d", lfps, tfps, gl.getSwapInterval(), (t1 - t0) / 1000.0, fontSizeFixed, drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]); renderString(drawable, font, pixelSize, getFontInfo(), 0, 0, 0, 0, -1000, true); renderString( drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, true); renderString( drawable, font, pixelSize, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "Hello World", 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "4567890123456", 4, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "I like JogAmp", 4, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "Hello World", 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, textX2, 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000, regionFPS); // no-cache if (TextAnim) { renderString( drawable, font, pixelSizeAnim, text1, 0, 0, 0, -1000, regionFPSAnim); // no-cache } } }