From: Chad S. <sta...@ea...> - 2002-06-08 00:13:53
|
Hello, I'm attempting to learn OpenGL by following the NeHe tutorials, = and using the GLJPanel to do so. However, I have so far been unable to = get anything to display. The frame is being displayed, but nothing is = being painted. I get no error message until I resize or close the = window, at which point I'm notified that gljDestroy failed (free). Any help would be appreciated. Thanks, Chad Below is the code I'm running: --------------------------------------------------------------------- import gl4java.swing.GLJPanel; import java.awt.BorderLayout; import javax.swing.JFrame; public class Exercise2 extends GLJPanel { // Constructors public Exercise2() { super(false); } // Overridden GLJPanel Protocol public void init() { super.init(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClearDepth(1.0f); gl.glShadeModel(GL_SMOOTH); gl.glEnable(GL_DEPTH_TEST); gl.glDepthFunc(GL_LESS); gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } public void display() { if (!glj.gljMakeCurrent()) { System.out.println("Make current failed"); return; } System.out.println("Started rendering"); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glTranslatef(-1.5f, 0.0f, -6.0f); gl.glBegin(GL_TRIANGLES); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 0.0f); gl.glEnd(); System.out.println("Ended rendering"); glj.gljSwap(); glj.gljFree(); } public void reshape(int pWidth, int pHeight) { gl.glViewport(0, 0, pWidth, pHeight); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, (float)pWidth/(float)pHeight, 0.1f, 100.0f); gl.glMatrixMode(GL_MODELVIEW); } // Test Driver public static void main(String[] args) { JFrame lFrame =3D new JFrame("Exercise2"); Exercise2 lPanel =3D new Exercise2(); lFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); lFrame.getContentPane().add(lPanel, BorderLayout.CENTER); lFrame.setSize(300, 300); lFrame.show(); } } |
From: Chad S. <sta...@ea...> - 2002-06-08 15:35:52
|
Problem resolved - Only after turning on the GLContext debugging (whose = debugging capabilities should be much more prominently documented) was I = able to determine that an exception was being thrown at the end of my = display method. It turns out that the glSwap call was the problem. If = I remove it and instead wrapper the display methods in a pushMatrix(), = popMatrix() combo, everything works fine. Now my question is: Why doesn't glSwap work even after I changed the = constructor to specify doubleBuffer =3D true? Does anyone know the = rules? I notice that the converted NeHe tutorials use glSwap, but are = run within the context of an Applet. None of the Swing demos use = glSwap. Is its usage verboten in Swing? Thanks in Advance, Chad ----- Original Message -----=20 From: Chad Stansbury=20 To: gl4...@li...=20 Sent: Friday, June 07, 2002 6:13 PM Subject: [gl4java-usergroup] Newbie: Using GLJPanel Hello, I'm attempting to learn OpenGL by following the NeHe tutorials, = and using the GLJPanel to do so. However, I have so far been unable to = get anything to display. The frame is being displayed, but nothing is = being painted. I get no error message until I resize or close the = window, at which point I'm notified that gljDestroy failed (free). Any help would be appreciated. Thanks, Chad Below is the code I'm running: --------------------------------------------------------------------- import gl4java.swing.GLJPanel; import java.awt.BorderLayout; import javax.swing.JFrame; public class Exercise2 extends GLJPanel { // Constructors public Exercise2() { super(true); } // Overridden GLJPanel Protocol public void init() { super.init(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClearDepth(1.0f); gl.glShadeModel(GL_SMOOTH); gl.glEnable(GL_DEPTH_TEST); gl.glDepthFunc(GL_LESS); gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } public void display() { if (!glj.gljMakeCurrent()) { System.out.println("Make current failed"); return; } System.out.println("Started rendering"); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glTranslatef(-1.5f, 0.0f, -6.0f); gl.glBegin(GL_TRIANGLES); gl.glVertex3f(0.0f, 1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 0.0f); gl.glEnd(); System.out.println("Ended rendering"); glj.gljSwap(); glj.gljFree(); } public void reshape(int pWidth, int pHeight) { gl.glViewport(0, 0, pWidth, pHeight); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, (float)pWidth/(float)pHeight, 0.1f, = 100.0f); gl.glMatrixMode(GL_MODELVIEW); } // Test Driver public static void main(String[] args) { JFrame lFrame =3D new JFrame("Exercise2"); Exercise2 lPanel =3D new Exercise2(); lFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); lFrame.getContentPane().add(lPanel, BorderLayout.CENTER); lFrame.setSize(300, 300); lFrame.show(); } } |
From: Chad S. <sta...@ea...> - 2002-06-08 18:11:02
|
Oops, looks like I spoke too soon. The gljSwap() works just fine, thank = you. It's the gljFree() that was throwing the exception. Please forget = all the nonsense that I spouted in my previous email. Thanks, Chad PS - This does, however, raise the question "When to use gljFree()? |
From: Chad S. <sta...@ea...> - 2002-07-10 13:26:04
|
Hello - I'm a newbie at both OpenGL, and GL4Java. However, I've been reading = the redbook, and using GL4Java to implement a lot of the exercise in the = redbook. I had a lot of problems getting GL4Java set up properly = (mostly due to my inability to read the FAQ), and would like to begin = writing some docs/tutorial to make the process easier for other = newbies... Does anyone think this would be useful? If so, is there someone who = would like to house these documents on the website? Thanks in Advance, Chad ----- Original Message -----=20 From: Chad Stansbury=20 To: gl4...@li...=20 Sent: Saturday, June 08, 2002 12:11 PM Subject: Re: [gl4java-usergroup] Newbie: Using GLJPanel Oops, looks like I spoke too soon. The gljSwap() works just fine, = thank you. It's the gljFree() that was throwing the exception. Please = forget all the nonsense that I spouted in my previous email. Thanks, Chad PS - This does, however, raise the question "When to use gljFree()? |
From: Antony R. <an...@li...> - 2002-07-10 15:14:16
|
I'm currently trying to develop a range of tutorials as well. I also in = the process of designing some kind of site to house all this info as = well. So, I'd be more than happy to put your documents up. Let me know what you think. Antony ----- Original Message -----=20 From: Chad Stansbury=20 To: gl4...@li...=20 Sent: Wednesday, July 10, 2002 2:27 PM Subject: [gl4java-usergroup] Additional GL4Java docs needed? Hello - I'm a newbie at both OpenGL, and GL4Java. However, I've been reading = the redbook, and using GL4Java to implement a lot of the exercise in the = redbook. I had a lot of problems getting GL4Java set up properly = (mostly due to my inability to read the FAQ), and would like to begin = writing some docs/tutorial to make the process easier for other = newbies... Does anyone think this would be useful? If so, is there someone who = would like to house these documents on the website? Thanks in Advance, Chad ----- Original Message -----=20 From: Chad Stansbury=20 To: gl4...@li...=20 Sent: Saturday, June 08, 2002 12:11 PM Subject: Re: [gl4java-usergroup] Newbie: Using GLJPanel Oops, looks like I spoke too soon. The gljSwap() works just fine, = thank you. It's the gljFree() that was throwing the exception. Please = forget all the nonsense that I spouted in my previous email. Thanks, Chad PS - This does, however, raise the question "When to use gljFree()? |