- updated

git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@117 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2015-01-05 13:35:46 +00:00
parent 3b38c6a587
commit 6e5aa7a991
156 changed files with 2332 additions and 1370 deletions
@@ -1,7 +1,7 @@
{
"id": "juce_opengl",
"name": "JUCE OpenGL classes",
"version": "3.0.8",
"version": "3.1.1",
"description": "Classes for rendering OpenGL in a JUCE window.",
"website": "http://www.juce.com/juce",
"license": "GPL/Commercial",
@@ -14,6 +14,8 @@
{ "file": "juce_opengl.mm", "target": "xcode" } ],
"browse": [ "opengl/*",
"geometry/*",
"utils/*",
"native/*" ],
"OSXFrameworks": "OpenGL",
@@ -207,5 +207,6 @@ private:
#endif
#include "opengl/juce_OpenGLContext.cpp"
#include "utils/juce_OpenGLAppComponent.cpp"
}
@@ -125,11 +125,12 @@ class OpenGLTexture;
class OpenGLFrameBuffer;
class OpenGLShaderProgram;
#include "geometry/juce_Quaternion.h"
#include "geometry/juce_Matrix3D.h"
#include "geometry/juce_Vector3D.h"
#include "geometry/juce_Draggable3DOrientation.h"
#include "native/juce_MissingGLDefinitions.h"
#include "opengl/juce_OpenGLHelpers.h"
#include "opengl/juce_Quaternion.h"
#include "opengl/juce_Matrix3D.h"
#include "opengl/juce_Draggable3DOrientation.h"
#include "opengl/juce_OpenGLPixelFormat.h"
#include "native/juce_OpenGLExtensions.h"
#include "opengl/juce_OpenGLRenderer.h"
@@ -141,7 +142,7 @@ class OpenGLShaderProgram;
#include "opengl/juce_OpenGLRenderer.h"
#include "opengl/juce_OpenGLShaderProgram.h"
#include "opengl/juce_OpenGLTexture.h"
#include "opengl/juce_Vector3D.h"
#include "utils/juce_OpenGLAppComponent.h"
}
@@ -40,7 +40,6 @@ public:
NSOpenGLPFAOpenGLProfile, version >= openGL3_2 ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy,
#endif
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAMPSafe,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFANoRecovery,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixFormat.redBits + pixFormat.greenBits + pixFormat.blueBits),
@@ -262,7 +262,16 @@ public:
glEnable (GL_TEXTURE_2D);
clearGLError();
#endif
context.extensions.glActiveTexture (GL_TEXTURE0);
#if JUCE_WINDOWS
// some stupidly old drivers are missing this function, so try to at least avoid a crash here,
// but if you hit this assertion you may want to have your own version check before using the
// component rendering stuff on such old drivers.
jassert (context.extensions.glActiveTexture != nullptr);
if (context.extensions.glActiveTexture != nullptr)
#endif
context.extensions.glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, cachedImageFrameBuffer.getTextureID());
const Rectangle<int> cacheBounds (cachedImageFrameBuffer.getWidth(), cachedImageFrameBuffer.getHeight());
@@ -38,18 +38,18 @@ struct TextureInfo
struct CachedImageList : public ReferenceCountedObject,
private ImagePixelData::Listener
{
CachedImageList (size_t totalCacheSizeInPixels = 8 * 1024 * 1024) noexcept
: totalSize (0), maxCacheSize (totalCacheSizeInPixels) {}
CachedImageList (OpenGLContext& c, size_t totalCacheSizeInPixels = 8 * 1024 * 1024) noexcept
: context (c), totalSize (0), maxCacheSize (totalCacheSizeInPixels) {}
static CachedImageList* get (OpenGLContext& context)
static CachedImageList* get (OpenGLContext& c)
{
const char cacheValueID[] = "CachedImages";
CachedImageList* list = static_cast<CachedImageList*> (context.getAssociatedObject (cacheValueID));
CachedImageList* list = static_cast<CachedImageList*> (c.getAssociatedObject (cacheValueID));
if (list == nullptr)
{
list = new CachedImageList();
context.setAssociatedObject (cacheValueID, list);
list = new CachedImageList (c);
c.setAssociatedObject (cacheValueID, list);
}
return list;
@@ -131,28 +131,45 @@ struct CachedImageList : public ReferenceCountedObject,
typedef ReferenceCountedObjectPtr<CachedImageList> Ptr;
private:
OpenGLContext& context;
OwnedArray<CachedImage> images;
size_t totalSize, maxCacheSize;
bool canUseContext() const noexcept
{
return OpenGLContext::getCurrentContext() == &context;
}
void imageDataChanged (ImagePixelData* im) override
{
if (CachedImage* c = findCachedImage (im))
c->texture.release();
if (canUseContext())
c->texture.release();
}
void imageDataBeingDeleted (ImagePixelData* im) override
{
for (int i = images.size(); --i >= 0;)
{
if (images.getUnchecked(i)->pixelData == im)
CachedImage& ci = *images.getUnchecked(i);
if (ci.pixelData == im)
{
totalSize -= images.getUnchecked(i)->imageSize;
images.remove (i);
if (canUseContext())
{
totalSize -= ci.imageSize;
images.remove (i);
}
else
{
ci.pixelData = nullptr;
}
break;
}
}
}
OwnedArray<CachedImage> images;
size_t totalSize, maxCacheSize;
CachedImage* findCachedImage (ImagePixelData* const pixelData) const
{
for (int i = 0; i < images.size(); ++i)
@@ -135,13 +135,17 @@ void OpenGLShaderProgram::use() const noexcept
OpenGLShaderProgram::Uniform::Uniform (const OpenGLShaderProgram& program, const char* const name)
: uniformID (program.context.extensions.glGetUniformLocation (program.getProgramID(), name)), context (program.context)
{
#if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR
jassert (uniformID >= 0);
#endif
}
OpenGLShaderProgram::Attribute::Attribute (const OpenGLShaderProgram& program, const char* name)
: attributeID (program.context.extensions.glGetAttribLocation (program.getProgramID(), name))
{
#if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR
jassert (attributeID >= 0);
#endif
}
void OpenGLShaderProgram::Uniform::set (GLfloat n1) const noexcept { context.extensions.glUniform1f (uniformID, n1); }
@@ -164,14 +164,21 @@ void OpenGLTexture::loadARGBFlipped (const PixelARGB* pixels, int w, int h)
void OpenGLTexture::release()
{
if (textureID != 0
&& ownerContext == OpenGLContext::getCurrentContext())
if (textureID != 0)
{
glDeleteTextures (1, &textureID);
// If the texture is deleted while the owner context is not active, it's
// impossible to delete it, so this will be a leak until the context itself
// is deleted.
jassert (ownerContext == OpenGLContext::getCurrentContext());
textureID = 0;
width = 0;
height = 0;
if (ownerContext == OpenGLContext::getCurrentContext())
{
glDeleteTextures (1, &textureID);
textureID = 0;
width = 0;
height = 0;
}
}
}