Bitmap: Add #v_flip / #h_flip methods
This commit is contained in:
parent
1c2dc115b8
commit
a651639524
4 changed files with 76 additions and 0 deletions
|
|
@ -259,6 +259,34 @@ struct BitmapPrivate
|
|||
|
||||
glState.viewport.pop();
|
||||
}
|
||||
|
||||
void flip(const IntRect &srcRect)
|
||||
{
|
||||
TEXFBO newTex = shState->texPool().request(gl.width, gl.height);
|
||||
|
||||
SimpleShader &shader = shState->shaders().simple;
|
||||
shader.bind();
|
||||
shader.setTexOffsetX(0);
|
||||
bindTexture(shader);
|
||||
|
||||
Quad &quad = shState->gpQuad();
|
||||
quad.setTexPosRect(srcRect, IntRect(0, 0, gl.width, gl.height));
|
||||
quad.setColor(Vec4(1, 1, 1, 1));
|
||||
|
||||
glState.blend.pushSet(false);
|
||||
pushSetViewport(shader);
|
||||
|
||||
FBO::bind(newTex.fbo);
|
||||
blitQuad(quad);
|
||||
|
||||
popViewport();
|
||||
glState.blend.pop();
|
||||
|
||||
shState->texPool().release(gl);
|
||||
gl = newTex;
|
||||
|
||||
onModified();
|
||||
}
|
||||
};
|
||||
|
||||
struct BitmapOpenHandler : FileSystem::OpenHandler
|
||||
|
|
@ -1410,6 +1438,22 @@ void Bitmap::writeToPng(const char *filename)
|
|||
IMG_SavePNG(p->surface, filename);
|
||||
}
|
||||
|
||||
void Bitmap::vFlip()
|
||||
{
|
||||
guardDisposed();
|
||||
GUARD_MEGA;
|
||||
|
||||
p->flip(IntRect(0, p->gl.height, p->gl.width, -p->gl.height));
|
||||
}
|
||||
|
||||
void Bitmap::hFlip()
|
||||
{
|
||||
guardDisposed();
|
||||
GUARD_MEGA;
|
||||
|
||||
p->flip(IntRect(p->gl.width, 0, -p->gl.width, p->gl.height));
|
||||
}
|
||||
|
||||
TEXFBO &Bitmap::getGLTypes()
|
||||
{
|
||||
return p->gl;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ public:
|
|||
/* extensions */
|
||||
void writeToPng(const char *filename);
|
||||
|
||||
void vFlip();
|
||||
void hFlip();
|
||||
|
||||
/* <internal> */
|
||||
TEXFBO &getGLTypes();
|
||||
SDL_Surface *megaSurface() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue