OpenGL n00b - when, where, why

I’ve just started experimenting with openGL in the hope that a little hardware acceleration would give my animated 2D components a better frame rate. However, simply attaching an OpenGLContext to the top level component actually slows down the rendering relative to the software renderer (on both mac and iPhone at least). This effect can be easily observed using the JUCE Demo on the opening page.

I’m guessing that folks here are not simply switching the entire rendering of their application over to openGL? When is it a good idea to use openGL over the software renderer? Is it ever a good idea when doing 2D stuff?

When you’re testing, make sure you use a fully-optimised release build, because that’ll make a big difference to the GL renderer.

It’s much faster for some things, and not for others… At the moment I think the only bottleneck is if you’re drawing a lot of memory-based images, and that’s something I’m planning on improving by caching images in texture memory.


I'm doing a release build with -O3 optimisation. On the rendering demo page in the JUCE demo with all component animation options set, I get . . . 

iPod touch 5th gen: 
30 fps using the software renderer and 9 FPS using OGL

iPhone 4S:
35 fps using the software renderer and 11 FPS using OGL

iPad 2 (bigger display area, so you'd expect slower):
15 fps software / 7 fps OGL

I haven't found a combination of settings where OGL > Software yet. Am I missing any special flags or something?

I’m doing a release build with -O3 optimisation. On the rendering demo page in the JUCE demo with all component animation options set, I get . . .

iPod touch 5th gen:
30 fps using the software renderer and 9 FPS using OGL

iPhone 4S:
35 fps using the software renderer and 11 FPS using OGL

iPad 2 (bigger display area, so you’d expect slower):
15 fps software / 7 fps OGL

I haven’t found a combination of settings where OGL > Software yet. Am I missing any special flags or something?

[quote=“billythekid”]make sure you use a fully-optimised release build

I’m doing a release build with -O3 optimisation. On the rendering demo page in the JUCE demo with all component animation options set, I get . . .

iPod touch 5th gen:
30 fps using the software renderer and 9 FPS using OGL

iPhone 4S:
35 fps using the software renderer and 11 FPS using OGL

iPad 2 (bigger display area, so you’d expect slower):
15 fps software / 7 fps OGL

I haven’t found a combination of settings where OGL > Software yet. Am I missing any special flags or something?[/quote]

TBH I was thinking more about desktop OSes rather than iOS. On iOS the CoreGraphics renderer will be hard to beat (I assume that’s what you’re talking about when you say “software” renderer, and not the actual software renderer)

I’m just going by the names in the dropdown menu of the JUCE demo. Those are “OpenGL” and “Software”.

Yes, that must be the CoreGraphics one.

2D juce OGL has always been slower for me than not using it. There are also problems on mobiles.

here i posted a simple test that didnt work too well on Android. its slower and i get screen corruption,

http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=11521&hilit=red+box

I havent tried this with the very latest tip however (and i know there’s been some changes recently in this area).

Meh. It’s ok. I have spent the afternoon judiciously adding setOpaque(true) to small regions and staggering animations so that there are fewer visible simultaneous components mid-animation on screen at any given time. This has gotten the frame-rate up considerably without significant loss in whizbang factor.