Overwrite paint() in an OpenGLComponent


I am new to Juce and of course… I already have the first questions (problems): I would like to create an application which captures a cam img and streams it to a texture in an OpenGL Component. To first learn how to do the basics, I had a look at the OpenGL demo and I noticed that the Graphics context is somehow set in the Constructor and even stranger to me - drawing of an image happens there (and not in the paint() method as I would anticipate ) :oops:

Why is that? I aks in particulary cos I would like to change the Image obj being drawn as a texture in each timer callback (as I want to get always the current cam frame). So how can I change the pixeldata of Image on the fly since I am apparently not able to overwrite the paint()?

I will be extremely happy for any tip!


Hi there. In the demo it just prepares a demo image before it starts, in the constructor, and uses the same thing later each time it redraws… There’s nothing stopping you creating your own images whenever you like, even in the paint routine.

Hi Jules,

Thx for replying. I tried to overwrite the paint() method, by firsti calling the base one through OpenGLComponent::paint(g) and then do some stuff afterwards (like drawing text) but nothing happens… What am I doing wrong?

The opengl comp is a bit unusual, as you don’t actually use its paint method - have a look at the comments for renderOpenGL().