Why doesn't GLJPanel work? (Works now thanks!!!)

I get an exception when I create a GLJPanel, that it can not set the pixel format.

I mean it’s not terribly important to have a GLJPanel, but I think if it was included in JOGL it should function.

I’m running Windows XP by the way, I don’t know if that has anything to do with it.

Other posts on the topic in this forum are somewhat confusing to me.

Hello,

When creating the GLJPanel turn double buffering off. call setDoubleBuffered(false) on the GLCapabilities object you use to create the GLJPanel. That seemed to clear up any problems for me.

,
steve

Thanks very much.

I tried what you said and I continue to get the same error!

Again, it’s not of any importance to me if I don’t get it working, althought I’d like to try. Perhaps I am not doing it correctly. If you would be so kind as to assist me with some example code on how to get a working GLJPanel up and running I’d be greatfull. :smiley:

Thanks again!

Can you be a little more specific about what OS you are using and what rgba/doublebuffer ect you are requesting?

I stated that I was running Windows XP on my computers, I have both Home and Pro versions. As far as requesting anything, I would like to get a GLJPanel working. I get an exception when I add the GLJPanel to a JPanel or a JFrame that says it could not set the pixel format.

All I would really like is a little code showing me how to set up the GLJPanel without getting that error.

Post your code. You are probably trying to request a surface that the software renderer does not support. The ms opengl implementation is rather restrictive since it is incredibly old software.

What I was doing was creating a program using the GLCanvas and thought, “gee… I wonder what that GLJPanel does different?” So I simply removed the code to create the GLCanvas and put code to create a GLJPanel with the same variable name as the GLCanvas had before.

Because my code is rather large as it is right now, I’d rather not post it.

I imagine it would be much easier to use one of Nehe’s early tutorials to explain how to replace the GLCanvas with a GLJPanel. Smaller code == less confusing.

If you would be so kind as to do that or something similar I would be very greatful. Thankyou.

Hello Again,

Try the following out, I just hacked it together for an example but seems to work. Try commenting out the setDoubleBuffered method in createGLJPanel and it won’t work anymore.

/*
 * Created on Dec 20, 2003
 *
 */
 
import net.java.games.jogl.*;

import javax.swing.*;
import java.awt.*;

/**
 * @author Stephen Johnson
 *
 * 
 */
public class CsGLJPanelTesting extends JFrame implements GLEventListener
{
      
      public CsGLJPanelTesting()
      {
            super("CsGLJPanelTesting");
            String strSelection = getSelection();
            if(strSelection.equals("GLCanvas"))
                  createGLCanvas();
            else
                  createGLJPanel();
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setSize(500,500);
            this.setVisible(true);
      }
      
      private String getSelection()
      {
            Object selection;
            String glpanels[] = {"GLCanvas","GLJPanel"};
            selection = JOptionPane.showInputDialog(this,
                                                                        "",
                                                                        "GL Panel Selection",
                                                                        JOptionPane.QUESTION_MESSAGE,
                                                                        null,
                                                                        glpanels,
                                                                        glpanels[0]
                                                                        );
            return (String) selection;
      }
      
      private void createGLJPanel()
      {
            GLCapabilities c = new GLCapabilities();
            c.setDoubleBuffered(false);
            GLJPanel panel = GLDrawableFactory.getFactory().createGLJPanel(c);
            panel.addGLEventListener(this);
            this.getContentPane().setLayout(new GridLayout(1,1));
            this.getContentPane().add(panel);
      }
      
      private void createGLCanvas()
      {
            GLCapabilities c = new GLCapabilities();
            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(c);
            canvas.addGLEventListener(this);
            this.getContentPane().setLayout(new GridLayout(1,1));
            this.getContentPane().add(canvas);
      }
      
      public static void main(String argsv[])
      {
            CsGLJPanelTesting p = new CsGLJPanelTesting();
      }

      /* (non-Javadoc)
       * @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable)
       */
      public void init(GLDrawable glDrawable) 
      {
            GL gl = glDrawable.getGL();
            gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
            gl.glColor3d(1.0,1.0,1.0);      
            
      }

      /* (non-Javadoc)
       * @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable)
       */
      public void display(GLDrawable glDrawable) 
      {
            GL gl = glDrawable.getGL();
            gl.glClear(GL.GL_COLOR_BUFFER_BIT);
            gl.glLoadIdentity();
            gl.glTranslated(0.0,0.0,-2.0);
            gl.glBegin(GL.GL_TRIANGLES);
                  gl.glVertex3d(0.0,0.0,0.0);
                  gl.glVertex3d(0.0,0.5,0.0);
                  gl.glVertex3d(0.5,0.0,0.0);
            gl.glEnd();
      }

      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);
            gl.glMatrixMode(GL.GL_PROJECTION);
            gl.glLoadIdentity();
            glu.gluPerspective(65.0,width/height,1.0,20.0);
            gl.glMatrixMode(GL.GL_MODELVIEW);
      }

      /* (non-Javadoc)
       * @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean)
       */
      public void displayChanged(GLDrawable glDrawable, boolean arg1, boolean arg2) {
            // TODO Auto-generated method stub
            
      }

}

,
steve

Thank You Steve. Your code works for me. I’ll have to tinker around with GLJPanel to see what it can do ( performance wise :smiley: ).

Also thanks to GKW for your help.

:smiley: :smiley: :smiley:

GKW:
A while back you posted an implementation of GLJPanel that uses pbuffers instead of the MS software renderer. This looks great to me: I’d like to use your GLJPanel in a project I’m working on, however, when I try to use the ‘jogl.jar’ on your http://www.geocities.com/groundskeeperwiley/ page I get some exceptions during startup that do not occur with the latest official release jogl.jar:

net.java.games.jogl.GLException: pbuffer creation error: wglChoosePixelFormatARB
() failed
at net.java.games.jogl.impl.windows.WindowsPbufferGLContext.createPbuffe
r(WindowsPbufferGLContext.java:221)
at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent
(WindowsOnscreenGLContext.java:118)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:230)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:196)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:88)
at net.java.games.jogl.impl.windows.WindowsGLContextFactory.createGLCont
ext(WindowsGLContextFactory.java:94)
at net.java.games.jogl.GLJPanel.reshape(GLJPanel.java:159)
at java.awt.Component.setBounds(Unknown Source)
at java.awt.Component.resize(Unknown Source)
at java.awt.Component.setSize(Unknown Source)
at java.awt.Component.resize(Unknown Source)
at java.awt.Component.setSize(Unknown Source)
at javax.swing.JViewport.setViewSize(Unknown Source)
at javax.swing.ViewportLayout.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.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 java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at LevelEdit.LevelEdit.init(LevelEdit.java:246)
at LevelEdit.LevelEdit.(LevelEdit.java:210)
at LevelEdit.LevelEdit$LevelEditManager.newEditor(LevelEdit.java:202)
at LevelEdit.LevelEdit.main(LevelEdit.java:186)
Cannot Create Pbuffer
Exception in thread “main” net.java.games.jogl.GLException: Unable to set pixel
format
at net.java.games.jogl.impl.windows.WindowsGLContext.choosePixelFormatAn
dCreateContext(WindowsGLContext.java:303)
at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.create(Win
dowsOffscreenGLContext.java:164)
at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(Windows
GLContext.java:120)
at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.makeCurren
t(WindowsOffscreenGLContext.java:120)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:230)
at net.java.games.jogl.GLJPanel.reshape(GLJPanel.java:170)
at java.awt.Component.setBounds(Unknown Source)
at java.awt.Component.resize(Unknown Source)
at java.awt.Component.setSize(Unknown Source)
at java.awt.Component.resize(Unknown Source)
at java.awt.Component.setSize(Unknown Source)
at javax.swing.JViewport.setViewSize(Unknown Source)
at javax.swing.ViewportLayout.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.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 java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at LevelEdit.LevelEdit.init(LevelEdit.java:246)
at LevelEdit.LevelEdit.(LevelEdit.java:210)
at LevelEdit.LevelEdit$LevelEditManager.newEditor(LevelEdit.java:202)
at LevelEdit.LevelEdit.main(LevelEdit.java:186)

Any idea what I’m doing wrong? I swapped out the latest release jogl.jar for your jogl.jar, kept the release dll, and am running on WindowsXP with an ATI card; am I missing a necessary extension?

Thanks for your GLJPanel work and any info on general restrictions or debugging advice you can provide,
lamster

Post your code that is related to creating the gljpanel or the glcapabilities you use. Also exactly what model of ati card do you have? I have only tested my code on nvidia cards so I have no idea if they work elsewhere.