mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-03-28 14:56:22 +01:00
Bitmap: make GUARD_MEGA attempt to convert Mega into non-Mega
This commit is contained in:
parent
faf17e64f2
commit
f78bad83d6
1 changed files with 42 additions and 1 deletions
|
@ -60,9 +60,13 @@ extern "C" {
|
|||
|
||||
#define GUARD_MEGA \
|
||||
{ \
|
||||
if (p->megaSurface) \
|
||||
if (p->megaSurface) { \
|
||||
p->ensureNonMega(); \
|
||||
if (p->megaSurface) { \
|
||||
throw Exception(Exception::MKXPError, \
|
||||
"Operation not supported for mega surfaces"); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GUARD_ANIMATED \
|
||||
|
@ -408,6 +412,43 @@ struct BitmapPrivate
|
|||
SDL_FreeSurface(surf);
|
||||
surf = surfConv;
|
||||
}
|
||||
|
||||
void ensureNonMega()
|
||||
{
|
||||
if (selfHires != nullptr) {
|
||||
if (selfHires->width() > glState.caps.maxTexSize || selfHires->height() > glState.caps.maxTexSize) {
|
||||
return;
|
||||
}
|
||||
selfHires->ensureNonMega();
|
||||
}
|
||||
|
||||
if (megaSurface->w > glState.caps.maxTexSize || megaSurface->h > glState.caps.maxTexSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TEXFBO tex;
|
||||
|
||||
try
|
||||
{
|
||||
tex = shState->texPool().request(megaSurface->w, megaSurface->h);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gl = tex;
|
||||
if (selfHires != nullptr) {
|
||||
gl.selfHires = &selfHires->getGLTypes();
|
||||
}
|
||||
|
||||
TEX::bind(gl.tex);
|
||||
TEX::uploadImage(gl.width, gl.height, megaSurface->pixels, GL_RGBA);
|
||||
|
||||
SDL_FreeSurface(megaSurface);
|
||||
megaSurface = nullptr;
|
||||
}
|
||||
|
||||
void onModified(bool freeSurface = true)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue