JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
NEWTRedSquareES2Activity.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 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 */
28package com.jogamp.opengl.demos.android;
29
30import com.jogamp.opengl.GLCapabilities;
31import com.jogamp.opengl.GLProfile;
32import com.jogamp.opengl.demos.es2.RedSquareES2;
33
34import jogamp.newt.driver.android.NewtBaseActivity;
35
36import com.jogamp.newt.event.MonitorEvent;
37import com.jogamp.newt.event.MonitorModeListener;
38import com.jogamp.newt.opengl.GLWindow;
39
40import com.jogamp.opengl.util.Animator;
41
42import android.os.Bundle;
43import android.util.Log;
44
45public class NEWTRedSquareES2Activity extends NewtBaseActivity {
46 static String TAG = "NEWTGearsES2Activity";
47
48 @Override
49 public void onCreate(final Bundle savedInstanceState) {
50 Log.d(TAG, "onCreate - 0");
51 super.onCreate(savedInstanceState);
52
53 // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
55 Log.d(TAG, "req caps: "+caps);
56 final GLWindow glWindow = GLWindow.create(caps);
57 // glWindow.setSize(200, 200);
58 // glWindow.setUndecorated(true);
59 glWindow.setFullscreen(true);
60 setContentView(getWindow(), glWindow);
61
62 final RedSquareES2 demo = new RedSquareES2(-1);
63 // demo.enableAndroidTrace(true);
64 glWindow.addGLEventListener(demo);
66 @Override
67 public void monitorModeChangeNotify(final MonitorEvent me) { }
68 @Override
69 public void monitorModeChanged(final MonitorEvent me, final boolean success) {
70 System.err.println("MonitorMode Changed (success "+success+"): "+me);
71 }
72 });
73 final Animator animator = new Animator(glWindow);
74 // animator.setRunAsFastAsPossible(true);
75 // glWindow.setSkipContextReleaseThread(animator.getThread());
76 glWindow.setVisible(true);
77
78 animator.setUpdateFPSFrames(60, System.err);
79 animator.resetFPSCounter();
80 glWindow.resetFPSCounter();
81
82 Log.d(TAG, "onCreate - X");
83 }
84
85 @Override
86 public void onResume() {
87 // android.os.Debug.startMethodTracing("GearsES2.trace");
88 // android.os.Debug.startAllocCounting();
89 super.onResume();
90 }
91
92 @Override
93 public void onPause() {
94 // android.os.Debug.stopAllocCounting();
95 // android.os.Debug.stopMethodTracing();
96 super.onPause();
97 }
98
99}
abstract void addMonitorModeListener(MonitorModeListener sml)
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final boolean setFullscreen(final boolean fullscreen)
Enable or disable fullscreen mode for this window.
Definition: GLWindow.java:534
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
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 final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
Definition: GLProfile.java:594
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
final void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
final void setUpdateFPSFrames(final int frames, final PrintStream out)
void resetFPSCounter()
Reset all performance counter (startTime, currentTime, frame number)
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.