mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Renamed CompressedData:getNumMipmaps to CompressedData:getMipmapCount; Improved type-checking error messages for some functions which expect function arguments
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(...)
|
||||
|
||||
Reference in New Issue
Block a user