28package com.jogamp.opengl.test.junit.jogl.perf;
30import java.lang.reflect.InvocationTargetException;
32import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
33import com.jogamp.nativewindow.GraphicsConfigurationFactory;
34import com.jogamp.nativewindow.VisualIDHolder;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLCapabilitiesImmutable;
37import com.jogamp.opengl.GLContext;
38import com.jogamp.opengl.GLDrawable;
39import com.jogamp.opengl.GLDrawableFactory;
40import com.jogamp.opengl.GLProfile;
42import org.junit.BeforeClass;
43import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47import com.jogamp.common.os.Platform;
48import com.jogamp.newt.Display;
49import com.jogamp.newt.NewtFactory;
50import com.jogamp.newt.Screen;
51import com.jogamp.opengl.test.junit.util.MiscUtils;
52import com.jogamp.opengl.test.junit.util.UITestCase;
57@FixMethodOrder(MethodSorters.NAME_ASCENDING)
65 public void testChooseOnly(
final int runNum,
final Screen screen,
final int count)
throws InterruptedException {
66 final long[] t =
new long[10];
68 final int[] chosenCfgs = { 0 };
73 if( wait && 0 == runNum ) {
76 System.err.println(
"INIT START #"+runNum);
77 screen.getDisplay().getEDTUtil().invoke(
true,
new Runnable() {
79 t[0] = Platform.currentTimeMillis();
80 for(
int i=0; i<count; i++) {
86 t[1] = Platform.currentTimeMillis();
89 final double countF = count;
90 System.err.printf(
"Run: %d, count %d/%d raw:%n\tchoose\t%6d/t %6.2f/1%n",
91 runNum, chosenCfgs[0], count, t[1]-t[0], (t[1]-t[0])/countF);
92 System.err.println(
"INIT END #"+runNum);
93 if( wait && 2 == runNum ) {
98 public void testFull(
final int runNum,
final int width,
final int height,
final int count) {
100 final long[] t =
new long[10];
106 if( wait && 0 == runNum ) {
109 System.err.println(
"INIT START #"+runNum);
110 t[0] = Platform.currentTimeMillis();
111 for(
int i=0; i<count; i++) {
114 t[1] = Platform.currentTimeMillis();
115 for(
int i=0; i<count; i++) {
118 t[2] = Platform.currentTimeMillis();
120 for(
int i=0; i<count; i++) {
125 glDrawables[i] =
null;
129 glConti[i] = context;
132 t[3] = Platform.currentTimeMillis();
134 for(
int i=0; i<count; i++) {
139 glDrawables[i] =
null;
145 t[4] = Platform.currentTimeMillis();
147 final double countF = count;
148 System.err.printf(
"Run: %d, count %d raw:%n\tglad-create\t%6d/t %6.2f/1%n"+
149 "\tglad-realize\t%6d/t %6.2f/1%n"+
150 "\tctx-create1\t%6d/t %6.2f/1%n"+
151 "\tctx-curren2\t%6d/t %6.2f/1%n"+
152 "\tglad-ctx-init\t%6d/t %6.2f/1%n",
154 t[1]-t[0], (t[1]-t[0])/countF,
155 t[2]-t[1], (t[2]-t[1])/countF,
156 t[3]-t[2], (t[3]-t[2])/countF,
157 t[4]-t[3], (t[4]-t[3])/countF,
158 t[3]-t[0], (t[3]-t[0])/countF);
159 System.err.println(
"INIT END #"+runNum);
160 if( wait && 2 == runNum ) {
165 for(
int i=0; i<count; i++) {
167 if(
null != context ) {
171 if(
null != glDrawable ) {
175 glDrawables[i] =
null;
181 if( 0 != manualTest && 1 != manualTest ) {
188 testChooseOnly(0, screen, count);
189 testChooseOnly(1, screen, count);
190 testChooseOnly(2, screen, count);
197 public void test02Full() throws InterruptedException, InvocationTargetException {
198 if( 0 != manualTest && 2 != manualTest ) {
201 testFull(0, width, height, count);
202 testFull(1, width, height, count);
203 testFull(2, width, height, count);
206 static boolean wait =
false;
207 static int manualTest = 0;
208 static int width = 800, height = 600, count = 50;
210 public static void main(
final String[] args) {
211 boolean waitMain =
false;
213 for(
int i=0; i<args.length; i++) {
214 if(args[i].equals(
"-width")) {
216 }
else if(args[i].equals(
"-height")) {
218 }
else if(args[i].equals(
"-count")) {
220 }
else if(args[i].equals(
"-wait")) {
222 }
else if(args[i].equals(
"-waitMain")) {
224 }
else if(args[i].equals(
"-test")) {
Provides the mechanism by which the graphics configuration for a window can be chosen before the wind...
final AbstractGraphicsConfiguration chooseGraphicsConfiguration(final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested, final CapabilitiesChooser chooser, final AbstractGraphicsScreen screen, final int nativeVisualID)
static GraphicsConfigurationFactory getFactory(final AbstractGraphicsDevice device, final CapabilitiesImmutable caps)
Returns the graphics configuration factory for use with the given device and capability.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract int addReference()
See Display#addReference().
abstract int removeReference()
See Display#removeReference().
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
static final int CONTEXT_NOT_CURRENT
Indicates that the context was not made current during the last call to makeCurrent,...
abstract int makeCurrent()
Makes this GLContext current on the calling thread.
abstract void release()
Releases control of this GLContext from the current thread.
abstract void destroy()
Destroys this OpenGL context and frees its associated resources.
abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height)
Creates an unrealized offscreen GLDrawable incl it's offscreen NativeSurface with the given capabilit...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static void initSingleton()
Static initialization of JOGL.
Raw initialization of multiple offscreen GLAutoDrawables.
static void main(final String[] args)
void testChooseOnly(final int runNum, final Screen screen, final int count)
void testFull(final int runNum, final int width, final int height, final int count)
static int atoi(final String str, final int def)
A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independ...
Visual ID holder interface.
static final int VID_UNDEFINED
getVisualID(VIDType) result indicating an undefined value, which could be cause by an unsupported que...
Specifies an immutable set of OpenGL capabilities.
An abstraction for an OpenGL rendering target.
void setRealized(boolean realized)
Indicates to GLDrawable implementations whether the underlying surface has been created and can be dr...
GLContext createContext(GLContext shareWith)
Creates a new context for drawing to this drawable that will optionally share buffer objects,...