Renamed CompressedData:getNumMipmaps to CompressedData:getMipmapCount; Improved type-checking error messages for some functions which expect function arguments

This commit is contained in:
Alex Szpakowski
2013-05-02 17:26:50 -04:00
parent 77c6efd8fd
commit 3bf43dadd8
14 changed files with 43 additions and 44 deletions
+7 -7
View File
@@ -645,14 +645,15 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image)
void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
{
strategy->bindFBO( fbo );
if (current != this)
strategy->bindFBO(fbo);
glReadPixels(x, height - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_rgba);
if (current)
strategy->bindFBO( current->fbo );
else
strategy->bindFBO( 0 );
if (current && current != this)
strategy->bindFBO(current->fbo);
else if (!current)
strategy->bindFBO(0);
}
const std::vector<Canvas *> &Canvas::getAttachedCanvases() const
@@ -692,8 +693,7 @@ bool Canvas::loadVolatile()
setFilter(settings.filter);
setWrap(settings.wrap);
Color c;
c.r = c.g = c.b = c.a = 0;
Color c(0, 0, 0, 0);
clear(c);
return true;
}
+3 -1
View File
@@ -880,7 +880,9 @@ void Graphics::printf(const char *str, float x, float y, float wrap, AlignMode a
if (currentFont == 0)
return;
using namespace std;
using std::string;
using std::vector;
string text(str);
vector<string> lines_to_draw = currentFont->getWrap(text, wrap);
+4 -4
View File
@@ -131,21 +131,21 @@ void Image::uploadCompressedMipmaps()
bind();
int numMipmaps = cdata->getNumMipmaps();
int mipmapcount = cdata->getMipmapCount();
// We have to inform OpenGL if the image doesn't have all mipmap levels.
if (GLEE_VERSION_1_2 || GLEE_SGIS_texture_lod)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, numMipmaps - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapcount - 1);
}
else if (cdata->getWidth(numMipmaps-1) > 1 || cdata->getHeight(numMipmaps-1) > 1)
else if (cdata->getWidth(mipmapcount-1) > 1 || cdata->getHeight(mipmapcount-1) > 1)
{
// Telling OpenGL to ignore certain levels isn't always supported.
throw love::Exception("Cannot load mipmaps: "
"compressed image does not have all required levels.");
}
for (int i = 1; i < numMipmaps; i++)
for (int i = 1; i < mipmapcount; i++)
{
glCompressedTexImage2DARB(GL_TEXTURE_2D,
i,
+9 -10
View File
@@ -44,8 +44,7 @@ int w_Canvas_renderTo(lua_State *L)
}
Canvas *canvas = luax_checkcanvas(L, 1);
if (!lua_isfunction(L, 2))
return luaL_error(L, "Need a function to render to canvas.");
luaL_checktype(L, 2, LUA_TFUNCTION);
try
{
@@ -182,19 +181,19 @@ int w_Canvas_clear(lua_State *L)
for (int i = 1; i <= 4; i++)
lua_rawgeti(L, 2, i);
c.r = (unsigned char)luaL_checkint(L, -4);
c.g = (unsigned char)luaL_checkint(L, -3);
c.b = (unsigned char)luaL_checkint(L, -2);
c.a = (unsigned char)luaL_optint(L, -1, 255);
c.r = (unsigned char)luaL_checkinteger(L, -4);
c.g = (unsigned char)luaL_checkinteger(L, -3);
c.b = (unsigned char)luaL_checkinteger(L, -2);
c.a = (unsigned char)luaL_optinteger(L, -1, 255);
lua_pop(L, 4);
}
else
{
c.r = (unsigned char)luaL_checkint(L, 2);
c.g = (unsigned char)luaL_checkint(L, 3);
c.b = (unsigned char)luaL_checkint(L, 4);
c.a = (unsigned char)luaL_optint(L, 5, 255);
c.r = (unsigned char)luaL_checkinteger(L, 2);
c.g = (unsigned char)luaL_checkinteger(L, 3);
c.b = (unsigned char)luaL_checkinteger(L, 4);
c.a = (unsigned char)luaL_optinteger(L, 5, 255);
}
canvas->clear(c);
@@ -241,8 +241,7 @@ int w_getScissor(lua_State *L)
int w_newStencil(lua_State *L)
{
// just return the function
if (!lua_isfunction(L, 1))
return luaL_typerror(L, 1, "function");
luaL_checktype(L, 1, LUA_TFUNCTION);
lua_settop(L, 1);
return 1;
}
@@ -256,8 +255,7 @@ static int setStencil(lua_State *L, bool invert)
return 0;
}
if (!lua_isfunction(L, 1))
return luaL_typerror(L, 1, "mask");
luaL_checktype(L, 1, LUA_TFUNCTION);
instance->defineStencil();
lua_call(L, lua_gettop(L) - 1, 0); // call mask(...)