com.jogamp.newt.opengl.GLWindow Java Examples
The following examples show how to use
com.jogamp.newt.opengl.GLWindow.
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: Input_into_rendering.java From hello-triangle with MIT License | 6 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Input into rendering"); window.setSize(1024, 768); window.addGLEventListener(this); window.addKeyListener(this); window.setVisible(true); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #2
Source File: GPUUISceneGLListener0A.java From jogl-samples with MIT License | 6 votes |
@Override public void dispose(final GLAutoDrawable drawable) { if(drawable instanceof GLWindow) { System.err.println("GPUUISceneGLListener0A: dispose (1)"); final GLWindow glw = (GLWindow) drawable; detachInputListenerFrom(glw); } else { System.err.println("GPUUISceneGLListener0A: dispose (0)"); } sceneUIController.dispose(drawable); // disposes all registered UIShapes final GL2ES2 gl = drawable.getGL().getGL2ES2(); renderer.destroy(gl); screenshot.dispose(gl); }
Example #3
Source File: GPUTextGLListener0A.java From jogl-samples with MIT License | 6 votes |
public void init(final GLAutoDrawable drawable) { if(drawable instanceof GLWindow) { final GLWindow glw = (GLWindow) drawable; attachInputListenerTo(glw); } super.init(drawable); final GL2ES2 gl = drawable.getGL().getGL2ES2(); final RenderState rs = getRenderer().getRenderState(); gl.setSwapInterval(1); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f); }
Example #4
Source File: HelloTriangle.java From hello-triangle with MIT License | 6 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Triangle (enhanced)"); window.setSize(1024, 768); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #5
Source File: CubeSample2.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
public CubeSample2() { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); glu = new GLU(); glWindow = GLWindow.create(caps); glWindow.setTitle("Cube demo (Newt)"); glWindow.setSize(300, 300); glWindow.addGLEventListener(this); glWindow.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent arg0) { System.exit(0); } }); glWindow.addMouseListener(this); glWindow.addKeyListener(this); //animator = new FPSAnimator(30); animator = new FPSAnimator(glWindow, 30, false); animator.add(glWindow); animator.start(); animator.pause(); glWindow.setVisible(true); }
Example #6
Source File: HelloGlobe.java From CPE552-Java with GNU General Public License v3.0 | 6 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Globe"); window.setSize(1024, 768); window.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #7
Source File: TestTextRendererNEWT00.java From jogl-samples with MIT License | 5 votes |
static GLWindow createWindow(final String title, final GLCapabilitiesImmutable caps, final int width, final int height) { Assert.assertNotNull(caps); final GLWindow window = GLWindow.create(caps); window.setSize(width, height); window.setPosition(10, 10); window.setTitle(title); Assert.assertNotNull(window); window.setVisible(true); return window; }
Example #8
Source File: P.java From haxademic with MIT License | 5 votes |
public static void appInitialized() { // now that the app/window is initialized, we can act on P.p properties // ... and anything that relied on PAppletHax.config() overrides per-app if(P.isOpenGL()) window = (GLWindow) P.p.getSurface().getNative(); if(Config.getInt(AppSettings.LOOP_FRAMES, 0) != 0) FrameLoop.instance(Config.getInt(AppSettings.LOOP_FRAMES, 0), Config.getInt(AppSettings.LOOP_TICKS, 4)); if(P.renderer != PRenderers.PDF) DebugView.instance(); ScreenSaverBlocker.instance(); UI.instance(); Mouse.instance(); KeyboardState.instance(); Renderer.instance(); }
Example #9
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
public void attachInputListenerTo(final GLWindow window) { if(null == sbcMouseListener) { sbcMouseListener = new SBCMouseListener(); window.addMouseListener(sbcMouseListener); sbcGestureListener = new SBCGestureListener(); window.addGestureListener(sbcGestureListener); pinchToZoomGesture = new PinchToZoomGesture(window.getNativeSurface(), false); window.addGestureHandler(pinchToZoomGesture); } }
Example #10
Source File: MapViewTileRenderer.java From constellation with Apache License 2.0 | 5 votes |
/** * Initialise the tile renderer. As of Processing 3, the {@link PApplet} * class no longer extends {@link Applet}, meaning in order to integrate a * processing sketch with Swing or JavaFX you must initialise and extract * the {@link PSurface} class responsible for rendering the sketch and * instead integrate that. * * @return */ public Component init() { // the magical line to make sure all of the jogl files are loaded, preventing Processing loading the wrong libraries SharedDrawable.getGLProfile(); // initialise the processing sketch path sketchPath(); // use reflection to set insideSettings variable to true, initialise // settings, and then set insideSettings back to false try { Field is = PApplet.class.getDeclaredField("insideSettings"); is.setAccessible(true); try { is.set(this, Boolean.TRUE); settings(); } finally { is.set(this, Boolean.FALSE); is = null; } } catch (NoSuchFieldException | SecurityException | IllegalAccessException ex) { LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } // initialise the surface if (surface != null) { surface.stopThread(); } initSurface(); surface.startThread(); // case the surface to the correct component type and return it glComponent = new NewtCanvasAWT((GLWindow) surface.getNative()); return glComponent; }
Example #11
Source File: UINewtDemo01.java From jogl-samples with MIT License | 5 votes |
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 #12
Source File: UIListenerBase01.java From jogl-samples with MIT License | 5 votes |
/** Attach the input listener to the window */ public void attachInputListenerTo(final GLWindow window) { if ( null == keyAction ) { keyAction = new KeyAction(); window.addKeyListener(keyAction); } if ( null == mouseAction ) { mouseAction = new MouseAction(); window.addMouseListener(mouseAction); } }
Example #13
Source File: UIListenerBase01.java From jogl-samples with MIT License | 5 votes |
public void detachFrom(final GLWindow window) { if ( null == keyAction ) { return; } if ( null == mouseAction ) { return; } window.removeGLEventListener(this); window.removeKeyListener(keyAction); window.removeMouseListener(mouseAction); }
Example #14
Source File: GPURendererListenerBase01.java From jogl-samples with MIT License | 5 votes |
/** Attach the input listener to the window */ public void attachInputListenerTo(final GLWindow window) { if ( null == keyAction ) { keyAction = new KeyAction(); window.addKeyListener(keyAction); } }
Example #15
Source File: TestTextRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
static GLWindow createWindow(final String title, final GLCapabilitiesImmutable caps, final int width, final int height) { Assert.assertNotNull(caps); final GLWindow window = GLWindow.create(caps); window.setSize(width, height); window.setPosition(10, 10); window.setTitle(title); Assert.assertNotNull(window); window.setVisible(true); return window; }
Example #16
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
static GLWindow createWindow(final String title, final GLCapabilitiesImmutable caps, final int width, final int height) { Assert.assertNotNull(caps); final GLWindow window = GLWindow.create(caps); window.setSize(width, height); window.setPosition(10, 10); window.setTitle(title); Assert.assertNotNull(window); window.setVisible(true); return window; }
Example #17
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
public void detachInputListenerFrom(final GLWindow window) { if(null != sbcMouseListener) { window.removeMouseListener(sbcMouseListener); sbcMouseListener = null; window.removeGestureListener(sbcGestureListener); sbcGestureListener = null; window.removeGestureHandler(pinchToZoomGesture); pinchToZoomGesture = null; } }
Example #18
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
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 #19
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
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 #20
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
@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 #21
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
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 #22
Source File: TestRegionRendererNEWT01.java From jogl-samples with MIT License | 5 votes |
@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 #23
Source File: GPUTextGLListener0A.java From jogl-samples with MIT License | 5 votes |
public void dispose(final GLAutoDrawable drawable) { if(drawable instanceof GLWindow) { final GLWindow glw = (GLWindow) drawable; detachInputListenerFrom(glw); } super.dispose(drawable); }
Example #24
Source File: ColorStateTest.java From jtk with Apache License 2.0 | 5 votes |
private static void initGL() { _window = NewtFactory.createWindow( new GLCapabilities(GLProfile.getDefault())); assertNotNull(_window); _glWindow = GLWindow.create(_window); assertNotNull(_glWindow); _glWindow.setVisible(true); _glContext = _glWindow.getContext(); assertNotNull(_glContext); _glContext.makeCurrent(); }
Example #25
Source File: HelloTriangle.java From hello-triangle with MIT License | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Triangle (enhanced)"); window.setSize(1024, 768); window.addGLEventListener(this); window.addKeyListener(this); window.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG); window.setVisible(true); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #26
Source File: HelloGlobe.java From hello-triangle with MIT License | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Globe"); window.setSize(1024, 768); window.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #27
Source File: HelloTriangleSimple.java From hello-triangle with MIT License | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Triangle (enhanced)"); window.setSize(1024, 768); window.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #28
Source File: GL_injection.java From hello-triangle with MIT License | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("gl injection"); window.setSize(1024, 768); window.addGLEventListener(this); window.addKeyListener(this); window.setAutoSwapBufferMode(false); window.setVisible(true); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #29
Source File: HelloTriangleSimple.java From CPE552-Java with GNU General Public License v3.0 | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Triangle (enhanced)"); window.setSize(1024, 768); window.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }
Example #30
Source File: HelloTexture.java From hello-triangle with MIT License | 5 votes |
private void setup() { GLProfile glProfile = GLProfile.get(GLProfile.GL3); GLCapabilities glCapabilities = new GLCapabilities(glProfile); window = GLWindow.create(glCapabilities); window.setTitle("Hello Texture"); window.setSize(1024, 768); window.setVisible(true); window.addGLEventListener(this); window.addKeyListener(this); animator = new Animator(); animator.add(window); animator.start(); window.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent e) { animator.stop(); System.exit(1); } }); }