Re: Mac Canvas3D location bug
Posted by
Sven Gothel on
Sep 27, 2013; 5:44am
URL: https://forum.jogamp.org/Mac-Canvas3D-location-bug-tp4030052p4030124.html
On 09/26/2013 06:00 PM, jimthev [via jogamp] wrote:
> I still get the error for applets with this change. For testing I use this
> class:
>
> package test;
>
> import java.applet.Applet;
> import java.awt.Color;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import javax.media.opengl.GL;
> import javax.media.opengl.GLAutoDrawable;
> import javax.media.opengl.GLCapabilities;
> import javax.media.opengl.GLCapabilitiesImmutable;
> import javax.media.opengl.GLEventListener;
> import javax.media.opengl.GLProfile;
> import javax.media.opengl.awt.GLCanvas;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
>
> public class JoglCanvasTest extends Applet implements GLEventListener {
>
> public JoglCanvasTest() {
> }
>
> public static JFrame frame;
> public static JPanel appletHolder;
> public static boolean isApplet = true;
>
> static public void main(String args[]) {
> Applet myApplet = null;
> isApplet = false;
>
> myApplet = new JoglCanvasTest();
> appletStarter(myApplet, "JoglCanvasTest", 800, 600);
> }
>
> static public void appletStarter(final Applet des, String frameName, int width, int height) {
> appletHolder = new JPanel();
> if (frame != null) {
> frame.dispose();
> frame = null;
> }
> frame = new JFrame(frameName);
> frame.setVisible(false);
> frame.getContentPane().add(appletHolder);
>
> appletHolder.setLayout(null);
> des.setBounds(0, 0, width, height);
> appletHolder.add(des);
>
> frame.setVisible(true);
> int frameBorderSize = appletHolder.getLocationOnScreen().x - frame.getLocationOnScreen().x;
> int titleBarHeight = appletHolder.getLocationOnScreen().y - frame.getLocationOnScreen().y;
> int frameWidth = width + 2 * frameBorderSize;
> int frameHeight = height + titleBarHeight + frameBorderSize;
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> frame.setSize(frameWidth, frameHeight);
> frame.setVisible(true);
> des.init();
> frame.addWindowListener(new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> System.exit(0);
> }
> });
> }
>
> public void init() {
> initOpenGLAWT();
> }
>
> public void initOpenGLAWT() {
> setBackground(Color.gray);
> setLayout(null);
>
> GLProfile glp = GLProfile.getDefault();
> GLCapabilities caps = new GLCapabilities(glp);
> GLCanvas canvas = new GLCanvas((GLCapabilitiesImmutable) caps);
> canvas.setBounds(50, 50, 200, 450);
> canvas.addGLEventListener(this);
> add(canvas);
> }
>
> public void init(GLAutoDrawable gLAutoDrawable) {
> GL gl = gLAutoDrawable.getGL();
> gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
> gl.glClear(GL.GL_COLOR_BUFFER_BIT);
> gLAutoDrawable.swapBuffers();
> }
>
> public void dispose(GLAutoDrawable glad) {
> }
>
> public void display(GLAutoDrawable glad) {
> }
>
> public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) {
> }
>
> }
>
> in the jar "JoglCanvasTest.jar". Along with this html ("applet.html"):
>
> <html>
> <body>
> <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
> width="800" height="600">
> <PARAM NAME = CODEBASE VALUE = ".">
> <param name="code" value="test.JoglCanvasTest">
> <param name="archive" value="lib/gluegen-rt.jar,
> lib/jogl-all.jar,
> JoglCanvasTest.jar">
> <comment>
> <embed code="test.JoglCanvasTest"
> CODEBASE = "."
> width="800" height="600"
> type="application/x-java-applet;version=1.6"
> archive="lib/gluegen-rt.jar,
> lib/jogl-all.jar,
> JoglCanvasTest.jar"
> </embed>
> </comment>
> </object>
> </body>
> </html>
>
> I put those two file in the same directory. I have a subdirectory there
> called 'lib' that there that contains gluegen-rt.jar, jogl-all.jar and the
> appropriate natives jars. You can either load the html page and run it in a
> browser or run the class as an application directly ("java -cp
> JoglCanvasTest.jar:lib\gluegen-rt.jar:lib\gluegen-rt-natives-macosx-universal.jar:lib\jogl-all.jar:lib\jogl-all-natives-macosx-universal.jar
> test.JoglCanvasTest").
>
> When I open the html page in a browser on OSX 10.6 using Apple's Java 1.6, the
> box is black and in the lower left (this is the error case).
> When I run the applet directly as an application under OSX 10.6 using Apple's
> Java 1.6 the box is red and in the correct location.
>
> Under Windows the box is always in the correct location and is black as an
> applet and red as an application.
> The color difference is because I'm intentionally not doing anything with the
> 'reshape'.
Perfect, thank you for you test, I will include this in our unit tests
and applet test page.
I guess that is OK w/ you ? You may also send me a git patch .. so your
name is preserved in the git history .. as you wish.
~Sven