forked from organicmaps/organicmaps
[iOS] Source code formatting.
This commit is contained in:
parent
aeec75b70e
commit
5e4b0bbd6e
2 changed files with 106 additions and 93 deletions
|
@ -6,33 +6,34 @@
|
|||
|
||||
@class CAEAGLLayer;
|
||||
|
||||
namespace iphone
|
||||
namespace iphone
|
||||
{
|
||||
class RenderBuffer : public graphics::RenderTarget
|
||||
{
|
||||
private:
|
||||
|
||||
unsigned int m_id;
|
||||
shared_ptr<RenderContext> m_renderContext;
|
||||
int m_width;
|
||||
int m_height;
|
||||
class RenderBuffer : public graphics::RenderTarget
|
||||
{
|
||||
private:
|
||||
unsigned int m_id;
|
||||
shared_ptr<RenderContext> m_renderContext;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
public:
|
||||
public:
|
||||
RenderBuffer(shared_ptr<RenderContext> renderContext, CAEAGLLayer * layer);
|
||||
RenderBuffer(shared_ptr<RenderContext> renderContext, int width, int height);
|
||||
~RenderBuffer();
|
||||
|
||||
RenderBuffer(shared_ptr<RenderContext> renderContext, CAEAGLLayer * layer);
|
||||
~RenderBuffer();
|
||||
void makeCurrent();
|
||||
|
||||
void makeCurrent();
|
||||
unsigned int id() const;
|
||||
|
||||
unsigned int id() const;
|
||||
void present();
|
||||
|
||||
void present();
|
||||
unsigned width() const;
|
||||
unsigned height() const;
|
||||
|
||||
unsigned width() const;
|
||||
unsigned height() const;
|
||||
void attachToFrameBuffer();
|
||||
void detachFromFrameBuffer();
|
||||
void coordMatrix(math::Matrix<float, 4, 4> & m);
|
||||
};
|
||||
|
||||
void attachToFrameBuffer();
|
||||
void detachFromFrameBuffer();
|
||||
void coordMatrix(math::Matrix<float, 4, 4> & m);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,81 +7,93 @@
|
|||
|
||||
namespace iphone
|
||||
{
|
||||
RenderBuffer::RenderBuffer(shared_ptr<RenderContext> renderContext, CAEAGLLayer * layer)
|
||||
|
||||
RenderBuffer::RenderBuffer(shared_ptr<RenderContext> renderContext, CAEAGLLayer * layer)
|
||||
: m_renderContext(renderContext)
|
||||
{
|
||||
OGLCHECK(glGenRenderbuffersOES(1, &m_id));
|
||||
makeCurrent();
|
||||
{
|
||||
OGLCHECK(glGenRenderbuffersOES(1, &m_id));
|
||||
makeCurrent();
|
||||
|
||||
BOOL res = [m_renderContext->getEAGLContext() renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer];
|
||||
BOOL res = [m_renderContext->getEAGLContext() renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer];
|
||||
|
||||
if (res == NO)
|
||||
LOG(LINFO, ("renderbufferStorage:fromDrawable has failed!"));
|
||||
if (res == NO)
|
||||
LOG(LINFO, ("renderbufferStorage:fromDrawable has failed!"));
|
||||
|
||||
OGLCHECK(glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &m_width));
|
||||
OGLCHECK(glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &m_height));
|
||||
}
|
||||
|
||||
void RenderBuffer::makeCurrent()
|
||||
{
|
||||
OGLCHECK(glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_id));
|
||||
}
|
||||
|
||||
RenderBuffer::~RenderBuffer()
|
||||
{
|
||||
OGLCHECK(glDeleteRenderbuffersOES(1, &m_id));
|
||||
}
|
||||
|
||||
unsigned int RenderBuffer::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void RenderBuffer::present()
|
||||
{
|
||||
makeCurrent();
|
||||
|
||||
const int maxTryCount = 100;
|
||||
int tryCount = 0;
|
||||
|
||||
while (!([m_renderContext->getEAGLContext() presentRenderbuffer:GL_RENDERBUFFER_OES])
|
||||
&& (tryCount++ < maxTryCount));
|
||||
|
||||
if (tryCount == maxTryCount + 1)
|
||||
NSLog(@"failed to present renderbuffer");
|
||||
else
|
||||
if (tryCount != 0)
|
||||
NSLog(@"renderBuffer was presented from %d try", tryCount);
|
||||
}
|
||||
|
||||
unsigned RenderBuffer::width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
unsigned RenderBuffer::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void RenderBuffer::attachToFrameBuffer()
|
||||
{
|
||||
OGLCHECK(glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
|
||||
GL_COLOR_ATTACHMENT0_OES,
|
||||
GL_RENDERBUFFER_OES,
|
||||
m_id));
|
||||
}
|
||||
|
||||
void RenderBuffer::detachFromFrameBuffer()
|
||||
{
|
||||
OGLCHECK(glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
|
||||
GL_COLOR_ATTACHMENT0_OES,
|
||||
GL_RENDERBUFFER_OES,
|
||||
0));
|
||||
}
|
||||
|
||||
void RenderBuffer::coordMatrix(math::Matrix<float, 4, 4> & m)
|
||||
{
|
||||
graphics::getOrthoMatrix(m, 0, width(), height(), 0, -graphics::maxDepth, graphics::maxDepth);
|
||||
}
|
||||
OGLCHECK(glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &m_width));
|
||||
OGLCHECK(glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &m_height));
|
||||
}
|
||||
|
||||
RenderBuffer::RenderBuffer(shared_ptr<RenderContext> renderContext, int width, int height)
|
||||
: m_renderContext(renderContext)
|
||||
{
|
||||
OGLCHECK(glGenRenderbuffersOES(1, &m_id));
|
||||
makeCurrent();
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
OGLCHECK(glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, m_width, m_height));
|
||||
}
|
||||
|
||||
void RenderBuffer::makeCurrent()
|
||||
{
|
||||
OGLCHECK(glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_id));
|
||||
}
|
||||
|
||||
RenderBuffer::~RenderBuffer()
|
||||
{
|
||||
OGLCHECK(glDeleteRenderbuffersOES(1, &m_id));
|
||||
}
|
||||
|
||||
unsigned int RenderBuffer::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void RenderBuffer::present()
|
||||
{
|
||||
makeCurrent();
|
||||
|
||||
const int maxTryCount = 100;
|
||||
int tryCount = 0;
|
||||
|
||||
while (!([m_renderContext->getEAGLContext() presentRenderbuffer:GL_RENDERBUFFER_OES])
|
||||
&& (tryCount++ < maxTryCount));
|
||||
|
||||
if (tryCount == maxTryCount + 1)
|
||||
NSLog(@"failed to present renderbuffer");
|
||||
else if (tryCount != 0)
|
||||
NSLog(@"renderBuffer was presented from %d try", tryCount);
|
||||
}
|
||||
|
||||
unsigned RenderBuffer::width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
unsigned RenderBuffer::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void RenderBuffer::attachToFrameBuffer()
|
||||
{
|
||||
OGLCHECK(glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
|
||||
GL_COLOR_ATTACHMENT0_OES,
|
||||
GL_RENDERBUFFER_OES,
|
||||
m_id));
|
||||
}
|
||||
|
||||
void RenderBuffer::detachFromFrameBuffer()
|
||||
{
|
||||
OGLCHECK(glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
|
||||
GL_COLOR_ATTACHMENT0_OES,
|
||||
GL_RENDERBUFFER_OES,
|
||||
0));
|
||||
}
|
||||
|
||||
void RenderBuffer::coordMatrix(math::Matrix<float, 4, 4> & m)
|
||||
{
|
||||
graphics::getOrthoMatrix(m, 0, width(), height(), 0, -graphics::maxDepth, graphics::maxDepth);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue