Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
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  
  Bad badder baddest!  (Read 1300 times)
0 Members and 1 Guest are viewing this topic.
Offline darcone

Junior Duke




Size matters


« Posted 2003-04-10 18:50:15 »

Many people get this error when trying to run my game:

C:\dist>java -cp lwjgl.jar; Schlug
java.lang.NullPointerException
       at org.lwjgl.Display.create(Unknown Source)
       at Schlug.initGL(Schlug.java:123)
       at Schlug.run(Schlug.java:40)
       at java.lang.Thread.run(Thread.java:536)

All of them can run AF without any problems, so it can´t be LWJGL fault... But I cant find any error in my code, can you take a look?

here is the init() method:

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  
31  
32  
33  
// Initialize Opengl
  
  public void initGL() throws Exception {
      
    org.lwjgl.DisplayMode[] modes = Display.getAvailableDisplayModes();
    for (int i = 0; i < modes.length; i++) {
        if (modes[i].width == 1600 && modes[i].height == 1200 && modes[i].bpp == 32) {
            displayMode = modes[i];
            break;
        }
    }
      
    Display.create(displayMode, true, displayName);
    gl.create();
    org.lwjgl.input.Mouse.create();
    Keyboard.create();

    gl.shadeModel(GL.SMOOTH); // Enable Smooth Shading
    gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    gl.clearDepth(1.0); // Depth Buffer Setup
    gl.enable(GL.DEPTH_TEST); // Enables Depth Testing
    gl.depthFunc(GL.LEQUAL); // The Type Of Depth Testing To Do
    gl.matrixMode(GL.PROJECTION); // Select The Projection Matrix

    // Calculate The Aspect Ratio Of The Window
    
    glu.perspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 100.0f);
    gl.matrixMode(GL.MODELVIEW); // Select The Modelview Matrix

    gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); // Really Nice Perspective Calculations

    if (org.lwjgl.opengl.GL.WGL_EXT_swap_control) gl.wglSwapIntervalEXT(1); // Sync with refresh rate of monitor
  }
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2003-04-10 19:16:09 »

Seems pretty simple to me. You're requiring people to have 1600x1200 as a resolution (which most don't) and thus you're never getting a DisplayMode. How about you try 1024x768 and then tell us if there's a problem?

Java Game Console Project
Last Journal Entry: 12/17/04
Offline darcone

Junior Duke




Size matters


« Reply #2 - Posted 2003-04-10 19:45:40 »

oh lol Smiley thanks *g*
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.

theagentd (13 views)
2014-10-25 15:46:29

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (45 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!