2014-07-22 14:31:30 +02:00
|
|
|
#include "graphics/tinygl/zrect.h"
|
2014-07-23 21:40:15 +02:00
|
|
|
#include "graphics/tinygl/zgl.h"
|
2014-07-22 14:31:30 +02:00
|
|
|
|
2014-07-23 14:20:59 +02:00
|
|
|
void tglPresentBuffer() {
|
2014-07-23 21:40:15 +02:00
|
|
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
|
|
|
for(int i = 0; i < c->drawCallsQueue.size(); ++i) {
|
|
|
|
c->drawCallsQueue[i]->execute();
|
|
|
|
delete c->drawCallsQueue[i];
|
|
|
|
}
|
|
|
|
c->drawCallsQueue.clear();
|
|
|
|
|
|
|
|
Graphics::Internal::tglCleanupImages();
|
2014-07-23 14:20:59 +02:00
|
|
|
}
|
2014-07-22 14:31:30 +02:00
|
|
|
|
2014-07-23 14:20:59 +02:00
|
|
|
namespace Graphics {
|
2014-07-22 14:31:30 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
DrawCall::DrawCall(DrawCallType type) : _type(type) {
|
|
|
|
}
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 21:40:15 +02:00
|
|
|
RasterizationDrawCall::RasterizationDrawCall() : DrawCall(DrawCall_Rasterization) {
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
}
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
void RasterizationDrawCall::execute() const {
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
}
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
void RasterizationDrawCall::execute( const Common::Rect &clippingRectangle ) const {
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
}
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 21:40:15 +02:00
|
|
|
BlittingDrawCall::BlittingDrawCall(Graphics::BlitImage *image, const BlitTransform &transform, BlittingMode blittingMode) : DrawCall(DrawCall_Blitting), _transform(transform), _mode(blittingMode), _image(image) {
|
|
|
|
_blitState = loadState();
|
2014-07-23 15:14:35 +02:00
|
|
|
}
|
2014-07-23 14:20:59 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
void BlittingDrawCall::execute() const {
|
2014-07-23 21:40:15 +02:00
|
|
|
BlittingState backupState = loadState();
|
|
|
|
applyState(_blitState);
|
|
|
|
|
|
|
|
switch (_mode)
|
|
|
|
{
|
|
|
|
case Graphics::BlittingDrawCall::BlitMode_Regular:
|
|
|
|
Graphics::Internal::tglBlit(_image, _transform);
|
|
|
|
break;
|
|
|
|
case Graphics::BlittingDrawCall::BlitMode_NoBlend:
|
|
|
|
Graphics::Internal::tglBlitNoBlend(_image, _transform);
|
|
|
|
break;
|
|
|
|
case Graphics::BlittingDrawCall::BlitMode_Fast:
|
|
|
|
Graphics::Internal::tglBlitFast(_image, _transform._destinationRectangle.left, _transform._destinationRectangle.top);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
applyState(backupState);
|
2014-07-23 15:14:35 +02:00
|
|
|
}
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
void BlittingDrawCall::execute(const Common::Rect &clippingRectangle) const {
|
2014-07-22 20:26:42 +02:00
|
|
|
|
2014-07-22 14:31:30 +02:00
|
|
|
}
|
2014-07-23 15:14:35 +02:00
|
|
|
|
2014-07-23 21:40:15 +02:00
|
|
|
BlittingDrawCall::BlittingState BlittingDrawCall::loadState() const {
|
|
|
|
BlittingState state;
|
|
|
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
|
|
|
state.alphaTest = c->fb->isAplhaTestEnabled();
|
|
|
|
c->fb->getBlendingFactors(state.sfactor, state.dfactor);
|
|
|
|
state.enableBlending = c->fb->isBlendingEnabled();
|
|
|
|
state.alphaFunc = c->fb->getAlphaTestFunc();
|
|
|
|
state.alphaRefValue = c->fb->getAlphaTestRefVal();
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlittingDrawCall::applyState(const BlittingState &state) const {
|
|
|
|
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
|
|
|
c->fb->setBlendingFactors(state.sfactor, state.dfactor);
|
|
|
|
c->fb->enableBlending(state.enableBlending);
|
|
|
|
c->fb->enableAlphaTest(state.alphaTest);
|
|
|
|
c->fb->setAlphaTestFunc(state.alphaFunc, state.alphaRefValue);
|
|
|
|
}
|
|
|
|
|
2014-07-23 15:14:35 +02:00
|
|
|
} // end of namespace Graphics
|