[quote=“colinbear”]if you are still using something like the following code to create your opengl class (this is based on line 191 of the jucedemo MainDemoWindow.cpp code)
then your returned demos object is actually a pointer to a Component rather than to your openGLComponent which has the setArrayPointer() function in it.
in a completely unsafe way you can see if the following works, just change your “outside” call to something like this:
Its generally unsafe as you are assuming that demos is actually an OpenGLDemo object. the best way would be for you to create a specific pointer to your OpenGLDemo object, rather than use the demos one like so:
then when you want to set the pointer just call
you will still be able to do all the same things to the gl object as you did with the demos object as the OpenGLDemo class inherits all of the Component attributes and methods.[/quote]
Hi Colinbear,
I tried to follow your advice on how to make an instance of the createOpenGLDemo() class from the Juce Demo.
This is how it is done from Jules:
addAndMakeVisible(demos = createOpenGLDemo());
Component* createOpenGLDemo()
{
return new OpenGLDemo();
}
I would like to do it the way you suggest but I haven’t succeeded and I’m getting frustrated since I’ve feel I have tried all possibilities…
To recall you recipy:
[b][i]Its generally unsafe as you are assuming that demos is actually an OpenGLDemo object. the best way would be for you to create a specific pointer to your OpenGLDemo object, rather than use the demos one like so:
Code:
OpenGLDemo *gl = new OpenGLDemo();
then when you want to set the pointer just call
Code:
gl->setArrayPointer(pointer);[/i][/b]
Doing it your way leads to the following “poor” error message in Visual Studio Express C++
…\src\DemoEditorComponent.cpp(104) : error C2061: syntax error : identifier ‘OpenGLDemo’
Do you have any suggestions?
The essential code lines from my project are presented below:
[i]DemoEditorComponent::DemoEditorComponent (DemoJuceFilter* const ownerFilter)
: AudioFilterEditor (ownerFilter)
{
static ShinyLookAndFeel* shinyLook = 0;
if (shinyLook == 0)
shinyLook = new ShinyLookAndFeel();
LookAndFeel::setDefaultLookAndFeel (shinyLook);
// create our gain slider..
addAndMakeVisible (gainSlider = new Slider (T("gain")));
gainSlider->addChangeListener (this);
gainSlider->setRange (0.0, 1.0, 0.01);
addAndMakeVisible (kneeSlider = new Slider (T("knee")));
kneeSlider->addChangeListener (this);
kneeSlider->setRange (0.0, 1.0, 0.01);
addAndMakeVisible (OpenGlZoomSlider = new Slider (T("OpenGlZoomSlider")));
OpenGlZoomSlider->addChangeListener (this);
OpenGlZoomSlider->setRange (0.0, 1.5, 0.01);
// get the gain parameter from the filter and use it to set up our slider
gainSlider->setValue (ownerFilter->getParameter (0), false);
kneeSlider->setValue (ownerFilter->getParameter (0), false);
// create and add the midi keyboard component..
//addAndMakeVisible (midiKeyboard
// = new MidiKeyboardComponent (ownerFilter->keyboardState,
// MidiKeyboardComponent::horizontalKeyboard));
// add a label that will display the current timecode and status..
//addAndMakeVisible (infoLabel = new Label (String::empty, String::empty));
// add the triangular resizer component for the bottom-right of the UI
addAndMakeVisible (resizer = new ResizableCornerComponent (this));
resizer->setResizeLimits (150, 150, 1024,1024);
// set our component's initial size to be the last one that was stored in the filter's settings
//setSize (ownerFilter->lastUIWidth,
// ownerFilter->lastUIHeight);
setSize (winWidth, winHeight);
// register ourselves with the filter - it will use its ChangeBroadcaster base
// class to tell us when something has changed, and this will call our changeListenerCallback()
// method.
ownerFilter->addChangeListener (this);
// Add a OpenGl canvas
//addAndMakeVisible(demos = createOpenGLDemo());
OpenGLDemo *gl = new OpenGLDemo();
}[/i]