Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Keyboard.poll() Access Violation?  (Read 1817 times)
0 Members and 1 Guest are viewing this topic.
Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Posted 2004-01-18 15:57:46 »

I'm on travel this week and have been showing various people the cool things you can do with Java and OpenGL.  So far, everyone has been impressed, even with the admittedly junior stuff I've put together thus far (although it does include some vertex and frag programming!  Yeah!)

Only on one computer have I had any problems.  Oddly enough, it throws an EXCEPTION_ACCESS_VIOLATION in the polling of the Keyboard...  Huh

1  
2  
3  
4  
5  
6  
7  
8  
9  
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x2C7A405
Function=Java_org_lwjgl_input_Keyboard_nPoll+0x5
Library=E:\Documents and Settings\Joshua Slack\Desktop\Dirt-OGL\Dirt-OGL\lwjgl.dll

Current Java thread:
      at org.lwjgl.input.Keyboard.nPoll(Native Method)
      at org.lwjgl.input.Keyboard.poll(Unknown Source)
      ...


I figured any problems I encountered would be in the rendering, etc.  (I have all the advanced stuff off by default to keep from crashing any low end pc on the first run...)

Anyhow, does anyhow have any suggestions on what I can try here?  I'd like to understand why this is happening in case I come across it again in support of a real program down the road.  I have access to the offending PC for about another week and can try tests.  I don't have any good way to code until I get back home though.  Sad

Here's the PC's specs:

Pentium 3 466MHZ
WinXP SP1
512MB Ram
several GB of available HD space.
Video card is on board and shares 16 MB of the system Ram... not sure who made it.
Java 1.4.2_01-b06

Thanks for any hints on this...

Renanse  (ruh-NON-say)
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #1 - Posted 2004-01-18 16:48:35 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll
  (JNIEnv * env, jclass clazz, jobject buffer)
{
      HRESULT ret;
      do {
            ret = lpdiKeyboard->Acquire();
            if (ret == DIERR_INPUTLOST) {
                  printf("Input lost\n");
                  return;
            } else if (ret == DIERR_NOTACQUIRED) {
                  printf("not acquired\n");
                  return;
            } else if (ret == DIERR_INVALIDPARAM) {
                  printf("invalid parameter\n");
                  return;
            } else if (ret == DIERR_NOTBUFFERED) {
                  printf("not buffered\n");
                  return;
            } else if (ret == DIERR_NOTINITIALIZED) {
                  printf("not inited\n");
                  return;
            } else if (ret != DI_OK && ret != S_FALSE) {
                  //printf("unknown keyboard error\n");
                  return;
            }
      } while (ret != DI_OK && ret != S_FALSE);
     
      void *keyboardBuffer = (void *)env->GetDirectBufferAddress(buffer);
      lpdiKeyboard->GetDeviceState(256, keyboardBuffer);
}


the supplied buffer is created by the java side in:
1  
2  
3  
/** The keys status from the last poll */
      private static final ByteBuffer keyDownBuffer = ByteBuffer.allocateDirect(256);
     


so basically either lpdiKeyboard is NULL or GetDeviceState is failing rather violently...- or aquire fails miserably forever?

What version of LWJGL, DirectX ?
Can you try this "debug" dll: http://www.matzon.dk/brian/Random%20Junk/lwjgl.zip

it just spews out numbers depending on where it is in the native code - want to track offending line.

Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2004-01-18 17:27:55 »

... and tell me if Alien Flux works on this machine, too.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #3 - Posted 2004-01-18 21:26:12 »

Well, I've tried Alien Flux and it bombs out saying that I need to have an OpenGL able card.  Would the kind of error I'm seeing be OpenGL related though?  (considering it is Keyboard and all)  Or perhaps your game tests all that before touching the keyboard...

I'll next run my app with the drivers you pointed to.  After that, I'll look up the board info and see if I can determine the manufacturer of the card.

Thanks for looking at this Cas.

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #4 - Posted 2004-01-18 21:27:43 »

PS: bombs was a fairly harsh way for me to put it... Alien Flux has really friendly "support logic".  Kudos!

Renanse  (ruh-NON-say)
Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #5 - Posted 2004-01-18 21:49:53 »

Results of run with debug dll...  It looks like a 1 and 2 are printed out...

I was able to access my code remotely and ack... I feel a bit stupid, and yet still puzzled too.  The local error was saying I had an NPE.  Based on the Exception error message discussing Keyboard, and my own remembrance of the code lines, I thought that the NPE corresponded to my call to Keyboard.create().  Looking at the actual code though I'm embarrassed because the error is a few lines earlier actually, where I am calling Window.create()

Since I am getting an NPE there, I'm guessing it was due to my use of mode.bpp, etc. without checking to make sure mode is non-null.  As Alien Flux indicated, this is probably due to no GL drivers for my card, thus no valid mode was found in my code before there.

Still, why is that whole message regarding the Keyboard and Exception access violation printing out?  Is that where the native side was when the java side failed?  :-/  

Sorry if this turned out to be a goose chase.  The error messages seemed to point the way I was going.  (I'd really like to understand why it says the Keyboard thing though.)  I will still look for an updated driver to whatever card this thing is running and let you know if that clears up the problem.

Renanse  (ruh-NON-say)
Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #6 - Posted 2004-01-18 22:11:38 »

Are you perchance catching and printing the NPE, but continuing regardless?  The last time I checked I believe LWJGL crashed out with that kind of error if you tried to open input devices without opening a GL window.  Maybe your code fails on opening the window but then tries the controller creation anyway?

Hellomynameis Charlie Dobbie.
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #7 - Posted 2004-01-19 03:45:58 »

Quote
Maybe your code fails on opening the window but then tries the controller creation anyway?
Or the keyboard.create is failing and you continue anyway... - it *is* possible to crash in poll, if keyboard wasn't created properly, and still calling poll...

Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2004-01-19 06:40:42 »

Hang on, I think Brian has just fixed this bug already in CVS. If keyboard creation failed in the current released 0.8 it was somehow possible to still call methods on it. I haven't looked at the fix yet.

It's sort of telling that AF complains you don't have an OpenGL card... it'll tend to do this when you genuinely don't have OpenGL drivers installed, and if you don't have drivers, it can't create the LWJGL window, and if you don't create the window, it can't create the DirectInput handler for the keyboard...

Cas Smiley

Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #9 - Posted 2004-01-19 14:14:40 »

Quote
Are you perchance catching and printing the NPE, but continuing regardless?  The last time I checked I believe LWJGL crashed out with that kind of error if you tried to open input devices without opening a GL window.  Maybe your code fails on opening the window but then tries the controller creation anyway?

Doh, that's the last piece of the puzzle.  Yeah, basically, mode was null, thus NPE... catch prints it out but continues... Comes back and goes into the main loop where it goes out to my Keyboard delegate and calls a poll.

Thanks all for helping me figure that out.  Sorry for the chase.  <muse>I think if we put together a best practices demo for gathering and selecting the proper display mode(s) (and handling exceptions... hehe,) that might help future lwjgl developers avoid mistakes like this.</muse>

As for me...  I'm just feeling pretty silly for not catching it myself.   Bad assumptions about ppl having GL on my part.   Embarrassed

Renanse  (ruh-NON-say)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #10 - Posted 2004-01-21 12:34:23 »

PS: After discovering the built in card was some form of nVidia Alladin TNT2, I was able to force an upgrade of the driver and now the app works fine (albeit a bit slow and without some parts of the app)  I'm impressed it can run on something so old!

Renanse  (ruh-NON-say)
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2004-01-21 19:31:46 »

Alien Flux even ran on something as ancient as a Voodoo 3! (Albeit glitchily because I occasionally use textures bigger than 256 wide which it doesn't support)

Cas Smiley

Offline renanse

Junior Devvie




Intelligence is light to a dark world.


« Reply #12 - Posted 2004-01-22 11:18:30 »

Pretty impressive!  

Do you know of a site or doco with information on what the various cards support in the way of textures, vertex programming, OpenGL version, etc?

Renanse  (ruh-NON-say)
Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #13 - Posted 2004-01-22 11:42:51 »

The best site I've found for that kind of info is the Delphi3D OpenGL Hardware Registry.  You can look at the hardware support for a particular extension, or look at the features of a particular card.

To pull a report on your exact hardware, you should be able to download and run GLinfo - although on my machine it just picks up the Microsoft GDI driver. :-/

Hellomynameis Charlie Dobbie.
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #14 - Posted 2004-01-22 13:28:21 »

Didn't I tell you, Charlie, to take your S3 card and smash it into bits and throw it out the window?

Cas Smiley

Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #15 - Posted 2004-01-22 13:44:27 »

Regrettably, that means throwing the laptop it's attached to out of the window as well... Grin

After discovering it completely screws up OpenGL lighting calculations, I've stopped doing anything developmental on it.  Still my primary web browser though, and thus I tried GLinfo on it first.

Hellomynameis Charlie Dobbie.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!