diff --git a/src/api/graphics.c b/src/api/graphics.c index da048f30..7c8ec053 100644 --- a/src/api/graphics.c +++ b/src/api/graphics.c @@ -786,7 +786,7 @@ int l_lovrGraphicsNewMaterial(lua_State* L) { lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture); lovrRelease(&texture->ref); } else if (lua_isuserdata(L, index)) { - Texture* texture = luax_checktype(L, index++, Texture); + Texture* texture = luax_checktypeof(L, index++, Texture); lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture); } diff --git a/src/graphics/canvas.c b/src/graphics/canvas.c index 3751fe72..c0b5ddf9 100644 --- a/src/graphics/canvas.c +++ b/src/graphics/canvas.c @@ -111,14 +111,14 @@ void lovrCanvasBind(Canvas* canvas) { lovrGraphicsSetProjection(projection); } else { mat4 projection = lovrGraphicsGetProjection(); - float b = -projection[5]; + float b = projection[5]; float c = projection[10]; float d = projection[14]; float aspect = (float) width / height; float k = (c - 1.f) / (c + 1.f); float near = (d * (1.f - k)) / (2.f * k); float far = k * near; - float fov = -2.f * atan(1.f / b); + float fov = 2.f * atan(1.f / b); float newProjection[16]; mat4_perspective(newProjection, near, far, fov, aspect); lovrGraphicsSetProjection(newProjection); diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 099974fd..25a23512 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -605,10 +605,10 @@ void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) { lovrGraphicsDrawPrimitive(material, GL_LINE_LOOP, false, false, false); } else if (mode == DRAW_MODE_FILL) { float data[] = { - -.5, .5, 0, 0, 0, -1, 0, 0, - -.5, -.5, 0, 0, 0, -1, 0, 1, - .5, .5, 0, 0, 0, -1, 1, 0, - .5, -.5, 0, 0, 0, -1, 1, 1 + -.5, .5, 0, 0, 0, -1, 0, 1, + -.5, -.5, 0, 0, 0, -1, 0, 0, + .5, .5, 0, 0, 0, -1, 1, 1, + .5, -.5, 0, 0, 0, -1, 1, 0 }; lovrGraphicsSetDefaultShader(SHADER_DEFAULT); diff --git a/src/loaders/model.c b/src/loaders/model.c index 5af02bbb..1e20068a 100644 --- a/src/loaders/model.c +++ b/src/loaders/model.c @@ -193,7 +193,7 @@ ModelData* lovrModelDataCreate(Blob* blob) { struct aiPropertyStore* propertyStore = aiCreatePropertyStore(); aiSetImportPropertyInteger(propertyStore, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_POINT | aiPrimitiveType_LINE); aiSetImportPropertyInteger(propertyStore, AI_CONFIG_PP_SBBC_MAX_BONES, 48); - unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_OptimizeGraph | aiProcess_FlipUVs | aiProcess_SplitByBoneCount; + unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_OptimizeGraph | aiProcess_SplitByBoneCount; const struct aiScene* scene = aiImportFileExWithProperties(blob->name, flags, &assimpIO, propertyStore); aiReleasePropertyStore(propertyStore); diff --git a/src/loaders/texture.c b/src/loaders/texture.c index d4fd8775..cbb76a31 100644 --- a/src/loaders/texture.c +++ b/src/loaders/texture.c @@ -163,7 +163,7 @@ TextureData* lovrTextureDataFromBlob(Blob* blob) { return textureData; } - stbi_set_flip_vertically_on_load(0); + stbi_set_flip_vertically_on_load(1); textureData->format = FORMAT_RGBA; textureData->data = stbi_load_from_memory(blob->data, blob->size, &textureData->width, &textureData->height, NULL, 4); textureData->blob = NULL; diff --git a/src/luax.h b/src/luax.h index 1870c118..19176165 100644 --- a/src/luax.h +++ b/src/luax.h @@ -12,10 +12,11 @@ #define luax_checktypeof(L, i, T) \ *(T**) (luaL_argcheck(L, lua_touserdata(L, i), i, "Expected " STRINGIFY(T)), \ lua_getmetatable(L, i), \ - lua_getfield(L, -1, "super"), \ + lua_getfield(L, -1, "name"), \ + lua_getfield(L, -2, "super"), \ lua_pushstring(L, #T), \ - luaL_argcheck(L, lua_equal(L, -1, -2), i, "Expected " STRINGIFY(T)), \ - lua_pop(L, 3), \ + luaL_argcheck(L, lua_equal(L, -1, -2) || lua_equal(L, -1, -3), i, "Expected " STRINGIFY(T)), \ + lua_pop(L, 4), \ lua_touserdata(L, i)) #define luax_newobject(L, T, x) \ T** u = (T**) lua_newuserdata(L, sizeof(T**)); \