It is currently 16 Apr 2024, 18:33
   
Text Size

Java, Swing, OpenGL and Jogl

Moderators: nantuko84, CCGHQ Admins

Java, Swing, OpenGL and Jogl

Postby nantuko84 » 24 Sep 2009, 05:29

Have anybody tried OpenGl and Jogl for Java applications?
I played with it few days and what I've seen and what I've made seems very powerfull for me.
I think a lot about moving MagicWars from Swing to Swing+Jogl(OpenGL) that will manage issue with free space on table for cards and will give the possibility to add multiplayer (it's my dream :D, now I have no idea how to implement multiplayer in 2D shandalar like layout).

Actually the question here is won't it make Java application not cross-platformed? When everything is on Swing, all you need is JRE installed - so just download the game and click .jar, .bat or whatever. Once OpenGL is used, I believe you'll need additional steps that is not so attractive.

So does anybody have any experience with Jogl?
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Java, Swing, OpenGL and Jogl

Postby Huggybaby » 24 Sep 2009, 11:24

OpenGL should be supported natively by the drivers of any video card out there AFAIK.
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Java, Swing, OpenGL and Jogl

Postby Snacko » 24 Sep 2009, 18:07

Jogl depends on some native libraries, but it's easy to set up depending on your system
* Mac OS X:
o libjogl.jnilib
o libjogl_awt.jnilib
o libjogl_cg.jnilib
* Windows:
o jogl.dll
o jogl_awt.dll
o jogl_cg.dll
* Linux:
o libjogl.so
o libjogl_awt.so
o libjogl_cg.so
o libjogl_drihack.so
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Java, Swing, OpenGL and Jogl

Postby nantuko84 » 25 Sep 2009, 05:18

it makes sense that you need different native libraries for every Os, but I don't like the idea that they should be installed separately from applicaiton (most users don't know what opengl is or even have no administrative rights to do that).

well, is it possible NOT to install them instead including all those native libraries into application? Thus, such program will determine OS itself and choose what native library it needs to run using OpenGL.
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Java, Swing, OpenGL and Jogl

Postby eugenrivniy » 26 Sep 2009, 10:39

As I read at http://kenai.com/projects/jogl/pages/FAQ, JOGL can use gluegen library to make a dynamic bindings to OpenGL library and you can create portable application without using native libraries.
eugenrivniy
 
Posts: 6
Joined: 20 Sep 2009, 21:02
Has thanked: 0 time
Been thanked: 1 time

Re: Java, Swing, OpenGL and Jogl

Postby Snacko » 26 Sep 2009, 14:59

You could bundle them all and it will pick up the one needed depending on the system however they are quite big.
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Re: Java, Swing, OpenGL and Jogl

Postby Arch » 29 Sep 2009, 12:45

If you use something like Java Web Start you can make it completely transparent to the user. Web Start can be configured to fetch different dependencies based on what OS the user is using. If I remember correctly you can host it as any regular file as well, no specific server-support needed.

It does have some "problems" though, like certificates.

That's if you are interested in minimizing the download. I don't think bundling all of them would be that much of a problem; most people these days won't notice an extra meg or two.
User avatar
Arch
Programmer
 
Posts: 206
Joined: 04 Jul 2009, 09:35
Has thanked: 0 time
Been thanked: 15 times

Re: Java, Swing, OpenGL and Jogl

Postby nantuko84 » 30 Sep 2009, 05:07

If I want Web Start to be used, then some changes will be needed to be done in MagicWars as now it doesn't even include images for cards and configuring is done on user side.

Yes, it's probably good option to use it but ... at the moment I can't see big advantages of it.

Anyway thanks for suggestion ;)
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Java, Swing, OpenGL and Jogl

Postby DennisBergkamp » 02 Oct 2009, 19:21

Nantuko,

Wow, this is cool. I've been playing with the same idea, using JOGL (or Java3D, or JME, or whatever) to improve the GUI of MTGForge. It looks like there's definitely a lot of possibilities and power using openGL.
Unfortunately, I haven't really done anything in openGL, do you know a good place to start messing around with this?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Java, Swing, OpenGL and Jogl

Postby nantuko84 » 03 Oct 2009, 05:17

Yes, it's really cool ;) And I'm impressed by its performance;)
I've made small example with JSplitPane with button on the left and openGL scene on the right with several objects on it that fire events on clicking them.
Unfortunately I'm not so experienced in OpenGL and as usual in such cases examples really helps.
So what can I advise you is to look for openGL examples and projects (open source for sure%)).
What I found was Aerith that is really cool!

and are you planning to use 3D or 2D openGL for MTGForge?
As for me, I'd choose 2D than 3D, at least it's easier to implement for me. But I still think over this.
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Java, Swing, OpenGL and Jogl

Postby DennisBergkamp » 04 Oct 2009, 20:23

Ah, yes I've been messing with some of the NeHe tutorials. I also downloaded the source of Twinkle (which I think is part of that Aerith program). Very cool stuff :)
2D seems to suit magic more, but I'm not sure... I'll play around with some more code examples and see what I can learn.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Java, Swing, OpenGL and Jogl

Postby DennisBergkamp » 05 Oct 2009, 01:15

I've been playing around with the Twinkle picture viewer, and I've got it to load images of magic cards. I can't load in too many pics though, because it runs out of memory fairly quickly. I tried setting the heap size in eclipse to 1GB instead of 256 megs, but it didn't seem to do much :rolleyes:
Attachments
twinkle.jpg
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Java, Swing, OpenGL and Jogl

Postby Huggybaby » 05 Oct 2009, 02:26

Wow, that's purdy. Keep at it, there are always ways around these memory problems. You'll find out how to do it in one meg eventually!
User avatar
Huggybaby
Administrator
 
Posts: 3205
Joined: 15 Jan 2006, 19:44
Location: Finally out of Atlanta
Has thanked: 696 times
Been thanked: 594 times

Re: Java, Swing, OpenGL and Jogl

Postby nantuko84 » 05 Oct 2009, 04:42

it looks amazing!)
about outofmemory exception: may be it uses image caching somewhere, I had the similar problem in MagicWars while looking through images in DeckEditor. If it's so, then it can be fixed easily (as far I understand it's open source).

btw, as MTGForge and MagicWars have similar GUI architecture (no matter that they may look different) having hand, table, stack description, input (with yes\no dialog), card image area, may be it will be possible to create configurable OpenGL GUI with some sort of API that then can be easily ported to MTGForge and MagicWars? and they still may look different with the help of skins and plugins.
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: Java, Swing, OpenGL and Jogl

Postby Snacko » 05 Oct 2009, 10:35

You need to load / unload textures as you need them and not keep all the 10k pictures in memory at all times (that's what the demo viewer does I presume as It runs out of memory).
In a game of magic you wont see more than ~60 different unique cards (the textures will be shared between the same cards).
Snacko
DEVELOPER
 
Posts: 826
Joined: 29 May 2008, 19:35
Has thanked: 4 times
Been thanked: 74 times

Next

Return to MagicWars

Who is online

Users browsing this forum: No registered users and 12 guests


Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 12 guests

Login Form