Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  libGDX - renderer lag  (Read 1780 times)
0 Members and 1 Guest are viewing this topic.
Offline ado

Senior Newbie





« Posted 2013-05-11 14:31:25 »

hi
I've been getting back into java development after a break due to a new job and other things and decided to learn to use the gdx library rather than do what I think might be a common newbie thing and try and reinvent the wheel like I was trying to.
Anyway, I followed a tutorial series on youtube and have been working using the code from that series in a rts for the last week when I have the time. I have a few basic functions like building and tree placement and selection via number keys but I've been ignoring renderer lag/clipping while I work on these and would like to fix this before I go any further but I have no idea what the problem is. I have tried to move the camera adjustment and cam.update from the renderer render method to the world update method to separate the logic from the render loop but that didnt fix it.
If someone could help me out it would be much appreciated Smiley

http://www.mediafire.com/?61p4q3wvnzoc4c0
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2013-05-11 14:52:01 »

What is renderer lag?

Offline ado

Senior Newbie





« Reply #2 - Posted 2013-05-11 14:56:06 »

By that I mean that when the camera is moved with wsad there is a jitter/delay when image are rendered in the render method being called. In saying I think the problem may be with the world.update taking too long
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2013-05-11 15:15:50 »

I'm not sure exactly what your problem is but there's a good article on separation of logic and rendering
here. Also from the site -
Offline ado

Senior Newbie





« Reply #4 - Posted 2013-05-11 15:32:44 »

thanks jimmt but I understand how the flow/separation should be, the problem Im having is that when I move the camera say two key presses(eg, one key press move the camera, cam.x + 5px*delta*80) in a direction, the renderer seems to only be rendering every 2nd frame, making it seem like things are jittery/jumping/expanding-shrinking.
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #5 - Posted 2013-05-11 15:35:05 »

Where are you focusing the camera on? If it's just the player there's no need to move the camera, just set it to the player x/y. Are you doing any scaling?
Offline ado

Senior Newbie





« Reply #6 - Posted 2013-05-11 15:42:01 »

This will be an rts style game so there will be no central character to centre on, rather the player freely moves the camera around the map and starts at (0,0).
The default window size is 800x600 and the cameras width, height is 480x320 and Im using:
1  
2  
batch = new SpriteBatch();
batch.setProjectionMatrix(cam.combined);

Im still using this from the tutorial I was following by dustin reily and I think it scales, am I correct?

EDIT: after some reading about resolutions and aspect ratios I think that maybe the window and camera scaling at different aspect ratios may be the problem. Im taking a break and will test this later. Any info still appreciated
Offline Cero
« Reply #7 - Posted 2013-05-11 17:13:29 »

Its a simple 'using delta time equals jitter problem'
I kinda dont like delta time and try to avoid it because of this
Our latest game does a low pass filter over a coupke of collected delta times and so on

My advice: either make sure you have a rock solud framerate,  which is good anyway; or read up on delta timing / time steps in video games

Offline relminator
« Reply #8 - Posted 2013-05-11 17:54:37 »

Its a simple 'using delta time equals jitter problem'
I kinda dont like delta time and try to avoid it because of this
Our latest game does a low pass filter over a coupke of collected delta times and so on

My advice: either make sure you have a rock solud framerate,  which is good anyway; or read up on delta timing / time steps in video games

Speaking of which, I only have this problems in windows using java.

I have the same java code that jitters like crap on my windows desktop while running smooth as silk on an android device.

Uses the same fixed timestep mechanism and the same codebase.  Android version uses ogl es and pc version uses lwjgl.

The same delta-timing mechanism used in both freebasic and c++ runs smooth.
Offline theagentd
« Reply #9 - Posted 2013-05-11 18:41:12 »

Too low delta values give precision problems. It probably runs better on the Android device since it's slower. Spikes will still cause explosions though and that might be worse on Androids.

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

Senior Newbie





« Reply #10 - Posted 2013-05-11 19:35:01 »

thanks cero. I changed:
1  
2  
renderer.getCamera().position.set(renderer.getCamera().position.x+velocity.x*Gdx.graphics.getDeltaTime()*80f, renderer.getCamera().position.y+velocity.y*Gdx.graphics.getDeltaTime()*80f, 0);
renderer.getCamera().update();

to:
1  
2  
renderer.getCamera().position.set(renderer.getCamera().position.x+velocity.x, renderer.getCamera().position.y+velocity.y, 0);
renderer.getCamera().update();

And now things are running smoothly Smiley.
I have worked through the new bostons tutorials and read a fair bit on delta timing as it was something I was having trouble understanding initially but in this case I was trying to use gdx's inbult getDelta function which I'm not sure of how well made it is. This is something I have been googling about for as I thought it was odd I didnt have to construct a game loop with delta timing in the tutorials. Is a game loop is supposed to be constructed in Gdx or does something like this:
1  
2  
3  
4  
   public void render(float delta) {      
      renderer.render();
      world.update();
   }

in the gameScreen suffice? Could this be done more efficiently/effectively?
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #11 - Posted 2013-05-11 20:21:56 »

Print your delta times to see why it isn't smooth.

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.

TehJavaDev (13 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (31 views)
2014-08-16 06:45:27

Tekkerue (30 views)
2014-08-16 06:22:17

Tekkerue (19 views)
2014-08-16 06:20:21

Tekkerue (29 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (42 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!