RoboticsWar Java2D+LWJGL+JOGL

OpenGL can’t be used in applet cos OpenGL is using dll, and applet can’t load dll. Or am I wrong about that? :stuck_out_tongue:

Still jittery? Even in 100 fps? Is the fps drops somewhat in Java2D/JOGL?

That’s alright whome, hiding mouse pointer in LWJGL indeed makes the mouse pointer gone for sure :slight_smile:
In other environment the mouse is not visible too, isn’t it? So what’s wrong?

I guess you need to uinstall all your JDK whome, and install a fresh new one. Looks like your JDK is a bit weird there, very slow, or is that perhaps because of the graphics card?

Well then JOGL still has the most irritating problem so far :frowning:

Huh keyboard bug in applet? Applet use pure Java2D key function. Are you sure?

JOGL and Java2D did not steal a mouse cursor, which is a must for windowed mode.

LWJGL stole a mouse curson even in windowed mode, which is something that should not happen/be done. I don’t know whether its internal LWJGL feature and not an application driven option.

Maybe I should try on offline without a webstart. Do you have a standalone application bundle available. I could then use several JDKs and see how JOGL behaves. And I could even change a JOGL library versions to see results.

[quote]I don’t know whether its internal LWJGL feature and not an application driven option.
[/quote]
Application driven.

[quote]JOGL and Java2D did not steal a mouse cursor, which is a must for windowed mode.
[/quote]
It is? - wonder why all those games got it wrong then…
It should steal the cursor, unless the cursor is of relevance. Nothig more annoying than having a cursor block the view.

JOGL and Java2D use the same core, the Java AWT.
JOGL is only canvas that replace java.awt.Canvas.
So the basic is same. Only set the mouse pointer to 1x1 size transparent.

For why LWJGL steal the mouse cursor in windowed mode, ask the LWJGL team :stuck_out_tongue:

Offline? Download the jar one by one :stuck_out_tongue:
The game
http://goldenstudios.or.id/products/games/bin/robosick.jar

GTGE
http://goldenstudios.or.id/products/games/bin/golden_0_2_1.jar
http://goldenstudios.or.id/products/games/bin/GTGE_add_ons.jar

LWJGL
http://goldenstudios.or.id/products/games/bin/lwjgl.jar
http://goldenstudios.or.id/products/games/bin/lwjgl-windows.jar

JOGL
http://goldenstudios.or.id/products/games/bin/jogl.jar
http://goldenstudios.or.id/products/games/bin/jogl-natives-win32.jar

And run robosick.jar, it should do

[quote] For why LWJGL steal the mouse cursor in windowed mode, ask the LWJGL team
[/quote]
It does so, because you asked it to do it by calling Mouse.setGrabbed(true);

??? So there is another way to hide mouse pointer in LWJGL, I don’t know that?
How to do that?
The problem here is, when in the game (windowed mode), the mouse pointer not shown, but when outside the game window, the mouse pointer shown, just like Java2D.

LWJGL defaults to showing the cursor in windowed mode, and “stealing” it in fullscreen mode.
If you don’t have a cursor when playing in windowed mode, it’s because you called the setGrabbed method - or you set the cursor to a transparent one.

[quote]??? So there is another way to hide mouse pointer in LWJGL, I don’t know that?
How to do that?
The problem here is, when in the game (windowed mode), the mouse pointer not shown, but when outside the game window, the mouse pointer shown, just like Java2D.
[/quote]
I think what you are after is setting a transparent cursor using org.lwjgl.input.Mouse.setNativeCursor(Cursor cursor).

Yup I setGrabbed both in windowed and fullscreen mode because I don’t want the mouse cursor visible.
But the problem, once again, in windowed mode, even the mouse outside the game window, the cursor still not visible.
In Java2D, when the mouse INSIDE the game window the mouse cursor NOT VISIBLE, BUT OUTSIDE the game window the mouse cursor BACK TO NORMAL (VISIBLE)
In LWJGL, even outside the game window, the mouse cursor still not visible, is there another way to set the mouse cursor not visible in LWJGL instead of setGrabbed method? And makes the mouse cursor only not visible while IN THE GAME WINDOW?

For a better explanation, try out the roboticswar game and see the difference between Java2D/JOGL windowed mode and LWJGL windowed mode mouse cursor.

In the javadoc it said, “if native cursor supported” what that’s suppose to mean? Is it only works in Windows OS?
And how to create the org.lwjgl.input.Cursor? I don’t see image or buffered image in constructor parameter.
Sorry I’m very new to LWJGL, I learn LWJGL plus JOGL starting from two weeks ago.

As I said in the previous post: use Mouse.setNativeCursor. It will change the mouse image when the mouse cursor is inside the lwjgl window. If you set it with a transparent image the mouse cursor will be invisible when it is inside the lwjgl window. When you move it outside it will be visible, showing the cursor the normal way by the os.

Hell, I’ll even give you the some source:

import java.nio.*;
import org.lwjgl.input.Mouse;
import org.lwjgl.input.Cursor;


/**
 * Mouse cursor utility class.
 */
public class MouseCursor {


      /**
       * Makes the native cursor transparent. Does not grab the mouse.
       */
      public static void hideNativeCursor() {
            int minSize = Cursor.getMinCursorSize();
            Cursor cursor = createCursor(new int[minSize*minSize], minSize, minSize, 0, 0);
            enableNativeCursor(cursor);
      }


      /**
       * Sets the native curosr to the image specified by the parameters. The
       * MouseCursor position is set to the middle of the window.
       */
      public static void enableNativeCursor(Cursor cursor) {
            try {
                  if (cursor != null && (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY ) != 0) {
                        Mouse.setNativeCursor(cursor);
                  } else {
                        System.out.println("No HW cursor support!");
                        Mouse.setNativeCursor(null);
                  }
            } catch (Exception e) {
                  System.out.println("Exception setting hardware cursor:"+e.getMessage());
            }
      }


      /**
       * Creates a cursor.
       * @return the created cursor or null if creating failed.
       */
      public static Cursor createCursor(int data[], int w, int h, int x, int y) {
            try {
                  if ((Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY ) != 0) {
                        ByteBuffer scratch = ByteBuffer.allocateDirect(4 * data.length);
                        for (int i=0; i<data.length; i++) {
                              if ((data[i]>>>24) > 0) {
                                    scratch.put((byte) 0xff);
                                    scratch.put((byte) ((data[i]>>16) & 0xff));
                                    scratch.put((byte) ((data[i]>>8) & 0xff));
                                    scratch.put((byte) ((data[i]) & 0xff));
                              } else {
                                    scratch.putInt(0);
                              }
                        }
                        
                        scratch.rewind();
                        return new Cursor(w,h, x, y, 1, scratch.asIntBuffer(), null);
                  }
            } catch (Exception e) {
                  System.out.println("Exception creating cursor:"+e.getMessage());
            }

            return null;
      }
}

To use it you:

  1. Do NOT grab the mouse
  2. Call MouseCursor.hideNativeCursor()

I think the code uses Lwjgl 0.95. If you use another version of lwjgl it might not compile because they keep moving stuff around. Then you have to search the javadocs for it.

[quote]I don’t see image or buffered image in constructor parameter.
[/quote]
As LWJGL is completely independant of awt, you will never ever see any use of any awt classes in the lwjgl core.

[quote]As LWJGL is completely independant of awt, you will never ever see any use of any awt classes in the lwjgl core.
[/quote]
::slight_smile:

Actually, while the display and input subsystem is AWT independant, there is some AWT stuff in LWJGL - mainly utility methods such as clipboard stuff, which is implemented natively on win32 and using Java in all other (will default to use Java actually).

Looks Great … Keep up the good work. ;D

I stand corrected :slight_smile:

I guess that’s ok as long as it works without awt on windows. But I hope that lwjgl will stay away from awt to allow native compilation and stripped vms.

I downloaded a separate files, but the following error was thrown after I chose JOGL renderer from the startup menu.


Game Exception on RoboticsWar v0.6
----------------------------------
java.lang.VerifyError: (class: com/golden/gamedev/engine/audio/MidiRenderer, method: <clinit> signature: ()V) Incompatible object argument for function call
      at com.golden.gamedev.Game.initEngine(Unknown Source)
      at com.golden.roboticswar.RoboticsWarSettings$1.initEngine(RoboticsWarGame.java:221)
      at com.golden.gamedev.Game.i(Unknown Source)
      at com.golden.gamedev.Game.start(Unknown Source)
      at com.golden.gamedev.GameLoader.start(Unknown Source)
      at com.golden.roboticswar.RoboticsWarSettings.start(RoboticsWarGame.java:245)
      at com.golden.gamedev.funbox.GameSettings.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:534)

Java Version      : 1.4.2_04-b05 Sun Microsystems Inc.
GTGE Version      : 0.2.1
Environment       : JOGL Windowed Mode [640x480] with VSync
Operating System  : Windows 2000 5.0

Okay I give it a go, thanks tom! Lwjgl 0.95, need to download it again then, I use 0.94 :frowning:
But what’s the meaning of if native cursor supported in the documentation of Mouse.setNativeCursor method?
I don’t want to use it if it’s only working in Windows OS.
And what is Mouse.setGrabbed anyway? What is grabbed in there means? Is that means the mouse is fully thrown out from the game or what?

What the? MidiRenderer? Incompatible object argument for function call in signature ???
How about Java2D and LWJGL, is it runs fine?
And don’t forget to extract the DLL from LWJGL and JOGL native lib and put it in the same directory.
Hmm I don’t know what is that, perhaps that cause the JOGL can’t play in your pc.

Wow, this what I’m looking for :slight_smile:
But how reliable is this anyway?
From the documentation said: whether native cursor is supported and the code that need to be surrounding with try catch sounds like mostly this method would fail.
If setMouseGrabbed is far more reliable than setNativeCursor I guess I will stick with setMouseGrabbed instead.

PS: I don’t need to upgrade to LWJGL 0.95, just need to edit Cursor.xxx to Mouse.xxx :slight_smile:

I don’t know if setNativeCursor works on linux or mac. You could try aksing the quiestion in the lwjgl thread.

But the best solution would be to first try setNativeCursor. If that fails you use setMouseGrabbed. That way you get the best that is available.

Great idea! I will try to setNativeCursor first and then setMouseGrabbed if setNativeCursor is failed.
Thanks!