Java Code Examples for com.jogamp.opengl.GL2ES2#glViewport()
The following examples show how to use
com.jogamp.opengl.GL2ES2#glViewport() .
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: DwPixelFlow.java From PixelFlow with MIT License | 5 votes |
@Override public void set(DwPixelFlow context, int x, int y, int w, int h) { GL2ES2 gl = context.gl; gl.glViewport(x, y, w, h); gl.glColorMask(true, true, true, true); gl.glDepthMask(false); gl.glDisable(GL.GL_DEPTH_TEST); gl.glDisable(GL.GL_SCISSOR_TEST); gl.glDisable(GL.GL_STENCIL_TEST); gl.glDisable(GL.GL_BLEND); gl.glDisable(GL.GL_MULTISAMPLE); }
Example 2
Source File: UIListenerBase01.java From jogl-samples with MIT License | 5 votes |
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 3
Source File: Es_200_draw_elements.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL2ES2 gl2es2 = (GL2ES2) gl; // Compute the MVP (Model View Projection matrix) Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); // Set the display viewport gl2es2.glViewport(0, 0, windowSize.x, windowSize.y); // Clear color buffer with black gl2es2.glClearColor(0f, 0f, 0f, 1f); gl2es2.glClearDepthf(1f); gl2es2.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Bind program gl2es2.glUseProgram(programName); // Set the value of MVP uniform. gl2es2.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl2es2.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); { gl2es2.glVertexAttribPointer(Semantic.Attr.POSITION, 2, GL_FLOAT, false, 0, 0); } gl2es2.glBindBuffer(GL_ARRAY_BUFFER, 0); gl2es2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl2es2.glEnableVertexAttribArray(Semantic.Attr.POSITION); { gl2es2.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0); } gl2es2.glDisableVertexAttribArray(Semantic.Attr.POSITION); // Unbind program gl2es2.glUseProgram(0); return true; }
Example 4
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 5
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); }