JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestOffscreen02BitmapNEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.jogl.offscreen;
30
31
32import com.jogamp.newt.Display;
33import com.jogamp.newt.NewtFactory;
34import com.jogamp.newt.Screen;
35import com.jogamp.newt.Window;
36import com.jogamp.newt.opengl.GLWindow;
37import org.junit.Assert;
38import org.junit.Test;
39import org.junit.FixMethodOrder;
40import org.junit.runners.MethodSorters;
41
42import com.jogamp.opengl.*;
43
44import com.jogamp.opengl.test.junit.util.UITestCase;
45import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
46import java.io.IOException;
47
48/**
49 * Using ES1 GL demo, since pixmap might not be hw accelerated,
50 * hence it is possible to not have GLSL.
51 */
52@FixMethodOrder(MethodSorters.NAME_ASCENDING)
54 static final int width = 640, height = 480;
55
56 @Test
58 // we need to stay w/ generic profile GL2ES1
59 // since software rasterizer might be required (pixmap/bitmap)
61 Assert.assertNotNull(glp);
62 final GLCapabilities caps = new GLCapabilities(glp);
63 Assert.assertNotNull(caps);
64
65 final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
66
67 final Display display = NewtFactory.createDisplay(null); // local display
68 Assert.assertNotNull(display);
69 final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
70 Assert.assertNotNull(screen);
71 final Window window = NewtFactory.createWindow(screen, caps2);
72 Assert.assertNotNull(window);
73 window.setSize(width, height);
74 final GLWindow glWindow = GLWindow.create(window);
75 Assert.assertNotNull(glWindow);
76 glWindow.setVisible(true);
77
78 final GLEventListener demo = new RedSquareES1();
79 WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
80 glWindow.addGLEventListener(demo);
81
82 while ( glWindow.getTotalFPSFrames() < 2) {
83 glWindow.display();
84 }
85
86 if(null!=glWindow) {
87 glWindow.destroy();
88 }
89 if(null!=window) {
90 window.destroy();
91 }
92 if(null!=screen) {
93 screen.destroy();
94 }
95 if(null!=display) {
96 display.destroy();
97 }
98 }
99
100 @Test
102 // we need to stay w/ generic profile GL2ES1
103 // since software rasterizer might be required (pixmap/bitmap)
105 Assert.assertNotNull(glp);
106 final GLCapabilities caps = new GLCapabilities(glp);
107 Assert.assertNotNull(caps);
108
109 final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, false, false);
110
111 final Display display = NewtFactory.createDisplay(null); // local display
112 Assert.assertNotNull(display);
113 final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
114 Assert.assertNotNull(screen);
115 final Window window = NewtFactory.createWindow(screen, caps2);
116 Assert.assertNotNull(window);
117 window.setSize(width, height);
118 final GLWindow glWindow = GLWindow.create(window);
119 Assert.assertNotNull(glWindow);
120 glWindow.setVisible(true);
121
122 WindowUtilNEWT.run(getSimpleTestName("."), glWindow, new RedSquareES1(), null, null, null, null,
123 2 /* frames */, true /*snapshot*/, false /*debug*/);
124
125 if(null!=glWindow) {
126 glWindow.destroy();
127 }
128 if(null!=window) {
129 window.destroy();
130 }
131 if(null!=screen) {
132 screen.destroy();
133 }
134 if(null!=display) {
135 display.destroy();
136 }
137 }
138 public static void main(final String args[]) throws IOException {
139 final String tstname = TestOffscreen02BitmapNEWT.class.getName();
140 org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
141 tstname,
142 "filtertrace=true",
143 "haltOnError=false",
144 "haltOnFailure=false",
145 "showoutput=true",
146 "outputtoformatters=true",
147 "logfailedtests=true",
148 "logtestlistenerevents=true",
149 "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
150 "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
151 }
152
153}
abstract void destroy()
Manually trigger the destruction, incl.
static Display createDisplay(final String name)
Create a Display entity.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
Definition: Screen.java:58
abstract void destroy()
Manually trigger the destruction, incl.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2ES1
The intersection of the desktop GL2 and embedded ES1 profile.
Definition: GLProfile.java:591
Using ES1 GL demo, since pixmap might not be hw accelerated, hence it is possible to not have GLSL.
static void setDemoFields(final GLEventListener demo, final Window window, final GLWindow glWindow, final boolean debug)
static void run(final String testName, final GLWindow windowOffScreen, final GLEventListener demo, final GLWindow windowOnScreenBlit, final WindowListener wl, final MouseListener ml, final SurfaceUpdatedListener ul, final int frames, final boolean snapshot, final boolean debug)
static GLCapabilities fixCaps(final GLCapabilities caps, final boolean onscreen, final boolean pbuffer, final boolean undecorated)
Specifying NEWT's Window functionality:
Definition: Window.java:115
void setSize(int width, int height)
Sets the size of the window's client area in window units, excluding decorations.
void destroy()
Destroys this window incl.releasing all related resources.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.