mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-23 15:23:44 +02:00
Fix Graphics.fadeout
/.fadein
causing screen flashing in libretro builds
This commit is contained in:
parent
996e47ed81
commit
ced3e697bd
3 changed files with 14 additions and 10 deletions
|
@ -127,13 +127,15 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_COROUTINE(coro,
|
||||
int32_t duration;
|
||||
int32_t i;
|
||||
int32_t brightness;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(duration, rb_num2int, value);
|
||||
brightness = shState->graphics().getBrightness();
|
||||
|
||||
for (i = 0; i < duration; ++i) {
|
||||
shState->graphics().fadeout(duration, i, i);
|
||||
shState->graphics().fadeout(duration, i, i, brightness);
|
||||
SANDBOX_YIELD;
|
||||
}
|
||||
}
|
||||
|
@ -149,13 +151,15 @@ namespace mkxp_sandbox {
|
|||
SANDBOX_COROUTINE(coro,
|
||||
int32_t duration;
|
||||
int32_t i;
|
||||
int32_t brightness;
|
||||
|
||||
VALUE operator()(VALUE self, VALUE value) {
|
||||
BOOST_ASIO_CORO_REENTER (this) {
|
||||
SANDBOX_AWAIT_AND_SET(duration, rb_num2int, value);
|
||||
brightness = shState->graphics().getBrightness();
|
||||
|
||||
for (i = 0; i < duration; ++i) {
|
||||
shState->graphics().fadein(duration, i, i);
|
||||
shState->graphics().fadein(duration, i, i, brightness);
|
||||
SANDBOX_YIELD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1458,14 +1458,14 @@ void Graphics::wait(int duration, int start, int stop) {
|
|||
}
|
||||
}
|
||||
|
||||
void Graphics::fadeout(int duration, int start, int stop) {
|
||||
void Graphics::fadeout(int duration, int start, int stop, int brightness) {
|
||||
FBO::unbind();
|
||||
|
||||
float curr = p->brightness;
|
||||
float curr = brightness >= 0 && brightness <= 255 ? brightness : p->brightness;
|
||||
float diff = 255.0f - curr;
|
||||
|
||||
for (int i = std::min(stop, duration - 1); i >= start; --i) {
|
||||
setBrightness(diff + (curr / duration) * i);
|
||||
for (int i = start; i <= stop && i < duration;) {
|
||||
setBrightness(diff + (curr / duration) * (duration - ++i));
|
||||
|
||||
if (p->frozen) {
|
||||
int scaleIsSpecial = GLMeta::blitScaleIsSpecial(p->integerScaleBuffer, false, IntRect(0, 0, p->scSize.x, p->scSize.y), p->frozenScene, IntRect(0, 0, p->scRes.x, p->scRes.y));
|
||||
|
@ -1485,10 +1485,10 @@ void Graphics::fadeout(int duration, int start, int stop) {
|
|||
}
|
||||
}
|
||||
|
||||
void Graphics::fadein(int duration, int start, int stop) {
|
||||
void Graphics::fadein(int duration, int start, int stop, int brightness) {
|
||||
FBO::unbind();
|
||||
|
||||
float curr = p->brightness;
|
||||
float curr = brightness >= 0 && brightness <= 255 ? brightness : p->brightness;
|
||||
float diff = 255.0f - curr;
|
||||
|
||||
for (int i = start; i <= stop && i < duration;) {
|
||||
|
|
|
@ -55,8 +55,8 @@ public:
|
|||
DECL_ATTR( Brightness, int )
|
||||
|
||||
void wait(int duration, int start = 0, int stop = INT_MAX);
|
||||
void fadeout(int duration, int start = 0, int stop = INT_MAX);
|
||||
void fadein(int duration, int start = 0, int stop = INT_MAX);
|
||||
void fadeout(int duration, int start = 0, int stop = INT_MAX, int brightness = -1);
|
||||
void fadein(int duration, int start = 0, int stop = INT_MAX, int brightness = -1);
|
||||
|
||||
Bitmap *snapToBitmap();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue