Trouble creating mouse

Started by Morgrog, January 12, 2004, 15:22:40

Previous topic - Next topic

Morgrog

Sorry for the long paste, but if anyone would be nice enough to check in my code, I'd love to know why/where it screws up :o

Here's what I get (on some computers) when starting my app (from webstart) (on most computers it starts great, altho it doesn't do much)

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x1D5E9AEC
Function=Java_org_lwjgl_input_Mouse_nCreate+0x1C
Library=C:\Documents and Settings\stamoun\Application Data\Sun\Java\Deployment\javaws\cache\http\Dstamoun.is-a-geek.org\P80\DMjava\RNlwjgl-windows.jar\lwjgl.dll

Current Java thread:
	at org.lwjgl.input.Mouse.nCreate(Native Method)
	at org.lwjgl.input.Mouse.create(Unknown Source)
	at com.stamoun.games.missilecommand.MCMain.createMouse(MCMain.java:83)
	at com.stamoun.games.missilecommand.MCMain.<init>(MCMain.java:44)
	at com.stamoun.games.missilecommand.MCMain.main(MCMain.java:268)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.sun.javaws.Launcher.executeApplication(Unknown Source)
	at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
	at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
	at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
	at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
	at com.sun.javaws.Launcher.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Dynamic libraries:
0x00400000 - 0x00407000 	C:\Java\j2re1.4.2_03\bin\javaw.exe
0x78460000 - 0x784E0000 	C:\WINNT\System32\ntdll.dll
0x77DA0000 - 0x77DFB000 	C:\WINNT\system32\ADVAPI32.dll
0x77E70000 - 0x77F2C000 	C:\WINNT\system32\KERNEL32.dll
0x770C0000 - 0x7712E000 	C:\WINNT\system32\RPCRT4.dll
0x77E00000 - 0x77E64000 	C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F7C000 	C:\WINNT\system32\GDI32.DLL
0x78000000 - 0x78046000 	C:\WINNT\system32\MSVCRT.dll
0x08000000 - 0x08138000 	C:\Java\j2re1.4.2_03\bin\client\jvm.dll
0x77540000 - 0x77571000 	C:\WINNT\System32\WINMM.dll
0x10000000 - 0x10007000 	C:\Java\j2re1.4.2_03\bin\hpi.dll
0x007E0000 - 0x007EE000 	C:\Java\j2re1.4.2_03\bin\verify.dll
0x007F0000 - 0x00809000 	C:\Java\j2re1.4.2_03\bin\java.dll
0x00810000 - 0x0081D000 	C:\Java\j2re1.4.2_03\bin\zip.dll
0x18270000 - 0x1837F000 	C:\Java\j2re1.4.2_03\bin\awt.dll
0x777F0000 - 0x7780D000 	C:\WINNT\System32\WINSPOOL.DRV
0x75E00000 - 0x75E1A000 	C:\WINNT\System32\IMM32.dll
0x77A40000 - 0x77B2C000 	C:\WINNT\system32\ole32.dll
0x18380000 - 0x183D0000 	C:\Java\j2re1.4.2_03\bin\fontmanager.dll
0x51000000 - 0x51044000 	C:\WINNT\System32\ddraw.dll
0x72810000 - 0x72816000 	C:\WINNT\System32\DCIMAN32.dll
0x5C000000 - 0x5C0C7000 	C:\WINNT\System32\D3DIM700.DLL
0x60000000 - 0x60045000 	C:\WINNT\System32\MSCTF.dll
0x1C690000 - 0x1C69A000 	C:\Java\j2re1.4.2_03\javaws\javawspl.dll
0x77580000 - 0x777C6000 	C:\WINNT\system32\SHELL32.dll
0x70BD0000 - 0x70C34000 	C:\WINNT\system32\SHLWAPI.dll
0x71780000 - 0x7180A000 	C:\WINNT\system32\COMCTL32.dll
0x1C970000 - 0x1C97F000 	C:\Java\j2re1.4.2_03\bin\net.dll
0x74FB0000 - 0x74FC3000 	C:\WINNT\System32\WS2_32.dll
0x74FA0000 - 0x74FA8000 	C:\WINNT\System32\WS2HELP.DLL
0x61210000 - 0x6121F000 	C:\Program Files\Microsoft Hardware\Mouse\POINT32.dll
0x77830000 - 0x7783C000 	C:\WINNT\System32\rnr20.dll
0x77970000 - 0x77994000 	C:\WINNT\System32\DNSAPI.DLL
0x74FD0000 - 0x74FD9000 	C:\WINNT\System32\WSOCK32.dll
0x77310000 - 0x77323000 	C:\WINNT\System32\iphlpapi.dll
0x774F0000 - 0x774F5000 	C:\WINNT\System32\ICMP.DLL
0x772F0000 - 0x77307000 	C:\WINNT\System32\MPRAPI.DLL
0x750D0000 - 0x750E0000 	C:\WINNT\System32\SAMLIB.DLL
0x750F0000 - 0x7513F000 	C:\WINNT\System32\NETAPI32.DLL
0x77BD0000 - 0x77BDF000 	C:\WINNT\System32\Secur32.dll
0x75140000 - 0x75146000 	C:\WINNT\System32\NETRAP.dll
0x77940000 - 0x77969000 	C:\WINNT\system32\WLDAP32.dll
0x779A0000 - 0x77A3B000 	C:\WINNT\system32\OLEAUT32.DLL
0x77380000 - 0x773AF000 	C:\WINNT\System32\ACTIVEDS.DLL
0x77350000 - 0x77372000 	C:\WINNT\System32\ADSLDPC.DLL
0x77820000 - 0x7782E000 	C:\WINNT\System32\RTUTILS.DLL
0x783C0000 - 0x78450000 	C:\WINNT\System32\SETUPAPI.DLL
0x77C00000 - 0x77C5F000 	C:\WINNT\System32\USERENV.DLL
0x774B0000 - 0x774E2000 	C:\WINNT\System32\RASAPI32.DLL
0x77490000 - 0x774A1000 	C:\WINNT\System32\RASMAN.DLL
0x77500000 - 0x77522000 	C:\WINNT\System32\TAPI32.DLL
0x77330000 - 0x77349000 	C:\WINNT\System32\DHCPCSVC.DLL
0x72C60000 - 0x72CE5000 	C:\WINNT\System32\CLBCATQ.DLL
0x777D0000 - 0x777D8000 	C:\WINNT\System32\winrnr.dll
0x777E0000 - 0x777E5000 	C:\WINNT\System32\rasadhlp.dll
0x74F50000 - 0x74F6F000 	C:\WINNT\system32\msafd.dll
0x74F90000 - 0x74F97000 	C:\WINNT\System32\wshtcpip.dll
0x77810000 - 0x77817000 	C:\WINNT\system32\version.dll
0x75950000 - 0x75956000 	C:\WINNT\system32\LZ32.DLL
0x1CEA0000 - 0x1CEA3000 	C:\WINNT\mui\fallback\040c\msctf.dll.mui
0x61220000 - 0x61232000 	C:\Program Files\Microsoft Hardware\Mouse\MSH_ZWF.dll
0x1CFE0000 - 0x1D002000 	C:\Java\j2re1.4.2_03\bin\dcpr.dll
0x1D570000 - 0x1D58E000 	C:\Java\j2re1.4.2_03\bin\jpeg.dll
0x1D5D0000 - 0x1D614000 	C:\Documents and Settings\stamoun\Application Data\Sun\Java\Deployment\javaws\cache\http\Dstamoun.is-a-geek.org\P80\DMjava\RNlwjgl-windows.jar\lwjgl.dll
0x5F580000 - 0x5F5A9000 	C:\WINNT\System32\DINPUT.dll
0x69310000 - 0x693D7000 	C:\WINNT\System32\OPENGL32.dll
0x6FA00000 - 0x6FA20000 	C:\WINNT\System32\GLU32.dll
0x6F8E0000 - 0x6F8E8000 	C:\WINNT\System32\HID.DLL
0x69500000 - 0x698C1000 	C:\WINNT\System32\nvoglnt.dll
0x77910000 - 0x77933000 	C:\WINNT\system32\imagehlp.dll
0x72970000 - 0x7299D000 	C:\WINNT\system32\DBGHELP.dll
0x68EA0000 - 0x68EAB000 	C:\WINNT\System32\PSAPI.DLL

Heap at VM Abort:
Heap
 def new generation   total 576K, used 402K [0x10010000, 0x100b0000, 0x104f0000)
  eden space 512K,  76% used [0x10010000, 0x10071870, 0x10090000)
  from space 64K,  19% used [0x10090000, 0x100932d0, 0x100a0000)
  to   space 64K,   0% used [0x100a0000, 0x100a0000, 0x100b0000)
 tenured generation   total 1916K, used 1410K [0x104f0000, 0x106cf000, 0x14010000)
   the space 1916K,  73% used [0x104f0000, 0x10650ba0, 0x10650c00, 0x106cf000)
 compacting perm gen  total 7680K, used 7436K [0x14010000, 0x14790000, 0x18010000)
   the space 7680K,  96% used [0x14010000, 0x14753260, 0x14753400, 0x14790000)

Local Time = Mon Jan 12 10:27:45 2004
Elapsed Time = 13
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_03-b02 mixed mode)
#



If you wanna see the source code, you can get it from here

I think my init code is messed up, also the app crashes if I alt-tab :cry:

(running on WinXP, lwjgl 8.0)

Can anybody help me out? pretty pretty plz? :D

princec

My guess is that you haven't inited the display first. Which shouldn't cause a crash, all the same. We'll have to investigate.

Cas :)

Matzon

confirming, investigating...

on a related note, cant wait to try out your Missile Command ;)

Matzon

fixed - NULL pointer on direct input, when no window
wonder why no one found it before...

Matzon

On a related and just as fun note, controller has been broken for some time...

I'll fix this as soon as I get a hold on Cas...

[EDIT] Fixed

Morgrog

yah, speaking of controllers, the controller test bundled with lwjgl doesn't seem to notice my usb gamepad :cry:


So, uh how do I get this "fixed" version of lwjgl? you updated the sf download?

And are there any ways to circumvent the aforementionned problem with code? or is it really a 'bug' in the native libraries?

Matzon

Quote from: "Morgrog"yah, speaking of controllers, the controller test bundled with lwjgl doesn't seem to notice my usb gamepad :cry:
It should work perfectly now

QuoteSo, uh how do I get this "fixed" version of lwjgl? you updated the sf download?
Hmm, you download it from CVS, and compile it yourself. Or you wait for next release. Or I'll provide you a dll (later, tonight, need your email) :)

QuoteAnd are there any ways to circumvent the aforementionned problem with code? or is it really a 'bug' in the native libraries?
The Mouse bug is a bug, that cannot and should not be circumvented. The fix merely throw an exception now, instead of crashing. You MUST create the window before input devices.

The controller bug cannot be circumvented, but has also been fixed in CVS.

Morgrog

I guess I'll need to look at my code then :)

Are there any ways to 'wait' for the window creation and then creating the input?

I'll also have to check with my alt-tab bug (when I alt-tab, my app crashes)

meh

And I hope Missile Command will be up soon, but I still have lots to learn (I must be the newbiest of all newbies when it comes to java/openGL, so the learning curve is quite steep) :D

Morgrog

Here's the part of my code that creates the mouse

public MCMain()
		{
			init_lwjgl(640, 480, 16);								// Init lwjgl
			createMouse();
			main_loop();											// Run the main loop
			cleanup();												// Cleanup
		}

		/** Init lwjgl (display and input if needed)
		 */
	
		public void init_lwjgl(int width, int height, int bpp)
		{
			try
			{
				  // Find the display mode
				DisplayMode[] modes = Display.getAvailableDisplayModes();

				for(int i = 0; i < modes.length; i++)
				{
					if(   modes[i].width == width
					   && modes[i].height == height
					   && modes[i].bpp >= bpp)
					{
						mode = modes[i];
					}
				}

				  // Start in windowed mode
				Window.create("Missile Command", 50, 50, mode.width, mode.height, mode.bpp, 0, 8, 0);

				init_gl();

				Keyboard.create();
			} catch(Exception e) 
			{
				e.printStackTrace();
			}
		}

		private void createMouse() {
		  	try {
				Mouse.create();
		  	} catch (Exception e) {
				e.printStackTrace();
				System.exit(-1);
		  	}
		}


So uh how come lwjgl didn't create the window in the first place, isn't it obvious that the mouse is created after?

Also, which is best, the way I create my keyboard (right after my init_gl, inside init_lwjgl) or the way I create my mouse (outside init_lwjgl)?

weee, I'm such a newb hehe Hopefully you guys will be patient enough with me :P

Matzon

hmm, your example works perfectly fine... *ponder*

Morgrog

Here's what I got from redirecting the console output to a file (take a close look at the 4th line) :)

Java Web Start 1.4.2_03 Console, démarrée Tue Jan 13 09:25:41 EST 2004
Environnement d'exécution Java 2 : version 1.4.2_03 par Sun Microsystems Inc.
Consignation dans le fichier : C:\Documents and Settings\stamoun\Bureau\j.log
java.lang.Exception: This application requires a greater colour depth
	at org.lwjgl.opengl.Window.nCreate(Native Method)
	at org.lwjgl.opengl.Window.createWindow(Unknown Source)
	at org.lwjgl.opengl.Window.create(Unknown Source)
	at com.stamoun.games.missilecommand.MCMain.init_lwjgl(MCMain.java:70)
	at com.stamoun.games.missilecommand.MCMain.<init>(MCMain.java:43)
	at com.stamoun.games.missilecommand.MCMain.main(MCMain.java:268)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.sun.javaws.Launcher.executeApplication(Unknown Source)
	at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
	at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
	at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
	at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
	at com.sun.javaws.Launcher.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Java Web Start 1.4.2_03 Console, démarrée Tue Jan 13 09:27:35 EST 2004
Environnement d'exécution Java 2 : version 1.4.2_03 par Sun Microsystems Inc.
Consignation dans le fichier : C:\Documents and Settings\stamoun\Bureau\j.log


Basically, my window creation sux, it tries and create a window in 32 bit even if the desktop is in 16 bits, time to revamp my init code :mrgreen:

Weird tho, my init_lwjgl is called with a 640x480 window with 16 bpp :/
Something's not right here :(

cfmdobbie

Quote from: "Morgrog"Weird tho, my init_lwjgl is called with a 640x480 window with 16 bpp :/
Something's not right here :(

But you're specifying >= the passed bpp.  I guess there's no reason to suppose that 16-bit comes before 32-bit in the display mode list. ;)
ellomynameis Charlie Dobbie.

Morgrog

gah, of course... *smacks forehead*

but why then if it's supported (from the getAvailableDisplayModes) does it shoots an exception?

gah, I hate being such a newbie at something as easy *cough* as opengl/java ;) hehe (I'm j/k of course)

princec

The display modes returned aren't a cast-iron guarantee of support which is why we throw Exceptions that you have to catch. But this is not the error you're getting.

You're actually asking for a minimum of 32 bits OpenGL buffer which is somewhat independent of the screen buffer. If you had a 32 bit screen and asked for 16 bit minimum OpenGL, you'd probably get a 32 bit OpenGL buffer regardless.

Cas :)

Morgrog

Hmm, not too sure I understand the difference between the two

One being the desktop's bpp and the other being the vid card's bpp?

It crashes when I start windowed, but I guess it wouldn't crash when running it fullscreen eh? or am I mistaking?

If that's true, don't I just have to get the Desktop's rez and make sure the bpp of the newly created window is the same if running in windowed mode?

Thanks for all your help :D