Raise exception on too big textures

This commit is contained in:
Jonas Kulla 2013-09-03 15:22:00 +02:00
parent 31c007b541
commit f81e20cc68
7 changed files with 41 additions and 43 deletions

View File

@ -53,6 +53,7 @@ struct
const char *name;
} static customExc[] =
{
{ MKXP, "MKXPError" },
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" }
@ -85,7 +86,8 @@ static const RbException excToRbExc[] =
ArgumentError,
PHYSFS, /* PHYSFSError */
SDL /* SDLError */
SDL, /* SDLError */
MKXP /* MKXPError */
};
void raiseRbExc(const Exception &exc)

View File

@ -31,6 +31,7 @@ enum RbException
RGSS = 0,
PHYSFS,
SDL,
MKXP,
ErrnoENOENT,

View File

@ -48,7 +48,7 @@ RB_METHOD(bitmapInitialize)
int width, height;
rb_get_args(argc, argv, "ii", &width, &height);
b = new Bitmap(width, height);
GUARD_EXC( b = new Bitmap(width, height); )
}
setPrivateData(self, b, BitmapType);

View File

@ -66,6 +66,7 @@ static const MrbExcData excData[] =
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" },
{ MKXP, "MKXPError" },
{ IO, "IOError" }
};
@ -117,21 +118,6 @@ MrbData::MrbData(mrb_state *mrb)
mrb_gc_arena_restore(mrb, arena);
}
//enum Type
//{
// RGSSError,
// NoFileError,
// IOError,
// /* Already defined by ruby */
// TypeError,
// ArgumentError,
// /* New types introduced in mkxp */
// PHYSFSError,
// SDLError
//};
/* Indexed with Exception::Type */
static const MrbException excToMrbExc[] =
{
@ -144,6 +130,7 @@ static const MrbException excToMrbExc[] =
PHYSFS, /* PHYSFSError */
SDL, /* SDLError */
MKXP /* MKXPError */
};
void raiseMrbExc(mrb_state *mrb, const Exception &exc)

View File

@ -64,6 +64,7 @@ enum MrbException
RGSS,
PHYSFS,
SDL,
MKXP,
ErrnoE2BIG,
ErrnoEACCES,

View File

@ -48,7 +48,7 @@ MRB_METHOD(bitmapInitialize)
mrb_int width, height;
mrb_get_args(mrb, "ii", &width, &height);
b = new Bitmap(width, height);
GUARD_EXC( b = new Bitmap(width, height); )
}
setPrivateData(mrb, self, b, BitmapType);

View File

@ -20,6 +20,9 @@
*/
#include "texpool.h"
#include "exception.h"
#include "globalstate.h"
#include "glstate.h"
#include <QHash>
#include <QQueue>
@ -121,7 +124,11 @@ TexFBO TexPool::request(int width, int height)
return cobj.obj;
}
// FIXME check here that requested dimensions don't exceed OpenGL limits
int maxSize = glState.caps.maxTexSize;
if (width > maxSize || height > maxSize)
throw Exception(Exception::MKXPError,
"Texture dimensions [%s, %s] exceed hardware capabilities",
QByteArray::number(width), QByteArray::number(height));
/* Nope, create it instead */
TexFBO::init(cobj.obj);