added Renderer::readPixels as a synchronization method.

This commit is contained in:
rachytski 2012-02-14 17:07:20 +04:00 committed by Alex Zolotarev
parent 0d6de239e5
commit 73c0130a44
2 changed files with 37 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#include "../base/SRC_FIRST.hpp"
#include "renderer.hpp"
#include "data_formats.hpp"
#include "utils.hpp"
#include "framebuffer.hpp"
#include "renderbuffer.hpp"
@ -177,6 +178,30 @@ namespace yg
OGLCHECK(glFinish());
}
Renderer::ReadPixels::ReadPixels(m2::RectU const & r, void * data)
: m_rect(r), m_data(data)
{}
void Renderer::ReadPixels::perform()
{
if (isDebugging())
LOG(LINFO, ("performing ReadPixels command"));
OGLCHECK(glReadPixels(m_rect.minX(),
m_rect.minY(),
m_rect.SizeX(),
m_rect.SizeY(),
RT_TRAITS::gl_pixel_format_type,
RT_TRAITS::gl_pixel_data_type,
m_data
));
}
void Renderer::readPixels(m2::RectU const & r, void * data, bool doForce)
{
processCommand(make_shared_ptr(new ReadPixels(r, data)), Packet::ECommand, doForce);
}
void Renderer::finish()
{
shared_ptr<Command> command(new FinishCommand());

View file

@ -6,6 +6,7 @@
#include "../base/threaded_list.hpp"
#include "../std/function.hpp"
#include "../std/shared_ptr.hpp"
#include "../geometry/rect2d.hpp"
namespace yg
{
@ -37,6 +38,16 @@ namespace yg
void perform();
};
struct ReadPixels : Command
{
m2::RectU m_rect;
void * m_data;
ReadPixels(m2::RectU const & r, void * data);
void perform();
};
struct ChangeFrameBuffer : Command
{
shared_ptr<FrameBuffer> m_frameBuffer;
@ -128,6 +139,7 @@ namespace yg
unsigned int height() const;
void finish();
void readPixels(m2::RectU const & r, void * data, bool doForce = false);
bool isDebugging() const;