# OpenGLComponent in the Juce Demo

**URL:** <https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932>\
**Category:** General JUCE discussion\
**Created:** [December 29, 2011, 10:43pm UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932 "2011-12-29T22:43:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce-wheaton](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bruce-wheaton](https://forum.juce.com/u/bruce-wheaton)\
**Post date:** [December 29, 2011, 10:43pm UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932/1 "2011-12-29T22:43:11Z")

</div>

A recent Git update says it supports threaded component updates now. But when I break into the debugger, it’s being called from a timer, not a thread.

Maybe the wrapping in a parent broke the threading behavior?

Or maybe the entire embedded component is being rendered on the main thread on purpose? In which case there’s no threaded activity really - the wrapper doesn’t draw anything.

Bruce

---

<div class="post-metadata">

**Author:** ![bruce-wheaton](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bruce-wheaton](https://forum.juce.com/u/bruce-wheaton)\
**Post date:** [December 29, 2011, 10:58pm UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932/2 "2011-12-29T22:58:21Z")

</div>

Ah, I see. Every demo but the OpenGL demo uses a threaded OpenGL component if the OpenGL renderer is active.

If the OpenGLDemo is selected, the OpenGLRenderer is disabled - the OpenGLDemo then runs in the main thread.

OK, so if the demo itself is set to multi-thread, the top components flicker like crazy unless the component is being altered (dragging the mouse around, for instance).

And I guess when a threaded OpenGLComponent is active, you can’t use the OpenGLRenderer?

Bruce

---

<div class="post-metadata">

**Author:** ![bruce-wheaton](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bruce-wheaton](https://forum.juce.com/u/bruce-wheaton)\
**Post date:** [December 29, 2011, 11:05pm UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932/3 "2011-12-29T23:05:48Z")

</div>

OK.

If I prevent the OpenGLRenderer from being disabled when the OpenGL demo is run, and I put the demo onto a thread, it works perfectly - no flicker, or maybe a very occasional beat - sliders disappear for a frame or too.

Awesome work on the OpenGL stuff Jules! If you weren’t an expert before, you are now. 😃

Bruce

---

<div class="post-metadata">

**Author:** ![bruce-wheaton](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bruce-wheaton](https://forum.juce.com/u/bruce-wheaton)\
**Post date:** [December 30, 2011, 3:15am UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932/4 "2011-12-30T03:15:44Z")

</div>

Having thought about the awesome implications, I have a feature or clarification request!

Let’s say I have an OpenGLComponent. It may or may not be in an OpenGLRenderer, I suppose. Inside that component are some ‘objects’. Currently I manage them. I would like it better if they were components, so I can use hierarchy, messages etc. but they need to render every single GL frame, i.e. they need to draw in renderGL(), not in paint().

Is that currently feasible? Or a feature request - components that have to be in an OpenGLComponent.

There’s a number of issues down the road, obviously - picking and the effect of OpenGL on visibility and position, but let’s assume the component has a main ‘bounding box’ - the component’s position - and clicks etc are based on that.

Bruce

---

<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:** [December 31, 2011, 11:52am UTC](https://forum.juce.com/t/openglcomponent-in-the-juce-demo/7932/5 "2011-12-31T11:52:41Z")

</div>

Yeah, that’s all stuff that I’ll be working on - the idea is that you’d probably make your top-level component an OpenGLComponent, and then in any sub-component, I’ll figure out a way that you can draw GL. (Perhaps by adding a Component::renderOpenGL method that any component could override, but I haven’t quite decided yet)
