Raise exception on too big textures
This commit is contained in:
		
							parent
							
								
									31c007b541
								
							
						
					
					
						commit
						f81e20cc68
					
				
					 7 changed files with 41 additions and 43 deletions
				
			
		| 
						 | 
					@ -53,6 +53,7 @@ struct
 | 
				
			||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
} static customExc[] =
 | 
					} static customExc[] =
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						{ MKXP,   "MKXPError"   },
 | 
				
			||||||
	{ RGSS,   "RGSSError"   },
 | 
						{ RGSS,   "RGSSError"   },
 | 
				
			||||||
	{ PHYSFS, "PHYSFSError" },
 | 
						{ PHYSFS, "PHYSFSError" },
 | 
				
			||||||
	{ SDL,    "SDLError"    }
 | 
						{ SDL,    "SDLError"    }
 | 
				
			||||||
| 
						 | 
					@ -85,7 +86,8 @@ static const RbException excToRbExc[] =
 | 
				
			||||||
    ArgumentError,
 | 
					    ArgumentError,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PHYSFS,      /* PHYSFSError */
 | 
					    PHYSFS,      /* PHYSFSError */
 | 
				
			||||||
    SDL          /* SDLError    */
 | 
					    SDL,         /* SDLError    */
 | 
				
			||||||
 | 
					    MKXP         /* MKXPError   */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void raiseRbExc(const Exception &exc)
 | 
					void raiseRbExc(const Exception &exc)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,7 @@ enum RbException
 | 
				
			||||||
	RGSS = 0,
 | 
						RGSS = 0,
 | 
				
			||||||
	PHYSFS,
 | 
						PHYSFS,
 | 
				
			||||||
	SDL,
 | 
						SDL,
 | 
				
			||||||
 | 
						MKXP,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ErrnoENOENT,
 | 
						ErrnoENOENT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ RB_METHOD(bitmapInitialize)
 | 
				
			||||||
		int width, height;
 | 
							int width, height;
 | 
				
			||||||
		rb_get_args(argc, argv, "ii", &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);
 | 
						setPrivateData(self, b, BitmapType);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,6 +66,7 @@ static const MrbExcData excData[] =
 | 
				
			||||||
	{ RGSS,     "RGSSError"   },
 | 
						{ RGSS,     "RGSSError"   },
 | 
				
			||||||
	{ PHYSFS,   "PHYSFSError" },
 | 
						{ PHYSFS,   "PHYSFSError" },
 | 
				
			||||||
	{ SDL,      "SDLError"    },
 | 
						{ SDL,      "SDLError"    },
 | 
				
			||||||
 | 
						{ MKXP,     "MKXPError"   },
 | 
				
			||||||
	{ IO,       "IOError"     }
 | 
						{ IO,       "IOError"     }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,21 +118,6 @@ MrbData::MrbData(mrb_state *mrb)
 | 
				
			||||||
	mrb_gc_arena_restore(mrb, arena);
 | 
						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 */
 | 
					/* Indexed with Exception::Type */
 | 
				
			||||||
static const MrbException excToMrbExc[] =
 | 
					static const MrbException excToMrbExc[] =
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -144,6 +130,7 @@ static const MrbException excToMrbExc[] =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PHYSFS,      /* PHYSFSError */
 | 
						PHYSFS,      /* PHYSFSError */
 | 
				
			||||||
	SDL,         /* SDLError    */
 | 
						SDL,         /* SDLError    */
 | 
				
			||||||
 | 
						MKXP         /* MKXPError   */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void raiseMrbExc(mrb_state *mrb, const Exception &exc)
 | 
					void raiseMrbExc(mrb_state *mrb, const Exception &exc)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,6 +64,7 @@ enum MrbException
 | 
				
			||||||
	RGSS,
 | 
						RGSS,
 | 
				
			||||||
	PHYSFS,
 | 
						PHYSFS,
 | 
				
			||||||
	SDL,
 | 
						SDL,
 | 
				
			||||||
 | 
						MKXP,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ErrnoE2BIG,
 | 
						ErrnoE2BIG,
 | 
				
			||||||
	ErrnoEACCES,
 | 
						ErrnoEACCES,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ MRB_METHOD(bitmapInitialize)
 | 
				
			||||||
		mrb_int width, height;
 | 
							mrb_int width, height;
 | 
				
			||||||
		mrb_get_args(mrb, "ii", &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);
 | 
						setPrivateData(mrb, self, b, BitmapType);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,9 @@
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "texpool.h"
 | 
					#include "texpool.h"
 | 
				
			||||||
 | 
					#include "exception.h"
 | 
				
			||||||
 | 
					#include "globalstate.h"
 | 
				
			||||||
 | 
					#include "glstate.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QHash>
 | 
					#include <QHash>
 | 
				
			||||||
#include <QQueue>
 | 
					#include <QQueue>
 | 
				
			||||||
| 
						 | 
					@ -121,7 +124,11 @@ TexFBO TexPool::request(int width, int height)
 | 
				
			||||||
		return cobj.obj;
 | 
							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 */
 | 
						/* Nope, create it instead */
 | 
				
			||||||
	TexFBO::init(cobj.obj);
 | 
						TexFBO::init(cobj.obj);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue