mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-26 08:43:44 +02:00
Fix some bitmap and gl-meta bugs in libretro builds
This commit is contained in:
parent
20c8f6d463
commit
071be23d74
3 changed files with 55 additions and 20 deletions
|
@ -423,6 +423,7 @@ struct BitmapPrivate
|
||||||
FBO::clear();
|
FBO::clear();
|
||||||
|
|
||||||
glState.clearColor.pop();
|
glState.clearColor.pop();
|
||||||
|
|
||||||
glState.scissorBox.pop();
|
glState.scissorBox.pop();
|
||||||
glState.scissorTest.pop();
|
glState.scissorTest.pop();
|
||||||
}
|
}
|
||||||
|
@ -443,7 +444,9 @@ struct BitmapPrivate
|
||||||
{
|
{
|
||||||
if (surface && freeSurface)
|
if (surface && freeSurface)
|
||||||
{
|
{
|
||||||
#ifndef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete surface;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
surface = 0;
|
surface = 0;
|
||||||
|
@ -570,9 +573,7 @@ Bitmap::Bitmap(const char *filename)
|
||||||
handler.gif->width, handler.gif->height, glState.caps.maxTexSize, glState.caps.maxTexSize);
|
handler.gif->width, handler.gif->height, glState.caps.maxTexSize, glState.caps.maxTexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MKXPZ_RETRO
|
|
||||||
p = new BitmapPrivate(this);
|
p = new BitmapPrivate(this);
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
|
|
||||||
p->selfHires = hiresBitmap;
|
p->selfHires = hiresBitmap;
|
||||||
|
|
||||||
|
@ -667,9 +668,15 @@ Bitmap::Bitmap(const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *imgSurf = handler.surface;
|
SDL_Surface *imgSurf = handler.surface;
|
||||||
|
|
||||||
initFromSurface(imgSurf, hiresBitmap, false);
|
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
|
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
SDL_Surface *imgSurf = new SDL_Surface;
|
||||||
|
// TODO: use actual image dimensions
|
||||||
|
imgSurf->w = 64;
|
||||||
|
imgSurf->h = 64;
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
|
initFromSurface(imgSurf, hiresBitmap, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::Bitmap(int width, int height, bool isHires)
|
Bitmap::Bitmap(int width, int height, bool isHires)
|
||||||
|
@ -732,24 +739,30 @@ Bitmap::Bitmap(void *pixeldata, int width, int height)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
TEXFBO tex;
|
TEXFBO tex;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
tex = shState->texPool().request(64, 64); // TODO: use actual image dimensions
|
||||||
|
#else
|
||||||
tex = shState->texPool().request(surface->w, surface->h);
|
tex = shState->texPool().request(surface->w, surface->h);
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
|
#ifndef MKXPZ_RETRO
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MKXPZ_RETRO
|
|
||||||
p = new BitmapPrivate(this);
|
p = new BitmapPrivate(this);
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
p->gl = tex;
|
p->gl = tex;
|
||||||
|
|
||||||
TEX::bind(p->gl.tex);
|
TEX::bind(p->gl.tex);
|
||||||
|
#ifndef MKXPZ_RETRO
|
||||||
TEX::uploadImage(p->gl.width, p->gl.height, surface->pixels, GL_RGBA);
|
TEX::uploadImage(p->gl.width, p->gl.height, surface->pixels, GL_RGBA);
|
||||||
|
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
|
@ -909,7 +922,9 @@ void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool for
|
||||||
{
|
{
|
||||||
if (hiresBitmap)
|
if (hiresBitmap)
|
||||||
delete hiresBitmap;
|
delete hiresBitmap;
|
||||||
#ifndef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete imgSurf;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(imgSurf);
|
SDL_FreeSurface(imgSurf);
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -923,9 +938,13 @@ void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool for
|
||||||
}
|
}
|
||||||
|
|
||||||
TEX::bind(p->gl.tex);
|
TEX::bind(p->gl.tex);
|
||||||
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
|
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
#ifndef MKXPZ_RETRO
|
||||||
|
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
|
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete imgSurf;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(imgSurf);
|
SDL_FreeSurface(imgSurf);
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
}
|
}
|
||||||
|
@ -2504,8 +2523,10 @@ int Bitmap::addFrame(Bitmap &source, int position)
|
||||||
|
|
||||||
p->animation.frames.push_back(p->gl);
|
p->animation.frames.push_back(p->gl);
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
if (p->surface)
|
if (p->surface)
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete p->surface;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(p->surface);
|
SDL_FreeSurface(p->surface);
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
p->gl = TEXFBO();
|
p->gl = TEXFBO();
|
||||||
|
@ -2514,7 +2535,9 @@ int Bitmap::addFrame(Bitmap &source, int position)
|
||||||
if (source.surface()) {
|
if (source.surface()) {
|
||||||
TEX::bind(newframe.tex);
|
TEX::bind(newframe.tex);
|
||||||
TEX::uploadImage(source.width(), source.height(), source.surface()->pixels, GL_RGBA);
|
TEX::uploadImage(source.width(), source.height(), source.surface()->pixels, GL_RGBA);
|
||||||
#ifndef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete p->surface;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(p->surface);
|
SDL_FreeSurface(p->surface);
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
p->surface = 0;
|
p->surface = 0;
|
||||||
|
@ -2714,12 +2737,13 @@ void Bitmap::releaseResources()
|
||||||
delete p->selfHires;
|
delete p->selfHires;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
if (p->megaSurface)
|
if (p->megaSurface)
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
delete p->megaSurface;
|
||||||
|
#else
|
||||||
SDL_FreeSurface(p->megaSurface);
|
SDL_FreeSurface(p->megaSurface);
|
||||||
else
|
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
if (p->animation.enabled) {
|
else if (p->animation.enabled) {
|
||||||
p->animation.enabled = false;
|
p->animation.enabled = false;
|
||||||
p->animation.playing = false;
|
p->animation.playing = false;
|
||||||
for (TEXFBO &tex : p->animation.frames)
|
for (TEXFBO &tex : p->animation.frames)
|
||||||
|
|
|
@ -211,10 +211,21 @@ int smoothScalingMethod(int scaleIsSpecial)
|
||||||
|
|
||||||
static void _blitBegin(FBO::ID fbo, const Vec2i &size, int scaleIsSpecial)
|
static void _blitBegin(FBO::ID fbo, const Vec2i &size, int scaleIsSpecial)
|
||||||
{
|
{
|
||||||
FBO::bind(fbo);
|
if (HAVE_NATIVE_BLIT)
|
||||||
|
|
||||||
if (!HAVE_NATIVE_BLIT)
|
|
||||||
{
|
{
|
||||||
|
FBO::boundFramebufferID = fbo;
|
||||||
|
gl.BindFramebuffer(
|
||||||
|
GL_DRAW_FRAMEBUFFER,
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
fbo.gl != 0 ? fbo.gl : mkxp_retro::hw_render.get_current_framebuffer()
|
||||||
|
#else
|
||||||
|
fbo.gl
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FBO::bind(fbo);
|
||||||
glState.viewport.pushSet(IntRect(0, 0, size.x, size.y));
|
glState.viewport.pushSet(IntRect(0, 0, size.x, size.y));
|
||||||
|
|
||||||
switch (smoothScalingMethod(scaleIsSpecial))
|
switch (smoothScalingMethod(scaleIsSpecial))
|
||||||
|
@ -320,7 +331,7 @@ void blitSource(TEXFBO &source, int scaleIsSpecial)
|
||||||
gl.BindFramebuffer(
|
gl.BindFramebuffer(
|
||||||
GL_READ_FRAMEBUFFER,
|
GL_READ_FRAMEBUFFER,
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
source.fbo.gl || mkxp_retro::hw_render.get_current_framebuffer()
|
source.fbo.gl != 0 ? source.fbo.gl : mkxp_retro::hw_render.get_current_framebuffer()
|
||||||
#else
|
#else
|
||||||
source.fbo.gl
|
source.fbo.gl
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace FBO
|
||||||
gl.BindFramebuffer(
|
gl.BindFramebuffer(
|
||||||
GL_FRAMEBUFFER,
|
GL_FRAMEBUFFER,
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
id.gl || mkxp_retro::hw_render.get_current_framebuffer()
|
id.gl != 0 ? id.gl : mkxp_retro::hw_render.get_current_framebuffer()
|
||||||
#else
|
#else
|
||||||
id.gl
|
id.gl
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
|
|
Loading…
Add table
Reference in a new issue