Kaydet (Commit) 396fa3b6 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

reimplement custom sprite rendering with FBO

Change-Id: I8d7a54fac61a3072d4f34615e71e37c70dec4e50
üst d4b80b6c
......@@ -10,20 +10,25 @@
#ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_BUFFERCONTEXT_HXX
#define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_BUFFERCONTEXT_HXX
#include <GL/glew.h>
#include <sal/config.h>
#include <boost/shared_ptr.hpp>
namespace oglcanvas
{
struct IBufferContext
{
virtual ~IBufferContext() {}
/// start render to buffer. changes gl current context
/// start render to buffer. changes current framebuffer
virtual bool startBufferRendering() = 0;
/// end render to buffer. switches to window context, and selects rendered texture
/// end render to buffer. switches to default framebuffer
virtual bool endBufferRendering() = 0;
virtual GLuint getTextureId() = 0;
};
typedef ::boost::shared_ptr<IBufferContext> IBufferContextSharedPtr;
......
......@@ -159,9 +159,8 @@ namespace oglcanvas
// composite that to screen
// TODO(P3): buffer texture
// TODO: moggi: reimplement as FBO with rendering to texture
pBufferContext = NULL;
// pBufferContext->startBufferRendering();
pBufferContext = maCanvasHelper.getDeviceHelper()->createBufferContext(aSpriteSizePixel);
pBufferContext->startBufferRendering();
}
// this ends up in pBufferContext, if that one's "current"
......@@ -174,6 +173,8 @@ namespace oglcanvas
// screen now. Calls below switches us back to window
// context, and binds to generated, dynamic texture
pBufferContext->endBufferRendering();
GLuint nTexture = pBufferContext->getTextureId();
glBindTexture(GL_TEXTURE_2D, nTexture);
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D,
......
......@@ -537,21 +537,29 @@ namespace oglcanvas
namespace
{
/*
* TODO: mogg: reimplement through FBO with texture as backend
class BufferContextImpl : public IBufferContext
{
::basegfx::B2IVector maSize;
const SpriteDeviceHelper& mrDeviceHelper;
GLuint mnFrambufferId;
GLuint mnDepthId;
GLuint mnTextureId;
virtual bool startBufferRendering() SAL_OVERRIDE
{
return false;
glBindFramebuffer(GL_FRAMEBUFFER, mnFrambufferId);
return true;
}
virtual bool endBufferRendering() SAL_OVERRIDE
{
return false;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
return true;
}
virtual GLuint getTextureId() SAL_OVERRIDE
{
return mnTextureId;
}
public:
......@@ -559,20 +567,26 @@ namespace oglcanvas
const ::basegfx::B2IVector& rSize) :
maSize(rSize),
mrDeviceHelper(rDeviceHelper),
mnTexture(0)
mnFrambufferId(0),
mnDepthId(0),
mnTextureId(0)
{
OpenGLHelper::createFramebuffer(maSize.getX(), maSize.getY(), mnFrambufferId,
mnDepthId, mnTextureId, false);
}
virtual ~BufferContextImpl()
{
glDeleteTextures(1, &mnTextureId);
glDeleteRenderbuffers(1, &mnDepthId);
glDeleteFramebuffers(1, &mnFrambufferId);
}
};
*/
}
IBufferContextSharedPtr SpriteDeviceHelper::createBufferContext(const ::basegfx::B2IVector& ) const
IBufferContextSharedPtr SpriteDeviceHelper::createBufferContext(const ::basegfx::B2IVector& rSize) const
{
return NULL;
return IBufferContextSharedPtr(new BufferContextImpl(*this, rSize));
}
TextureCache& SpriteDeviceHelper::getTextureCache() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment