Display problem on Mac OSX

We’ve encountered an interesting display problem with a GLJPanel on Mac OSX 10.3 (using JDK 1.4.2_03)

This problem only occurs on the Mac (the sample code works fine on Windows).

I’ve included a java source file that reproduces the problem along with a screen-shot of what it looks like.

There is a significant gap between the top of the JInternalFrame window and the start of the GLJPanel display. Try resizing the window to a square and it will go away, but will reappear in a funny manner when you make the window’s aspect ratio not = 1. This does not appear to be related to an improper use of the GLEventListener methods as far as I can tell.

Any suggestions as to why this is happening would be most appreciated. We’ve been unable to figure it out thus far.

Cheers,
Mark

Sorry, I forgot to include the code snippet.


import net.java.games.jogl.;
import javax.swing.
;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Test extends JFrame {
JDesktopPane desktopPane = new JDesktopPane();

public Test() {
    Container contentPane = getContentPane();

    contentPane.add(desktopPane, BorderLayout.CENTER);

    desktopPane.setLayout(new BorderLayout());

    myJInternalFrame jif = new myJInternalFrame("Swing JOGL Test");
    jif.setSize(new Dimension(250, 100));
    jif.show();
    desktopPane.add(jif, BorderLayout.CENTER);
    desktopPane.revalidate();
}

public static void main(String args[]) {
    final JFrame f = new Test();

    f.setBounds(100, 100, 600, 500);
    f.setVisible(true);
    f.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    f.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            System.exit(0);
        }
    });
}

}

class myJInternalFrame extends JInternalFrame implements GLEventListener {
GLDrawable m_GLdrawable;

public myJInternalFrame(String title) {
    super(title, true, true, true, true);

    //MacOSXGLContext macGLContext = new MacOSXGLContext(c)
    //MacOSXGLImpl macGL = new MacOSXGLImpl();
    //macGL.resetGLFunctionAvailability();

    GLCapabilities c = new GLCapabilities();
    c.setDoubleBuffered(false);
    m_GLdrawable = GLDrawableFactory.getFactory().createGLJPanel(c);
    m_GLdrawable.addGLEventListener(this);
    getContentPane().add((GLJPanel) m_GLdrawable);
}

public void init(GLDrawable glDrawable) {
    GL gl = glDrawable.getGL();
    float lightPos[] = {50.0f, 50.0f, 100.0f, 10.0f};
    gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPos);
    gl.glEnable(GL.GL_CULL_FACE);
    gl.glEnable(GL.GL_LIGHT0);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glEnable(GL.GL_NORMALIZE);

    gl.glClearDepth(100000000.0f);                      // Depth Buffer Setup
    gl.glClearColor(1.f, 0.f, 0.f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
}

public void display(GLDrawable glDrawable) {
    GL gl = glDrawable.getGL();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    GLU glu = glDrawable.getGLU();
    String stringGLDrawable = glDrawable.toString();
    setVisible(true);
}

public void reshape(GLDrawable glDrawable, int x, int y, int width, int height) {
    GL gl = glDrawable.getGL();
    GLU glu = glDrawable.getGLU();
    gl.glViewport(x, y, width, height);

    double fovy = 30;
    double aspect = (double) width / (double) height;
    double nearClip = 1.0;
    double farClip = 40.0;

    // Set the perspective transformation.
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluPerspective(fovy, aspect, nearClip, farClip);
}

public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1) {
}

}

You might want to post this one to Apple. It may be something specific to what they’re doing with their L&F.

It would be great if someone else might try this bit of code on their MAC and let me know if they get the same display problem :slight_smile:

Thanks for the suggestion regarding Apple. We’re trying to get in touch with someone and see if they also can repro the problem.

Mark

I don’t need the snipped for that. I know that it happens :slight_smile: Post to Apple. Only in numbers will it rise to a level where its noticed.

Sounds good. Can you direct me to the correct forum for posting to Apple? Thanks again.

Mark

http://developer.apple.com/bugreporter/index.html

You will need to sign up for a free ADC membership.

You can also look around their website for links to their mailing lists. There is a Java mailing list.