TINYGL: Added tglBlitZBuffer as a way to render to the Z buffer.
This commit is contained in:
parent
00ae985fb0
commit
b5720b425f
3 changed files with 40 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "graphics/pixelbuffer.h"
|
||||
#include "common/array.h"
|
||||
#include "graphics/tinygl/zrect.h"
|
||||
#include "graphics/tinygl/gl.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace Graphics {
|
||||
|
@ -131,6 +132,25 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void tglBlitZBuffer(int dstX, int dstY) {
|
||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||
|
||||
int clampWidth, clampHeight;
|
||||
int width = _surface.w, height = _surface.h;
|
||||
int srcWidth = 0, srcHeight = 0;
|
||||
if (clipBlitImage(c, srcWidth, srcHeight, width, height, dstX, dstY, clampWidth, clampHeight) == false)
|
||||
return;
|
||||
|
||||
Graphics::PixelBuffer srcBuf(_surface.format, (byte *)const_cast<void *>(_surface.getPixels()));
|
||||
Graphics::PixelBuffer dstBuf(_surface.format, (byte *)c->fb->getZBuffer());
|
||||
|
||||
for (int l = 0; l < clampHeight; l++) {
|
||||
dstBuf.copyBuffer(0, clampWidth, srcBuf);
|
||||
dstBuf.shiftBy(c->fb->xsize);
|
||||
srcBuf.shiftBy(srcWidth);
|
||||
}
|
||||
}
|
||||
|
||||
template <bool disableColoring, bool disableBlending, bool enableAlphaBlending>
|
||||
FORCEINLINE void tglBlitRLE(int dstX, int dstY, int srcX, int srcY, int srcWidth, int srcHeight, float aTint, float rTint, float gTint, float bTint);
|
||||
|
||||
|
@ -489,6 +509,12 @@ void tglBlitFast(BlitImage *blitImage, int x, int y) {
|
|||
TinyGL::glIssueDrawCall(new BlittingDrawCall(blitImage, transform, BlittingDrawCall::BlitMode_Fast));
|
||||
}
|
||||
|
||||
void tglBlitZBuffer(BlitImage *blitImage, int x, int y) {
|
||||
BlitTransform transform(x, y);
|
||||
TinyGL::glIssueDrawCall(new BlittingDrawCall(blitImage, transform, BlittingDrawCall::BlitMode_ZBuffer));
|
||||
}
|
||||
|
||||
|
||||
namespace Internal {
|
||||
|
||||
void tglBlit(BlitImage *blitImage, const BlitTransform &transform) {
|
||||
|
@ -579,6 +605,10 @@ void tglBlitFast(BlitImage *blitImage, int x, int y) {
|
|||
blitImage->tglBlitGeneric<true, true, true, false, false, false>(transform);
|
||||
}
|
||||
|
||||
void tglBlitZBuffer(BlitImage *blitImage, int x, int y) {
|
||||
blitImage->tglBlitZBuffer(x, y);
|
||||
}
|
||||
|
||||
void tglCleanupImages() {
|
||||
TinyGL::GLContext *c = TinyGL::gl_get_context();
|
||||
for (int32 i = 0; i < c->blitImages.size(); i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue