Resize of a JCanvas3D

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Resize of a JCanvas3D

Andreas
I'm developing a Netbeans Platform application. If I use two different TopComponents (InternalFrames?) where both have a JCanvas3D inside the resizing does not work properly.
If I resize while only one TopComponent is visible and switch to the other the Canvas3D (or the offscreenbuffer) have the wrong size. But I can't find an error. The setBounds methode is called with the correct values. But it seems that they are not used.

Can someone helpt me even it's Netbeans spezific?
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

elotter
Hi Andreas

Unfortunately I cannot say that I've experienced exactly your problem, although I have had some small issues with 2D overlays in plain Java3D. Are you using this Java3D reboot under NetBeans platform, or standard Java3D?

Good to see somebody else also building Java3d based stuff on the NetBeans Platform - we'll have to write up a tutorial for GJ's blog at some point :)

E
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
What do you mean by "standard" Java3D? Java3D was no more maintained when I initiated its port to JOGL 2.0. I use Netbeans RCP at work with JOGL but I don't see which problems may occur with Java3D.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
I wrote a small example. If I run the following code as a Netbeans Platform Module a new Netbeans instance opens with the standard start TopComponent. When I open the test TopComponent anything works including resizing with two TopComponents open. Then I switch to the start TopComponent tab and resize the Netbeans window. If I switch back to the test TopComponent tab the Java3D part is still in the size before switching to the other TopComponent.

import com.sun.j3d.exp.swing.JCanvas3D;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.media.j3d.Alpha;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingBox;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Font3D;
import javax.media.j3d.FontExtrusion;
import javax.media.j3d.Material;
import javax.media.j3d.PointLight;
import javax.media.j3d.RotationInterpolator;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Text3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3d;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.TopComponent;

/**
 * Top component which displays something.
 */
@ConvertAsProperties(
    dtd = "-//de.test//Test//EN",
autostore = false)
@TopComponent.Description(
    preferredID = "TestTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE",
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = false)
@ActionID(category = "Window", id = "de.test.TestTopComponent")
@ActionReference(path = "Menu/Window" /*, position = 333 */)
@TopComponent.OpenActionRegistration(
    displayName = "#CTL_TestAction",
preferredID = "TestTopComponent")
@Messages({
    "CTL_TestAction=Test",
    "CTL_TestTopComponent=Test Window",
    "HINT_TestTopComponent=This is a Test window"
})
public final class TestTopComponent extends TopComponent {

    public TestTopComponent() {
        initComponents();
        setName(Bundle.CTL_TestTopComponent());
        setToolTipText(Bundle.HINT_TestTopComponent());
        init();
    }
   
    public void init(){
       
        JCanvas3D jCanvas = new JCanvas3D();
        jCanvas.setResizeMode(JCanvas3D.RESIZE_IMMEDIATELY);
        jCanvas.setSize(new Dimension(100, 100));
        add(jCanvas, BorderLayout.CENTER);  

        Canvas3D canvas3D = jCanvas.getOffscreenCanvas3D();
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
        simpleU.getViewingPlatform().setNominalViewingTransform();
       
        BranchGroup bg = createSceneGraph();
        bg.compile();
        simpleU.addBranchGraph(bg);
    }

    private BranchGroup createSceneGraph() {
        BranchGroup root = new BranchGroup();
        TransformGroup spin = new TransformGroup();
        spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        root.addChild(spin);
        Appearance ap = new Appearance();
        ap.setMaterial(new Material());
        FontExtrusion fontExtrusion = new FontExtrusion();
        double tessellationTolerance = 1e-2;
        Text3D text3d = new Text3D(
                new Font3D(
                new Font("Helvetica", Font.PLAIN, 48),
                tessellationTolerance,
                fontExtrusion),
                "01234567890 TEXT 3D");
        Shape3D text2 = new Shape3D(text3d);
        text2.setAppearance(ap);
        BoundingBox boundingBox = new BoundingBox();
        text3d.getBoundingBox(boundingBox);
        System.out.printf("boundingBox: %s\n", boundingBox);
        Point3d p1 = new Point3d();
        boundingBox.getUpper(p1);
        System.out.printf("upper: %s\n", p1);
        TransformGroup textTrans = new TransformGroup();
        Transform3D t3d = new Transform3D();
        t3d.setTranslation(new Vector3d(-(p1.x / 2), -(p1.y / 2), -(p1.z / 2)));
        textTrans.setTransform(t3d);
        textTrans.addChild(text2);
        Transform3D tr = new Transform3D();
        tr.setScale(0.05);
        TransformGroup tg = new TransformGroup(tr);
        spin.addChild(tg);
        tg.addChild(textTrans);
        Alpha alpha = new Alpha(-1, 1000000000);
        RotationInterpolator rotator = new RotationInterpolator(alpha, spin);
        BoundingSphere bounds = new BoundingSphere();
        rotator.setSchedulingBounds(bounds);
        spin.addChild(rotator);
        Background background = new Background(0.0f, 0.0f, 0.0f);
        background.setApplicationBounds(bounds);
        root.addChild(background);
        AmbientLight light = new AmbientLight(true, new Color3f(Color.white));
        light.setInfluencingBounds(bounds);
        root.addChild(light);
        PointLight ptlight = new PointLight(new Color3f(Color.white), new Point3f(3f, 3f, 3f), new Point3f(1f, 0f, 0f));
        ptlight.setInfluencingBounds(bounds);
        root.addChild(ptlight);
        PointLight ptlight2 = new PointLight(new Color3f(Color.white),
                new Point3f(-2f, 2f, 2f), new Point3f(1f, 0f, 0f));
        ptlight2.setInfluencingBounds(bounds);
        root.addChild(ptlight2);
        return root;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>

    // Variables declaration - do not modify
    // End of variables declaration
    @Override
    public void componentOpened() {
        // TODO add custom code on component opening
    }

    @Override
    public void componentClosed() {
        // TODO add custom code on component closing
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
Oh, I forgot. I'm using Java3D 1.6.0 Pre 5 with JOGL 2.0-rc11 under Linux 64bit and Windows 64bit.

And many thanks for the JOGL port of Java3D. So I don't have the port my Java3D code to another 3D Engine which saves a lot of time!

Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
Can you test with a plain AWT canvas and then with GLCanvas in order to determine if it comes from Java itself, JOGL or Java3D?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
I tried to do so. For the AWT Canvas every thing is ok with the resizing beside the haevyweight lightweight problems. If I run a GLCanvas example I get the following error. Perhaps I did something wrong.

javax.media.opengl.GLException: Error: NULL AWTGraphicsConfiguration
        at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:531)
        at java.awt.Container.addNotify(Container.java:2769)
        at javax.swing.JComponent.addNotify(JComponent.java:4743)
        at org.openide.windows.TopComponent.addNotify(TopComponent.java:281)
        at java.awt.Container.addImpl(Container.java:1114)
        at java.awt.Container.add(Container.java:966)

I never used JOGL before, so I also copied the used code.

import com.jogamp.opengl.util.Animator;
import com.sun.j3d.exp.swing.JCanvas3D;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
import java.awt.event.ComponentAdapter;
import java.awt.event.WindowEvent;
import javax.media.j3d.Alpha;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingBox;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Font3D;
import javax.media.j3d.FontExtrusion;
import javax.media.j3d.GraphicsConfigTemplate3D;
import javax.media.j3d.Material;
import javax.media.j3d.PointLight;
import javax.media.j3d.RotationInterpolator;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Text3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3d;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.TopComponent;

/**
 * Top component which displays something.
 */
@ConvertAsProperties(
    dtd = "-//de.test//Test//EN",
autostore = false)
@TopComponent.Description(
    preferredID = "TestTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE",
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = false)
@ActionID(category = "Window", id = "de.test.TestTopComponent")
@ActionReference(path = "Menu/Window" /*, position = 333 */)
@TopComponent.OpenActionRegistration(
    displayName = "#CTL_TestAction",
preferredID = "TestTopComponent")
@Messages({
    "CTL_TestAction=Test",
    "CTL_TestTopComponent=Test Window",
    "HINT_TestTopComponent=This is a Test window"
})
public final class TestTopComponent extends TopComponent implements GLEventListener {

    public TestTopComponent() {
        initComponents();
        setName(Bundle.CTL_TestTopComponent());
        setToolTipText(Bundle.HINT_TestTopComponent());
        initJOGL();
    }

    public void initSwing() {

        JCanvas3D jCanvas = new JCanvas3D();
        jCanvas.setSize(new Dimension(100, 100));
        add(jCanvas, BorderLayout.CENTER);

        Canvas3D canvas3D = jCanvas.getOffscreenCanvas3D();
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
        simpleU.getViewingPlatform().setNominalViewingTransform();

        BranchGroup bg = createSceneGraph();
        bg.compile();
        simpleU.addBranchGraph(bg);
    }

    public void initAWT() {

        GraphicsConfigTemplate3D gct3D = new GraphicsConfigTemplate3D();
        GraphicsConfiguration gc = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(gct3D);

        Canvas3D canvas3D = new Canvas3D(gc);
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
        simpleU.getViewingPlatform().setNominalViewingTransform();

        BranchGroup bg = createSceneGraph();
        bg.compile();
        simpleU.addBranchGraph(bg);

        add(canvas3D, BorderLayout.CENTER);
    }

    public void initJOGL() {
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(this);
        add(canvas, BorderLayout.CENTER);
        final Animator animator = new Animator(canvas);
        addComponentListener(new ComponentAdapter() {
            public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        animator.start();
    }

    private BranchGroup createSceneGraph() {
        BranchGroup root = new BranchGroup();
        TransformGroup spin = new TransformGroup();
        spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        root.addChild(spin);
        Appearance ap = new Appearance();
        ap.setMaterial(new Material());
        FontExtrusion fontExtrusion = new FontExtrusion();
        double tessellationTolerance = 1e-2;
        Text3D text3d = new Text3D(
                new Font3D(
                new Font("Helvetica", Font.PLAIN, 48),
                tessellationTolerance,
                fontExtrusion),
                "01234567890 TEXT 3D");
        Shape3D text2 = new Shape3D(text3d);
        text2.setAppearance(ap);
        BoundingBox boundingBox = new BoundingBox();
        text3d.getBoundingBox(boundingBox);
        System.out.printf("boundingBox: %s\n", boundingBox);
        Point3d p1 = new Point3d();
        boundingBox.getUpper(p1);
        System.out.printf("upper: %s\n", p1);
        TransformGroup textTrans = new TransformGroup();
        Transform3D t3d = new Transform3D();
        t3d.setTranslation(new Vector3d(-(p1.x / 2), -(p1.y / 2), -(p1.z / 2)));
        textTrans.setTransform(t3d);
        textTrans.addChild(text2);
        Transform3D tr = new Transform3D();
        tr.setScale(0.05);
        TransformGroup tg = new TransformGroup(tr);
        spin.addChild(tg);
        tg.addChild(textTrans);
        Alpha alpha = new Alpha(-1, 1000000000);
        RotationInterpolator rotator = new RotationInterpolator(alpha, spin);
        BoundingSphere bounds = new BoundingSphere();
        rotator.setSchedulingBounds(bounds);
        spin.addChild(rotator);
        Background background = new Background(0.0f, 0.0f, 0.0f);
        background.setApplicationBounds(bounds);
        root.addChild(background);
        AmbientLight light = new AmbientLight(true, new Color3f(Color.white));
        light.setInfluencingBounds(bounds);
        root.addChild(light);
        PointLight ptlight = new PointLight(new Color3f(Color.white), new Point3f(3f, 3f, 3f), new Point3f(1f, 0f, 0f));
        ptlight.setInfluencingBounds(bounds);
        root.addChild(ptlight);
        PointLight ptlight2 = new PointLight(new Color3f(Color.white),
                new Point3f(-2f, 2f, 2f), new Point3f(1f, 0f, 0f));
        ptlight2.setInfluencingBounds(bounds);
        root.addChild(ptlight2);
        return root;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {

        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>                       

    // Variables declaration - do not modify                    
    // End of variables declaration                  
    @Override
    public void componentOpened() {
        // TODO add custom code on component opening
    }

    @Override
    public void componentClosed() {
        // TODO add custom code on component closing
    }

    void writeProperties(java.util.Properties p) {
        // better to version settings since initial version as advocated at
        // http://wiki.apidesign.org/wiki/PropertyFiles
        p.setProperty("version", "1.0");
        // TODO store your settings
    }

    void readProperties(java.util.Properties p) {
        String version = p.getProperty("version");
        // TODO read your settings according to their version
    }

    @Override
    public void init(GLAutoDrawable glad) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void dispose(GLAutoDrawable glad) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void display(GLAutoDrawable glad) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
Don't throw exceptions in GLEventListener methods. You can use this example:
http://en.wikipedia.org/wiki/Java_OpenGL#Code_example
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
With the given example I'm getting the same error.

javax.media.opengl.GLException: Error: NULL AWTGraphicsConfiguration
        at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:531)
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
Ok, I will try to make it work soon, it will allow us to have a working example using Netbeans RCP + JOGL.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
In reply to this post by Andreas
Can you try this example in the bottom of the page?
http://forums.netbeans.org/ptopic46275.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
This post was updated on .
Could it be that this is an example for an older version of JOGL. If I try this with JOGL 2.0 many of the constants are not available that are used in the GLRenderer class of the example.

Someone seems to get it work, but also have trouble with resizeing

http://forum.jogamp.org/Jogl-and-the-Netbeans-Platform-can-you-help-me-td2482729.html (last post)
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
Ok I'll try to make it work with GLJPanel first, then I'll try to do the same with GLCanvas. You can make it work with a small hack, just put the GLCanvas into a JPanel or any other Swing container. I use Netbeans 7.2.1.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
I found the answer for the GLCanvas problem. There is an if statement "Beans.isDesignTime()" in line 1086 of the GLCanvas which was true for my Netbeans runs and the GUIBuilder. So it returns a null AWTGraphicsConfiguration for the chooseGraphicsConfiguration method. If I set Beans.setDesignTime(false); before the GLCanvas is started everything works fine.

So the answer for the resize test is Canvas3D is resized correctly, GLCanvas is resized correctly but the JCanvas3D not.

Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

gouessej
Administrator
Thank you so much. I succeeded in using GLJPanel but I failed to use GLCanvas in a Netbeans RCP application. GLJPanel resizing works fine in my case, it is strange :s
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Sven Gothel
Administrator
In reply to this post by Andreas
On 01/18/2013 09:01 PM, Andreas [via jogamp] wrote:
> I found the answer for the GLCanvas problem. There is an if statement
> "Beans.isDesignTime()" in line 1086 of the GLCanvas which was true for my
> Netbeans runs and the GUIBuilder. So it returns a null
> AWTGraphicsConfiguration for the chooseGraphicsConfiguration method. If I set
> Beans.setDesignTime(false); before the GLCanvas is started everything works fine.

Sorry .. I am not very familiar w/ this NB and 'Beans.isDesignTime()' semantics.

Is it possible to have a test case w/o NB (and Java3d)
exposing the problem ?

Do I understand you right that the 'Beans.isDesignTime()' introduces
erroneous behavior into GLCanvas?

>
> So the answer for the resize test is Canvas3D is resized correctly, GLCanvas
> is resized correctly
(with your 'hack' only?)
> but the JCanvas3D not.

.. would need a Beans/designTime hack ?

~Sven

--
health & wealth
mailto:[hidden email] ; http://jausoft.com
land : +49 (471) 4707742 ; fax : +49 (471) 4707741
Timezone CET: PST+9, EST+6, UTC+1


signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
After I found the Beans/desginTime problem, I was able to look if other had this problem. And there were some.

http://netbeans.org/bugzilla/show_bug.cgi?id=139304
http://kenai.com/nonav/projects/netbeans-opengl-pack/forums/forum/topics/2025-Problem-closing-the-OpenGL-Capabilities-Viewer-

So I'm not sure if this is a bug or just two points of view.

Additionally the Beans/desginTime problem is not connected to my original resizing problem of the JCanvas3D inside the a Netbeans Platform Application with different TopComponents.

A simple example is what happens when the GLCanvas is used inside Netbeans is the following where Beans/desginTime is set true:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jrealitytest;

import com.jogamp.opengl.util.Animator;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.Beans;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.fixedfunc.GLLightingFunc;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.swing.JFrame;

public class JOGLQuad implements GLEventListener {

    private float rotateT = 0.0f;

    @Override
    public void display(GLAutoDrawable gLDrawable) {
        final GL2 gl = gLDrawable.getGL().getGL2();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();
        gl.glTranslatef(0.0f, 0.0f, -5.0f);

        // rotate on the three axis
        gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
        gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
        gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);

        // Draw A Quad
        gl.glBegin(GL2.GL_QUADS);
        gl.glColor3f(0.0f, 1.0f, 1.0f);   // set the color of the quad
        gl.glVertex3f(-1.0f, 1.0f, 0.0f);   // Top Left
        gl.glVertex3f(1.0f, 1.0f, 0.0f);   // Top Right
        gl.glVertex3f(1.0f, -1.0f, 0.0f);   // Bottom Right
        gl.glVertex3f(-1.0f, -1.0f, 0.0f);   // Bottom Left
        // Done Drawing The Quad
        gl.glEnd();

        // increasing rotation for the next iteration                  
        rotateT += 0.2f;
    }

    @Override
    public void init(GLAutoDrawable glDrawable) {
        GL2 gl = glDrawable.getGL().getGL2();
        gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glClearDepth(1.0f);
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);
        gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
    }

    @Override
    public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) {
        GL2 gl = gLDrawable.getGL().getGL2();
        final float aspect = (float) width / (float) height;
        gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
        gl.glLoadIdentity();
        final float fh = 0.5f;
        final float fw = fh * aspect;
        gl.glFrustumf(-fw, fw, -fh, fh, 1.0f, 1000.0f);
        gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    @Override
    public void dispose(GLAutoDrawable gLDrawable) {
    }

    public static void main(String[] args) {
        Beans.setDesignTime(true);
        final GLCanvas canvas = new GLCanvas();
        final JFrame frame = new JFrame("Jogl Quad drawing");
        final Animator animator = new Animator(canvas);
        canvas.addGLEventListener(new JOGLQuad());
        frame.add(canvas);
        frame.setSize(640, 480);
        frame.setResizable(false);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                animator.stop();
                frame.dispose();
                System.exit(0);
            }
        });
        frame.setVisible(true);
        animator.start();
        canvas.requestFocus();
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Sven Gothel
Administrator
On 01/22/2013 01:43 PM, Andreas [via jogamp] wrote:

> After I found the Beans/desginTime problem, I was able to look if other had
> this problem. And there were some.
>
> http://netbeans.org/bugzilla/show_bug.cgi?id=139304
> http://kenai.com/nonav/projects/netbeans-opengl-pack/forums/forum/topics/2025-Problem-closing-the-OpenGL-Capabilities-Viewer-
>
> So I'm not sure if this is a bug or just two points of view.
>
> Additionally the Beans/desginTime problem is not connected to my original
> resizing problem of the JCanvas3D inside the a Netbeans Platform Application
> with different TopComponents.

>
> A simple example is what happens when the GLCanvas is used inside Netbeans is
> the following where Beans/desginTime is set true:

...
https://jogamp.org/bugzilla/show_bug.cgi?id=675

Thank you .. will fix the inDesignTime() bug in GLCanvas.

Ofc .. the other issue (resizing .. ) is unrelated.

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

elotter
In reply to this post by gouessej
Sorry for the late reply ...

By "standard" (which is probably a misnomer) I mean the ancient 1.5.2 and earlier, while by the "reboot" I mean 1.6 pre* . I've been using Harvey's Java3D 1.6 pre* with JOGL2 in RCP apps without problem since RC11.

Regards,
Ernest
Reply | Threaded
Open this post in threaded view
|

Re: Resize of a JCanvas3D

Andreas
Thanks for the answer. In this case I'm making something wrong. Can you give me a small code example? I found that stopping and starting rendering for the view in case of hidding and showing the TopComponent solves the problem for Windows but not for Linux.

Andreas