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,7 +66,8 @@ static const MrbExcData excData[] =
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" },
{ IO, "IOError" }
{ MKXP, "MKXPError" },
{ IO, "IOError" }
};
static elementsN(excData);
@ -75,22 +76,22 @@ static elementsN(excData);
static const MrbExcData enoExcData[] =
{
ENO(E2BIG),
ENO(EACCES),
ENO(EAGAIN),
ENO(EBADF),
ENO(ECHILD),
ENO(EDEADLOCK),
ENO(EDOM),
ENO(EEXIST),
ENO(EINVAL),
ENO(EMFILE),
ENO(ENOENT),
ENO(ENOEXEC),
ENO(ENOMEM),
ENO(ENOSPC),
ENO(ERANGE),
ENO(EXDEV)
ENO(E2BIG),
ENO(EACCES),
ENO(EAGAIN),
ENO(EBADF),
ENO(ECHILD),
ENO(EDEADLOCK),
ENO(EDOM),
ENO(EEXIST),
ENO(EINVAL),
ENO(EMFILE),
ENO(ENOENT),
ENO(ENOEXEC),
ENO(ENOMEM),
ENO(ENOSPC),
ENO(ERANGE),
ENO(EXDEV)
};
static elementsN(enoExcData);
@ -117,33 +118,19 @@ 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[] =
{
RGSS, /* RGSSError */
ErrnoENOENT, /* NoFileError */
IO,
RGSS, /* RGSSError */
ErrnoENOENT, /* NoFileError */
IO,
TypeError,
ArgumentError,
TypeError,
ArgumentError,
PHYSFS, /* PHYSFSError */
SDL, /* SDLError */
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);