Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 May 2016 23:21:10 +0300
From:      Michael Zhilin <mizhka@gmail.com>
To:        mexas@bris.ac.uk
Cc:        freebsd-java@freebsd.org
Subject:   Re: java.lang.IllegalArgumentException: Drawable already added to animator
Message-ID:  <CAF19XB%2BN1Fr9ixDEM8xChbXuoA4tvR%2BwaSSYids0g5a=ooqKNA@mail.gmail.com>
In-Reply-To: <201605161631.u4GGVFc0019850@mech-as222.men.bris.ac.uk>
References:  <201605161631.u4GGVFc0019850@mech-as222.men.bris.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
I suppose commenting line 33 may resolve issue. :) Because animator
constructor already passed canvas.

Thanks!

On Mon, May 16, 2016 at 7:31 PM, Anton Shterenlikht <mexas@bris.ac.uk>
wrote:

> I advanced a step further.
>
> I can compile this JOGL program:
>
> import java.awt.Frame;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import javax.media.opengl.*;
> import javax.media.opengl.awt.GLCanvas;
> import com.jogamp.opengl.util.*;
>
> public class SimpleScene implements GLEventListener {
>
>     private double theta = 0;
>     private double s = 0;
>     private double c = 0;
>
>     public static void main(String[] args) {
>         GLProfile glp = GLProfile.getDefault();
>         GLCapabilities caps = new GLCapabilities(glp);
>         GLCanvas canvas = new GLCanvas(caps);
>
>         Frame frame = new Frame("AWT Window Test");
>         frame.setSize(300, 300);
>         frame.add(canvas);
>         frame.setVisible(true);
>
>         frame.addWindowListener(new WindowAdapter() {
>             public void windowClosing(WindowEvent e) {
>                 System.exit(0);
>             }
>         });
>
>         canvas.addGLEventListener(new SimpleScene());
>
>         FPSAnimator animator = new FPSAnimator(canvas, 60);
>         animator.add(canvas);
>         animator.start();
>     }
>
>     @Override
>     public void display(GLAutoDrawable drawable) {
>         update();
>         render(drawable);
>     }
>
>     @Override
>     public void dispose(GLAutoDrawable drawable) {
>     }
>
>     @Override
>     public void init(GLAutoDrawable drawable) {
>     }
>
>     @Override
>     public void reshape(GLAutoDrawable drawable, int x, int y, int w, int
> h) {
>     }
>
>     private void update() {
>         theta += 0.01;
>         s = Math.sin(theta);
>         c = Math.cos(theta);
>     }
>
>     private void render(GLAutoDrawable drawable) {
>         GL2 gl = drawable.getGL().getGL2();
>
>         gl.glClear(GL.GL_COLOR_BUFFER_BIT);
>
>         // draw a triangle filling the window
>         gl.glBegin(GL.GL_TRIANGLES);
>         gl.glColor3f(1, 0, 0);
>         gl.glVertex2d(-c, -c);
>         gl.glColor3f(0, 1, 0);
>         gl.glVertex2d(0, c);
>         gl.glColor3f(0, 0, 1);
>         gl.glVertex2d(s, -s);
>         gl.glEnd();
>     }
> }
>
> with
>
> $ javac SimpleScene.java
> warning: Supported source version 'RELEASE_6' from annotation processor
> 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than -source
> '1.8'
> 1 warning
>
> but when I run it, I get this error:
>
> $ java SimpleScene
> Exception in thread "main" java.lang.IllegalArgumentException: Drawable
> already added to animator: com.jogamp.opengl.util.FPSAnimator[started
> false, animating false, paused false, drawable 1, totals[dt 0, frames 0,
> fps 0.0], modeBits 1, init'ed true, animThread null, exclCtxThread
> false(null)], AWT-GLCanvas[Realized false,
>         jogamp.opengl.x11.glx.X11OnscreenGLXDrawable,
>         Factory   jogamp.opengl.x11.glx.X11GLXDrawableFactory@91161c7,
>         handle    0x2600020,
>         Drawable size 286x269 surface[286x269],
>         AWT[pos 7/24, size 286x269,
>         visible true, displayable true, showing true,
>         AWTGraphicsConfiguration[AWTGraphicsScreen[AWTGraphicsDevice[type
> .awt, connection :0.0, unitID 0, awtDevice X11GraphicsDevice[screen=0],
> handle 0x0], idx 0],
>         chosen    GLCaps[glx vid 0xba, fbc 0x81: rgba 8/8/8/0, opaque,
> accum-rgba 0/0/0/0, dp/st/ms 24/8/0, dbl, mono  , hw,
> GLProfile[GL2/GL2.hw], on-scr[.]],
>         requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0,
> dp/st/ms 16/0/0, dbl, mono  , hw, GLProfile[GL2/GL2.hw], on-scr[.]],
>         X11GraphicsConfig[dev=X11GraphicsDevice[screen=0],vis=0xba],
>         encapsulated
> X11GLXGraphicsConfiguration[X11GraphicsScreen[X11GraphicsDevice[type .x11,
> connection :0.0, unitID 0, handle 0x8d73fd800, owner true,
> JAWTToolkitLock[obj 0x604ed9f0, isOwner false, <6a4f787b, 685cb137>[count
> 0, qsz 0, owner <NULL>]]], idx 0], visualID 0xba, fbConfigID 0x81,
>         requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0,
> dp/st/ms 16/0/0, dbl, mono  , hw, GLProfile[GL2/GL2.hw], on-scr[.]],
>         chosen    GLCaps[glx vid 0xba, fbc 0x81: rgba 8/8/8/0, opaque,
> accum-rgba 0/0/0/0, dp/st/ms 24/8/0, dbl, mono  , hw,
> GLProfile[GL2/GL2.hw], on-scr[.]]]]]]
>         at com.jogamp.opengl.util.AnimatorBase.add(AnimatorBase.java:201)
>         at SimpleScene.main(SimpleScene.java:33)
>
> Anything obvious?
>
> Thanks
>
> Anton
> _______________________________________________
> freebsd-java@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-java
> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF19XB%2BN1Fr9ixDEM8xChbXuoA4tvR%2BwaSSYids0g5a=ooqKNA>