GLJPanel not working on w2k

I modified a simple example shown before to make use of GLJPanel:

import net.java.games.jogl.GLEventListener;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.DebugGL;
import net.java.games.jogl.*;

import java.awt.;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.
;

public class Test
{
public static void main( String[] args )
{
try
{
JFrame testFrame = new JFrame(“TestFrame”);
testFrame.setSize( 512, 384 );

        GLCapabilities glCaps = new GLCapabilities(); 
        glCaps.setRedBits(8); 
        glCaps.setBlueBits(8); 
        glCaps.setGreenBits(8); 
        glCaps.setAlphaBits(8); 

        GLJPanel canvas = GLDrawableFactory.getFactory().createGLJPanel( glCaps ); 

        testFrame.getContentPane().add( canvas ); 

        canvas.addGLEventListener(new TestRenderer()); 

        final Animator animator = new Animator( canvas); 
        testFrame.addWindowListener(new WindowAdapter() { 
            public void windowClosing(WindowEvent e) { 
              animator.stop(); 
              System.exit(0); 
            } 
          }); 
        testFrame.show(); 
        animator.start(); 
    } 
    catch( Exception e ) 
    { 
        e.printStackTrace(); 
    } 
} 

}

class TestRenderer implements GLEventListener
{
private GL gl;
private GLDrawable glDrawable;

public void init(GLDrawable drawable) 
{ 
    this.gl = drawable.getGL(); 
    this.glDrawable = drawable; 

    drawable.setGL( new DebugGL(drawable.getGL() )); 

    System.out.println("Init GL is " + gl.getClass().getName()); 
} 

public void display(GLDrawable drawable) 
{ 
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); 
    gl.glLoadIdentity(); 

    gl.glColor3f(1.0f, 0.0f, 0.0f ); 

    gl.glBegin( GL.GL_TRIANGLES ); 
        gl.glVertex3f( 0.0f, 0.0f, 0.0f ); 
        gl.glVertex3f( 1.0f, 0.0f, 0.0f ); 
        gl.glVertex3f( 1.0f, 1.0f, 0.0f ); 
    gl.glEnd(); 
} 

public void reshape(GLDrawable drawable, int x, int y, int width, int height) 
{ 
} 

public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) 
{ 
} 

}

It compiles just fine, but when I try to run it I get the following message error:

C:\PETE>java Test
net.java.games.jogl.GLException: Unable to set pixel format
at net.java.games.jogl.impl.windows.WindowsGLContext.choosePixelFormatAn
dCreateContext(WindowsGLContext.java:294)
at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.create(Win
dowsOffscreenGLContext.java:156)
at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(Windows
GLContext.java:117)
at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.makeCurren
t(WindowsOffscreenGLContext.java:116)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)
at net.java.games.jogl.GLJPanel.reshape(GLJPanel.java:131)
at java.awt.Component.setBounds(Unknown Source)
at java.awt.BorderLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at java.awt.Window.show(Unknown Source)
at Test.main(Test.java:41)

This is just a self contained way to generate the error message, I normally use Linux and the GLJPanel works just fine in there.

I would appreciate any feedback on how to solve this problem.

Thanks
Joan

Try using the default canvas capabilities

new GLCapabilities();

or play around with the RGBA values to see if something works. Your video card might not support 8-bits each for RGBA.

It’s also a little curious that the offscreen context

net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.makeCurren
t(WindowsOffscreenGLContext.java:116)

is invoked when it appears you are creating an onscreen buffer. Maybe someone else has some insight on this.

Sean

I tried what you suggested (and in fact is what I do on the original code) but it still doesn’t work.

Is it because it tries to use hardware acceleration? Is there a way to disable that?

Joan

PS: If that helps I have a Radeon Mobility on the Linux machine and a GeForce4 MX 420 on the windows machine

You can’t have a doublebuffered gljpanel. I believe it is fixed in the cvs but using the precompiled binaries you will have to manually set it.

At this point, I don’t really need anything fancy. I want my program to work just like it does under Linux. Is it a known problem that GLJPanel doesn’t work on windows? is it my vide card? One of the exceptions says: Unable to set pixel format, how can I change that from the default?

Joan

Try adding glCaps.setDoubleBuffered(false) to your code and see if it works. The MS software renderer does not support doublebuffering so you must not request it, as the default GLCapabilities does.

Thanks a lot, I just got it running.
Joan