mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
This commit is contained in:
parent
c0bd385d6c
commit
7ba402348e
6 changed files with 76 additions and 45 deletions
|
|
@ -2482,7 +2482,7 @@ void juce_windowMessageReceive (XEvent* event)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool clipToWorkArea) throw()
|
||||
void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool /*clipToWorkArea*/) throw()
|
||||
{
|
||||
#if JUCE_USE_XINERAMA
|
||||
int major_opcode, first_event, first_error;
|
||||
|
|
@ -2518,8 +2518,7 @@ void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool c
|
|||
if (monitorCoords.size() == 0)
|
||||
#endif
|
||||
{
|
||||
Atom hints = clipToWorkArea ? XInternAtom (display, "_NET_WORKAREA", True)
|
||||
: None;
|
||||
Atom hints = XInternAtom (display, "_NET_WORKAREA", True);
|
||||
|
||||
if (hints != None)
|
||||
{
|
||||
|
|
@ -2909,7 +2908,7 @@ public:
|
|||
XDestroyWindow (display, embeddedWindow);
|
||||
}
|
||||
|
||||
bool makeActive() throw()
|
||||
bool makeActive() const throw()
|
||||
{
|
||||
jassert (renderContext != 0);
|
||||
|
||||
|
|
@ -2917,7 +2916,7 @@ public:
|
|||
&& XSync (display, False);
|
||||
}
|
||||
|
||||
bool makeInactive() throw()
|
||||
bool makeInactive() const throw()
|
||||
{
|
||||
return (! isActive()) || glXMakeCurrent (display, None, 0);
|
||||
}
|
||||
|
|
@ -2997,7 +2996,8 @@ void juce_glViewport (const int w, const int h)
|
|||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (OwnedArray <OpenGLPixelFormat>& results)
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* component,
|
||||
OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
results.add (new OpenGLPixelFormat()); // xxx
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3357,14 +3357,14 @@ public:
|
|||
aglDestroyContext (renderContext);
|
||||
}
|
||||
|
||||
bool makeActive() throw()
|
||||
bool makeActive() const throw()
|
||||
{
|
||||
jassert (renderContext != 0);
|
||||
|
||||
return aglSetCurrentContext (renderContext);
|
||||
}
|
||||
|
||||
bool makeInactive() throw()
|
||||
bool makeInactive() const throw()
|
||||
{
|
||||
return (! isActive()) || aglSetCurrentContext (0);
|
||||
}
|
||||
|
|
@ -3456,7 +3456,8 @@ static int getAGLAttribute (AGLPixelFormat p, const GLint attrib)
|
|||
return result;
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (OwnedArray <OpenGLPixelFormat>& results)
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/,
|
||||
OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
GLint attribs [64];
|
||||
int n = 0;
|
||||
|
|
|
|||
|
|
@ -3079,27 +3079,17 @@ static void getWglExtensions (HDC dc, StringArray& result) throw()
|
|||
class WindowedGLContext : public OpenGLContext
|
||||
{
|
||||
public:
|
||||
WindowedGLContext (Component* const component, HGLRC contextToShareWith)
|
||||
WindowedGLContext (Component* const component_,
|
||||
HGLRC contextToShareWith,
|
||||
const OpenGLPixelFormat& pixelFormat)
|
||||
: renderContext (0),
|
||||
nativeWindow (0)
|
||||
nativeWindow (0),
|
||||
dc (0),
|
||||
component (component_)
|
||||
{
|
||||
jassert (component != 0);
|
||||
Win32ComponentPeer* const peer = dynamic_cast <Win32ComponentPeer*> (component->getTopLevelComponent()->getPeer());
|
||||
|
||||
nativeWindow = new Win32ComponentPeer (component, 0);
|
||||
nativeWindow->dontRepaint = true;
|
||||
nativeWindow->setVisible (true);
|
||||
|
||||
HWND hwnd = (HWND) nativeWindow->getNativeHandle();
|
||||
|
||||
if (peer != 0)
|
||||
{
|
||||
SetParent (hwnd, (HWND) peer->getNativeHandle());
|
||||
juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_CHILD, true);
|
||||
juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_POPUP, false);
|
||||
}
|
||||
|
||||
dc = GetDC (hwnd);
|
||||
createNativeWindow();
|
||||
|
||||
// Use a default pixel format that should be supported everywhere
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
|
@ -3108,7 +3098,7 @@ public:
|
|||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 16;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cDepthBits = 16;
|
||||
|
||||
const int format = ChoosePixelFormat (dc, &pfd);
|
||||
|
|
@ -3117,6 +3107,9 @@ public:
|
|||
SetPixelFormat (dc, format, &pfd);
|
||||
|
||||
renderContext = wglCreateContext (dc);
|
||||
makeActive();
|
||||
|
||||
setPixelFormat (pixelFormat);
|
||||
|
||||
if (contextToShareWith != 0 && renderContext != 0)
|
||||
wglShareLists (renderContext, contextToShareWith);
|
||||
|
|
@ -3127,18 +3120,18 @@ public:
|
|||
makeInactive();
|
||||
|
||||
wglDeleteContext (renderContext);
|
||||
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
|
||||
|
||||
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
|
||||
delete nativeWindow;
|
||||
}
|
||||
|
||||
bool makeActive() throw()
|
||||
bool makeActive() const throw()
|
||||
{
|
||||
jassert (renderContext != 0);
|
||||
return wglMakeCurrent (dc, renderContext) != 0;
|
||||
}
|
||||
|
||||
bool makeInactive() throw()
|
||||
bool makeInactive() const throw()
|
||||
{
|
||||
return (! isActive()) || (wglMakeCurrent (0, 0) != 0);
|
||||
}
|
||||
|
|
@ -3152,6 +3145,7 @@ public:
|
|||
{
|
||||
OpenGLPixelFormat pf;
|
||||
|
||||
makeActive();
|
||||
StringArray availableExtensions;
|
||||
getWglExtensions (dc, availableExtensions);
|
||||
|
||||
|
|
@ -3166,13 +3160,8 @@ public:
|
|||
|
||||
bool setPixelFormat (const OpenGLPixelFormat& pixelFormat)
|
||||
{
|
||||
jassert (renderContext != 0);
|
||||
|
||||
makeActive();
|
||||
|
||||
StringArray availableExtensions;
|
||||
getWglExtensions (dc, availableExtensions);
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
zerostruct (pfd);
|
||||
pfd.nSize = sizeof (pfd);
|
||||
|
|
@ -3198,6 +3187,9 @@ public:
|
|||
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = 0;
|
||||
|
||||
StringArray availableExtensions;
|
||||
getWglExtensions (dc, availableExtensions);
|
||||
|
||||
if (availableExtensions.contains ("WGL_ARB_pixel_format")
|
||||
&& WGL_EXT_FUNCTION_INIT (PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB))
|
||||
{
|
||||
|
|
@ -3268,7 +3260,14 @@ public:
|
|||
{
|
||||
makeInactive();
|
||||
|
||||
// Create the real context..
|
||||
// win32 can't change the pixel format of a window, so need to delete the
|
||||
// old one and create a new one..
|
||||
jassert (nativeWindow != 0);
|
||||
ReleaseDC ((HWND) nativeWindow->getNativeHandle(), dc);
|
||||
delete nativeWindow;
|
||||
|
||||
createNativeWindow();
|
||||
|
||||
if (SetPixelFormat (dc, format, &pfd))
|
||||
{
|
||||
wglDeleteContext (renderContext);
|
||||
|
|
@ -3303,6 +3302,8 @@ public:
|
|||
|
||||
bool setSwapInterval (const int numFramesPerSwap)
|
||||
{
|
||||
makeActive();
|
||||
|
||||
StringArray availableExtensions;
|
||||
getWglExtensions (dc, availableExtensions);
|
||||
|
||||
|
|
@ -3315,6 +3316,8 @@ public:
|
|||
|
||||
int getSwapInterval() const
|
||||
{
|
||||
makeActive();
|
||||
|
||||
StringArray availableExtensions;
|
||||
getWglExtensions (dc, availableExtensions);
|
||||
|
||||
|
|
@ -3374,9 +3377,30 @@ public:
|
|||
|
||||
private:
|
||||
Win32ComponentPeer* nativeWindow;
|
||||
Component* const component;
|
||||
HDC dc;
|
||||
|
||||
//==============================================================================
|
||||
void createNativeWindow()
|
||||
{
|
||||
nativeWindow = new Win32ComponentPeer (component, 0);
|
||||
nativeWindow->dontRepaint = true;
|
||||
nativeWindow->setVisible (true);
|
||||
|
||||
HWND hwnd = (HWND) nativeWindow->getNativeHandle();
|
||||
|
||||
Win32ComponentPeer* const peer = dynamic_cast <Win32ComponentPeer*> (component->getTopLevelComponent()->getPeer());
|
||||
|
||||
if (peer != 0)
|
||||
{
|
||||
SetParent (hwnd, (HWND) peer->getNativeHandle());
|
||||
juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_CHILD, true);
|
||||
juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_POPUP, false);
|
||||
}
|
||||
|
||||
dc = GetDC (hwnd);
|
||||
}
|
||||
|
||||
bool fillInPixelFormatDetails (const int pixelFormatIndex,
|
||||
OpenGLPixelFormat& result,
|
||||
const StringArray& availableExtensions) const throw()
|
||||
|
|
@ -3477,9 +3501,10 @@ OpenGLContext* OpenGLContext::createContextForWindow (Component* const component
|
|||
const OpenGLContext* const contextToShareWith)
|
||||
{
|
||||
WindowedGLContext* c = new WindowedGLContext (component,
|
||||
contextToShareWith != 0 ? (HGLRC) contextToShareWith->getRawContext() : 0);
|
||||
contextToShareWith != 0 ? (HGLRC) contextToShareWith->getRawContext() : 0,
|
||||
pixelFormat);
|
||||
|
||||
if (c->renderContext == 0 || ! c->setPixelFormat (pixelFormat))
|
||||
if (c->renderContext == 0)
|
||||
deleteAndZero (c);
|
||||
|
||||
return c;
|
||||
|
|
@ -3490,12 +3515,13 @@ void juce_glViewport (const int w, const int h)
|
|||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (OwnedArray <OpenGLPixelFormat>& results)
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* component,
|
||||
OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
Component tempComp;
|
||||
|
||||
{
|
||||
WindowedGLContext wc (&tempComp, 0);
|
||||
WindowedGLContext wc (component, 0, OpenGLPixelFormat (8, 8, 16, 0));
|
||||
wc.makeActive();
|
||||
wc.findAlternativeOpenGLPixelFormats (results);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
// Just for demo purposes, let's dump a list of all the available pixel formats..
|
||||
OwnedArray <OpenGLPixelFormat> availablePixelFormats;
|
||||
OpenGLPixelFormat::getAvailablePixelFormats (availablePixelFormats);
|
||||
OpenGLPixelFormat::getAvailablePixelFormats (this, availablePixelFormats);
|
||||
|
||||
for (int i = 0; i < availablePixelFormats.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
// Just for demo purposes, let's dump a list of all the available pixel formats..
|
||||
OwnedArray <OpenGLPixelFormat> availablePixelFormats;
|
||||
OpenGLPixelFormat::getAvailablePixelFormats (availablePixelFormats);
|
||||
OpenGLPixelFormat::getAvailablePixelFormats (this, availablePixelFormats);
|
||||
|
||||
for (int i = 0; i < availablePixelFormats.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -77,8 +77,12 @@ struct OpenGLPixelFormat
|
|||
|
||||
//==============================================================================
|
||||
/** Returns a list of all the pixel formats that can be used in this system.
|
||||
|
||||
A reference component is needed in case there are multiple screens with different
|
||||
capabilities - in which case, the one that the component is on will be used.
|
||||
*/
|
||||
static void getAvailablePixelFormats (OwnedArray <OpenGLPixelFormat>& results);
|
||||
static void getAvailablePixelFormats (Component* component,
|
||||
OwnedArray <OpenGLPixelFormat>& results);
|
||||
|
||||
//==============================================================================
|
||||
bool operator== (const OpenGLPixelFormat&) const throw();
|
||||
|
|
@ -101,9 +105,9 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Makes this context the currently active one. */
|
||||
virtual bool makeActive() throw() = 0;
|
||||
virtual bool makeActive() const throw() = 0;
|
||||
/** If this context is currently active, it is disactivated. */
|
||||
virtual bool makeInactive() throw() = 0;
|
||||
virtual bool makeInactive() const throw() = 0;
|
||||
/** Returns true if this context is currently active. */
|
||||
virtual bool isActive() const throw() = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue