Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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  
  [JOGL] How to set up a pretty basic game loop WITHOUT having to use any Animator  (Read 859 times)
0 Members and 1 Guest are viewing this topic.
Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Posted 2014-03-12 20:58:04 »

Hi there,

I am not new to Java nor am I new to OpenGL. It's just that I have not done anything gaming related since my first few attempts some 2 years back..

As the last time I looked into Java and OpenGL I've been using LWJGL, I've been thinking I might now again try to look into the other implementation which I dropped last time as it looked too scary to me back then.

Said done I tried a few things, browsed through the few available tutorials on JOGL gaming that all cover the merest basics using the 'FPSAnimator' as a mean of driving the loop.

Now I am asking: Are there any non-FPSAnimator resp. Animator driven examples for a simple gaming loop with JOGL out there? It is not that I don't appreciate the Animator, but it's rather that I want to use JOGL really only as a wrapper, same as if I were working with OpenGL directly in a C-Language..

(Also the Animator kind of makes me back off when looking at the source code digging through classes extending classes implementing interfaces that extend other interfaces again, making me wonder even more why the FPSAnimator is based on an AnimatorBase, that bases on a GLAnimatorControl class thats based on an interface called FPSCounter...nvm)

I hope I did not offend anyone nor the forum rules by posing that question, otherwise please point me into the right direction, thanks.

Looking forward for constructive help Smiley


EDIT: having changed the title in order not to insult anyone by accident..
Offline Grunnt

JGO Wizard


Medals: 84
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #1 - Posted 2014-03-12 21:18:24 »

Not sure if this is what you are looking for, but I find the GafferOnGames loops very good:
http://gafferongames.com/game-physics/fix-your-timestep/

Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #2 - Posted 2014-03-12 21:21:33 »

Not sure if this is what you are looking for, but I find the GafferOnGames loops very good:
http://gafferongames.com/game-physics/fix-your-timestep/
~

Well, actually looking for some JOGL related thing in that case. Although the link just wandered into my favourites, as it indeed looks quite nice (at least at first look)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline saucymeatman
« Reply #3 - Posted 2014-03-12 21:46:47 »

For a basic game loop I use java.util.Timer.
Not sure if thats the wrong way to do it, but its always worked perfectly for me, as long as you understand proper thread saftey.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2014-03-12 22:08:40 »

When I wanted to use my own implementation of Game Loops in JogAmp, I tried (and managed) to extend AnimatorBase. Believe me, it's not too hard. I don't know how to exactly use it only as an OpenGL wrapper, but that's not what I'd suggest you to do, except if you have no other choice.

When extending AnimatorBase you have to add two simple classes:

A class extending "AnimatorBase". It should store a GLAutoDrawable. In the constructor of this class call
add(drawable);
, if the drawable isn't null.

Another class containing the actual game loop work itself. It should create another thread which runs the loop and is controlled (in terms of pausing and unpausing) from the AnimatorBase.

For the stuff about locking in the AnimatorBase you can simply try to copy whats inside the basic prebuild Animator from JogAmp.


That's how I did it a long time ago, at least. I have just had a very small glimpse at my code for now, but it's late for me and I hope this helps you Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline gouessej
« Reply #5 - Posted 2014-03-12 22:47:57 »

Hi

The right place to post questions about JogAmp APIs including JOGL is the official JogAmp forum.

If you don't want to use a GLEventListener, use GLAutoDrawable.invoke(boolean,GLRunnable) as I do in Ardor3D.

You can call GLAutoDrawable.display() wherever you want, for example in your own loop but we had some really good reasons to implement animators and OpenGL event listeners. JOGL is forced to be a bit more than just a plain OpenGL wrapper, it has to provide at least a few things to work with standard windowing tool kits. matheus23's suggestion is very good, that's the way to go if you need some more flexibility. Otherwise, you can use Animator instead of FPSAnimator and if you need to call a particular piece of code for each frame, just put it into GLEventListener.display(GLAutoDrawable) (even though it is not very smart especially if those operations don't require a current OpenGL context).

Just keep in mind that if you don't use any animator and a GLEventListener, you'll have to treat some corner cases by yourself. When I used OpenGL in plain C, I used GLUT, it had similar mechanisms. I had to avoid using GLEventListener and Animator when I worked on the JOGL backend of Ardor3D, it's doable for a very simple test case but when things become more elaborated, you have to manage the context by yourself and you may do some things that ruin your performance or cause crash on some machines. JOGL is flexible enough to let you do that at your own risk. You can even disable the automatic buffer swap and do it by yourself.

Edit.: Animators aren't fancy. Please be kind.

Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #6 - Posted 2014-03-13 06:19:50 »

When I wanted to use my own implementation of Game Loops in JogAmp, I tried (and managed) to extend AnimatorBase. Believe me, it's not too hard. I don't know how to exactly use it only as an OpenGL wrapper, but that's not what I'd suggest you to do, except if you have no other choice.

that actually sounds pretty good to me. Gonna look into it this evening. Thanks for the hint.

also I'll prolly gonna put more specific questions such as about the, as I perceive it to be, lack of proper javadoc on the jogamp forums as @gouessej recommended

also: @gouessej, I did not mean the term fancy as an insult or degradation of the class nor of the work the jogamp team does. As said I wanted to give JOGL another try now that I've been in the industry for some time and understand Java better


EDIT: the jogamp forums scared me off at first (and actually still do do) as they are kept pretty simple. E.g. No sub forum for stuff such as newbie questions (which I consider this one to be) additionally made me ask rather here than on the jogamp forums
Offline trollwarrior1
« Reply #7 - Posted 2014-03-13 06:42:13 »

Why not go with LWJGL? I mean it is opengl binding to make games with extra features such as keyboard, openal and some more.
Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #8 - Posted 2014-03-13 07:09:27 »

Why not go with LWJGL? I mean it is opengl binding to make games with extra features such as keyboard, openal and some more.

because I don't like the extra features being a compulsory part of the main distro. Wouldn't mind if they were in optional jars.

EDIT: Also JOGL has NEWT. Which offers some imho quite amazing possibilities.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2014-03-13 15:16:40 »

Why not go with LWJGL? I mean it is opengl binding to make games with extra features such as keyboard, openal and some more.

(I think it's a fact that) JogAmp has much more features than LWJGL. Keyboard, Mouse, OpenCL and OpenAL are the minimum.

If I had to compare JogAmp to LWJGL then I'd say:
JogAmp is 'more OOP' (LWJGL 3 might change that Wink ).
JogAmp has a richer / more Windowing Toolkit(s) (LWJGL 3 might change that, too Cheesy )
JogAmp especially has the wonderful idea of having classes / Objects for each GL version. So you have a GLCommon, GL2, GL3, ... Class. And GL3 extends GL2 and so on Smiley It also has a Debug version of the GL interface, which checks gl-errors after each gl call.

In the end JogAmp is a Wrapper that wraps the C OpenGL Api in a Object-Oriented way.
LWJGL is a 'straight' Wrapper from C OpenGL to Java. You can copy n' paste parts of C OpenGL code and it would work syntactically.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2014-03-13 16:31:39 »

Why not go with LWJGL? I mean it is opengl binding to make games with extra features such as keyboard, openal and some more.
Please don't do that here. He asks for help, he doesn't ask which library he should use. Moreover, both this library and JogAmp are (mainly) sets of Java bindings. JogAmp contains a binding for OpenGL (JOGL), another one for OpenAL (JOAL) and another one for OpenCL (JOCL). The library that you suggest and JogAmp both have their own windowing toolkits, both can be used with JInput, both supports keyboards, mices, both supports OpenALSoft, ... Your remark is unfair and inappropriate. Please don't turn this thread into yet another useless "JogAmp vs L*****" debate. You just show your ignorance.

dot_Sp0T, now you see the main reason why I encourage developers to ask for help on the official JogAmp forum, this is the same story, it was already like that in 2006. You ask for help and they suggest you to use their favorite library.

JogAmp APIs are heavily tested on embedded devices, several contributors own some Beagleboards, Pandaboards, ODroids, Raspberry Pi, ... which helps us to support them much earlier than any of our competitors, especially thanks to Xerxes (xranby). Oversimplified APIs wil have to get less simple to support as much use cases as us which means that we did some great choices since Sun / Oracle abandoned us. Actually, JOGL, JOAL and JOCL work under Android for example. Yes NEWT rocks, and it will rock even more with NEWT Input API Smiley You can even preserve OpenGL states when your application is paused (very useful for mobile games). JogAmp is modular, there are several granularities of packaging so that the newbies can just use the biggest JARs if they want something simple (jogl-all.jar, joal.jar, jocl.jar and gluegen-rt.jar) and others can use "atomic" smaller JARs to bundle only what they need.

Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #11 - Posted 2014-03-13 19:36:53 »

dot_Sp0T, now you see the main reason why I encourage developers to ask for help on the official JogAmp forum, this is the same story, it was already like that in 2006. You ask for help and they suggest you to use their favorite library.

Well, that is in the human nature. Being excited about something and asking other to check it out, promoting the features one likes most. After being 4 years in the industry working as a programmer for a bank I certainly know that Wink

As in others things, I do not think people are being ignorant. As I get it, most of the programmers here, including main contributors to both 'competitors' are hobby programmers, they certainly will look at things differently than people who do their daily work in the field.

For now I sadly have to tell that I put my JOGL fascination into another hibernation as I see that I do not know all to much about OpenGL anymore. So I think I'll do the learning the same way I did it back 2 years ago and go check out the delphiGL wiki and translate their stuff to java - probably starting with using lwjgl as it is almost C syntax, then switching implementations just for the fun of compariung.

Programming is fun and it should stay fun, so please people, don't ruin it by fighting each other and defending yourselves against everything that maybe could be in some sort of way a mild spark of a questionable insult..

Also I would like to ask a MOD to CLOSE this thread as I have gotten the insights I've been looking for, thank ye all Smiley
Offline Grunnt

JGO Wizard


Medals: 84
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #12 - Posted 2014-03-13 20:39:24 »

For now I sadly have to tell that I put my JOGL fascination into another hibernation as I see that I do not know all to much about OpenGL anymore. So I think I'll do the learning the same way I did it back 2 years ago and go check out the delphiGL wiki and translate their stuff to java - probably starting with using lwjgl as it is almost C syntax, then switching implementations just for the fun of compariung.

The way I'm learning OpenGL right now is by doing the ArcSynth tutorials. What may be useful for you are the very nice and clean Java implementations of these (and other) tutorials by forum member ra4king. Maybe its useful for you when translating stuff to Java. These happen to be in LWJGL, but I'm sure similar examples of JOGL should exist.

@gouessej: no offense, but you appear to be overreacting a bit here...

Offline dot_Sp0T

Senior Newbie


Medals: 1
Exp: 4 years



« Reply #13 - Posted 2014-03-13 21:43:48 »

Am right now digging into SHCs tutorial series. Nice and small lessons, good to freshen up and look at specific things.

And just to say: LWJGL has the nasty habbit of being terribly time consuming to set up to run....
I can include the JOGL dependency into maven, do a clean install and I've got the libraries and can run my test app. For LWJGL I got to customize my build phase, introduce new environment variables and finally still got to change stuff in my IDE's project config (that I bet my last shirt will be reset by maven everytime I do a eclipse:clean eclipse:eclipse)... So the point for user friendlieness goes to JOGL Smiley
Offline gouessej
« Reply #14 - Posted 2014-03-14 06:32:23 »

@gouessej: no offense, but you appear to be overreacting a bit here...
No offense, you appear to misunderstand the way JOGL has been "treated" the last 8 years (and the examples of the book "Learning Modern 3D Graphic Programming" have been ported to JOGL here). I will (try to) no longer argue.

I agree with dot_Sp0T, I would like a mod to close this thread.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #15 - Posted 2014-03-14 07:36:42 »

Having a question answered is no ground for locking a thread. You're free to make reading this thread a waste of time, if you're so inclined. We're old enough not to depend on a moderator to stop the bickering.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
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.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (34 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (54 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!