ok, here’s a uDiff. This is the clearest i can make it unfortunately. I can generate HTML differences that look nice but i cant post them 
Jules, the ios.h file is not too bad, you can just take the changes, but the horrible hack i have in OpenGLContext needs attention. basically i just hack in an extra flag for IOS. MSAA/FSAA selection should be made at a more general level, but i wanted to minimise Juce changes here.
the upside, its that MSAA is really worth it on the ipad mini. on the retina pads, it’s better to have a higher frame rate, since you’ve already got 320 dpi.
– hugh
[code]Left base folder: w:\sw\juce
Right base folder: c:\sw\juce
— modules\juce_opengl\opengl\juce_OpenGLContext.h 2013-07-19 11:55:19.000000000 +0100
+++ modules\juce_opengl\opengl\juce_OpenGLContext.h 2013-07-19 12:31:35.000000000 +0100
@@ -125,12 +125,18 @@
/
static OpenGLContext getCurrentContext();
/** Asynchronously causes a repaint to be made. */
void triggerRepaint();
- // if implemented, call before attach
- void enableMSAA()
- {
-
msaa = true;
- }
- //==============================================================================
/** If this context is backed by a frame buffer, this returns its ID number,
or 0 if the context does not use a framebuffer.
*/
unsigned int getFrameBufferID() const noexcept;
@@ -240,14 +246,15 @@
NativeContext* nativeContext;
OpenGLRenderer* renderer;
ScopedPointer attachment;
OpenGLPixelFormat pixelFormat;
void* contextToShareWith;
bool renderComponents;
#endif // JUCE_OPENGLCONTEXT_H_INCLUDED
— modules\juce_opengl\opengl\juce_OpenGLContext.cpp 2013-07-19 11:55:19.000000000 +0100
+++ modules\juce_opengl\opengl\juce_OpenGLContext.cpp 2013-07-19 12:31:16.000000000 +0100
@@ -24,25 +24,33 @@
class OpenGLContext::CachedImage : public CachedComponentImage,
public Thread
{
public:
CachedImage (OpenGLContext& c, Component& comp,
-
const OpenGLPixelFormat& pixFormat,
-
void* contextToShare,
-
bool msaa)
: Thread ("OpenGL Rendering"),
context (c), component (comp),
scale (1.0),
#if JUCE_OPENGL_ES
shadersAvailable (true),
#else
shadersAvailable (false),
#endif
hasInitialised (false),
needsUpdate (1)
{
-
-
// XXX HACK, need common constructor
+#ifdef JUCE_IOS
+#else
nativeContext = new NativeContext (component, pixFormat, contextToShare);
+#endif
if (nativeContext->createdOk())
context.nativeContext = nativeContext;
else
nativeContext = nullptr;
}
@@ -493,13 +507,13 @@
void attach()
{
Component& comp = *getComponent();
CachedImage* const newCachedImage = new CachedImage (context, comp,
context.pixelFormat,
-
context.contextToShareWith, context.msaa);
comp.setCachedComponentImage (newCachedImage);
newCachedImage->start(); // (must wait until this is attached before starting its thread)
newCachedImage->updateViewportSize (true);
}
void detach()
@@ -520,12 +534,13 @@
//==============================================================================
OpenGLContext::OpenGLContext()
: nativeContext (nullptr), renderer (nullptr), contextToShareWith (nullptr),
renderComponents (true)
{
OpenGLContext::~OpenGLContext()
{
detach();
}
[/code]
[code]Left base folder: w:\sw\juce
Right base folder: c:\sw\juce
— modules\juce_opengl\native\juce_OpenGL_ios.h 2013-06-27 13:08:11.000000000 +0100
+++ modules\juce_opengl\native\juce_OpenGL_ios.h 2013-07-19 12:30:26.000000000 +0100
@@ -42,17 +42,22 @@
class OpenGLContext::NativeContext
{
public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixelFormat,
-
void* contextToShareWith,
-
bool msaa = false)
: frameBufferHandle (0), colorBufferHandle (0), depthBufferHandle (0),
lastWidth (0), lastHeight (0), needToRebuildBuffers (false),
-
swapFrames (0), useDepthBuffer (pixelFormat.depthBufferBits > 0),
-
useMSAA(msaa)
{
-
msaaColorHandle = 0;
-
msaaBufferHandle = 0;
-
JUCE_AUTORELEASEPOOL
{
ComponentPeer* const peer = component.getPeer();
jassert (peer != nullptr);
const Rectangle<int> bounds (peer->getComponent().getLocalArea (&component, component.getLocalBounds()));
@@ -64,12 +69,13 @@
view.hidden = NO;
view.backgroundColor = [UIColor blackColor];
view.userInteractionEnabled = NO;
glLayer = (CAEAGLLayer*) [view layer];
glLayer.contentsScale = Desktop::getInstance().getDisplays().getMainDisplay().scale;
@@ -111,13 +117,17 @@
bool makeActive() const noexcept
{
if (! [EAGLContext setCurrentContext: context])
return false;
-
if (useMSAA)
-
glBindFramebuffer (GL_FRAMEBUFFER, msaaBufferHandle);
-
else
-
glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle);
-
return true;
}
bool isActive() const noexcept
{
return [EAGLContext currentContext] == context;
@@ -127,12 +137,22 @@
{
[EAGLContext setCurrentContext: nil];
}
void swapBuffers()
{
-
if (useMSAA)
-
{
-
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, frameBufferHandle);
-
glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, msaaBufferHandle);
-
glResolveMultisampleFramebufferAPPLE();
-
-
const GLenum discards[] = {GL_COLOR_ATTACHMENT0,GL_DEPTH_ATTACHMENT};
-
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE,2,discards);
-
}
-
glBindRenderbuffer (GL_RENDERBUFFER, colorBufferHandle);
[context presentRenderbuffer: GL_RENDERBUFFER];
if (needToRebuildBuffers)
{
needToRebuildBuffers = false;
@@ -167,48 +187,71 @@
private:
JuceGLView* view;
CAEAGLLayer* glLayer;
EAGLContext* context;
GLuint frameBufferHandle, colorBufferHandle, depthBufferHandle;
-
GLuint msaaBufferHandle;
-
GLuint msaaColorHandle;
int volatile lastWidth, lastHeight;
bool volatile needToRebuildBuffers;
int swapFrames;
bool useDepthBuffer;
-
bool useMSAA;
//==============================================================================
void createGLBuffers()
{
glGenFramebuffers (1, &frameBufferHandle);
glGenRenderbuffers (1, &colorBufferHandle);
-
glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle);
glBindRenderbuffer (GL_RENDERBUFFER, colorBufferHandle);
-
-
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorBufferHandle);
-
bool ok = [context renderbufferStorage: GL_RENDERBUFFER fromDrawable: glLayer];
jassert (ok); (void) ok;
-
if (useDepthBuffer)
-
{
-
GLint width, height;
-
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
-
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
-
GLint width, height;
-
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width);
-
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height);
-
if (useMSAA)
-
{
-
glGenFramebuffers (1, &msaaBufferHandle);
-
glGenRenderbuffers (1, &msaaColorHandle);
-
-
glBindFramebuffer (GL_FRAMEBUFFER, msaaBufferHandle);
-
glBindRenderbuffer (GL_RENDERBUFFER, msaaColorHandle);
-
-
glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGBA8_OES, width, height);
-
-
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaColorHandle);
-
}
-
-
if (useDepthBuffer)
-
{
glGenRenderbuffers (1, &depthBufferHandle);
glBindRenderbuffer (GL_RENDERBUFFER, depthBufferHandle);
-
-
if (useMSAA)
-
{
-
glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT16, width, height);
-
}
-
else
-
{
-
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
-
}
-
glBindRenderbuffer (GL_RENDERBUFFER, colorBufferHandle);
-
-
glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle);
-
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorBufferHandle);
-
-
if (useDepthBuffer)
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBufferHandle);
-
}
jassert (glCheckFramebufferStatus (GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
JUCE_CHECK_OPENGL_ERROR
-
}
void freeGLBuffers()
{
JUCE_CHECK_OPENGL_ERROR
[context renderbufferStorage: GL_RENDERBUFFER fromDrawable: nil];
@@ -228,17 +271,32 @@
if (depthBufferHandle != 0)
{
glDeleteRenderbuffers (1, &depthBufferHandle);
depthBufferHandle = 0;
}
-
if (msaaBufferHandle)
-
{
-
glDeleteFramebuffers(1, &msaaBufferHandle);
-
msaaBufferHandle = 0;
-
}
-
-
if (msaaColorHandle)
-
{
-
glDeleteRenderbuffers(1, &msaaColorHandle);
-
msaaColorHandle = 0;
-
}
-
JUCE_CHECK_OPENGL_ERROR
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeContext)
};
-
//==============================================================================
bool OpenGLHelpers::isContextActive()
{
return [EAGLContext currentContext] != nil;
}
+
+#undef MSAA
[/code]