VM error running nehe lesson#1

i’m trying to run the code of the first nehe opengl tutorials

everything goes well until i close the window, then the vm crashes with the following message

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0xb1993198, pid=9330, tid=2981018544
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
# Problematic frame:
# C  0xb1993198
#
# An error report file with more information is saved as hs_err_pid9330.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

hs_err_pid9330.log attached for it could be of some use

well, it seems to be caused by a Display.destroy() call on exit, commenting that line prevents the vm to crash, but is it safe? can i exit a lwgl program without destroying the display?

pardon my noobnes, both with lwgl and with opengl at all :stuck_out_tongue:

Which version of LWJGL are you using?

Kev

0.99, downloaded today :slight_smile:

[edit] nevermind i was importing the wrong “DisplayMode” :S [/edit]
one more oditie, rewriting this tutorial miself, i get the DisplayModes as follows

DisplayMode[] modes = Display.getAvailableDisplayModes();

but i get this compilation problem

Type mismatch: cannot convert from DisplayMode[] to DisplayMode[]

I’m still getting this error sometimes

this is my code, the vm crashes when i don’t select any display mode in my selector, say, when the display is not set nor created.

public class Tutorial_1 implements Runnable{
	public boolean running = true, presionando_f1;
	private DisplayMode displayMode;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Tutorial_1();
		System.err.println("exiting...");
	}
	
	public Tutorial_1(){
		createWindow(false);
		run();
	}
	
	private void createWindow(boolean fullscreen){//init the window
		try{
			Display.setFullscreen(fullscreen);
			DisplayMode[] modes = Display.getAvailableDisplayModes();
			
			//This shows a dialog to let you choose a display mode
			int opcion = JOptionPane.showOptionDialog(null, "Select a display mode", "!",
					JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
					null, modes, 0);
			if(opcion != JOptionPane.CLOSED_OPTION) {//If you have selected an option...
				displayMode = modes[opcion];
				Display.setDisplayMode(displayMode);
				Display.setTitle("Tutorial 1 de Opengl con LWGL");
				Display.create();
				
			} else {//else, we won't loop on the run() method
				//System.exit(0); // Commented to avoid vm-crash (but i still get them), i'll use this instead
				running = false;
			}
			
		}catch(LWJGLException e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public void run(){
		while(running){
			if(Display.isCloseRequested()){//Exits if requested
				running = false;
			}
		}
	}
}

thanks for the help, i’m off to a good start and i want to know where do this errors come to avoid them in further projects ;D

nvidia issue, fixed in cvs by not unloading OpenGL

Index: GLContext.java
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- GLContext.java	29 Aug 2005 20:14:59 -0000	1.53
+++ GLContext.java	12 Jan 2006 12:25:12 -0000	1.54
@@ -320,7 +320,11 @@
 	/** The OpenGL library reference count is decremented, and if it reaches 0, the library is unloaded. */
 	public static synchronized void unloadOpenGLLibrary() {
 		gl_ref_count--;
-		if ( gl_ref_count == 0 )
+		/*
+		 * Unload the native OpenGL library unless we're on linux, since
+		 * some drivers (NVIDIA proprietary) crash on exit when unloading the library.
+		 */
+		if (gl_ref_count == 0 && LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_LINUX)
 			nUnloadOpenGLLibrary();
 	}

wow, thanks!
you are doing a grat job with lwgl :slight_smile: