Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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  
  The move to JOGL  (Read 3807 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2003-07-26 19:30:03 »

Just in case anyone is interested, I've moved my stuff over into JOGL from Java2D. Its here,

http://www.cokeandcode.com/astroprime

I've actually put together an abstraction layer which can be implemented in Java2D or JOGL, so hopefully I can always swap back if needs be Wink

Kev

Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #1 - Posted 2003-07-27 15:09:23 »

It does look a lot better with JOGL than with Java2D. Although in the JOGL version there is a problem that the keyboard locks up when you have more than two buttons down. So you cant fly, turn and shoot at the same time unlike the Java2D. Still very nice. Have you found it easier or faster to develop with JOGL or just better due to the things openGL can do? Also why did you decide to use JOGL instead of something like LWJGL?

Kommi
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #2 - Posted 2003-07-27 15:20:10 »

Quote
Although in the JOGL version there is a problem that the keyboard locks up when you have more than two buttons down. So you cant fly, turn and shoot at the same time unlike the Java2D.


Works fine for me Huh

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2003-07-27 15:29:47 »

Thanks for the responses:

JOGL shouldn't have any effect on the keyboard. Its infact using the same routines it was before. JOGL might be overriding the AWT thread more.. what platform/driver/OS etc.. I'd really like to look into it.

JOGL was harder to work in, since I spent time wrapping GL. Hopefully I won't have to do that again. I've not really got any great benefit as yet. I thought I could use Alpha on more platforms with JOGL, but it turns out MacOS isn't properly supported yet. It does seem to be far far far faster than using Java2D tho Smiley It also took me 2 evenings to get a generic texture loader written that I could use for my sprites. Sad

I didn't use LWJGL simply because it seems to be in flux (excuse the pun) at the moment. Didn't want to learn into something that was changing. Although it seems JOGL is going to be changing constantly.

So far, so good. JOGL is relatively easy to work in. I've my abstraction layer in place, so I can get back to Java2D nice and quickly if needs be Smiley Been focusing mostly on network code recently, reakon I got it down now. Onto actual game play..

Kev

Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #4 - Posted 2003-07-27 17:06:23 »

I guess the keyboard thing could be just me. Im running Win2k service pack 4 and jdk 1.4.2 In the Java2D demo everything is fine but in the JOGL emo they keyboad locks up and the pc starts giving me the error beep, when I have more than 2 buttons down.

Oh also what do you mean exactly by a generic texture loader? How does it work? I though the ship was an image and the starfield and cannon fire were just drawn with Java2D or JOGL.

Kommi
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2003-07-27 22:00:37 »

The ship, stars and cannon fire are images actually. But in JOGL there is no concept of an Image. Everything is a textured piece of geometry. Whats more its not in a standard Java Image format, its a byte encoded data buffer.

Now, there had been a few texture loaders for specific file types publicised but I have quite a few different requirements. So it took me a while to write a loader that could load any image I wanted, convert it into a texture to be used by JOGL to create a sprite.

Kev

Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #6 - Posted 2003-07-28 02:47:44 »

What is the significance of having a byte encoed data buffer over a gif or png image type in your situation? I take it you first made the sprites in a regular paint program and then converted the image to your specific type through an encoder that you wrote?

Kommi
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2003-07-28 11:57:55 »

I did start a paint package, but I saved my images as PNG or GIF. The byte encoding is how JOGL expects to recieve textures/images. I load up my standard images with ImageIO, which gives me a BufferedImage. However, JOGL doesn't know anything about BufferedImages, all it knows about its a byte array full of bytes in a certain order. This is where the conversion comes in:

BufferedImage -> JOGL Byte Buffer

Kev

Offline troggan

Junior Member




no guts no glory


« Reply #8 - Posted 2003-07-28 15:57:40 »

Could you put that code online? I am trying to do the same stuff, but it's stupid to reinvent everything or even steal it from someone Wink ....

thanks!

(http://www.wannawork.de) - Will work for food
(http://tvbrowser.org) - Java EPG
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #9 - Posted 2003-07-28 15:59:08 »

Sure, actually its already online...

http://www.cokeandcode.com/jogl

Fraid you'll have to do a bit of hacking to remove my "GameFrame" and just pass in GL instead.

My stuff is all bounds to my 2D graphics abstraction at the moment. Going to implement the Java2D version soon I think, just to do a comparison.

Kev

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

Junior Member




while(true) { self.caffeinate (); }


« Reply #10 - Posted 2003-07-30 10:08:02 »

Kevin;
FYI, It locked my screen the first time I tried to launch via webstart(After it went into fullscreen) After that It didn't give me the option to run in windowed mode.
It did start drawing the menus, but all i saw was red rectangles.

Thought you'd like to know. S3 SavagePro ddr card.


JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #11 - Posted 2003-07-30 10:30:20 »

Been having reports like this all the time, just seems that JOGL/Java ain't that happy on alot of platforms.

I'll be adding the Java2D version tonight/tomorrow so hopefully you'll be able to play in that Smiley

Kev

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #12 - Posted 2003-07-30 10:36:44 »

Incidently, if you want to switch it back into windowed mode (normally you'd do this from within the game), but if you look in your home directory,

C:\Documents and Settings\username on newer windows systems.

You'll find a directory called .astroprime. It has a client.props file which contains all the settings. Just set fullscreen option to false.

If you get a chance, I'd appreciate you seeing if it works in windowed mode.

Kev

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2003-07-30 18:50:03 »

Well, interesting, I've swapped back to using Java2D (well, really just implemented a new version of my abstraction). I'm fraid there won't be a Java2D version any time too soon (probably wait for 1.5). Just doing the basics of my game on a relatively decent machine with a fully accelerated graphics card and 64 meg of memory I go down from an easily sustainable (fixed) 100 fps to around 54.

Although this wouldn't be terrible, its only the very basics of my game. It also takes so long to draw the screen it has a minor effect on network comms. Although I still think Java 2D has its place, I can't imagine using it for fast paced actions games ever again.

Kev 'Possibly Converted' Glass

PS. I really would appreciate someone pointing out what i'm doing wrong. I'll even post my embarrsing code if you want..

Offline troggan

Junior Member




no guts no glory


« Reply #14 - Posted 2003-08-02 16:53:32 »

I have changed the Texture-Classes a little bit. They don't need the GameFrame Classes anymore. And I fixed a bug with images that have a width/height that's not a fraction of 2. You can find them there:

http://www.informatik.uni-oldenburg.de/~troggan/bodo/Texture.java
http://www.informatik.uni-oldenburg.de/~troggan/bodo/TextureLoader.java

(http://www.wannawork.de) - Will work for food
(http://tvbrowser.org) - Java EPG
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #15 - Posted 2003-08-02 17:24:11 »

Thanks again for that, its made my considerably easier. About the red textures btw, just ensuring that I'm asking for the right mode seems to have fixed the problems I've seen... but then I can only test it by turning off acceleration of my laptop..

Kev

Offline troggan

Junior Member




no guts no glory


« Reply #16 - Posted 2003-08-02 18:25:52 »

Could you be more specific on what you changed? Now we have the 2 things fixed Cheesy

(http://www.wannawork.de) - Will work for food
(http://tvbrowser.org) - Java EPG
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #17 - Posted 2003-08-02 18:44:52 »

I actually saw it in that code you set me..

GLCapabilities cap = new GLCapabilities();
cap.setRedBits(bpp/4);
cap.setGreenBits(bpp/4);
cap.setBlueBits(bpp/4);
cap.setAlphaBits(bpp/4);

then initialise the canvas with this capabilities.

I detect the bpp from the graphics device with getDisplayMode().getColorDepth().

Everything seems to be happy after this, will test again on monday on the work (low spec of doom) machine.

Incidently, my stuff goes down to around 20 fps with no graphics acceleration at all.

Kev

Offline troggan

Junior Member




no guts no glory


« Reply #18 - Posted 2003-08-02 22:09:03 »

I tested that with an old Matrox Card, but I saw only Red Boxes  Huh...hope you have more luck with it.

(http://www.wannawork.de) - Will work for food
(http://tvbrowser.org) - Java EPG
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #19 - Posted 2003-08-03 07:04:50 »

Damn it, my problem is I don't have anyway of testing the red box thing relyably.

Kev

Offline Max Pesce

Junior Member




Nil tam arduum quod non ingenio vincas


« Reply #20 - Posted 2003-08-03 07:54:48 »

Quote
Just in case anyone is interested, I've moved my stuff over into JOGL from Java2D. Its here,

http://www.cokeandcode.com/astroprime

I've actually put together an abstraction layer which can be implemented in Java2D or JOGL, so hopefully I can always swap back if needs be Wink

Kev


I'm totally new to JOGL, buy I'm interested in alternatives to Java2D.

Are you using hardware rotations in your game?

If yes, how do you replace them if you have to turn back to Java2D?

Rotations with this library are sluggish. So I don't think there's a real way to turn back...

Maybe I'm wrong.


Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #21 - Posted 2003-08-03 08:16:09 »

I use hardware rotations. I wrap up JOGL in a layer so that I can replace it with Java2D later. Rotatations in Java2D are pretty damn awful, true, but apparantly its being reimplemented ontop of OpenGL. When/If that happens I'll switch back.

HTH

Kev

Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #22 - Posted 2003-08-03 16:58:20 »

Kev can you explain the theory behind wrapping JOGL in a layer so as to be able to switch between Java2D and JOGL. What does that mean exactly and how does it work?

Kommi
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #23 - Posted 2003-08-04 07:06:32 »

Well, I only really tell you the way I'm doing it, not sure if it could be improved or can even be considered right.. but hey.

I have a central interface called a "GameFrame". GameFrame displays a window to be drawn into. It also supports the creation of resources like Sprites and BitmapFonts. These also have interfaces "Sprite" and "BitmapFont". GameFrame also has a callback interface for draw, allowing you to plug in a drawing object. So I have a bunch of interfaces describing all my graphics objects.

Now I implement two versions of GameFrame called JoglGameFrame and J2DGameFrame. When a start my game I instance one of these two classes but I maintain it as a references to the interface "GameFrame". Then when I want to load a sprite I can call getSprite() on my game frame which will return me an object conforming to the Sprite interface. The sprite that is returned could be implemented in J2D or Jogl, my program doesn't know. At this point it doesn't matter.

Finally, in my draw() routine, I call sprite.draw(). Draw is implemented different by the J2D and Jogl versions. Logically, one draws it in J2D and one draws it in Jogl.

So, to swap between the two rendering methods, I have to change one like at the start of my code, a create an appropriate GameFrame.

If you want to see, I can post the code somewhere tonight, but its pretty simple stuff really.

Kev

PS. Damn this forum could do with a UML tool Smiley

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #24 - Posted 2003-08-11 16:52:24 »

Right, I was going to try and document this stuff, but since I'm not going to have time, here's my abstraction code. The Java2D section is massively under developed since I gave up early on. The Jogl version is what I'm currently using for my game..

http://www.newdawnsoftware.com/astroprime/test/mook-stuff.zip

Kev

Offline tortoise

Junior Member




<3 Shmups


« Reply #25 - Posted 2003-08-11 17:02:13 »

Quote
Damn it, my problem is I don't have anyway of testing the red box thing relyably.

Kev


I do though, I've got plenty of machines willing to spit out red boxes at me. I'll test this out tonight and see what's up.

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #26 - Posted 2003-08-11 17:09:17 »

If you want to test for the red box thing, it'd be best to try:

http://www.newdawnsoftware.com/astroprime/test/JoglModeTest.zip

But its failed generally on some systems..

Kev

Offline tortoise

Junior Member




<3 Shmups


« Reply #27 - Posted 2003-08-11 17:51:42 »

I'm at work right now so I only played with it a bit, but did find one mode that caused the red box syndrome

Trying option :17
GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccelerated: false
, DepthBits: 16, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0, Red Accum:
0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0 ]

surprisingly a lot of modes seem to work just fine on this machine, a dell with an Intel 82815 onboard graphics chip with 4mb ram, running default drivers. My laptop will be the true test though.

Anything allocating something other than 8 bits per component (ie 5 or 3) just results in a blank white screen.

This seems to be the best mode I'm capable of...

Trying option :2
GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: false,
DepthBits: 32, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0, Red Accum:
16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 0 ]
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #28 - Posted 2003-08-11 18:11:41 »

Yep, concurs with what I've found so far. The red textures seem to be occuring with the lack of a Accum settings.

Kev

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.

CogWheelz (17 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!