Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (602)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  LWJGL Game Init and Main Loop  (Read 8248 times)
0 Members and 1 Guest are viewing this topic.
Offline princec

« JGO Spiffy Duke »


Medals: 434
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Posted 2004-04-16 08:47:22 »

With the advent of LWJGL 0.9 marking a freeze in the API I thought there might be some clubies who'd like to see how simple a LWJGL game can look.

So here is a complete Game class. Fill in the blanks with your game Wink (This code is checked into LWJGL CVS too)

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  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
/*
 * Copyright (c) 2002 Light Weight Java Game Library Project
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of 'Light Weight Java Game Library' nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


package org.lwjgl.examples;

import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.openal.AL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Window;

/**
 * $Id: Game.java,v 1.3 2004/05/05 14:35:05 cix_foo Exp $
 *
 * This is a <em>very basic</em> skeleton to init a game and run it.
 *
 * @author $Author: cix_foo $
 * @version $Revision: 1.3 $
 */

public class Game {
     
      /** Game title */
      public static final String GAME_TITLE = "My Game";
     
      /** Desired frame time */
      private static final int FRAMERATE = 60;
     
      /** Exit the game */
      private static boolean finished;
     
      /**
       * No constructor needed - this class is static
       */

      private Game() {}
     
      /**
       * Application init
       * @param args Commandline args
       */

      public static void main(String[] args) {
            try {
                  init();
                  run();
            } catch (Exception e) {
                  e.printStackTrace(System.err);
                  Sys.alert(GAME_TITLE, "An error occured and the game will exit.");
            } finally {
                  cleanup();
            }
      }
     
      /**
       * Initialise the game
       * @throws Exception if init fails
       */

      private static void init() throws Exception {
            // Create a fullscreen window with 1:1 orthographic 2D projection, and with
            // mouse, keyboard, and gamepad inputs.
            Window.create(GAME_TITLE);
           
            // Enable vsync if we can
            Window.setVSyncEnabled(true);
           
            // Start up the sound system
            AL.create();
           
            // TODO: Load in your textures etc here
      }
     
      /**
       * Runs the game (the "main loop")
       */

      private static void run() {
            while (!finished) {
                  // Always call Window.update(), all the time
                  Window.update();
                 
                  if (Window.isCloseRequested()) {
                        // Check for O/S close requests
                        finished = true;
                  } else if (Window.isActive()) {
                        // The window is in the foreground, so we should play the game
                        logic();
                        render();
                        org.lwjgl.Display.sync(FRAMERATE);
                  } else {
                        // The window is not in the foreground, so we can allow other stuff to run and
                        // infrequently update
                        try {
                              Thread.sleep(100);
                        } catch (InterruptedException e) {
                        }
                        logic();
                        if (Window.isVisible() || Window.isDirty()) {
                              // Only bother rendering if the window is visible or dirty
                              render();
                        }
                  }
            }
      }
     
      /**
       * Do any game-specific cleanup
       */

      private static void cleanup() {
            // TODO: save anything you want to disk here

            // Stop the sound
            AL.destroy();
           
            // Close the window
            Window.destroy();
      }
     
      /**
       * Do all calculations, handle input, etc.
       */

      private static void logic() {
            // Example input handler: we'll check for the ESC key and finish the game instantly when it's pressed
            if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
                  finished = true;
            }
            // TODO: all your game logic goes here.
      }
     
      /**
       * Render the current frame
       */

      private static void render() {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
            // TODO: all your rendering goes here
      }

}

<edit> fixed a bug in cleanup
<edit2> New timing code!

Cas Smiley

Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #1 - Posted 2004-04-16 13:30:42 »

1  
2  
3  
             // Create a fullscreen window with 1:1 orthographic 2D projection, and with
            // mouse, keyboard, and gamepad inputs.
            Window.create(GAME_TITLE) ;


Sweet! Grin

It's in things like that where LWJGL really shines.

Hellomynameis Charlie Dobbie.
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #2 - Posted 2004-04-16 16:22:11 »

as dobbie said....sweet!  Been wanting to play with this for while....that being said, let me fall into my semi-permanent roll as a clubie!

I found a statement that went something like this:  must have good graphics card to use lwjgl.

I don;t on my dev box and I am getting the follwoing error running any of the openGL demos:
org.lwjgl.LWJGLException: Could not choose ARB pixel formats.

I posted to this forum because I am getting a error:
1  
2  
3  
4  
Exception in thread "main" java.lang.NoClassDefFoundError
        at org.lwjgl.openal.AL.<clinit>(Unknown Source)
        at org.lwjgl.examples.Game.cleanup(Game.java:147)
        at org.lwjgl.examples.Game.main(Game.java:77)

for me line 147 is:
1  
  AL.destroy(); 

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #3 - Posted 2004-04-16 17:16:32 »

Quote
I found a statement that went something like this:  must have good graphics card to use lwjgl.

Hmm, no - but it does make sense to have an OGL capable card Wink - that said, some use mesa - and you have to specify allowSoftwareOpenGL to enable software gl mode.

Quote
I don;t on my dev box and I am getting the follwoing error running any of the openGL demos:
org.lwjgl.LWJGLException: Could not choose ARB pixel formats.

Hmm, strange - do normal OpenGL apps work at all? - it's a pretty fatal error.

Quote

I posted to this forum because I am getting a error:
1  
2  
3  
4  
Exception in thread "main" java.lang.NoClassDefFoundError
        at org.lwjgl.openal.AL.<clinit>(Unknown Source)
        at org.lwjgl.examples.Game.cleanup(Game.java:147)
        at org.lwjgl.examples.Game.main(Game.java:77)

for me line 147 is:
1  
  AL.destroy(); 

That error is a bit strange:
1 - the constructor has never been called in the init, which is why it's just now being called in the destroy
2 - It can't find the AL class - sure you have lwjgl.jar in the classpath ??

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #4 - Posted 2004-04-16 17:45:46 »

Quote
Hmm, strange - do normal OpenGL apps work at all? - it's a pretty fatal error.

Well Java3D for OpenGL works fine.

Classpath...it compiles fine, just does not run.  i wil double check classpath for run command in JCreator.

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline K.I.L.E.R

Senior Devvie




Java games rock!


« Reply #5 - Posted 2004-04-17 09:07:25 »

Here is a texture loader:
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  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.glu.*;

import javax.swing.*;
import java.awt.image.*;
import java.io.*;
import java.awt.*;
import java.nio.*;


public class Main
{


      private void programExec()
      {
      buff = BufferUtils.createIntBuffer(MAX);

      buff.put(getIntContents()).flip();

      GL11.glGenTextures(buff);
      }


      private int[] getIntContents()
      {
            int[] c = new int[MAX];
            int i=0;

            try
            {
          c[i] = fr.read();

          while(c[i] != -1)
                  {
                        i++;
                        c[i] = fr.read();
                  }
            }catch (Exception e)
            {
                  JOptionPane.showMessageDialog(null, e.getMessage());
                  e.printStackTrace();
            }

            return c;
      }



      /**
       * MAIN
       */

      public Main()
  {
        try
            {
               fr = new FileReader("c:\\texture.PNG");
            } catch (Exception e)
            {
                  JOptionPane.showMessageDialog(null, e.getMessage());
                  e.printStackTrace();
            }
      }

      public static void main(String[] args)
  {
            Main main = new Main();

            main.programExec();
      }
      /**
       * MAIN
       */


      BufferedImage bufImg;
      Image img;
      ImageIcon imgIc;
      FileReader fr;
      IntBuffer buff;

      final static int MAX = 25000;
}

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline D.t.O

Junior Devvie




Psych'd about Java Games


« Reply #6 - Posted 2004-04-17 18:26:13 »

Quote
With the advent of LWJGL 0.9 marking a freeze in the API I thought there might be some clubies who'd like to see how simple a LWJGL game can look.

Are you trying to convince me that LWJGL is better than others, or that game development in general is simple?

Enjoy.
Regards,
     - D.t.O
Offline SpuTTer

Senior Devvie


Medals: 1
Exp: 14 years


Lazy Middle Class Intellectual


« Reply #7 - Posted 2004-04-17 21:05:57 »

I think he was spending is time trying to give out a simple game loop to help out newbies who might want to be able to get a game going up quickly with a solid framework.

I think that's great. More people should be giving back to the community. We should encourage this, not be all 'mean' about it.

Huh

Sacramento Volleyball
"Whitty phrase goes here."
Offline nonnus29

Senior Devvie




Giving Java a second chance after ludumdare fiasco


« Reply #8 - Posted 2004-04-17 21:14:55 »

I could never run any lwjgl demos until I installed a newer driver for my POS intel onboard gfx.  I didn't think drivers would be available for it but after about 30 minutes of searching I did find them on the intel site.  

So you might try updating your drivers.
Offline D.t.O

Junior Devvie




Psych'd about Java Games


« Reply #9 - Posted 2004-04-18 14:10:31 »

Quote
I think that's great. More people should be giving back to the community. We should encourage this, not be all 'mean' about it

Oops...looks like I miscommunicated something Embarrassed.
Don't get me wrong here, I think this is a great idea! To me, all these relatively low-level APIs are just scary Cry.
Thanks Cas. Grin

Enjoy.
Regards,
     - D.t.O
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Morgrog

Senior Newbie




Rubber bands and cafeine, weeeee~


« Reply #10 - Posted 2004-04-23 17:38:07 »

1) /bump

2) woot! thx a zillion, that's gonna motivate me to actually do something (heck I've been around for a while and have yet to start anything, gd time constraints)

3) private static final float FRAMETIME = 1.0f / 60.0f; *claps at the time based loop* what happens if the fps drops below 60? (i.e. if the graphic card/cpu can't handle it?) and huh if this works like I think it does, do you really need to put setVSyncEnable?

4) no mouse? tsk tsk Wink

Thanks again from the most experienced in noobiness newless clubie  Grin
Offline princec

« JGO Spiffy Duke »


Medals: 434
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2004-04-24 10:35:48 »

Quote

2) woot! thx a zillion, that's gonna motivate me to actually do something (heck I've been around for a while and have yet to start anything, gd time constraints)

I've just started my 80hr game project based on this code. 4 hrs down, 76 to go.

Quote

3) private static final float FRAMETIME = 1.0f / 60.0f; *claps at the time based loop* what happens if the fps drops below 60? (i.e. if the graphic card/cpu can't handle it?) and huh if this works like I think it does, do you really need to put setVSyncEnable?

Then it slows down Smiley If you can use vsync then you'll not get any tearing, and that's all the difference it makes.

Quote

4) no mouse? tsk tsk

Mouse, controller, and keyboard are automatically created and polled by LWJGL for you now.

Cas Smiley

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #12 - Posted 2004-04-28 18:26:39 »

Found where I am dying when trying to run your simple game loop:
Window.create(GAME_TITLE);

I have a println in front of this and after.  The after never gets called, nothing is caught, then it goes straight to the finally() and throws a nullpointer because the AL.create() was never called. (since I cant get past WIndow.create(GAME_TITLE)Wink

hmmmm, I am cluieless and lost.

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #13 - Posted 2004-04-28 18:30:55 »

Try running in debug mode:
-Dorg.lwjgl.Sys.debug=true

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #14 - Posted 2004-04-28 18:53:23 »

1  
2  
3  
4  
5  
in the finally clause...
Exception in thread "main" java.lang.NoClassDefFoundError
        at org.lwjgl.openal.AL.<clinit>(Unknown Source)
        at org.lwjgl.examples.Game.cleanup(Game.java:163)
        at org.lwjgl.examples.Game.main(Game.java:81)

same as above...the AL is never created, debug mode showed nothing different

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #15 - Posted 2004-04-28 20:15:05 »

hmm, you really sholdn't ever receive a NoClassDefFoundError, unless you have your project setup in some wierd way...

could I get a copy of your project to find the error - this is really strange...

another way would be to grab the source and start adding debug code to find the exact line thats failing. I just dont get why you don't get any output when running in debug mode... *ponder*

Offline mezcal

Senior Newbie




Java games rock!


« Reply #16 - Posted 2004-04-29 01:12:14 »

I'm getting the same error...

Quote
Exception in thread "main" java.lang.NoClassDefFoundError
  at org.lwjgl.openal.AL.<clinit>(Unknown Source)
  at org.lwjgl.examples.Game.cleanup(Game.java:147)
  at org.lwjgl.examples.Game.main(Game.java:77)




Quote
Try running in debug mode:
-Dorg.lwjgl.Sys.debug=true


How do I do this?  (I'm using JCreater freeware, by the way..)
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #17 - Posted 2004-04-29 03:46:19 »

hmm this is getting odd...

the debug switch is something you append to your commandline... so if you normally do:
java org.lwjgl.examples.Game
you should now do:
java -Dorg.lwjgl.Sys.debug=true org.lwjgl.examples.Game

if you don't get *any* output - something is way wrong... I get:
Quote
Window registered
Releasing DC
Destroy window
Could not locate symbol glPointParameteriNV
NOTICE: GL_NV_point_sprite disabled because of missing driver symbols
Could not locate symbol glLoadProgramNV
Could not locate symbol glVertexStream1fATI
NOTICE: GL_ATI_vertex_streams disabled because of missing driver symbols
found X-axis
found Y-axis
found Wheel
found Button 0
found Button 1
found Button 2
found Button 3
found Button 4
found Button 5
found Button 6
found Button 7
WARNING: Clamping to 4 mouse buttons
found X Axis
found Y Axis
found Button 0
found Button 1
found Button 2
found Button 3
Adapter key: \Registry\Machine\System\CurrentControlSet\Control\Video\{70DC50FE-
FB2D-4BF2-BEB0-EAB6417827E1}\0000
Adapter key: \Registry\Machine\System\CurrentControlSet\Control\Video\{70DC50FE-
FB2D-4BF2-BEB0-EAB6417827E1}\0000
Adapter: ati2dvag Version: 6.14.10.6430
JWS Classloader looking for: lwjglaudio
Failure locating OpenAL using classloader:java.lang.NoSuchMethodException: sun.m
isc.Launcher$AppClassLoader.findLibrary(java.lang.String)
Found 2 OpenAL paths
Testing '..\libs\win32\'
Found OpenAL at '..\libs\win32\'
Deleting GL context
Destroying directinput
Releasing DC
Destroy window

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #18 - Posted 2004-04-29 11:08:01 »

Interesting I am using JCreator Pro.  Decided to try from command line with the following:

1  
C:\java\simple\lwjgl\Test\classes>java -Dorg.lwjgl.Sys.debug=true -classpath .;c:\java\simple\lwjgl9\lwjgl-win32-0.9\lwjgl.jar org.lwjgl.examples.Game


and still get the exact same thing.

My package
http://www22.brinkster.com/mbowles/lwjgl_test.zip

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #19 - Posted 2004-04-29 11:37:51 »

Quote
1  
C:\java\simple\lwjgl\Test\classes>java -Dorg.lwjgl.Sys.debug=true -classpath .;c:\java\simple\lwjgl9\lwjgl-win32-0.9\lwjgl.jar org.lwjgl.examples.Game

Hmm, and where's the lwjgl.dll placed? It might look like you'd need a:
1  
java -Djava.library.path=c:\java\simple\lwjgl9\lwjgl-win32-0.9\ -Dorg.lwjgl.Sys.debug=true -classpath .;c:\java\simple\lwjgl9\lwjgl-win32-0.9\lwjgl.jar org.lwjgl.examples.Game

?

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #20 - Posted 2004-04-29 13:16:01 »

ok, got a little further...

here is the out put from my app, I added a number of out.println()'s for my own testing, they all start with a --

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
Begin Main...
--Begin init...
--build window...
Adapter key: \REGISTRY\Machine\System\ControlSet001\Services\idisw2km\Device0
Adapter key: \REGISTRY\Machine\System\ControlSet001\Services\idisw2km\Device0
Adapter:  Version: null
Window registered
Releasing DC
Destroy window
Releasing DC
Destroy window
--beginning catch for an error...
org.lwjgl.LWJGLException: Could not choose ARB pixel formats.
        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 org.lwjgl.opengl.Window.create(Unknown Source)
        at org.lwjgl.examples.Game.init(Game.java:96)
        at org.lwjgl.examples.Game.main(Game.java:73)
*** Alert ***My Game
An error occured and the game will exit.
--in the finally clause...

C:\java\simple\lwjgl\Test\classes>


Your change helped, now what have I blown up?   Smiley


MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline mezcal

Senior Newbie




Java games rock!


« Reply #21 - Posted 2004-04-29 14:13:09 »

Mine is working now.


The "-Djava.library.path=c:\lwjgl-win32-0.9\" seemed to be what I was missing.

Quote
4. Should you wish to place the dll's in some other directory than you're class files (say /native as opposed to /classes) you could do so, by using the java.library.path property. For example

     java -cp classes; -Djava.library.path=native org.lwjgl.test.WindowCreationTest


That's from the lwjgl page.  I guess I should have listened to them, hehe.  I didn't know what they were talking about, though.  Why do you have to set Djava.library.path if your classes are in a different directory than the dll's?  I was kindof under the impression that's what classpath takes care of?

Am I correct when I assume that if there were no dll's involved.. (if I was just using someone else's pure java classes, from a different package..) then changing the classpath would have been enough?

Also, I didn't know that you had to set classpath both when you were compiling and executing.  So I was doing something like "javac Game.java -classpath .;c:\...\lwjgl.jar"  but later I would try to run it using java org.lwjgl.examples.Game.  (This was the first time I had to change the classpath for anything, so, if nothing else, I've learned something about it Smiley )
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #22 - Posted 2004-04-29 14:32:27 »

Quote
Why do you have to set Djava.library.path if your classes are in a different directory than the dll's?  I was kindof under the impression that's what classpath takes care of?
No, the classpath has to do with the classes loaded by the VM. The library path on the other hand, tells the VM where to locate it's native libraries.

Quote
Am I correct when I assume that if there were no dll's involved.. (if I was just using someone else's pure java classes, from a different package..) then changing the classpath would have been enough?
Yes

Quote
Also, I didn't know that you had to set classpath both when you were compiling and executing.  So I was doing something like "javac Game.java -classpath .;c:\...\lwjgl.jar"  but later I would try to run it using java org.lwjgl.examples.Game.  (This was the first time I had to change the classpath for anything, so, if nothing else, I've learned something about it Smiley )
Well, the classpath tells the VM where to find classes. When compiling, the compiler also needs to solve any dependencies which is why a classpath often also has to be set.

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #23 - Posted 2004-04-29 14:38:14 »

Quote

1  
2  
Adapter:  Version: null
org.lwjgl.LWJGLException: Could not choose ARB pixel formats.



Hmm, seems to be some OpenGL issues...
What graphics card?
could you try to download OpenGL Extensions Viewer from:
http://www.realtech-vr.com/glview/

then try the OGL tests...

Finish off with choosing File -> Save and email me the generated xml file (info@lwjgl.org)

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #24 - Posted 2004-04-29 16:18:29 »

glview will not run.  Missing dll. I am using the base graphics with my system, no additional video card.  I was informed one was not required, is it?

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline M4g3

Senior Newbie




Java games rock!


« Reply #25 - Posted 2004-04-29 16:31:08 »

Being the clueless newbie that I am (I read all the basics/essentials from the sun's tutorial and am able to draw some stuff in java2d) I really thank you for putting this up Smiley

I was struggling through some 2d tutorials which introduced me to a lot of methods for getting timers up and getting a gameloop to run at a proper FPS. And finding this was a pleasant surprise. Especially because all the test were working (except the grass, it gives me exceptions even while I have a nvidia card) and I got it into jcreator perfectly. Everything compiles perfectly and is working Smiley So thanks a lot and hopefully I'll be able to make a game in a month or something like that.

Now let's grab some opengl book or some tutorials Smiley

EDIT: I got NeHe's tutorials for java, and I figured a lot of the code just does the window creating which can be done easier since version 0.X. So I copied this code into my render function, but I aint getting any polygons on my screen, no errors either.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
      private static void render() { 
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
            GL11.glLoadIdentity();                                          // Reset The Current Modelview Matrix
                  GL11.glTranslatef(-1.5f,0.0f,-6.0f);                        // Move Left 1.5 Units And Into The Screen 6.0
                  GL11.glBegin(GL11.GL_TRIANGLES);                              // Drawing Using Triangles
                        GL11.glVertex3f( 0.0f, 1.0f, 0.0f);                  // Top
                        GL11.glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left
                        GL11.glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right
                  GL11.glEnd();                                                            // Finished Drawing The Triangle
                  GL11.glTranslatef(3.0f,0.0f,0.0f);                        // Move Right 3 Units
                  GL11.glBegin(GL11.GL_QUADS);                                    // Draw A Quad
                        GL11.glVertex3f(-1.0f, 1.0f, 0.0f);                  // Top Left
                        GL11.glVertex3f( 1.0f, 1.0f, 0.0f);                  // Top Right
                        GL11.glVertex3f( 1.0f,-1.0f, 0.0f);                  // Bottom Right
                        GL11.glVertex3f(-1.0f,-1.0f, 0.0f);                  // Bottom Left
                  GL11.glEnd();                                                            // Done Drawing The Quad
      }
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #26 - Posted 2004-04-29 17:09:18 »

NeHe demos usually have an init method which sets a bunch of default gl state. Did you remember to copy that as well...?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline M4g3

Senior Newbie




Java games rock!


« Reply #27 - Posted 2004-04-29 17:30:48 »

EDIT:
sorry for the confusion but everything is working correctly now, I did it all over and I must have made a stupid mistake in the init somewhere
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #28 - Posted 2004-04-29 18:14:41 »

Quote
glview will not run.  Missing dll. I am using the base graphics with my system, no additional video card.  I was informed one was not required, is it?
Well, you'll need an OpenGL capable card... it sounds like you don't have that ?`What card is it, or rather whats the name of the integrated graphics chip/ motherboard?

If you don't have opengl drivers, you're out of luck (and you have a *very* old graphics card/chip!)

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #29 - Posted 2004-04-30 11:03:35 »

Not sure of the chip, Dell Lattitude bought in OCt of 2002.  Not sure it this is related, but I do some Java3D work on this box using the java3d install for opengl and it works fine.

I'll poke around and see if I can determine the motherboard/chipset.

Edit: After running dxdiag, I found its a Radeon Mobility chipset with DirectDraw, Direct3D and AGP Texturing all accelerated and tested fine. doh!  I still must be screwing something up.

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Pages: [1] 2
  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 (30 views)
2014-12-15 09:26:44

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

BurntPizza (42 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 (51 views)
2014-12-03 16:27:13

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

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

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

toopeicgaming1999 (31 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!