Morgrog
Senior Newbie 
Rubber bands and cafeine, weeeee~
|
 |
«
Reply #30 - Posted
2004-05-02 18:36:39 » |
|
VSync is based on the desktop's refresh rate and that can range from 60 to 85 (normally). So when VSync isn't enabled you have to use the hardcoded frame rate (60) right?
so huh won't the game run faster on a 85Hz vsynced computer as opposed to a 60Hz app controlled computer? Will there be a big difference?
|
|
|
|
erikd
|
 |
«
Reply #31 - Posted
2004-05-02 19:59:39 » |
|
So when VSync isn't enabled you have to use the hardcoded frame rate (60) right? Right. so huh won't the game run faster on a 85Hz vsynced computer as opposed to a 60Hz app controlled computer? Will there be a big difference? It depends on how you calculate the movement of your game objects. If you update all movement time based instead of frame based, the game will be equally fast on all refresh rates. So think for movement speed in 'units per second' rather than 'units per frame' (units being pixels, meters, miles or whatever) and all will be well.
|
|
|
|
MickeyB
|
 |
«
Reply #32 - Posted
2004-05-03 11:38:03 » |
|
I have updated my video drivers and according to the ATI site, my Mobility Radeon is OpenGL ready for 2d and 3d accelerated graphics. I am at a loss. 
|
|
|
|
Games published by our own members! Check 'em out!
|
|
tom
|
 |
«
Reply #33 - Posted
2004-05-04 12:38:57 » |
|
Out of curiosity, (when looking at Cas' code) is it better to use a different thread for the logic() function and only call that thread at fixed amount of time? (time proc?) No! I mean, the thread sleeps for a given interval of time and only executes the logic every now and then (25ms or whatever is the standard) Is that the way to do time based logic, thus isolating the rendering and the logic part of the game? Your rendering will use the data updated in the logic right? The 2 threads can't run at the same time or you'll get synchronization bugs. So you get absolutely nothing from using 2 threads except some really complex logic that synchronizes the threads. Btw. You can call the logic() function more than once per game loop if it the logic is lagging behind.
|
|
|
|
Morgrog
Senior Newbie 
Rubber bands and cafeine, weeeee~
|
 |
«
Reply #34 - Posted
2004-05-04 12:57:12 » |
|
ok, so how do I force time based logic?
create an application tick (i.e. something time based that is constantly updated, kinda like the frame rate I suppose) and if that application tick is greater than our update rate, we update our logic? is that how it should be implemented?
Anyways, thanks for the eye opener, I'll see how I can turn my game into a time based one  edit: NM, just went through parts of Kevin Glass' tutorial and it's pretty straightforward  , 2 thumbs up for Kevin
|
|
|
|
Orangy Tang
|
 |
«
Reply #35 - Posted
2004-05-04 13:32:00 » |
|
ok, so how do I force time based logic? Time based logic would call .logic and .render once per loop, but the logic method would caculate the time elapsed since the last frame. Then all your game updates are done based on that elapsed time. Thats usually pretty easy and often just requires scaling your speed/velocity type calculations based on that frames delta time. However it can make collision a real pain, since you can get varying steps. You often need to check the entire path an object moved though rather than just the end point (otherwise you 'leapfrog' over an object). Time based is great for 'proper' 3d worlds where you can get something that runs smoother on faster machines. However for a 2d game you'll get a much smoother scrolling with a fixed framerate rather than a variable one.
|
|
|
|
princec
|
 |
«
Reply #36 - Posted
2004-05-05 13:02:47 » |
|
Hey y'all - the timing code has been revised in the CVS of LWJGL! Now in 0.91 (ahem) we've got the most super-groovy method in the universe to take care of all your frame-capped woes: Yes! It does exactly what you think it's gonna do! Now you can just sit back and let our system-friendly bit of code take care of capping framerates while you get on and make the tea. Cas 
|
|
|
|
Morgrog
Senior Newbie 
Rubber bands and cafeine, weeeee~
|
 |
«
Reply #37 - Posted
2004-05-05 14:53:43 » |
|
ohh, this makes me think of a question to add to the wiki which I'm gonna do right now that is, how to get the latest working binaries from CVS (if it's even possible, if not, how to compile them) so uh yah *goes on the wiki* Thanks again! Now if I can only finish my personnal SCM perl script (it's gonna do a bunch of fun things, all based on a config file, like huh backup the latest version of a project, package and sign the jars, copy the source to a showsrc directory and what not) 
|
|
|
|
oNyx
|
 |
«
Reply #38 - Posted
2004-05-05 22:16:33 » |
|
Hm... just took a look and experimented a bit. As I expected (and as I already pointed out in the other thread) using the same cap rate as hz will lead to frame skips if vsync is actually enabled. Aiming for some fps more helps (eg +3). I also checked the code and I think my version is a bit neater (shorter and no casts)  1 2 3 4 5 6 7 8 9 10 11
| public static void sync(long fps) { long gapTo = Sys.getTimerResolution() / fps + timeThen; timeNow = Sys.getTime(); while(gapTo>timeNow) { Thread.yield(); timeNow = Sys.getTime(); } timeThen=timeNow; } |
|
|
|
|
princec
|
 |
«
Reply #39 - Posted
2004-05-06 06:31:38 » |
|
Smartass  I will change to CVS to reflect your nicer version. I don't get frame skips with vsync enabled, but I can see that it might happen. +3 is probably overkill, +1 ought to do the trick. Cas 
|
|
|
|
Games published by our own members! Check 'em out!
|
|
MickeyB
|
 |
«
Reply #40 - Posted
2004-05-07 14:42:28 » |
|
got the sample loop working on my gaming machine at home...so laptop will never do it. Time to code at home. 
|
|
|
|
cfmdobbie
Senior Devvie    Medals: 1
Who, me?
|
 |
«
Reply #41 - Posted
2004-05-07 15:47:40 » |
|
got the sample loop working on my gaming machine at home...so laptop will never do it. Time to code at home.  How very true! My laptop has been repurposed to playing Battlestar Galactica DVDs while I work on my desktop machine - I ran into too many display driver bugs to make it worthwhile persisting with. Re: Display.sync() - is that the right place for it? Isn't it more of a Window function than a Display function? Another thought - is there any mileage in having a setFrameRate(int) method in initialization, then collapse the synchronization code into the Window.update() call? This would change the function of the update method even further away from the concept of "update", I suppose. Regardless, what's the short-term release schedule? Is there going to be an interim (i.e. non-1.0) release for this (slight) API change?
|
Hellomynameis Charlie Dobbie.
|
|
|
princec
|
 |
«
Reply #42 - Posted
2004-05-07 21:20:43 » |
|
We are, er, looking at totally deleting the Window class and merging its functionality with Display... Cas 
|
|
|
|
oNyx
|
 |
«
Reply #43 - Posted
2004-05-07 22:25:40 » |
|
Sounds good. I often searched in the javadoc in the display class only to find out that the thing I need is over at the window class and vice versa. So +1 
|
|
|
|
cfmdobbie
Senior Devvie    Medals: 1
Who, me?
|
 |
«
Reply #44 - Posted
2004-05-08 09:10:57 » |
|
A good answer! I was pondering the same thing last night. I await the next release with interest!
|
Hellomynameis Charlie Dobbie.
|
|
|
zulo
Junior Devvie  
Java games rock!
|
 |
«
Reply #45 - Posted
2004-05-28 20:54:30 » |
|
hi this is so great!!
I have a basic game setup with eclipse and lwjgl09 cvs build now, your game class worked with no problems:)
LWJGL is easier then i thought, I looked at a opengl faq (i also have some opengl ebooks that im going to look at) with examples for c/c++ and learned how to draw quads, I used GL_QUADS setting. I want to make a 2d platform so can i use a texture on my quad? is that the way to go? or is there some other technique to draw the textures as sprites?
could you give me an example of render code to render 1 image/texture? ( as a 2d image )
I understood how to load a texture from nehes tutorial, but he is using awt to load..is there another method? so that i dont need to use awt because i want the opportunity to compile the game to native..
|
|
|
|
princec
|
 |
«
Reply #46 - Posted
2004-05-29 07:31:12 » |
|
My advice is to use AWT first and get it working to learn the ropes. Then when you know what you're doing, start removing it all and replacing it with your own code. Cas 
|
|
|
|
|