Slow mesh rendering because of glPushAttrib

I have a considerable amount of box meshes that I am rendering perfectly fine at 60fps. I switched over to rendering a single ofMesh many times that only has 6 verts and it drops the frame rate in half.

I am using OF 0073 official release, non-git version.

When I comment out glPushAttrib in ofGLRenderer, it jumps back up to 60fps

  
  
//----------------------------------------------------------  
void ofGLRenderer::draw(ofMesh & vertexData, ofPolyRenderMode renderType, bool useColors, bool useTextures, bool useNormals){  
		if (bSmoothHinted) startSmoothing();  
#ifndef TARGET_OPENGLES  
//		glPushAttrib(GL_POLYGON_BIT);  
//		glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType));  
		draw(vertexData,useColors,useTextures,useNormals);  
//		glPopAttrib(); //TODO: GLES doesnt support polygon mode, add renderType to gl renderer?  
#else  
  

Any thoughts? I would like to leverage the functionality in ofMesh, but not with such a big performance hit.

Also, on a separate note. I can’t get the app and example apps included with the download
to run higher than 60 fps. I tried ofSetFramerate to 10000, 0 and everything in between. Is this a bug?

Best,
Nick

concerning the 60fps cap - I just downloaded and added

  
ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), 20, 20, ofColor::black, ofColor::yellow);  
  

and was getting 2000fps

edit: this was to emptyExample

nick, about the 60fps cap, it’s probably your graphics card doing vertical sync by default, you can probably disable it in the dirver preferences

about the push attrib, yes, there’s several push/pop get/set attribs all over the core that i would like to get rid of since they should slow down things a lot. we could store the state in variables without using gl calls but that won’t work if people mix gl with of calls, so not sure what’s the best solution. can you post an issue on github so we can disscuss it there

Thanks @arturo,
I have submitted a pull request

  
[https://github.com/openframeworks/openFrameworks/issues/1759](https://github.com/openframeworks/openFrameworks/issues/1759)  

I disabled vertical sync and I switched off automatic graphics switching in the preferences panel in osx 10.8

@jvcleave, I was trying the color example, but don’t think that should slow it to 60fps.

what graphics card do you have? at least on linux intel cards default to vsync and can’t be deactivated

I have the NVIDIA GeForce GT 650M 1024 MB on my macbook pro.
I run into less issues with ofEnableVerticalSync( false );

Not sure how to avoid it.

it could be that they default to vsync activated and you can disable per application. also don’t use ofSetFramerate at all, that sets the application to sleep from time to time. with that you should get the maximum fps.

I’ve just migrate to 0073.
My project with 0071 runs at 300 fps
With 0073 it stays at 60 fps.
I’ve change only some things related to ofxQTKitVideoPlayer (changed to ofQTKitPlayer).
It seems that ofSetVerticalSync(false); can’t change the settings of the output.
Don’t know if it’s relevant …

Nick - I just went back and tried the color example and was only getting 64fps (with ofSetFrameRate() disabled). I also ran it in 0071 where it actually only got 45fps

Both were in debug mode

Ok,

I’ve found that my slow down int the framerate with 0073 and 10.8 is due to the addon ofxfernster.