Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 2:27 pm

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat Mar 10, 2012 3:07 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
@Davedes
In your test case you call flush() on the batch... I copied the SpriteBatch but there is no flush-method :D

Ah okay for styled text I use a list of commands (like waveing a set of letters) :D Did not thought on other options xD

Nice, does this mean I can translate inside a bind/unbind? If so I love you 8)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Sat Mar 10, 2012 3:58 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
R.D. wrote:
@Davedes
In your test case you call flush() on the batch... I copied the SpriteBatch but there is no flush-method :D

Ah, whoops. Made some local changes I forgot about. Here's the new version:
http://pastebin.com/HTCRgLkn

Quote:
Nice, does this mean I can translate inside a bind/unbind? If so I love you 8)

Since startUse/endUse uses glBegin/glEnd you can't use glRotate/glTranslate/etc. inside it.
The new drawEmbedded method transforms the vertices (same way ImageTransform did, basically) so that you can rotate images within startUse/endUse.


Top
 Profile  
 
PostPosted: Sat Mar 10, 2012 5:01 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Started the test, with 2000 balls nothing else changed, but when using drawEmbedded (push Space once) I get more fps :o

So this means no translation huh? Dammit. Rotation is not the big deal but it would be awesome if I ould be able to translate inside a start/end by manipulating the vertex data. That's what I do when making a wave animation for a set of letters. I translate the current letter and translate back after drawing it.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Wed Mar 14, 2012 11:03 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
R.D. wrote:
Started the test, with 2000 balls nothing else changed, but when using drawEmbedded (push Space once) I get more fps :o

So this means no translation huh? Dammit. Rotation is not the big deal but it would be awesome if I ould be able to translate inside a start/end by manipulating the vertex data. That's what I do when making a wave animation for a set of letters. I translate the current letter and translate back after drawing it.

What is the FPS difference? GPU/system specs?

I'm not sure why it's slower on your machine. In the end both are doing one draw call per frame, but drawEmbedded needs a lot of calls to glVertex, whereas the sprite batch does all of that in one go.

Might be that:
  • Your driver optimizes for GL_QUAD, whereas the default sprite batch mode is GL_TRIANGLES (setUseTriangles changes this)
  • The batch size given to glDrawArrays is too large, slowing things down
  • The need to draw color info is slowing down SpriteBatch (drawEmbedded ignores it unless specified)

For typical use SpriteBatch will probably be faster than many calls to drawEmbedded as it will have fewer texture binds, render calls, etc. And for most machines it should perform far better, again I'm not sure why this isn't the case for you.

As for translation, this is definitely possible. I required it in my own game so I added a "translate" method to SpriteBatch:
http://pastebin.com/yV0NUrq7 (Ignore the VBO stuff as it isn't ready yet.)

Should work as expected.. Example:
Code:
batch.resetTranslation(); //call at beginning or end of each frame to reset the translation
batch.drawImage(img, 0, 0); //will draw at (0, 0)
batch.translate(10, 10);
batch.drawImage(img, 0, 0); //will translate to (10, 10) before drawing
batch.translate(-10, -10);
batch.drawImage(img, 0, 0); //will draw at (0, 0)
batch.flush();


Todos:
  • Optional point sprite mode for faster rendering
  • VBO + shader + instancing for newer GL versions
  • Transform matrix to rotate/scale the batch (in addition to translate)
  • Replace SpriteFont with Slick's AngelCodeFont


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 8:25 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
I will give you a detailed view today I I have the time. If not, sunday :) But I can tell you the deifference in fps it's 200 FPS. Normally it does something like 500 - 530 but with drawEmbedded it does 700-760.

Running on a Laptop with iCore 5 and NVidia GT 330MN (newiest Driver). System is Windows 7 64-bit.

Indeed, setting setUseTriangles to falsse increase the batch's speed to about 600-680 :)

I will test the new batch later as said.

Edit:
maybe it's just the amount of code too. While drawEmbedded uses like... 20 lines of code the batch takes a lot more :o Should be a problem imho but it might slow down a lot of stuff.
Nice that you make translation possible, maybe you want to show that to badLogicGames since their batch does not support such stuff.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Fri Mar 16, 2012 8:30 pm 
Offline

Joined: Wed Mar 09, 2011 10:40 pm
Posts: 49
Let me just pop in real quick and take my hat of for this SpriteBatch stuff. Even without atlases or any other optimizations, just swapping image.draw to batch draw increased speed by orders of magnitude. HURRAY!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yuri6037 and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group