TINYGL: Implemented scissor rectangle in frame buffer.

This commit is contained in:
Stefano Musumeci 2014-08-01 19:21:35 +02:00
parent 5049413d24
commit 79ea06e41d
2 changed files with 17 additions and 0 deletions

View File

@ -67,6 +67,8 @@ FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelBuffer &fra
this->pixelbits = this->cmode.bytesPerPixel * 8;
this->linesize = (xsize * this->pixelbytes + 3) & ~3;
this->setScissorRectangle(0, xsize, 0, ysize);
size = this->xsize * this->ysize * sizeof(unsigned int);
this->zbuf = (unsigned int *)gl_malloc(size);

View File

@ -166,6 +166,13 @@ struct FrameBuffer {
if (!checkAlphaTest(aSrc))
return;
int x = pixel % xsize;
int y = pixel / xsize;
if (x < _clipLeft || x > _clipRight || y < _clipTop || y > _clipBottom) {
return;
}
if (_blendingEnabled == false) {
this->pbuf.setPixelAt(pixel, aSrc, rSrc, gSrc, bSrc);
} else {
@ -338,6 +345,14 @@ struct FrameBuffer {
void fillLineFlat(ZBufferPoint *p1, ZBufferPoint *p2, int color);
void fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2);
void setScissorRectangle(int left, int right, int top, int bottom) {
_clipLeft = left;
_clipRight = right;
_clipTop = top;
_clipBottom = bottom;
}
int _clipLeft, _clipTop, _clipRight, _clipBottom;
int xsize, ysize;
int linesize; // line size, in bytes
Graphics::PixelFormat cmode;