# OpenGL Renderer: massive performance decrease in Juce V.2

**URL:** <https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541>\
**Category:** General JUCE discussion\
**Created:** [April 22, 2012, 5:45pm UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541 "2012-04-22T17:45:35Z")\
**Posts on this page:** 5\
**Page:** 3

<div class="post-metadata">

**Author:** ![Bruce\_Wheaton](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@Bruce\_Wheaton](https://forum.juce.com/u/Bruce_Wheaton)\
**Post date:** [April 23, 2012, 10:14pm UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541/41 "2012-04-23T22:14:13Z")

</div>

All the GL error checking was introduced there. If you’re running a debug build, then CPU and GPU threads will be sync’ed at every glGetError() call, and if there’s a lot of drawing to be done, flushing the whole GL queue to get current state could be very expensive.

In a release build, what times do you see?

EDIT - you specified release, sorry. Then I would say - double check that glGetError is _not_ being called in your release build, and/or comment that out. It could certainly have the effect you describe. Since your frame times look suspiciously like a multiple of frame times, that may be what’s going on: a glGetXXXX type command that causes the thread to stop while all drawing takes place and the swap happens.

Bruce

---

<div class="post-metadata">

**Author:** ![friscokid](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@friscokid](https://forum.juce.com/u/friscokid)\
**Post date:** [April 23, 2012, 10:23pm UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541/42 "2012-04-23T22:23:04Z")

</div>

Ok, I got it.

It is as simple as this:  
The whole OpenGL Renderer code is just fine. It is the Juce Demo itself that causes the performance loss.  
As soon as the TopLevelWindow is used for the OpenGl Context the performance goes down.

If you change line 163 in MainDemoWindow.cpp from

```auto

```

to

```auto

```

everything is fine and you can enjoy great performance.

In my case the render times droped from 22ms to 1.8ms at a canvas size of 2342 x 1177 !

This is also valid for the latest tip of juce version 2.

So the OpenGL Renderer is great, but it cannot be recommended to attach it to the TopLevelComponent.  
Perhaps Jules has some ideas on how to improve this.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 24, 2012, 9:08am UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541/43 "2012-04-24T09:08:28Z")

</div>

Wow. Glad you guys got there in the end - I’m not sure I’d have thought of looking outside of the actual GL rendering code!

I’m surprised that it makes any difference when you attach it to the top-level component though… I can’t see any code that would behave differently in that case, so I guess the difference is just that it’s redrawing the underlying components. (But it shouldn’t actually need to do that… I’ll take a look in there and see what I can do)

Thanks for all your debugging help, chaps!

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [April 24, 2012, 1:23pm UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541/44 "2012-04-24T13:23:44Z")

</div>

Could this have to do with transparent top level window with drop shadow?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 24, 2012, 1:58pm UTC](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541/45 "2012-04-24T13:58:43Z")

</div>

> [@TheVinn](#):
>
> Could this have to do with transparent top level window with drop shadow?

No… the window itself isn’t transparent, I don’t think it’ll make any difference. I suspect something like e.g. the normal paint routines being called as well as the GL one… I’ll investigate when I get a moment.

[Previous page](https://forum.juce.com/t/opengl-renderer-massive-performance-decrease-in-juce-v-2/8541.md?page=2)
