Show Posts
|
|
Pages: [1] 2
|
|
3
|
Java Game APIs & Engines / Java 2D / Re: Graphics2D / BufferStrategy / Swing mess
|
on: 2005-08-17 06:52:20
|
|
OK. New strategy. I found that I can build a BufferStrategy from a Canvas, so I replaced the internal JPanel with a Canvas. Now I am using the BufferedStrategy with a backbuffer, on the Canvas. Doing this sped me up significantly and eliminated the offset for the titlebar, while still letting me use my backbuffer to retain my scaling and scrolling functionality.
All that's left now is getting Swing to render right. I can get it to draw by calling my Swing components' paint() and passing in the buffer strategy's getDrawGraphics(), but the component doesn't register clicks. I think it's because I am forcibly drawing them there, as opposed to them natively being there. I tried putting the Swing and the Canvas in the JFrame's getLayeredPane() with the Swing higher than the Canvas. Doing this still doesn't render the swing (it may be overdrawn by my Canvas somehow) unless I call the swing's paint(), at which point it still doesn't see clicks.
|
|
|
|
|
4
|
Java Game APIs & Engines / Java 2D / Graphics2D / BufferStrategy / Swing mess
|
on: 2005-08-17 06:22:57
|
|
Hey, guys. Having a really hairy quandary here that perhaps you could help me with.
I'm working on a 2D adventure game engine, and doing the following:
1. Rendering to an offscreen image, then getting the Graphics2D of a JPanel inside of / same size as my JFrame, rendering the image to the panel. 2. That render performs a scale operation as well, so that my entire scene fits in the window regardless of the window size. 3. Trying to render a Swing component or two over top of this panel. They should stay in the same position onscreen, even when the underlying panel scrolls to reveal more of the game scene. 4. Manually repainting the object using a timer.
Here's the issues I have:
1. Rendering Swing over the JPanel causes the Swing to flicker badly. I tried using a JLayeredPane to help, it didn't. -Dsun.java2d.noddraw and the other posted tweaks didn't help either. The only solution I was able to find is to render the swing into the same graphics as my game objects (thus, onto the backbuffer) and then drawing it all at once. Now it doesn't flicker as much, but the Swing rendering doesn't look quite right and the game doesn't acknowledge that I've clicked on the Swing object. 2. Rendering performance is awful and seems to be fill-bound, as it gets significantly worse as the window gets bigger.
I recently tried switching the solution to a BufferedStrategy. I gained a ton of framerate by so doing, but the Swing was still an issue. Additionally, if I render to the JFrame's Graphics2D object, in windowed (decorated) mode, the game seems to count the titlebar as part of the window and cost me 30 px of my scene's image. Finally, without an Image object in hand, I can't use the drawImage function that permits me to scale a rectangle of an image into another rectangle, which I have been using to get the window the appropriate size.
I also looked at using a RepaintManager but didn't see much luck there either.
Here's the solution I need; maybe one of you can point me in the right direction.
1. My scene is often bigger than the window, so I need to be able to scroll. Right now I am using a Rectangle as a "viewport", copying out of the back buffer image (which is the size of the entire screen) only what is needed.
2. I need to be able to render Swing components on top of the still-refreshing Graphics2D work, either on a JPanel or in the JFrame itself without losing the pixels on the top of the window to the titlebar.
3. I need to be able to scale the final render so that it fits in the window regardless of the window's size (or full screen). Optimally, the Swing components would scale also, but this is not crucial. They do, however, need to stay in place while the background (the game's graphics) scroll.
4. I need rendering performance to not totally suck.
Can anyone help me with this conundrum?
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: Doublebuffering
|
on: 2005-08-17 06:02:53
|
(3) There are 2 alternate open source scene-graph projects in the works that play ina similar space as Java3D but are being developed with a bit more of a game-focus. Those are Xith and a currently unnamed project of Shawn Kendall
OMG Shawn Kendall.. Had him as a teacher once. Used to rag on him about Java; now I'm doing it too. LOL.
|
|
|
|
|
7
|
Java Game APIs & Engines / JOGL Development / Re: Animator performance issue?
|
on: 2005-08-09 23:00:52
|
The Animator currently consumes 100% of the CPU. If you have anything else going on in your application then the Animator will swamp it. This will be fixed in the JSR-231 APIs and is in progress. You could try using the FPSAnimator from this thread. Something like that will be included in the JSR-231 rewrite of the Animator. .... Wow.
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / Animator performance issue?
|
on: 2005-08-09 18:39:26
|
|
Hey, all.
I have some very simple 2D rendering code running, with a few moving images I'm doing with glDrawPixels. I had set rendering on its own timer through my event scheduling package. I then decided to take advantage of the Animator class. Doing nothing but removing the draw from the timer and adding an Animator, my performance falls by almost 60%.
Are there any "common suggestions", or is it necessary to start pasting code?
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / Suggestion / Call to Arms: JOGL Bridge Utilities
|
on: 2005-08-08 04:13:47
|
|
You know, after looking at the demos and seeing the amount of code that floats around these forums, I got to thinking.
There are only so many ways to make a fullscreen window. There are only so many ways to handle the problem where AWT and OpenGL have opposite direction Y values. Everybody could use a feature to extract the current buffer to a java.awt.Image file for saving as a screenshot. The dynamic lib loader discussed on another thread is another great example. It's obvious people have written these kinds of things. And while JOGL is intended as a straight binding, it seems to me that there is no reason everybody should have to implement these basic functions of a game window.
I'm sure people will reply and say, there's LWJGL and all of those things, and they'd be absolutely right. But, those are large, overarching frameworks for a certain kind of task; game development and so forth. What I'm wondering is if Ken and the JOGL gang could accept submissions on this forum for just incredibly useful, GENERAL PURPOSE functionality that can be seen as needed in 75% or more of JOGL apps. Take the best ones, focusing on the relationship between AWT/Swing and JOGL, and create a few additional classes for the utils package.. Perhaps a subclass of JFrame that incorporates a GLCanvas or GLJpanel and includes such user methods as toFullScreen(), scaleToFitFrame2D(), and getBackBufferAsImage()? How about a GLImage class that wraps the byte buffers we use to render 2D graphics? Again, we're not looking for "HalfYourProject.class"... Just some basic, everybody-needs-it functionality.
Doing it this way, asking for tested, proven submissions from the forum, is also a benefit because you get the work done without taking your time from the new JSR. Additionally, it gives forum members, who can't get Developer status on JOGL because the team is kept very small, a chance to contribute to this great project, get a little kudos for it, and feel great. I know of a few small things I'd submit, and I'd love to say some of my code was being distributed with JOGL.
Anybody have any suggestions / comments / TESTED and LICENSE-FRIENDLY submissions?
|
|
|
|
|
14
|
Java Game APIs & Engines / JOGL Development / Re: Dynamic loading of the .DLLs - hitting a snag
|
on: 2005-08-04 14:41:55
|
I don't know if that solution would be any better than just shipping the natives unpacked and I guess that java doesn't allow you to mount a virtual filesystem in RAM memory either ?
It would still enable them to make a function to load the libs dynamically for the right os without the user needing to use -Djava.library.path. Incidentally, does anyone know of a way to do the noddraw workaround in code?
|
|
|
|
|
15
|
Java Game APIs & Engines / JOGL Development / Re: Coordinate flipping issue
|
on: 2005-08-04 04:19:35
|
|
OK. Got it solved! I had to invert the coordinates in the gluOrtho2D call, then change around the way I was loading images (it was inverting to deal with the AWT/OpenGL coordinate discrepancy already), and then needed to display the images at x, y + height in order to have the image's 0,0 be upper left instead of lower right. So now AWT, JOGL and my individual objects are all in the same page about it, and life is good! No longer do my objects' bounding boxes zoom off one way and the object another! There was much rejoicing!
|
|
|
|
|
18
|
Java Game APIs & Engines / JOGL Development / Easy 2D scaling solution?
|
on: 2005-08-03 05:17:09
|
|
Forgive all my questions; I'm way, way rusty with OpenGL.
Working on a 2D project, I'm finding a lot of issue with keeping things in the proper scale as the window resizes. It seems to be that the reshape() method of GLEventListener should be able to keep everything in scale for me, and there's some crucial GL call I'm missing or something. Does anyone know of a simple way to have reshape() scale my view without manually scaling every object?
|
|
|
|
|
20
|
Java Game APIs & Engines / JOGL Development / Coordinate flipping issue
|
on: 2005-08-03 04:37:06
|
|
I'm working on a 2D game, and having some trouble with clicking. I'm using java.awt.Polygon for the boundaries on the click areas, so they can be arbitrary shapes. However, because JOGL's 0,0 is in the bottom left and AWT's is top left, my click boundary and my image are on opposite sides of the screen. Is there a way to change one coordinate set or the other so that they match?
|
|
|
|
|
22
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Considering using JOAL
|
on: 2005-08-02 22:37:44
|
|
Hrmm.
Really, it seems like the biggest problem is the java.nio. buffers... LW uses them, JOAL uses straight int arrays (modeling the straight C syntax).
Maybe I can figure it out if I dig thru the buffer javadocs; who knows, there might be a toIntArray I coud use to convert the stuff prior to the call.
Would you mind me posting the class to the forum, in case somebody else would be able to help? Also, would you be interested in distributing a JOAL version of your player if I can generate one?
|
|
|
|
|
23
|
Java Game APIs & Engines / JOGL Development / Re: Dynamic loading of the .DLLs - hitting a snag
|
on: 2005-08-02 19:43:56
|
It's just a bunch of static utilities I wrote. Nothing major. Here's a version of the code, which now works, with the Tools calls replaced with straight java: 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
| public static void loadOpenGL(boolean bLoadCg) { net.java.games.jogl.impl.NativeLibLoader.disableLoading(); java.awt.Toolkit.getDefaultToolkit(); System.loadLibrary("jawt"); String strOS = System.getProperty("os.name"); String strJOGL = System.getProperty("user.dir") + System.getProperty("file.separator") + "lib" + System.getProperty("file.separator"); if (strOS.startsWith("Windows")) { System.load(strJOGL + "jogl.dll"); if (bLoadCg) System.load(strJOGL + "jogl_cg.dll"); } if (strOS.startsWith("Mac OS")) { System.load(strJOGL + "libjogl.jnlib"); if (bLoadCg) System.load(strJOGL + "libjogl_cg.jnlib"); } if (strOS.startsWith("Linux")) { System.load(strJOGL + "libjogl.so"); if (bLoadCg) System.load(strJOGL + "libjogl_cg.so"); } if (strOS.startsWith("Solaris")) { String strArch = System.getProperty("os.arch"); if (strArch.equalsIgnoreCase("sparc")) { System.load(strJOGL + "libjogl_solsparc.so"); } if (strArch.equalsIgnoreCase("x86")) { System.load(strJOGL + "libjogl_solx86.so"); } } }
|
|
|
|
|
|
25
|
Java Game APIs & Engines / Java Sound & OpenAL / Re: Considering using JOAL
|
on: 2005-08-02 17:42:54
|
|
Tom, I downloaded your Ogg player and stuff, and love it. I'd like to use it in a game I'm working on where the sounds will primarily be ogg. However, we're using JOAL instead of LWJGL.
What are the chances I could ask you to give me a hand in making a JOAL version of OggPlayer.java? The input stream class is fine; it doesn't rely on OpenAL at all.
|
|
|
|
|
28
|
Discussions / General Discussions / Re: Looking for people, that are interested in wrapping Direct3D for Java
|
on: 2005-08-02 16:39:53
|
|
What about going the other way, and writing a "port" of DirectX? It would be a lot more work, but a lot more useful to people familiar with DX. By that, I mean generate the same class names as DX, with the same function calls, and have the work inside done by something lower-level like J3D (or perhaps even JOGL)?
In this way users of Dx could bring their knowledge to bear in Java projects to similar, but xplatform, results.
|
|
|
|
|
29
|
Java Game APIs & Engines / JOGL Development / Re: Playing a movie?
|
on: 2005-08-02 16:21:46
|
|
I found a free player that builds over jVorbis that I really like, but it's set up for LWJGL. I posted the code to another thread in hopes someone could help me get it translated to JOAL.
I may be doing other stuff with JOAL, so I'd really like to have it running, and use this player I found.
As far as video files - do you think JMF is the best solution there?
|
|
|
|
|
30
|
Java Game APIs & Engines / JOGL Development / Re: Dynamic loading of the .DLLs - hitting a snag
|
on: 2005-08-02 08:51:53
|
OK. Ignoring the jar for a minute (I can handle the classloader later...), I'm getting UnsatisfiedLinks on jogl.dll when I try to dynamically load it, now. Here's the code: 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
| public static void loadOpenGL() { java.awt.Toolkit.getDefaultToolkit(); System.loadLibrary("jawt"); String strOS = Tools.GetOS(); String strJOGL = Tools.GetRelativePath("lib") + Tools.GetFileSeparator(); if (strOS.startsWith("Windows")) { System.load(strJOGL + "jogl.dll"); if (bLoadCg) System.load(strJOGL + "jogl_cg.dll"); } if (strOS.startsWith("Mac OS")) { System.load(strJOGL + "libjogl.jnlib"); if (bLoadCg) System.load(strJOGL + "libjogl_cg.jnlib"); } if (strOS.startsWith("Linux")) { System.load(strJOGL + "libjogl.so"); if (bLoadCg) System.load(strJOGL + "libjogl_cg.so"); } if (strOS.startsWith("Solaris")) { String strArch = System.getProperty("os.arch"); if (strArch.equalsIgnoreCase("sparc")) { System.load(strJOGL + "libjogl_solsparc.so"); } if (strArch.equalsIgnoreCase("x86")) { System.load(strJOGL + "libjogl_solx86.so"); } } } |
And this is the exception trace I get: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at net.java.games.jogl.impl.NativeLibLoader$1.run(NativeLibLoader.java:72) at java.security.AccessController.doPrivileged(Native Method) at net.java.games.jogl.impl.NativeLibLoader.load(NativeLibLoader.java:58) at net.java.games.jogl.impl.GLContext.<clinit>(GLContext.java:52) at net.java.games.jogl.impl.windows.WindowsGLContextFactory.createGLContext(WindowsGLContextFactory.java:147) at net.java.games.jogl.GLCanvas.<init>(GLCanvas.java:72) at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:150) at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:118) at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:85) at org.slage.ui.GameFrame.<init>(GameFrame.java:84) at org.slage.SLAGE.initialize(SLAGE.java:94) at org.slage.tests.ImageTest.main(ImageTest.java:41) |
All I want to do is get the dlls and jars loading in such a way as to prevent a lot of command line switches. It seems that I shouldn't be the first person to have wanted to do this - what am I missing here?
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|