Slick Forums

Discuss the Slick 2D Library
It is currently Sun Feb 17, 2019 4:35 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Sep 28, 2011 7:00 pm 
Offline

Joined: Wed Sep 28, 2011 6:44 pm
Posts: 3
My program was stuttering becuase of the array allocation in ImmediateModeOGLRenderer.glColor4f :-
Code:
public void glColor4f(float r, float g, float b, float a) {
  a *= alphaScale;
  current = new float[] {r,g,b,a};
  GL11.glColor4f(r, g, b, a);
}


This was being called every time a line was drawn, through the sub methods bind(), TextureImpl.bindNone(), even though I was *not* changing the color. (so alot of the same allocation even within the scope of a single drawLine method, let alone across calls to drawLine of the same color)
My quick fix for my program was, which reduced garbage by approx 30% (the other 60% of garbage remaining is the bloody HashSet iterator :( ), to just double check the current array values are not the same as the parameters

Code:
public void glColor4f(float r, float g, float b, float a) {
  a *= alphaScale;
  if(current[0] != r && current[1]!=g && current[2]!=b && current[3]!=a)
    current = new float[] {r,g,b,a};
  GL11.glColor4f(r, g, b, a);
}


Dunno if that is tidy enough for slick but it did help me alot


Top
 Profile  
 
PostPosted: Sat Nov 12, 2011 8:11 pm 
Offline
Regular

Joined: Mon Dec 08, 2008 2:17 pm
Posts: 160
The issue has been solved by Tommy. See viewtopic.php?p=23914#p23914
moving topic to resolved rfes...

Thanks for reporting!


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