Java Code Examples for com.jogamp.opengl.GLCapabilities#setAlphaBits()

The following examples show how to use com.jogamp.opengl.GLCapabilities#setAlphaBits() . 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: UINewtDemo01.java    From jogl-samples with MIT License 5 votes vote down vote up
public static void main(final String[] args) {
    final GLProfile glp = GLProfile.getGL2ES2();
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);
    System.out.println("Requested: " + caps);

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(10, 10);
    window.setSize(800, 400);
    window.setTitle("GPU UI Newt Demo 01");
    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final UIGLListener01 uiGLListener = new UIGLListener01 (0, rs, DEBUG, TRACE);
    uiGLListener.attachInputListenerTo(window);
    window.addGLEventListener(uiGLListener);
    window.setVisible(true);

    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example 2
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void test00RegionRendererNONE01() throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
//    caps.setOnscreen(false);
    caps.setAlphaBits(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
    window.addGLEventListener(listener);

    listener.setTech(-20, 0, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 0, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 0,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 3
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void test01RegionRendererNONE02() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa0", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
    window.addGLEventListener(listener);

    listener.setTech(-20, 0, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 0, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 0,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 4
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Test
public void test10RegionRendererMSAA01() throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
//    caps.setOnscreen(false);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
    window.addGLEventListener(listener);

    listener.setTech(-20, 00, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 00, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 00,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 5
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
public void test11RegionRendererMSAA02() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);

    final GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());

    final GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARWEIGHT_RENDERING_BIT, 0, false, false);
    demo01Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo01Listener);

    final RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
    window.addGLEventListener(listener);

    listener.setTech(-20, 00, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 00, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 00,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 6
Source File: TestRegionRendererNEWT01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Test
public void test20RegionRendererR2T01() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.getGL2ES2();

    final GLCapabilities caps = new GLCapabilities(glp);
    //caps.setOnscreen(false);
    caps.setAlphaBits(4);

    final GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final GPURegionGLListener02  demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 4, false, false);
    demo02Listener.attachInputListenerTo(window);
    window.addGLEventListener(demo02Listener);

    final RegionGLListener listener = new RegionGLListener(demo02Listener, window.getTitle(), "GPURegionNewtDemo02");
    window.addGLEventListener(listener);

    listener.setTech(-20, 00, -300, 0f, 2);
    window.display();

    listener.setTech(-20, 00, -150, 0f, 3);
    window.display();

    listener.setTech(-20, 00,  -50, 0f, 4);
    window.display();

    destroyWindow(window);
}
 
Example 7
Source File: SWTOpenGLDisplaySurface.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public GLCanvas createCanvas(final Composite parent) {
	final GLProfile profile = GLProfile.getDefault();
	final GLCapabilities cap = new GLCapabilities(profile);
	cap.setDepthBits(24);
	cap.setDoubleBuffered(true);
	cap.setHardwareAccelerated(true);
	cap.setSampleBuffers(true);
	cap.setAlphaBits(8);
	cap.setNumSamples(8);
	final GLCanvas canvas = new GLCanvas(parent, SWT.NONE, cap, null) {

		@SuppressWarnings ("restriction")
		@Override
		public Rectangle getClientArea() {
			// see Issue #2378
			// if (isWindows() || isLinux()) { return autoScaleUp(super.getClientArea()); }
			return super.getClientArea();
		}
	};
	canvas.setAutoSwapBufferMode(true);
	final SWTGLAnimator animator = new SWTGLAnimator(canvas);
	animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null);
	renderer.setCanvas(canvas);
	final FillLayout gl = new FillLayout();
	canvas.setLayout(gl);
	return canvas;
}
 
Example 8
Source File: OpenGLGFXCMD.java    From sagetv with Apache License 2.0 4 votes vote down vote up
private void initpbuffer()
{
  GL2 gl;
  System.out.println("initpbuffer");
  osdwidth=newosdwidth;
  osdheight=newosdheight;
  GLCapabilities caps = new GLCapabilities(null);
  caps.setHardwareAccelerated(true);
  caps.setDoubleBuffered(false);
  caps.setAlphaBits(8);
  caps.setRedBits(8);
  caps.setGreenBits(8);
  caps.setBlueBits(8);
  caps.setDepthBits(0);
  caps.setFBO(false);
  System.out.println("initpbuffer2");
  if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null, caps.getGLProfile()))
  {
    throw new GLException("pbuffers unsupported");
  }
  if(pbuffer!=null) pbuffer.destroy();
  System.out.println("initpbuffer3");
  pbuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null,
      caps,
      null,
      osdwidth,
      osdheight
      );
  pbuffer.setContext(pbuffer.createContext(c.getContext()), true);
  //pbuffer.setContext(c.getContext(), false);
  System.out.println("initpbuffer4: pbuffers is null? " + (pbuffer==null));
  if(pbuffer.getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT)
  {
    System.out.println("Couldn't make pbuffer current?");
    return;
  }
  System.out.println("initpbuffer5");
  gl = pbuffer.getGL().getGL2();

  gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f);

  gl.glClear( gl.GL_COLOR_BUFFER_BIT);

  gl.glViewport(0, 0, osdwidth, osdheight);
  gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
  gl.glLoadIdentity();
  gl.glOrtho(0,osdwidth,0,osdheight,-1.0,1.0);
  gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
  gl.glLoadIdentity();

  // TODO: look into reusing same texture like OSX version...
  if(osdt!=null) gl.glDeleteTextures(1, osdt, 0);
  osdt = new int[1];
  byte img[] = new byte[osdwidth*osdheight*4];
  gl.glGenTextures(1, osdt, 0);
  gl.glEnable(gl.GL_TEXTURE_RECTANGLE);
  gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,osdt[0]);
  gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
  gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
  gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 4, osdwidth, osdheight, 0,
      gl.GL_BGRA, bigendian ? gl.GL_UNSIGNED_INT_8_8_8_8_REV : gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img));

  gl.glEnable(gl.GL_TEXTURE_RECTANGLE);
  gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, osdt[0]);
  gl.glCopyTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, 0, 0, osdwidth, osdheight);
  gl.glDisable(gl.GL_TEXTURE_RECTANGLE);
  System.out.println("initpbuffer6");
  pbuffer.getContext().release();
  System.out.println("initpbuffer7");
}
 
Example 9
Source File: GPURegionNewtDemo.java    From jogl-samples with MIT License 4 votes vote down vote up
public static void main(final String[] args) {
    int width = 800, height = 400;
    int x = 10, y = 10;
    if( 0 != args.length ) {
        SceneMSAASamples = 0;
        GraphMSAASamples = 0;
        GraphVBAASamples = 0;
        GraphUseWeight = false;

        for(int i=0; i<args.length; i++) {
            if(args[i].equals("-smsaa")) {
                i++;
                SceneMSAASamples = MiscUtils.atoi(args[i], SceneMSAASamples);
            } else if(args[i].equals("-gmsaa")) {
                i++;
                GraphMSAASamples = MiscUtils.atoi(args[i], GraphMSAASamples);
                GraphVBAASamples = 0;
            } else if(args[i].equals("-gvbaa")) {
                i++;
                GraphMSAASamples = 0;
                GraphVBAASamples = MiscUtils.atoi(args[i], GraphVBAASamples);
            } else if(args[i].equals("-gweight")) {
                GraphUseWeight = true;
            } else if(args[i].equals("-width")) {
                i++;
                width = MiscUtils.atoi(args[i], width);
            } else if(args[i].equals("-height")) {
                i++;
                height = MiscUtils.atoi(args[i], height);
            } else if(args[i].equals("-x")) {
                i++;
                x = MiscUtils.atoi(args[i], x);
            } else if(args[i].equals("-y")) {
                i++;
                y = MiscUtils.atoi(args[i], y);
            }
        }
    }
    System.err.println("Desired win size "+width+"x"+height);
    System.err.println("Desired win pos  "+x+"/"+y);
    System.err.println("Scene MSAA Samples "+SceneMSAASamples);
    System.err.println("Graph MSAA Samples"+GraphMSAASamples);
    System.err.println("Graph VBAA Samples "+GraphVBAASamples);
    System.err.println("Graph Weight Mode "+GraphUseWeight);

    final GLProfile glp = GLProfile.getGL2ES2();
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    if( SceneMSAASamples > 0 ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(SceneMSAASamples);
    }
    System.out.println("Requested: " + caps);

    int rmode = GraphUseWeight ? Region.VARWEIGHT_RENDERING_BIT : 0;
    int sampleCount = 0;
    if( GraphVBAASamples > 0 ) {
        rmode |= Region.VBAA_RENDERING_BIT;
        sampleCount += GraphVBAASamples;
    } else if( GraphMSAASamples > 0 ) {
        rmode |= Region.MSAA_RENDERING_BIT;
        sampleCount += GraphMSAASamples;
    }

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(x, y);
    window.setSize(width, height);
    window.setTitle("GPU Curve Region Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, rmode, sampleCount, DEBUG, TRACE);
    regionGLListener.attachInputListenerTo(window);
    window.addGLEventListener(regionGLListener);
    window.setVisible(true);

    //FPSAnimator animator = new FPSAnimator(60);
    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example 10
Source File: GLEventListenerButton.java    From jogl-samples with MIT License 4 votes vote down vote up
@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 11
Source File: GPUTextNewtDemo.java    From jogl-samples with MIT License 4 votes vote down vote up
public static void main(final String[] args) {
    int width = 800, height = 400;
    int x = 10, y = 10;
    if( 0 != args.length ) {
        SceneMSAASamples = 0;
        GraphMSAASamples = 0;
        GraphVBAASamples = 0;

        for(int i=0; i<args.length; i++) {
            if(args[i].equals("-smsaa")) {
                i++;
                SceneMSAASamples = MiscUtils.atoi(args[i], SceneMSAASamples);
            } else  if(args[i].equals("-gmsaa")) {
                i++;
                GraphMSAASamples = MiscUtils.atoi(args[i], GraphMSAASamples);
                GraphVBAASamples = 0;
            } else if(args[i].equals("-gvbaa")) {
                i++;
                GraphMSAASamples = 0;
                GraphVBAASamples = MiscUtils.atoi(args[i], GraphVBAASamples);
            } else if(args[i].equals("-width")) {
                i++;
                width = MiscUtils.atoi(args[i], width);
            } else if(args[i].equals("-height")) {
                i++;
                height = MiscUtils.atoi(args[i], height);
            } else if(args[i].equals("-x")) {
                i++;
                x = MiscUtils.atoi(args[i], x);
            } else if(args[i].equals("-y")) {
                i++;
                y = MiscUtils.atoi(args[i], y);
            }
        }
    }
    System.err.println("Desired win size "+width+"x"+height);
    System.err.println("Desired win pos  "+x+"/"+y);
    System.err.println("Scene MSAA Samples "+SceneMSAASamples);
    System.err.println("Graph MSAA Samples "+GraphMSAASamples);
    System.err.println("Graph VBAA Samples "+GraphVBAASamples);

    final GLProfile glp = GLProfile.getGL2ES2();

    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    if( SceneMSAASamples > 0 ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(SceneMSAASamples);
    }
    System.out.println("Requested: " + caps);

    int rmode = 0; // Region.VARIABLE_CURVE_WEIGHT_BIT;
    int sampleCount = 0;
    if( GraphVBAASamples > 0 ) {
        rmode |= Region.VBAA_RENDERING_BIT;
        sampleCount += GraphVBAASamples;
    } else if( GraphMSAASamples > 0 ) {
        rmode |= Region.MSAA_RENDERING_BIT;
        sampleCount += GraphMSAASamples;
    }

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(x, y);
    window.setSize(width, height);
    window.setTitle("GPU Text Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, rmode, sampleCount, true, DEBUG, TRACE);
    // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32);
    window.addGLEventListener(textGLListener);
    window.setVisible(true);
    // FPSAnimator animator = new FPSAnimator(60);
    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example 12
Source File: TestTextRendererNEWTBugXXXX.java    From jogl-samples with MIT License 4 votes vote down vote up
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 13
Source File: TestTextRendererNEWT00.java    From jogl-samples with MIT License 4 votes vote down vote up
public void testImpl(final int sceneMSAASamples, final int graphMSAASamples, final int graphVBAASamples) throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    if( 0 < sceneMSAASamples ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(sceneMSAASamples);
    }
    System.err.println("Requested: "+caps+", graph[msaaSamples "+graphMSAASamples+", vbaaSamples "+graphVBAASamples+"]");

    final GLWindow window = createWindow("text-gvbaa"+graphVBAASamples+"-gmsaa"+graphMSAASamples+"-smsaa"+sceneMSAASamples, caps, 1024, 640);
    window.display();
    System.err.println("Chosen: "+window.getChosenGLCapabilities());
    if( WaitStartEnd ) {
        JunitTracer.waitForKey("Start");
    }

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final int renderModes, sampleCount;
    if( graphVBAASamples > 0 ) {
        renderModes = Region.VBAA_RENDERING_BIT;
        sampleCount = graphVBAASamples;
    } else if ( graphMSAASamples > 0 ) {
        renderModes = Region.MSAA_RENDERING_BIT;
        sampleCount = graphMSAASamples;
    } else {
        renderModes = 0;
        sampleCount = 0;
    }
    final TextRendererGLEL textGLListener = new TextRendererGLEL(rs, renderModes, sampleCount);
    System.err.println(textGLListener.getFontInfo());

    window.addGLEventListener(textGLListener);

    final Animator anim = new Animator();
    anim.add(window);
    anim.start();
    anim.setUpdateFPSFrames(60, null);
    sleep();
    window.invoke(true, new GLRunnable() {
        @Override
        public boolean run(final GLAutoDrawable drawable) {
            try {
                textGLListener.printScreen(renderModes, drawable, "./", "TestTextRendererNEWT00-snap"+screenshot_num, false);
                screenshot_num++;
            } catch (final Exception e) {
                e.printStackTrace();
            }
            return true;
        }
    });
    anim.stop();
    if( WaitStartEnd ) {
        JunitTracer.waitForKey("Stop");
    }
    destroyWindow(window);
}
 
Example 14
Source File: TestTextRendererNEWT10.java    From jogl-samples with MIT License 4 votes vote down vote up
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);
}
 
Example 15
Source File: TestTextRendererNEWT01.java    From jogl-samples with MIT License 4 votes vote down vote up
@Test
public void testTextRendererR2T01() throws InterruptedException {
    if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) { // FIXME
        // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
        System.err.println("disabled on non desktop (x86) arch for now ..");
        return;
    }
    final GLProfile glp = GLProfile.getGL2ES2();

    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    System.err.println("Requested: "+caps);

    final GLWindow window = createWindow("text-vbaa1-msaa0", caps, 800,400);
    window.display();
    System.err.println("Chosen: "+window.getChosenGLCapabilities());

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, DEBUG, TRACE);
    textGLListener.attachInputListenerTo(window);
    window.addGLEventListener(textGLListener);

    if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 2);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0f,  -380, 3);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0f,   -80, 4);
        window.display();
        sleep();
    }

    if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 2);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0f,  -380, 3);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0f,   -80, 4);
        window.display();
        sleep();
    }

    destroyWindow(window);
}
 
Example 16
Source File: TestTextRendererNEWT01.java    From jogl-samples with MIT License 4 votes vote down vote up
@Test
public void testTextRendererMSAA01() throws InterruptedException {
    final GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);
    System.err.println("Requested: "+caps);

    final GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
    window.display();
    System.err.println("Chosen: "+window.getChosenGLCapabilities());

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
    textGLListener.attachInputListenerTo(window);
    window.addGLEventListener(textGLListener);

    if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0,   -380, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0,    -80, 0);
        window.display();
        sleep();
    }

    if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
        textGLListener.setTech(-400, -30, 0f, -1000, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -30, 0,   -380, 0);
        window.display();
        sleep();

        textGLListener.setTech(-400, -20, 0,    -80, 0);
        window.display();
        sleep();
    }

    destroyWindow(window);
}