Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  Slow JOGL Performance on new Macbook PRO  (Read 3458 times)
0 Members and 1 Guest are viewing this topic.
Offline WillLight

Junior Newbie





« Posted 2011-07-03 09:54:50 »

Hi,

Newbie here so please be gentle Smiley

I'm trying to build a hex-mapped turn-based game.  I started out with processing and ran into performance problems, rendering the map taking 800ms each time.  I built a stand-along program that uses JOGL 2 that only draws the hex-map and as soon as there are many hexes, it takes a very long time to draw, i.e. 1200ms to draw 1200 hexes (30 rows, 40 columns).
The JOGL display function is really simple, it clears the background, and then draws the hexes in a loop.  Each hex is drawn by using a glBegin(GL_LINE_LOOP) call, followed by 6 glVertex2d for each vertex, and finished off with a glEnd.  I push the matrix at the beginning of each render and at the beginning of each row, and then pop them out respectively.

My machine is a brand new Macbook PRO and I simply don't understand how this is taking so long.  I ran the JOGL Gears demo from JNLP, and maximised the window, and it runs very smoothly.  So, on the assumption that a whole lot more lines and quads are being rendered in the Gears demo, I must be doing something wrong.

Any advice?

Thanks in advance!
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2011-07-03 12:04:58 »

AFAIK lines are not accelerated on modern hardware.

Further, once you converted it to use triangles, you might also want to render as much as possible in a few OpenGL calls.

http://www.java-gaming.org/topics/introduction-to-vertex-arrays-and-vertex-buffer-objects-opengl/24272/view.html

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline gouessej
« Reply #2 - Posted 2011-07-03 13:03:17 »

Hi!

First of all, this problem has nothing to do with JOGL in particular, it would happen even with plain C/C++ OpenGL. Secondly, as Riven said, lines are not accelerated on modern hardware, splitting your hexes into triangles can be done easily with a very naive algorithm. Thirdly, you use immediate rendering (glBegin, glEnd, etc...) which is extremely slow. I succeeded in drawing between 150 000 and 1 500 000 triangles with an "old" (ATI Radeon 9250 Pro) graphics card and JOGL. Fourthly, avoid doing a lot of calls to glPushMatrix & glPopMatrix, rather use the same approach than current scenegraphs like Ardor3D (I wrote a JOGL 2.0 renderer for this engine). In your case, maybe you should compute the exact geometry by appliying the transform(s) on your vertices. Thank you for using JOGL 2.0.

Best regards.

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

Junior Newbie





« Reply #3 - Posted 2011-07-03 18:51:59 »

Thanks guys!  Your advice really helped.  The problem was indeed far too many calls to glBegin, vertex, and end.  Reading the articles on vertex arrays and buffers led me to another one on display lists and simply switching the sequence of begin, 6 x vertex and end into a single list and calling that multiple times, even within the same transforms, and matrix stack functions, and even still using GL_LINE_LOOP, yielded a render time of around 3 ms!!!!  Now I know I've chosen the simplest, probably least beneficial way of doing this, and have more options up my sleeve for later.

Cheers!
Offline avm1979
« Reply #4 - Posted 2011-07-03 20:44:10 »

That's really odd. In my experience, display lists are a wash vs immediate mode for these kinds of low numbers of vertices per list.

Maybe it becomes accelerated when it's in a display list - that's the only thing that comes to mind. Not sure that's even possible, though.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2011-07-03 21:18:04 »

FYI: 3ms is still slow, and is no indication whatsoever that lines are suddenly accelerated.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline avm1979
« Reply #6 - Posted 2011-07-04 00:27:27 »

FYI: 3ms is still slow, and is no indication whatsoever that lines are suddenly accelerated.

Well, something else must be going on, that was just a hypothesis. Switching to a 6-vertex display list per hex doesn't account for going from 1200 to 3 ms. On its own, it shouldn't account for much of an improvement, if any.

Offline WillLight

Junior Newbie





« Reply #7 - Posted 2011-07-04 08:41:09 »

FYI: 3ms is still slow, and is no indication whatsoever that lines are suddenly accelerated.

Yeah, I figured it's not necessarily that lines are accelerated, it's just that this is essentially a board game so if after all the additional stuff I need to draw it ends up being about 10ms, I'm more than happy with that.  At any rate, your post helped me a lot.  Thank you.
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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (40 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!