com.jogamp.opengl.GLDrawable Java Examples
The following examples show how to use
com.jogamp.opengl.GLDrawable.
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: TestTextRendererNEWTBugXXXX.java From jogl-samples with MIT License | 6 votes |
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final Font font, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) { final int height = drawable.getSurfaceHeight(); int dx = 0; int dy = height; if(0>row) { row = lastRow + 1; } final AABBox textBox = font.getMetricBounds(text, fontSize); dx += font.getAdvanceWidth('X', fontSize) * column; dy -= (int)textBox.getHeight() * ( row + 1 ); final PMVMatrix pmv = renderer.getMatrix(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); pmv.glTranslatef(dx, dy, z0); textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount); lastRow = row; }
Example #2
Source File: TestTextRendererNEWT10.java From jogl-samples with MIT License | 6 votes |
void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) { final int height = drawable.getSurfaceHeight(); int dx = 0; int dy = height; if(0>row) { row = lastRow + 1; } final AABBox textBox = font.getMetricBounds(text, fontSize); dx += font.getAdvanceWidth('X', fontSize) * column; dy -= (int)textBox.getHeight() * ( row + 1 ); final PMVMatrix pmv = renderer.getMatrix(); pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmv.glLoadIdentity(); pmv.glTranslatef(dx, dy, z0); textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount); lastRow = row; }
Example #3
Source File: TestTextRendererNEWTBugXXXX.java From jogl-samples with MIT License | 5 votes |
public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException { final String dir = "./"; final String objName = getSimpleTestName(".")+"-snap"+screenshot_num; screenshot_num++; final String modeS = Region.getRenderModeString(renderModes); final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName, drawable.getChosenGLCapabilities().getNumSamples(), TestTextRendererNEWTBugXXXX.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount); final String filename = dir + bname +".png"; if(screenshot.readPixels(gl, false)) { screenshot.write(new File(filename)); } }
Example #4
Source File: TestTextRendererNEWT10.java From jogl-samples with MIT License | 5 votes |
public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException { final String dir = "./"; final String objName = getSimpleTestName(".")+"-snap"+screenshot_num; screenshot_num++; final String modeS = Region.getRenderModeString(renderModes); final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName, drawable.getChosenGLCapabilities().getNumSamples(), TestTextRendererNEWT10.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount); final String filename = dir + bname +".png"; if(screenshot.readPixels(gl, false)) { screenshot.write(new File(filename)); } }
Example #5
Source File: GLEventListenerButton.java From jogl-samples with MIT License | 4 votes |
@Override public void drawShape(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) { if( null == fboGLAD ) { final ImageSequence imgSeq = (ImageSequence)texSeq; final GLContext ctx = gl.getContext(); final GLDrawable drawable = ctx.getGLDrawable(); final GLCapabilitiesImmutable reqCaps = drawable.getRequestedGLCapabilities(); final GLCapabilities caps = (GLCapabilities) reqCaps.cloneMutable(); caps.setFBO(true); caps.setDoubleBuffered(false); if( !useAlpha ) { caps.setAlphaBits(0); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); fboGLAD = (GLOffscreenAutoDrawable.FBO) factory.createOffscreenAutoDrawable( drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(), caps, null, fboWidth, fboHeight); fboWidth = 0; fboHeight = 0; fboGLAD.setSharedContext(ctx); fboGLAD.setTextureUnit(imgSeq.getTextureUnit()); fboGLAD.addGLEventListener(glel); fboGLAD.display(); // 1st init! final FBObject.TextureAttachment texA01 = fboGLAD.getColorbuffer(GL.GL_FRONT).getTextureAttachment(); final Texture tex = new Texture(texA01.getName(), imgSeq.getTextureTarget(), fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), fboGLAD.getSurfaceWidth(), fboGLAD.getSurfaceHeight(), false /* mustFlipVertically */); imgSeq.addFrame(gl, tex); markStateDirty(); } else if( 0 != fboWidth*fboHeight ) { fboGLAD.setSurfaceSize(fboWidth, fboHeight); fboWidth = 0; fboHeight = 0; markStateDirty(); } else if( animateGLEL ) { fboGLAD.display(); } super.drawShape(gl, renderer, sampleCount); if( animateGLEL ) { markStateDirty(); // keep on going } }
Example #6
Source File: TestTextRendererNEWTBugXXXX.java From jogl-samples with MIT License | 4 votes |
void testTextRendererImpl(final Font[] fonts, final int renderModes, final int sampleCount, final boolean onlyIssues) throws InterruptedException, GLException, IOException { final GLProfile glp; if(forceGL3) { glp = GLProfile.get(GLProfile.GL3); } else if(forceES2) { glp = GLProfile.get(GLProfile.GLES2); } else { glp = GLProfile.getGL2ES2(); } final GLCapabilities caps = new GLCapabilities( glp ); caps.setAlphaBits(4); if( 0 < sampleCount && !Region.isVBAA(renderModes) ) { caps.setSampleBuffers(true); caps.setNumSamples(sampleCount); } caps.setOnscreen(false); System.err.println("Requested: "+caps); System.err.println("Requested: "+Region.getRenderModeString(renderModes)); final int totalHeight = ( (int)fontSize + 1 ) * ( onlyIssues ? 3 : 6 ) * fonts.length; final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, 800, totalHeight, true); final GLDrawable drawable = winctx.context.getGLDrawable(); final GL2ES2 gl = winctx.context.getGL().getGL2ES2(); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); final RenderState rs = RenderState.createRenderState(SVertex.factory()); final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes); // init gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); renderer.init(gl, 0); rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); screenshot = new GLReadBufferUtil(false, false); // reshape gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f); renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f); final int[] sampleCountIO = { sampleCount }; // display gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); for(int i=0; i<fonts.length; i++) { final Font font = fonts[i]; renderString(drawable, gl, renderer, font, textRenderUtil, font.getFullFamilyName(null).toString()+": "+issues, 0, 0==i?0:-1, -1000, sampleCountIO); if(!onlyIssues) { renderString(drawable, gl, renderer, font, textRenderUtil, "012345678901234567890123456789", 0, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, font, textRenderUtil, "abcdefghijklmnopqrstuvwxyz", 0, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, font, textRenderUtil, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, -1, -1000, sampleCountIO); } renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO); } drawable.swapBuffers(); printScreen(renderModes, drawable, gl, false, sampleCount); sleep(); // dispose screenshot.dispose(gl); renderer.destroy(gl); NEWTGLContext.destroyWindow(winctx); }
Example #7
Source File: TestTextRendererNEWT10.java From jogl-samples with MIT License | 4 votes |
void testTextRendererImpl(final int renderModes, final int sampleCount) throws InterruptedException, GLException, IOException { final GLProfile glp; if(forceGL3) { glp = GLProfile.get(GLProfile.GL3); } else if(forceES2) { glp = GLProfile.get(GLProfile.GLES2); } else { glp = GLProfile.getGL2ES2(); } final GLCapabilities caps = new GLCapabilities( glp ); caps.setAlphaBits(4); if( 0 < sampleCount && !Region.isVBAA(renderModes) ) { caps.setSampleBuffers(true); caps.setNumSamples(sampleCount); } System.err.println("Requested: "+caps); System.err.println("Requested: "+Region.getRenderModeString(renderModes)); final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(caps, 800, 400, true); final GLDrawable drawable = winctx.context.getGLDrawable(); final GL2ES2 gl = winctx.context.getGL().getGL2ES2(); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); System.err.println("Chosen: "+winctx.window.getChosenCapabilities()); final RenderState rs = RenderState.createRenderState(SVertex.factory()); final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED); final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes); // init gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); renderer.init(gl, 0); rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); screenshot = new GLReadBufferUtil(false, false); // reshape gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f); renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f); final int[] sampleCountIO = { sampleCount }; // display gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); if( null == customStr ) { renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000,sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000, sampleCountIO); int c = 0; renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000, sampleCountIO); renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000, sampleCountIO); } else { renderString(drawable, gl, renderer, textRenderUtil, customStr, 0, 0, -1000, sampleCountIO); } drawable.swapBuffers(); printScreen(renderModes, drawable, gl, false, sampleCount); sleep(); // dispose screenshot.dispose(gl); renderer.destroy(gl); NEWTGLContext.destroyWindow(winctx); }