utils: add transform-aware clipping rectangle functions

This commit is contained in:
Sebastian Krzyszkowiak 2019-02-26 01:59:49 +01:00
parent 43c830bf99
commit b84727bff0
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 15 additions and 1 deletions

View file

@ -613,6 +613,18 @@ SYMBOL_EXPORT void SetFramebufferAsTarget(struct Game* game) {
}
}
SYMBOL_EXPORT void SetClippingRectangle(int x, int y, int width, int height) {
ALLEGRO_TRANSFORM transform = *al_get_current_transform();
float nx = x, ny = y, nx2 = x + width, ny2 = y + height;
al_transform_coordinates(&transform, &nx, &ny);
al_transform_coordinates(&transform, &nx2, &ny2);
al_set_clipping_rectangle(nx, ny, nx2 - nx, ny2 - ny);
}
SYMBOL_EXPORT void ResetClippingRectangle(void) {
al_reset_clipping_rectangle();
}
SYMBOL_EXPORT ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height) {
int flags = al_get_new_bitmap_flags();
//al_set_new_bitmap_depth(24);

View file

@ -72,9 +72,11 @@ void SetupViewport(struct Game* game);
void WindowCoordsToViewport(struct Game* game, int* x, int* y);
ALLEGRO_BITMAP* GetFramebuffer(struct Game* game);
void SetFramebufferAsTarget(struct Game* game);
void SetClippingRectangle(int x, int y, int width, int height);
void ResetClippingRectangle(void);
ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height);
void EnableCompositor(struct Game* game, void compositor(struct Game* game, struct Gamestate* gamestates, ALLEGRO_BITMAP* loading_fb));