|
|
|
@@ -28,11 +28,31 @@ extern XContext windowHandleXContext; |
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
// Defined juce_linux_Windowing.cpp
|
|
|
|
Rectangle<int> juce_LinuxScaledToPhysicalBounds(ComponentPeer* peer, const Rectangle<int>& bounds);
|
|
|
|
Rectangle<int> juce_LinuxScaledToPhysicalBounds (ComponentPeer* peer, const Rectangle<int>& bounds);
|
|
|
|
void juce_LinuxAddRepaintListener (ComponentPeer* peer, Component* dummy);
|
|
|
|
void juce_LinuxRemoveRepaintListener (ComponentPeer* peer, Component* dummy);
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
class OpenGLContext::NativeContext
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
class DummyComponent : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DummyComponent (OpenGLContext::NativeContext& nativeParentContext)
|
|
|
|
: native (nativeParentContext)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void handleCommandMessage (int commandId) override
|
|
|
|
{
|
|
|
|
if (commandId == 0)
|
|
|
|
native.triggerRepaint();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
OpenGLContext::NativeContext& native;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
NativeContext (Component& comp,
|
|
|
|
const OpenGLPixelFormat& cPixelFormat,
|
|
|
|
@@ -40,7 +60,7 @@ public: |
|
|
|
bool /*useMultisampling*/,
|
|
|
|
OpenGLVersion)
|
|
|
|
: component (comp), renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0),
|
|
|
|
contextToShareWith (shareContext)
|
|
|
|
contextToShareWith (shareContext), context (nullptr), dummy (*this)
|
|
|
|
{
|
|
|
|
ScopedXLock xlock;
|
|
|
|
XSync (display, False);
|
|
|
|
@@ -96,10 +116,14 @@ public: |
|
|
|
XFreeColormap (display, colourMap);
|
|
|
|
|
|
|
|
XSync (display, False);
|
|
|
|
|
|
|
|
juce_LinuxAddRepaintListener (peer, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
~NativeContext()
|
|
|
|
{
|
|
|
|
juce_LinuxRemoveRepaintListener (component.getPeer(), &dummy);
|
|
|
|
|
|
|
|
if (embeddedWindow != 0)
|
|
|
|
{
|
|
|
|
ScopedXLock xlock;
|
|
|
|
@@ -111,15 +135,17 @@ public: |
|
|
|
XFree (bestVisual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void initialiseOnRenderThread (OpenGLContext& context)
|
|
|
|
void initialiseOnRenderThread (OpenGLContext& c)
|
|
|
|
{
|
|
|
|
ScopedXLock xlock;
|
|
|
|
renderContext = glXCreateContext (display, bestVisual, (GLXContext) contextToShareWith, GL_TRUE);
|
|
|
|
context.makeActive();
|
|
|
|
c.makeActive();
|
|
|
|
context = &c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shutdownOnRenderThread()
|
|
|
|
{
|
|
|
|
context = nullptr;
|
|
|
|
deactivateCurrentContext();
|
|
|
|
glXDestroyContext (display, renderContext);
|
|
|
|
renderContext = nullptr;
|
|
|
|
@@ -183,6 +209,12 @@ public: |
|
|
|
void* getRawContext() const noexcept { return renderContext; }
|
|
|
|
GLuint getFrameBufferID() const noexcept { return 0; }
|
|
|
|
|
|
|
|
void triggerRepaint()
|
|
|
|
{
|
|
|
|
if (context != nullptr)
|
|
|
|
context->triggerRepaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Locker { Locker (NativeContext&) {} };
|
|
|
|
|
|
|
|
private:
|
|
|
|
@@ -195,6 +227,9 @@ private: |
|
|
|
XVisualInfo* bestVisual;
|
|
|
|
void* contextToShareWith;
|
|
|
|
|
|
|
|
OpenGLContext* context;
|
|
|
|
DummyComponent dummy;
|
|
|
|
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext)
|
|
|
|
};
|
|
|
|
|
|
|
|
|