Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 2:23 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Image.subImage
PostPosted: Wed Apr 25, 2007 10:48 pm 
Offline
Oldbie

Joined: Tue Nov 28, 2006 6:18 pm
Posts: 429
To draw a background image, I'm currently using Image.subImage. It works fine, but on a blank slate game with just the background drawing and a simple sprite, it's "only" 2200 FPS on my screen. I wish I could profile and find out what's eating things up, but my computer can't run NB or its profiler at the moment. :/

Is the following usage of subImage reasonable to call every update?

Code:
public void render(Graphics g)
{
      Viewport viewport = getViewport();
      
      float x = viewport.getX();
      float y = viewport.getY();
      
      float clipx = viewport.getClip().x;
      float clipy = viewport.getClip().y;
      
      float width = viewport.getClip().width;
      float height = viewport.getClip().height;
      
      Image sub = image.getSubImage((int) x, (int) y, (int) width, (int) height);
      
      sub.draw(clipx, clipy);
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 11:17 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Sub-image doesn't do anything but move the texture coordinates. So it's more likely it's just the fact that you're now touching every pixel on the screen.

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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