Skip to content

Commit 6e2ddc7

Browse files
author
Glendon Holst
committed
working fix for issue #9 renderer assert
1 parent 5af4398 commit 6e2ddc7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

GLStats/renderer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef std::set< uint32_t > ThreadSet;
4848
typedef ThreadSet::const_iterator ThreadSetCIter;
4949
typedef std::map< uint32_t, ThreadSet > EntityMap;
5050
typedef EntityMap::const_iterator EntityMapCIter;
51-
typedef stde::hash_map< uint32_t, uint32_t > EntityPos;
51+
typedef stde::hash_map< uint32_t, float > EntityPos;
5252

5353
typedef Items::const_iterator ItemsCIter;
5454

@@ -109,13 +109,13 @@ class Renderer
109109
threads.insert( item.thread );
110110
}
111111

112-
uint32_t nextY = height - gap - topMargin; // start at top
112+
float nextY = float(height) - float( gap + topMargin ); // start at top
113113
EntityPos yPos;
114114
for( EntityMapCIter i = entities.begin(); i != entities.end(); ++i )
115115
{
116116
const ThreadSet& threads = i->second;
117117
yPos[ i->first ] = nextY;
118-
nextY -= uint32_t( threads.size() * rowHeight );
118+
nextY -= float( threads.size() * rowHeight );
119119
}
120120

121121
//----- alternating frame background, entity names
@@ -144,7 +144,7 @@ class Renderer
144144
LBASSERTINFO( false, "Entity " << item.entity <<
145145
" undeclared, item: " << item );
146146
yPos[ item.entity ] = nextY;
147-
nextY -= rowHeight;
147+
nextY -= float( rowHeight );
148148
}
149149

150150
if( item.entity != last->entity || item.thread != last->thread ||
@@ -178,9 +178,9 @@ class Renderer
178178
const uint32_t thread = row & 0xFFFFFFFFu;
179179
const ThreadSet& threads = entities[ entity ];
180180
const ThreadSetCIter threadPos = threads.find( thread );
181-
const uint32_t y = yPos[ entity ] -
182-
std::distance( threads.begin(), threadPos ) * rowHeight;
183-
const float y2 = float( y - barHeight - space );
181+
const float y = yPos[ entity ] -
182+
float( std::distance( threads.begin(), threadPos ) * rowHeight );
183+
const float y2 = y - float( barHeight + space );
184184
#if 1
185185
// per-frame alternating background color
186186
const float y1 = float( y + space );
@@ -227,15 +227,15 @@ class Renderer
227227
const Type& type = data.getType( item.type );
228228
const ThreadSet& threads = entities[ item.entity ];
229229
const ThreadSetCIter j = threads.find( item.thread );
230-
const uint32_t y = yPos[ item.entity ] -
231-
std::distance( threads.begin(), j ) * rowHeight;
230+
const float y = yPos[ item.entity ] -
231+
float(std::distance( threads.begin(), j ) * rowHeight);
232232

233233
const float x1 = float( item.start - xOffset ) / scale;
234234
const float x2 = float( item.end - xOffset ) / scale;
235235

236236
const uint32_t inset = item.layer * space;
237-
const float y1 = float( y - inset );
238-
const float y2 = float( y + inset ) - float( barHeight ); // Fix #9
237+
const float y1 = float( y ) - float( inset );
238+
const float y2 = float( y + inset ) - float( barHeight );
239239
LBASSERTINFO( y2 < y1, y2 << " >= " << y1 << " (" << y << ")" );
240240

241241
glColor4fv( type.color );

0 commit comments

Comments
 (0)