aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-01-09 17:53:36 +0100
committerSven Gothel <[email protected]>2012-01-09 17:53:36 +0100
commitb7252ec43e5e658a561d380bed882666d8e47f55 (patch)
treecb7c4277059c2e0ad368cc33204880146ea9a15f
parent8b66da812b21725c8d0ca309f476b92be282ec8e (diff)
SWT GLCanvas: Java 1.5 clean (No @override for interfaces); Add license header; Remove dummy comments
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java (renamed from src/jogl/classes/jogamp/opengl/swt/GLCanvas.java)163
1 files changed, 30 insertions, 133 deletions
diff --git a/src/jogl/classes/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index d8c1f33d1..689047235 100644
--- a/src/jogl/classes/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -1,7 +1,31 @@
/**
- *
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
*/
-package jogamp.opengl.swt;
+package com.jogamp.opengl.swt;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
@@ -41,7 +65,7 @@ import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
/**
- *
+ * Native SWT Canvas implementing GLAutoDrawable
*/
public class GLCanvas extends Canvas implements GLAutoDrawable {
@@ -83,7 +107,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* Invokes init(...) on all GLEventListeners. Assumes context is current when run.
*/
private final Runnable initAction = new Runnable() {
- @Override
public void run() {
drawableHelper.init(GLCanvas.this);
}
@@ -95,7 +118,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* Assumes GLContext is current when run.
*/
private final Runnable displayAction = new Runnable() {
- @Override
public void run() {
if (sendReshape) {
drawableHelper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight());
@@ -107,7 +129,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
/* Action to make specified context current prior to running displayAction */
private final Runnable makeCurrentAndDisplayAction = new Runnable() {
- @Override
public void run() {
drawableHelper.invokeGL(drawable, context, displayAction, initAction);
}
@@ -115,7 +136,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
/* Swaps buffers, assuming the GLContext is current */
private final Runnable swapBuffersAction = new Runnable() {
- @Override
public void run() {
drawable.swapBuffers();
}
@@ -123,7 +143,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
/* Swaps buffers, making the GLContext current first */
private final Runnable makeCurrentAndSwapBuffersAction = new Runnable() {
- @Override
public void run() {
drawableHelper.invokeGL(drawable, context, swapBuffersAction, initAction);
}
@@ -133,7 +152,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* Disposes of OpenGL resources
*/
private final Runnable disposeGLAction = new Runnable() {
- @Override
public void run() {
drawableHelper.dispose(GLCanvas.this);
@@ -151,14 +169,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
};
private final Runnable makeCurrentAndDisposeGLAction = new Runnable() {
- @Override
public void run() {
drawableHelper.invokeGL(drawable, context, disposeGLAction, null);
}
};
private final Runnable disposeGraphicsDeviceAction = new Runnable() {
- @Override
public void run() {
if (null != device) {
device.close();
@@ -216,16 +232,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
/* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */
/* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */
addPaintListener(new PaintListener() {
-
- @Override
public void paintControl(final PaintEvent arg0) {
if (!drawableHelper.isExternalAnimatorAnimating()) {
display();
}
}
});
+
addControlListener(new ControlAdapter() {
-
@Override
public void controlResized(final ControlEvent arg0) {
/* Mark for OpenGL reshape next time the control is painted */
@@ -234,18 +248,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
});
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#addGLEventListener(javax.media.opengl.GLEventListener)
- */
- @Override
public void addGLEventListener(final GLEventListener arg0) {
drawableHelper.addGLEventListener(arg0);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#addGLEventListener(int, javax.media.opengl.GLEventListener)
- */
- @Override
public void addGLEventListener(final int arg0, final GLEventListener arg1) throws IndexOutOfBoundsException {
drawableHelper.addGLEventListener(arg0, arg1);
}
@@ -255,98 +261,53 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
* <p>
* Also disposes of the SWT component.
*/
- @Override
public void destroy() {
drawable.setRealized(false);
dispose();
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#display()
- */
- @Override
public void display() {
runInGLThread(makeCurrentAndDisplayAction, displayAction);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#getAnimator()
- */
- @Override
public GLAnimatorControl getAnimator() {
return drawableHelper.getAnimator();
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#getAutoSwapBufferMode()
- */
- @Override
public boolean getAutoSwapBufferMode() {
return drawableHelper.getAutoSwapBufferMode();
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#getContext()
- */
- @Override
public GLContext getContext() {
return context;
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#getContextCreationFlags()
- */
- @Override
public int getContextCreationFlags() {
return ctxCreationFlags;
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#getGL()
- */
- @Override
public GL getGL() {
final GLContext ctx = getContext();
return (ctx == null) ? null : ctx.getGL();
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#invoke(boolean, javax.media.opengl.GLRunnable)
- */
- @Override
public void invoke(final boolean wait, final GLRunnable run) {
/* Queue task for running during the next display(). */
drawableHelper.invoke(this, wait, run);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#removeGLEventListener(javax.media.opengl.GLEventListener)
- */
- @Override
public void removeGLEventListener(final GLEventListener arg0) {
drawableHelper.removeGLEventListener(arg0);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#setAnimator(javax.media.opengl.GLAnimatorControl)
- */
- @Override
public void setAnimator(final GLAnimatorControl arg0) throws GLException {
drawableHelper.setAnimator(arg0);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#setAutoSwapBufferMode(boolean)
- */
- @Override
public void setAutoSwapBufferMode(final boolean arg0) {
drawableHelper.setAutoSwapBufferMode(arg0);
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#setContext(javax.media.opengl.GLContext)
- */
- @Override
public void setContext(final GLContext ctx) {
this.context = ctx;
if (ctx instanceof GLContextImpl) {
@@ -354,18 +315,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#setContextCreationFlags(int)
- */
- @Override
public void setContextCreationFlags(final int arg0) {
ctxCreationFlags = arg0;
}
- /*
- * @see javax.media.opengl.GLAutoDrawable#setGL(javax.media.opengl.GL)
- */
- @Override
public GL setGL(final GL arg0) {
final GLContext ctx = getContext();
if (ctx != null) {
@@ -375,10 +328,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
return null;
}
- /*
- * @see javax.media.opengl.GLDrawable#createContext(javax.media.opengl.GLContext)
- */
- @Override
public GLContext createContext(final GLContext arg0) {
lock.lock();
try {
@@ -389,10 +338,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLDrawable#getChosenGLCapabilities()
- */
- @Override
public GLCapabilitiesImmutable getChosenGLCapabilities() {
return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getChosenCapabilities();
}
@@ -406,10 +351,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getRequestedCapabilities();
}
- /*
- * @see javax.media.opengl.GLDrawable#getFactory()
- */
- @Override
public GLDrawableFactory getFactory() {
lock.lock();
try {
@@ -420,18 +361,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLDrawable#getGLProfile()
- */
- @Override
public GLProfile getGLProfile() {
return glCapsRequested.getGLProfile();
}
- /*
- * @see javax.media.opengl.GLDrawable#getHandle()
- */
- @Override
public long getHandle() {
lock.lock();
try {
@@ -442,18 +375,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLDrawable#getHeight()
- */
- @Override
public int getHeight() {
return getClientArea().height;
}
- /*
- * @see javax.media.opengl.GLDrawable#getNativeSurface()
- */
- @Override
public NativeSurface getNativeSurface() {
lock.lock();
try {
@@ -464,18 +389,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLDrawable#getWidth()
- */
- @Override
public int getWidth() {
return getClientArea().width;
}
- /*
- * @see javax.media.opengl.GLDrawable#isRealized()
- */
- @Override
public boolean isRealized() {
lock.lock();
try {
@@ -486,34 +403,19 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
}
}
- /*
- * @see javax.media.opengl.GLDrawable#setRealized(boolean)
- */
- @Override
public void setRealized(final boolean arg0) {
/* Intentionally empty */
}
- /*
- * @see javax.media.opengl.GLDrawable#swapBuffers()
- */
- @Override
public void swapBuffers() throws GLException {
runInGLThread(makeCurrentAndSwapBuffersAction, swapBuffersAction);
}
- /*
- * @see mil.afrl.rrs.ifsb.jview.graph.graph3d.RenderSurface#update()
- */
- @Override
+ // FIXME: API of update() method ?
public void update() {
-// display();
+ // FIXME: display();
}
- /*
- * @see mil.afrl.rrs.ifsb.jview.graph.graph3d.RenderSurface#dispose()
- */
- @Override
public void dispose() {
lock.lock();
try {
@@ -610,7 +512,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
public static void main(final String[] args) {
- GLProfile.initSingleton(true);
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(800,600);
@@ -621,22 +522,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
canvas.addGLEventListener(new GLEventListener() {
- @Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
System.out.println("Reshape");
}
- @Override
public void init(final GLAutoDrawable drawable) {
System.out.println("Init");
}
- @Override
public void dispose(final GLAutoDrawable drawable) {
System.out.println("Dispose");
}
- @Override
public void display(final GLAutoDrawable drawable) {
System.out.println("Display");
}