Fix texture coordinates;

This commit is contained in:
bjorn 2017-12-09 19:11:53 -08:00
parent 6df8dfe456
commit 6f58b758e3
6 changed files with 13 additions and 12 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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**)); \