diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index d2013183e0..bd6c36ee44 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -304,6 +304,7 @@ OBJECTS := \ $(OBJDIR)/juce_linux_Midi_4bad86cb.o \ $(OBJDIR)/juce_linux_NativeCode_8a61cd0e.o \ $(OBJDIR)/juce_linux_Network_f47a1c4e.o \ + $(OBJDIR)/juce_linux_OpenGLComponent_ba2f042e.o \ $(OBJDIR)/juce_linux_SystemStats_9f6d6b50.o \ $(OBJDIR)/juce_linux_Threads_dc4a4049.o \ $(OBJDIR)/juce_linux_WebBrowserComponent_358c0a49.o \ @@ -1711,6 +1712,11 @@ $(OBJDIR)/juce_linux_Network_f47a1c4e.o: ../../src/native/linux/juce_linux_Netwo @echo "Compiling juce_linux_Network.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" +$(OBJDIR)/juce_linux_OpenGLComponent_ba2f042e.o: ../../src/native/linux/juce_linux_OpenGLComponent.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_linux_OpenGLComponent.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/juce_linux_SystemStats_9f6d6b50.o: ../../src/native/linux/juce_linux_SystemStats.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_linux_SystemStats.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index 45ee4f4c16..bca8d68e5c 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -273,6 +273,7 @@ 07645D91AFD4F8512ECD48ED = { isa = PBXBuildFile; fileRef = 4366712140FBEBEDBCBDCE9B; }; D132232A4A404A7C08D10928 = { isa = PBXBuildFile; fileRef = E0A2C24581917DD090186333; }; 83B488D64AB9828CFFBC55A9 = { isa = PBXBuildFile; fileRef = 3F3D429025A92B6F0FB6F8EF; }; + 8305C5E01476E99FBB1A0315 = { isa = PBXBuildFile; fileRef = 275F2210628D9E9968B1B258; }; FF613B604C2333F4A4ACEDDA = { isa = PBXBuildFile; fileRef = 5DEA687D261C59CBABB782E9; }; CECE3D66B19693E41850C30D = { isa = PBXBuildFile; fileRef = 5593DEC14D551C38CCB50D70; }; DF419EBD05F13A0D2073D47A = { isa = PBXBuildFile; fileRef = B8E47498C7C6D5ECF41F0EAB; }; @@ -972,6 +973,7 @@ E0A2C24581917DD090186333 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_NativeCode.cpp"; path = "../../src/native/linux/juce_linux_NativeCode.cpp"; sourceTree = "SOURCE_ROOT"; }; E61B485B10F8D4A3986953CD = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_linux_NativeIncludes.h"; path = "../../src/native/linux/juce_linux_NativeIncludes.h"; sourceTree = "SOURCE_ROOT"; }; 3F3D429025A92B6F0FB6F8EF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_Network.cpp"; path = "../../src/native/linux/juce_linux_Network.cpp"; sourceTree = "SOURCE_ROOT"; }; + 275F2210628D9E9968B1B258 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../src/native/linux/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 5DEA687D261C59CBABB782E9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_SystemStats.cpp"; path = "../../src/native/linux/juce_linux_SystemStats.cpp"; sourceTree = "SOURCE_ROOT"; }; 5593DEC14D551C38CCB50D70 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_Threads.cpp"; path = "../../src/native/linux/juce_linux_Threads.cpp"; sourceTree = "SOURCE_ROOT"; }; B8E47498C7C6D5ECF41F0EAB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_WebBrowserComponent.cpp"; path = "../../src/native/linux/juce_linux_WebBrowserComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1812,6 +1814,7 @@ E0A2C24581917DD090186333, E61B485B10F8D4A3986953CD, 3F3D429025A92B6F0FB6F8EF, + 275F2210628D9E9968B1B258, 5DEA687D261C59CBABB782E9, 5593DEC14D551C38CCB50D70, B8E47498C7C6D5ECF41F0EAB, @@ -2332,6 +2335,7 @@ 07645D91AFD4F8512ECD48ED, D132232A4A404A7C08D10928, 83B488D64AB9828CFFBC55A9, + 8305C5E01476E99FBB1A0315, FF613B604C2333F4A4ACEDDA, CECE3D66B19693E41850C30D, DF419EBD05F13A0D2073D47A, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index 435a14cb44..a36c3cef00 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -873,6 +873,7 @@ + diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index a3e43a7714..1c2aae5792 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -873,6 +873,7 @@ + diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index e2b7f5a0f8..1c8a608a17 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -875,6 +875,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index c059ce5395..a119988e57 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -387,6 +387,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index 9f53b920f3..5fc890c022 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -1018,6 +1018,9 @@ Juce\Source\native\linux + + Juce\Source\native\linux + Juce\Source\native\linux diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index 2963342a75..9124e3dd91 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -273,6 +273,7 @@ 07645D91AFD4F8512ECD48ED = { isa = PBXBuildFile; fileRef = 4366712140FBEBEDBCBDCE9B; }; D132232A4A404A7C08D10928 = { isa = PBXBuildFile; fileRef = E0A2C24581917DD090186333; }; 83B488D64AB9828CFFBC55A9 = { isa = PBXBuildFile; fileRef = 3F3D429025A92B6F0FB6F8EF; }; + 8305C5E01476E99FBB1A0315 = { isa = PBXBuildFile; fileRef = 275F2210628D9E9968B1B258; }; FF613B604C2333F4A4ACEDDA = { isa = PBXBuildFile; fileRef = 5DEA687D261C59CBABB782E9; }; CECE3D66B19693E41850C30D = { isa = PBXBuildFile; fileRef = 5593DEC14D551C38CCB50D70; }; DF419EBD05F13A0D2073D47A = { isa = PBXBuildFile; fileRef = B8E47498C7C6D5ECF41F0EAB; }; @@ -972,6 +973,7 @@ E0A2C24581917DD090186333 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_NativeCode.cpp"; path = "../../src/native/linux/juce_linux_NativeCode.cpp"; sourceTree = "SOURCE_ROOT"; }; E61B485B10F8D4A3986953CD = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_linux_NativeIncludes.h"; path = "../../src/native/linux/juce_linux_NativeIncludes.h"; sourceTree = "SOURCE_ROOT"; }; 3F3D429025A92B6F0FB6F8EF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_Network.cpp"; path = "../../src/native/linux/juce_linux_Network.cpp"; sourceTree = "SOURCE_ROOT"; }; + 275F2210628D9E9968B1B258 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../src/native/linux/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; 5DEA687D261C59CBABB782E9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_SystemStats.cpp"; path = "../../src/native/linux/juce_linux_SystemStats.cpp"; sourceTree = "SOURCE_ROOT"; }; 5593DEC14D551C38CCB50D70 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_Threads.cpp"; path = "../../src/native/linux/juce_linux_Threads.cpp"; sourceTree = "SOURCE_ROOT"; }; B8E47498C7C6D5ECF41F0EAB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_WebBrowserComponent.cpp"; path = "../../src/native/linux/juce_linux_WebBrowserComponent.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1812,6 +1814,7 @@ E0A2C24581917DD090186333, E61B485B10F8D4A3986953CD, 3F3D429025A92B6F0FB6F8EF, + 275F2210628D9E9968B1B258, 5DEA687D261C59CBABB782E9, 5593DEC14D551C38CCB50D70, B8E47498C7C6D5ECF41F0EAB, @@ -2336,6 +2339,7 @@ 07645D91AFD4F8512ECD48ED, D132232A4A404A7C08D10928, 83B488D64AB9828CFFBC55A9, + 8305C5E01476E99FBB1A0315, FF613B604C2333F4A4ACEDDA, CECE3D66B19693E41850C30D, DF419EBD05F13A0D2073D47A, diff --git a/Juce.jucer b/Juce.jucer index 3510a50fa4..a27b39a836 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -1328,6 +1328,8 @@ resource="0" file="src/native/linux/juce_linux_NativeIncludes.h"/> + #include @@ -194969,15 +194976,15 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_JPEGLoader.cpp ***/ #if JUCE_MSVC - #pragma warning (push) + #pragma warning (push) #endif namespace jpeglibNamespace { -#if JUCE_INCLUDE_JPEGLIB_CODE - #if JUCE_MINGW +#if JUCE_INCLUDE_JPEGLIB_CODE || ! defined (JUCE_INCLUDE_JPEGLIB_CODE) + #if JUCE_MINGW typedef unsigned char boolean; - #endif + #endif #define JPEG_INTERNALS #undef FAR @@ -218413,7 +218420,7 @@ jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, #undef min #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif BEGIN_JUCE_NAMESPACE @@ -218422,17 +218429,13 @@ namespace JPEGHelpers { using namespace jpeglibNamespace; - #if ! JUCE_MSVC - using jpeglibNamespace::boolean; - #endif + #if ! JUCE_MSVC + using jpeglibNamespace::boolean; + #endif struct JPEGDecodingFailure {}; - void fatalErrorHandler (j_common_ptr) - { - throw JPEGDecodingFailure(); - } - + void fatalErrorHandler (j_common_ptr) { throw JPEGDecodingFailure(); } void silentErrorCallback1 (j_common_ptr) {} void silentErrorCallback2 (j_common_ptr, int) {} void silentErrorCallback3 (j_common_ptr, char*) {} @@ -218441,16 +218444,14 @@ namespace JPEGHelpers { zerostruct (err); - err.error_exit = fatalErrorHandler; - err.emit_message = silentErrorCallback2; - err.output_message = silentErrorCallback1; - err.format_message = silentErrorCallback3; + err.error_exit = fatalErrorHandler; + err.emit_message = silentErrorCallback2; + err.output_message = silentErrorCallback1; + err.format_message = silentErrorCallback3; err.reset_error_mgr = silentErrorCallback1; } - void dummyCallback1 (j_decompress_ptr) - { - } + void dummyCallback1 (j_decompress_ptr) {} void jpegSkip (j_decompress_ptr decompStruct, long num) { @@ -218473,9 +218474,7 @@ namespace JPEGHelpers char* buffer; }; - void jpegWriteInit (j_compress_ptr) - { - } + void jpegWriteInit (j_compress_ptr) {} void jpegWriteTerminate (j_compress_ptr cinfo) { @@ -218503,7 +218502,7 @@ JPEGImageFormat::JPEGImageFormat() { } -JPEGImageFormat::~JPEGImageFormat() {} +JPEGImageFormat::~JPEGImageFormat() {} void JPEGImageFormat::setQuality (const float newQuality) { @@ -218679,7 +218678,6 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) jpegCompStruct.dct_method = JDCT_FLOAT; jpegCompStruct.optimize_coding = 1; - //jpegCompStruct.smoothing_factor = 10; if (quality < 0.0f) quality = 0.85f; @@ -218750,7 +218748,7 @@ namespace pnglibNamespace { using namespace zlibNamespace; -#if JUCE_INCLUDE_PNGLIB_CODE +#if JUCE_INCLUDE_PNGLIB_CODE || ! defined (JUCE_INCLUDE_PNGLIB_CODE) #if _MSC_VER != 1310 using ::calloc; // (causes conflict in VS.NET 2003) @@ -268242,207 +268240,6 @@ Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, i return createSoftwareImage (format, width, height, clearImage); } -#if JUCE_OPENGL - -class WindowedGLContext : public OpenGLContext -{ -public: - WindowedGLContext (Component* const component, - const OpenGLPixelFormat& pixelFormat_, - GLXContext sharedContext) - : renderContext (0), - embeddedWindow (0), - pixelFormat (pixelFormat_), - swapInterval (0) - { - jassert (component != nullptr); - LinuxComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); - if (peer == nullptr) - return; - - ScopedXLock xlock; - XSync (display, False); - - GLint attribs [64]; - int n = 0; - attribs[n++] = GLX_RGBA; - attribs[n++] = GLX_DOUBLEBUFFER; - attribs[n++] = GLX_RED_SIZE; - attribs[n++] = pixelFormat.redBits; - attribs[n++] = GLX_GREEN_SIZE; - attribs[n++] = pixelFormat.greenBits; - attribs[n++] = GLX_BLUE_SIZE; - attribs[n++] = pixelFormat.blueBits; - attribs[n++] = GLX_ALPHA_SIZE; - attribs[n++] = pixelFormat.alphaBits; - attribs[n++] = GLX_DEPTH_SIZE; - attribs[n++] = pixelFormat.depthBufferBits; - attribs[n++] = GLX_STENCIL_SIZE; - attribs[n++] = pixelFormat.stencilBufferBits; - attribs[n++] = GLX_ACCUM_RED_SIZE; - attribs[n++] = pixelFormat.accumulationBufferRedBits; - attribs[n++] = GLX_ACCUM_GREEN_SIZE; - attribs[n++] = pixelFormat.accumulationBufferGreenBits; - attribs[n++] = GLX_ACCUM_BLUE_SIZE; - attribs[n++] = pixelFormat.accumulationBufferBlueBits; - attribs[n++] = GLX_ACCUM_ALPHA_SIZE; - attribs[n++] = pixelFormat.accumulationBufferAlphaBits; - - // xxx not sure how to do fullSceneAntiAliasingNumSamples on linux.. - - attribs[n++] = None; - - XVisualInfo* const bestVisual = glXChooseVisual (display, DefaultScreen (display), attribs); - - if (bestVisual == 0) - return; - - renderContext = glXCreateContext (display, bestVisual, sharedContext, GL_TRUE); - - Window windowH = (Window) peer->getNativeHandle(); - - Colormap colourMap = XCreateColormap (display, windowH, bestVisual->visual, AllocNone); - XSetWindowAttributes swa; - swa.colormap = colourMap; - swa.border_pixel = 0; - swa.event_mask = ExposureMask | StructureNotifyMask; - - embeddedWindow = XCreateWindow (display, windowH, - 0, 0, 1, 1, 0, - bestVisual->depth, - InputOutput, - bestVisual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &swa); - - XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); - - XMapWindow (display, embeddedWindow); - XFreeColormap (display, colourMap); - - XFree (bestVisual); - XSync (display, False); - } - - ~WindowedGLContext() - { - ScopedXLock xlock; - deleteContext(); - - XUnmapWindow (display, embeddedWindow); - XDestroyWindow (display, embeddedWindow); - } - - void deleteContext() - { - makeInactive(); - - if (renderContext != 0) - { - ScopedXLock xlock; - glXDestroyContext (display, renderContext); - renderContext = nullptr; - } - } - - bool makeActive() const noexcept - { - jassert (renderContext != 0); - - ScopedXLock xlock; - return glXMakeCurrent (display, embeddedWindow, renderContext) - && XSync (display, False); - } - - bool makeInactive() const noexcept - { - ScopedXLock xlock; - return (! isActive()) || glXMakeCurrent (display, None, 0); - } - - bool isActive() const noexcept - { - ScopedXLock xlock; - return glXGetCurrentContext() == renderContext; - } - - const OpenGLPixelFormat getPixelFormat() const - { - return pixelFormat; - } - - void* getRawContext() const noexcept - { - return renderContext; - } - - void updateWindowPosition (const Rectangle& bounds) - { - ScopedXLock xlock; - XMoveResizeWindow (display, embeddedWindow, - bounds.getX(), bounds.getY(), jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight())); - } - - void swapBuffers() - { - ScopedXLock xlock; - glXSwapBuffers (display, embeddedWindow); - } - - bool setSwapInterval (const int numFramesPerSwap) - { - static PFNGLXSWAPINTERVALSGIPROC GLXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress ((const GLubyte*) "glXSwapIntervalSGI"); - - if (GLXSwapIntervalSGI != 0) - { - swapInterval = numFramesPerSwap; - GLXSwapIntervalSGI (numFramesPerSwap); - return true; - } - - return false; - } - - int getSwapInterval() const - { - return swapInterval; - } - - void repaint() - { - } - - GLXContext renderContext; - -private: - Window embeddedWindow; - OpenGLPixelFormat pixelFormat; - int swapInterval; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowedGLContext); -}; - -OpenGLContext* OpenGLComponent::createContext() -{ - ScopedPointer c (new WindowedGLContext (this, preferredPixelFormat, - contextToShareListsWith != 0 ? (GLXContext) contextToShareListsWith->getRawContext() : 0)); - - return (c->renderContext != 0) ? c.release() : nullptr; -} - -void juce_glViewport (const int w, const int h) -{ - glViewport (0, 0, w, h); -} - -void OpenGLPixelFormat::getAvailablePixelFormats (Component* component, - OwnedArray & results) -{ - results.add (new OpenGLPixelFormat()); // xxx -} - -#endif - bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMoveFiles) { jassertfalse; // not implemented! @@ -268586,6 +268383,193 @@ const int KeyPress::rewindKey = (0xffeeff03) | Keys::extendedKeyModifier; /*** End of inlined file: juce_linux_Windowing.cpp ***/ +/*** Start of inlined file: juce_linux_OpenGLComponent.cpp ***/ +// (This file gets included by juce_linux_NativeCode.cpp, rather than being +// compiled on its own). +#if JUCE_INCLUDED_FILE && JUCE_OPENGL + +class WindowedGLContext : public OpenGLContext +{ +public: + WindowedGLContext (Component* const component, + const OpenGLPixelFormat& pixelFormat_, + GLXContext sharedContext) + : renderContext (0), + embeddedWindow (0), + pixelFormat (pixelFormat_), + swapInterval (0) + { + jassert (component != nullptr); + LinuxComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); + if (peer == nullptr) + return; + + ScopedXLock xlock; + XSync (display, False); + + GLint attribs[] = + { + GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, pixelFormat.redBits, + GLX_GREEN_SIZE, pixelFormat.greenBits, + GLX_BLUE_SIZE, pixelFormat.blueBits, + GLX_ALPHA_SIZE, pixelFormat.alphaBits, + GLX_DEPTH_SIZE, pixelFormat.depthBufferBits, + GLX_STENCIL_SIZE, pixelFormat.stencilBufferBits, + GLX_ACCUM_RED_SIZE, pixelFormat.accumulationBufferRedBits, + GLX_ACCUM_GREEN_SIZE, pixelFormat.accumulationBufferGreenBits, + GLX_ACCUM_BLUE_SIZE, pixelFormat.accumulationBufferBlueBits, + GLX_ACCUM_ALPHA_SIZE, pixelFormat.accumulationBufferAlphaBits, + None + }; + + XVisualInfo* const bestVisual = glXChooseVisual (display, DefaultScreen (display), attribs); + + if (bestVisual == 0) + return; + + renderContext = glXCreateContext (display, bestVisual, sharedContext, GL_TRUE); + + Window windowH = (Window) peer->getNativeHandle(); + + Colormap colourMap = XCreateColormap (display, windowH, bestVisual->visual, AllocNone); + XSetWindowAttributes swa; + swa.colormap = colourMap; + swa.border_pixel = 0; + swa.event_mask = ExposureMask | StructureNotifyMask; + + embeddedWindow = XCreateWindow (display, windowH, + 0, 0, 1, 1, 0, + bestVisual->depth, + InputOutput, + bestVisual->visual, + CWBorderPixel | CWColormap | CWEventMask, + &swa); + + XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); + + XMapWindow (display, embeddedWindow); + XFreeColormap (display, colourMap); + + XFree (bestVisual); + XSync (display, False); + } + + ~WindowedGLContext() + { + ScopedXLock xlock; + deleteContext(); + + XUnmapWindow (display, embeddedWindow); + XDestroyWindow (display, embeddedWindow); + } + + void deleteContext() + { + makeInactive(); + + if (renderContext != 0) + { + ScopedXLock xlock; + glXDestroyContext (display, renderContext); + renderContext = nullptr; + } + } + + bool makeActive() const noexcept + { + jassert (renderContext != 0); + + ScopedXLock xlock; + return glXMakeCurrent (display, embeddedWindow, renderContext) + && XSync (display, False); + } + + bool makeInactive() const noexcept + { + ScopedXLock xlock; + return (! isActive()) || glXMakeCurrent (display, None, 0); + } + + bool isActive() const noexcept + { + ScopedXLock xlock; + return glXGetCurrentContext() == renderContext; + } + + const OpenGLPixelFormat getPixelFormat() const + { + return pixelFormat; + } + + void* getRawContext() const noexcept + { + return renderContext; + } + + void updateWindowPosition (const Rectangle& bounds) + { + ScopedXLock xlock; + XMoveResizeWindow (display, embeddedWindow, + bounds.getX(), bounds.getY(), jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight())); + } + + void swapBuffers() + { + ScopedXLock xlock; + glXSwapBuffers (display, embeddedWindow); + } + + bool setSwapInterval (const int numFramesPerSwap) + { + static PFNGLXSWAPINTERVALSGIPROC GLXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress ((const GLubyte*) "glXSwapIntervalSGI"); + + if (GLXSwapIntervalSGI != 0) + { + swapInterval = numFramesPerSwap; + GLXSwapIntervalSGI (numFramesPerSwap); + return true; + } + + return false; + } + + int getSwapInterval() const { return swapInterval; } + void repaint() {} + + GLXContext renderContext; + +private: + Window embeddedWindow; + OpenGLPixelFormat pixelFormat; + int swapInterval; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowedGLContext); +}; + +OpenGLContext* OpenGLComponent::createContext() +{ + ScopedPointer c (new WindowedGLContext (this, preferredPixelFormat, + contextToShareListsWith != 0 ? (GLXContext) contextToShareListsWith->getRawContext() : 0)); + + return (c->renderContext != 0) ? c.release() : nullptr; +} + +void juce_glViewport (const int w, const int h) +{ + glViewport (0, 0, w, h); +} + +void OpenGLPixelFormat::getAvailablePixelFormats (Component* component, OwnedArray & results) +{ + results.add (new OpenGLPixelFormat()); // xxx +} + +#endif + +/*** End of inlined file: juce_linux_OpenGLComponent.cpp ***/ + + /*** Start of inlined file: juce_linux_Audio.cpp ***/ // (This file gets included by juce_linux_NativeCode.cpp, rather than being // compiled on its own). diff --git a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp index b9e844c1c3..eebbb45c7b 100644 --- a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp @@ -39,6 +39,11 @@ BEGIN_JUCE_NAMESPACE namespace OggVorbisNamespace { #if JUCE_INCLUDE_OGGVORBIS_CODE || ! defined (JUCE_INCLUDE_OGGVORBIS_CODE) + #if JUCE_MSVC + #pragma warning (push) + #pragma warning (disable : 4995) + #endif + #include "oggvorbis/vorbisenc.h" #include "oggvorbis/codec.h" #include "oggvorbis/vorbisfile.h" @@ -66,6 +71,10 @@ namespace OggVorbisNamespace #include "oggvorbis/libvorbis-1.3.2/lib/vorbisenc.c" #include "oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c" #include "oggvorbis/libvorbis-1.3.2/lib/window.c" + + #if JUCE_MSVC + #pragma warning (pop) + #endif #else #include #include diff --git a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp index 3409069993..691d230014 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp @@ -26,15 +26,15 @@ #include "../../../../core/juce_StandardHeader.h" #if JUCE_MSVC - #pragma warning (push) + #pragma warning (push) #endif namespace jpeglibNamespace { -#if JUCE_INCLUDE_JPEGLIB_CODE - #if JUCE_MINGW +#if JUCE_INCLUDE_JPEGLIB_CODE || ! defined (JUCE_INCLUDE_JPEGLIB_CODE) + #if JUCE_MINGW typedef unsigned char boolean; - #endif + #endif #define JPEG_INTERNALS #undef FAR #include "jpglib/jpeglib.h" @@ -118,7 +118,7 @@ namespace jpeglibNamespace #undef min #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif BEGIN_JUCE_NAMESPACE @@ -133,17 +133,13 @@ namespace JPEGHelpers { using namespace jpeglibNamespace; - #if ! JUCE_MSVC - using jpeglibNamespace::boolean; - #endif + #if ! JUCE_MSVC + using jpeglibNamespace::boolean; + #endif struct JPEGDecodingFailure {}; - void fatalErrorHandler (j_common_ptr) - { - throw JPEGDecodingFailure(); - } - + void fatalErrorHandler (j_common_ptr) { throw JPEGDecodingFailure(); } void silentErrorCallback1 (j_common_ptr) {} void silentErrorCallback2 (j_common_ptr, int) {} void silentErrorCallback3 (j_common_ptr, char*) {} @@ -152,18 +148,15 @@ namespace JPEGHelpers { zerostruct (err); - err.error_exit = fatalErrorHandler; - err.emit_message = silentErrorCallback2; - err.output_message = silentErrorCallback1; - err.format_message = silentErrorCallback3; + err.error_exit = fatalErrorHandler; + err.emit_message = silentErrorCallback2; + err.output_message = silentErrorCallback1; + err.format_message = silentErrorCallback3; err.reset_error_mgr = silentErrorCallback1; } - //============================================================================== - void dummyCallback1 (j_decompress_ptr) - { - } + void dummyCallback1 (j_decompress_ptr) {} void jpegSkip (j_decompress_ptr decompStruct, long num) { @@ -187,9 +180,7 @@ namespace JPEGHelpers char* buffer; }; - void jpegWriteInit (j_compress_ptr) - { - } + void jpegWriteInit (j_compress_ptr) {} void jpegWriteTerminate (j_compress_ptr cinfo) { @@ -218,7 +209,7 @@ JPEGImageFormat::JPEGImageFormat() { } -JPEGImageFormat::~JPEGImageFormat() {} +JPEGImageFormat::~JPEGImageFormat() {} void JPEGImageFormat::setQuality (const float newQuality) { @@ -394,7 +385,6 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) jpegCompStruct.dct_method = JDCT_FLOAT; jpegCompStruct.optimize_coding = 1; - //jpegCompStruct.smoothing_factor = 10; if (quality < 0.0f) quality = 0.85f; diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index 1c269656a2..794e48973f 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -49,7 +49,7 @@ namespace pnglibNamespace { using namespace zlibNamespace; -#if JUCE_INCLUDE_PNGLIB_CODE +#if JUCE_INCLUDE_PNGLIB_CODE || ! defined (JUCE_INCLUDE_PNGLIB_CODE) #if _MSC_VER != 1310 using ::calloc; // (causes conflict in VS.NET 2003) diff --git a/src/native/linux/juce_linux_NativeCode.cpp b/src/native/linux/juce_linux_NativeCode.cpp index cb6503b70b..5ff6fc2309 100644 --- a/src/native/linux/juce_linux_NativeCode.cpp +++ b/src/native/linux/juce_linux_NativeCode.cpp @@ -115,6 +115,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_linux_Messaging.cpp" #include "juce_linux_Fonts.cpp" #include "juce_linux_Windowing.cpp" + #include "juce_linux_OpenGLComponent.cpp" #include "juce_linux_Audio.cpp" #include "juce_linux_JackAudio.cpp" #include "juce_linux_Midi.cpp" diff --git a/src/native/linux/juce_linux_OpenGLComponent.cpp b/src/native/linux/juce_linux_OpenGLComponent.cpp new file mode 100644 index 0000000000..675b73254c --- /dev/null +++ b/src/native/linux/juce_linux_OpenGLComponent.cpp @@ -0,0 +1,212 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +// (This file gets included by juce_linux_NativeCode.cpp, rather than being +// compiled on its own). +#if JUCE_INCLUDED_FILE && JUCE_OPENGL + + +//============================================================================== +class WindowedGLContext : public OpenGLContext +{ +public: + WindowedGLContext (Component* const component, + const OpenGLPixelFormat& pixelFormat_, + GLXContext sharedContext) + : renderContext (0), + embeddedWindow (0), + pixelFormat (pixelFormat_), + swapInterval (0) + { + jassert (component != nullptr); + LinuxComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); + if (peer == nullptr) + return; + + ScopedXLock xlock; + XSync (display, False); + + GLint attribs[] = + { + GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_RED_SIZE, pixelFormat.redBits, + GLX_GREEN_SIZE, pixelFormat.greenBits, + GLX_BLUE_SIZE, pixelFormat.blueBits, + GLX_ALPHA_SIZE, pixelFormat.alphaBits, + GLX_DEPTH_SIZE, pixelFormat.depthBufferBits, + GLX_STENCIL_SIZE, pixelFormat.stencilBufferBits, + GLX_ACCUM_RED_SIZE, pixelFormat.accumulationBufferRedBits, + GLX_ACCUM_GREEN_SIZE, pixelFormat.accumulationBufferGreenBits, + GLX_ACCUM_BLUE_SIZE, pixelFormat.accumulationBufferBlueBits, + GLX_ACCUM_ALPHA_SIZE, pixelFormat.accumulationBufferAlphaBits, + None + }; + + XVisualInfo* const bestVisual = glXChooseVisual (display, DefaultScreen (display), attribs); + + if (bestVisual == 0) + return; + + renderContext = glXCreateContext (display, bestVisual, sharedContext, GL_TRUE); + + Window windowH = (Window) peer->getNativeHandle(); + + Colormap colourMap = XCreateColormap (display, windowH, bestVisual->visual, AllocNone); + XSetWindowAttributes swa; + swa.colormap = colourMap; + swa.border_pixel = 0; + swa.event_mask = ExposureMask | StructureNotifyMask; + + embeddedWindow = XCreateWindow (display, windowH, + 0, 0, 1, 1, 0, + bestVisual->depth, + InputOutput, + bestVisual->visual, + CWBorderPixel | CWColormap | CWEventMask, + &swa); + + XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); + + XMapWindow (display, embeddedWindow); + XFreeColormap (display, colourMap); + + XFree (bestVisual); + XSync (display, False); + } + + ~WindowedGLContext() + { + ScopedXLock xlock; + deleteContext(); + + XUnmapWindow (display, embeddedWindow); + XDestroyWindow (display, embeddedWindow); + } + + void deleteContext() + { + makeInactive(); + + if (renderContext != 0) + { + ScopedXLock xlock; + glXDestroyContext (display, renderContext); + renderContext = nullptr; + } + } + + bool makeActive() const noexcept + { + jassert (renderContext != 0); + + ScopedXLock xlock; + return glXMakeCurrent (display, embeddedWindow, renderContext) + && XSync (display, False); + } + + bool makeInactive() const noexcept + { + ScopedXLock xlock; + return (! isActive()) || glXMakeCurrent (display, None, 0); + } + + bool isActive() const noexcept + { + ScopedXLock xlock; + return glXGetCurrentContext() == renderContext; + } + + const OpenGLPixelFormat getPixelFormat() const + { + return pixelFormat; + } + + void* getRawContext() const noexcept + { + return renderContext; + } + + void updateWindowPosition (const Rectangle& bounds) + { + ScopedXLock xlock; + XMoveResizeWindow (display, embeddedWindow, + bounds.getX(), bounds.getY(), jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight())); + } + + void swapBuffers() + { + ScopedXLock xlock; + glXSwapBuffers (display, embeddedWindow); + } + + bool setSwapInterval (const int numFramesPerSwap) + { + static PFNGLXSWAPINTERVALSGIPROC GLXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress ((const GLubyte*) "glXSwapIntervalSGI"); + + if (GLXSwapIntervalSGI != 0) + { + swapInterval = numFramesPerSwap; + GLXSwapIntervalSGI (numFramesPerSwap); + return true; + } + + return false; + } + + int getSwapInterval() const { return swapInterval; } + void repaint() {} + + //============================================================================== + GLXContext renderContext; + +private: + Window embeddedWindow; + OpenGLPixelFormat pixelFormat; + int swapInterval; + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowedGLContext); +}; + +//============================================================================== +OpenGLContext* OpenGLComponent::createContext() +{ + ScopedPointer c (new WindowedGLContext (this, preferredPixelFormat, + contextToShareListsWith != 0 ? (GLXContext) contextToShareListsWith->getRawContext() : 0)); + + return (c->renderContext != 0) ? c.release() : nullptr; +} + +void juce_glViewport (const int w, const int h) +{ + glViewport (0, 0, w, h); +} + +void OpenGLPixelFormat::getAvailablePixelFormats (Component* component, OwnedArray & results) +{ + results.add (new OpenGLPixelFormat()); // xxx +} + +#endif diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index a7fde24099..a567a3f506 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -3075,215 +3075,6 @@ Image::SharedImage* Image::SharedImage::createNativeImage (PixelFormat format, i return createSoftwareImage (format, width, height, clearImage); } - -//============================================================================== -#if JUCE_OPENGL - - -//============================================================================== -class WindowedGLContext : public OpenGLContext -{ -public: - WindowedGLContext (Component* const component, - const OpenGLPixelFormat& pixelFormat_, - GLXContext sharedContext) - : renderContext (0), - embeddedWindow (0), - pixelFormat (pixelFormat_), - swapInterval (0) - { - jassert (component != nullptr); - LinuxComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); - if (peer == nullptr) - return; - - ScopedXLock xlock; - XSync (display, False); - - GLint attribs [64]; - int n = 0; - attribs[n++] = GLX_RGBA; - attribs[n++] = GLX_DOUBLEBUFFER; - attribs[n++] = GLX_RED_SIZE; - attribs[n++] = pixelFormat.redBits; - attribs[n++] = GLX_GREEN_SIZE; - attribs[n++] = pixelFormat.greenBits; - attribs[n++] = GLX_BLUE_SIZE; - attribs[n++] = pixelFormat.blueBits; - attribs[n++] = GLX_ALPHA_SIZE; - attribs[n++] = pixelFormat.alphaBits; - attribs[n++] = GLX_DEPTH_SIZE; - attribs[n++] = pixelFormat.depthBufferBits; - attribs[n++] = GLX_STENCIL_SIZE; - attribs[n++] = pixelFormat.stencilBufferBits; - attribs[n++] = GLX_ACCUM_RED_SIZE; - attribs[n++] = pixelFormat.accumulationBufferRedBits; - attribs[n++] = GLX_ACCUM_GREEN_SIZE; - attribs[n++] = pixelFormat.accumulationBufferGreenBits; - attribs[n++] = GLX_ACCUM_BLUE_SIZE; - attribs[n++] = pixelFormat.accumulationBufferBlueBits; - attribs[n++] = GLX_ACCUM_ALPHA_SIZE; - attribs[n++] = pixelFormat.accumulationBufferAlphaBits; - - // xxx not sure how to do fullSceneAntiAliasingNumSamples on linux.. - - attribs[n++] = None; - - XVisualInfo* const bestVisual = glXChooseVisual (display, DefaultScreen (display), attribs); - - if (bestVisual == 0) - return; - - renderContext = glXCreateContext (display, bestVisual, sharedContext, GL_TRUE); - - Window windowH = (Window) peer->getNativeHandle(); - - Colormap colourMap = XCreateColormap (display, windowH, bestVisual->visual, AllocNone); - XSetWindowAttributes swa; - swa.colormap = colourMap; - swa.border_pixel = 0; - swa.event_mask = ExposureMask | StructureNotifyMask; - - embeddedWindow = XCreateWindow (display, windowH, - 0, 0, 1, 1, 0, - bestVisual->depth, - InputOutput, - bestVisual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &swa); - - XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); - - XMapWindow (display, embeddedWindow); - XFreeColormap (display, colourMap); - - XFree (bestVisual); - XSync (display, False); - } - - ~WindowedGLContext() - { - ScopedXLock xlock; - deleteContext(); - - XUnmapWindow (display, embeddedWindow); - XDestroyWindow (display, embeddedWindow); - } - - void deleteContext() - { - makeInactive(); - - if (renderContext != 0) - { - ScopedXLock xlock; - glXDestroyContext (display, renderContext); - renderContext = nullptr; - } - } - - bool makeActive() const noexcept - { - jassert (renderContext != 0); - - ScopedXLock xlock; - return glXMakeCurrent (display, embeddedWindow, renderContext) - && XSync (display, False); - } - - bool makeInactive() const noexcept - { - ScopedXLock xlock; - return (! isActive()) || glXMakeCurrent (display, None, 0); - } - - bool isActive() const noexcept - { - ScopedXLock xlock; - return glXGetCurrentContext() == renderContext; - } - - const OpenGLPixelFormat getPixelFormat() const - { - return pixelFormat; - } - - void* getRawContext() const noexcept - { - return renderContext; - } - - void updateWindowPosition (const Rectangle& bounds) - { - ScopedXLock xlock; - XMoveResizeWindow (display, embeddedWindow, - bounds.getX(), bounds.getY(), jmax (1, bounds.getWidth()), jmax (1, bounds.getHeight())); - } - - void swapBuffers() - { - ScopedXLock xlock; - glXSwapBuffers (display, embeddedWindow); - } - - bool setSwapInterval (const int numFramesPerSwap) - { - static PFNGLXSWAPINTERVALSGIPROC GLXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress ((const GLubyte*) "glXSwapIntervalSGI"); - - if (GLXSwapIntervalSGI != 0) - { - swapInterval = numFramesPerSwap; - GLXSwapIntervalSGI (numFramesPerSwap); - return true; - } - - return false; - } - - int getSwapInterval() const - { - return swapInterval; - } - - void repaint() - { - } - - //============================================================================== - GLXContext renderContext; - -private: - Window embeddedWindow; - OpenGLPixelFormat pixelFormat; - int swapInterval; - - //============================================================================== - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowedGLContext); -}; - -//============================================================================== -OpenGLContext* OpenGLComponent::createContext() -{ - ScopedPointer c (new WindowedGLContext (this, preferredPixelFormat, - contextToShareListsWith != 0 ? (GLXContext) contextToShareListsWith->getRawContext() : 0)); - - return (c->renderContext != 0) ? c.release() : nullptr; -} - -void juce_glViewport (const int w, const int h) -{ - glViewport (0, 0, w, h); -} - -void OpenGLPixelFormat::getAvailablePixelFormats (Component* component, - OwnedArray & results) -{ - results.add (new OpenGLPixelFormat()); // xxx -} - -#endif - - //============================================================================== bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMoveFiles) {