mirror of https://github.com/bjornbytes/lovr.git
Fix texture coordinates;
This commit is contained in:
parent
6df8dfe456
commit
6f58b758e3
|
@ -786,7 +786,7 @@ int l_lovrGraphicsNewMaterial(lua_State* L) {
|
||||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
||||||
lovrRelease(&texture->ref);
|
lovrRelease(&texture->ref);
|
||||||
} else if (lua_isuserdata(L, index)) {
|
} 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);
|
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,14 +111,14 @@ void lovrCanvasBind(Canvas* canvas) {
|
||||||
lovrGraphicsSetProjection(projection);
|
lovrGraphicsSetProjection(projection);
|
||||||
} else {
|
} else {
|
||||||
mat4 projection = lovrGraphicsGetProjection();
|
mat4 projection = lovrGraphicsGetProjection();
|
||||||
float b = -projection[5];
|
float b = projection[5];
|
||||||
float c = projection[10];
|
float c = projection[10];
|
||||||
float d = projection[14];
|
float d = projection[14];
|
||||||
float aspect = (float) width / height;
|
float aspect = (float) width / height;
|
||||||
float k = (c - 1.f) / (c + 1.f);
|
float k = (c - 1.f) / (c + 1.f);
|
||||||
float near = (d * (1.f - k)) / (2.f * k);
|
float near = (d * (1.f - k)) / (2.f * k);
|
||||||
float far = k * near;
|
float far = k * near;
|
||||||
float fov = -2.f * atan(1.f / b);
|
float fov = 2.f * atan(1.f / b);
|
||||||
float newProjection[16];
|
float newProjection[16];
|
||||||
mat4_perspective(newProjection, near, far, fov, aspect);
|
mat4_perspective(newProjection, near, far, fov, aspect);
|
||||||
lovrGraphicsSetProjection(newProjection);
|
lovrGraphicsSetProjection(newProjection);
|
||||||
|
|
|
@ -605,10 +605,10 @@ void lovrGraphicsPlane(DrawMode mode, Material* material, mat4 transform) {
|
||||||
lovrGraphicsDrawPrimitive(material, GL_LINE_LOOP, false, false, false);
|
lovrGraphicsDrawPrimitive(material, GL_LINE_LOOP, false, false, false);
|
||||||
} else if (mode == DRAW_MODE_FILL) {
|
} else if (mode == DRAW_MODE_FILL) {
|
||||||
float data[] = {
|
float data[] = {
|
||||||
-.5, .5, 0, 0, 0, -1, 0, 0,
|
-.5, .5, 0, 0, 0, -1, 0, 1,
|
||||||
-.5, -.5, 0, 0, 0, -1, 0, 1,
|
-.5, -.5, 0, 0, 0, -1, 0, 0,
|
||||||
.5, .5, 0, 0, 0, -1, 1, 0,
|
.5, .5, 0, 0, 0, -1, 1, 1,
|
||||||
.5, -.5, 0, 0, 0, -1, 1, 1
|
.5, -.5, 0, 0, 0, -1, 1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
lovrGraphicsSetDefaultShader(SHADER_DEFAULT);
|
lovrGraphicsSetDefaultShader(SHADER_DEFAULT);
|
||||||
|
|
|
@ -193,7 +193,7 @@ ModelData* lovrModelDataCreate(Blob* blob) {
|
||||||
struct aiPropertyStore* propertyStore = aiCreatePropertyStore();
|
struct aiPropertyStore* propertyStore = aiCreatePropertyStore();
|
||||||
aiSetImportPropertyInteger(propertyStore, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_POINT | aiPrimitiveType_LINE);
|
aiSetImportPropertyInteger(propertyStore, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_POINT | aiPrimitiveType_LINE);
|
||||||
aiSetImportPropertyInteger(propertyStore, AI_CONFIG_PP_SBBC_MAX_BONES, 48);
|
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);
|
const struct aiScene* scene = aiImportFileExWithProperties(blob->name, flags, &assimpIO, propertyStore);
|
||||||
aiReleasePropertyStore(propertyStore);
|
aiReleasePropertyStore(propertyStore);
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ TextureData* lovrTextureDataFromBlob(Blob* blob) {
|
||||||
return textureData;
|
return textureData;
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_set_flip_vertically_on_load(0);
|
stbi_set_flip_vertically_on_load(1);
|
||||||
textureData->format = FORMAT_RGBA;
|
textureData->format = FORMAT_RGBA;
|
||||||
textureData->data = stbi_load_from_memory(blob->data, blob->size, &textureData->width, &textureData->height, NULL, 4);
|
textureData->data = stbi_load_from_memory(blob->data, blob->size, &textureData->width, &textureData->height, NULL, 4);
|
||||||
textureData->blob = NULL;
|
textureData->blob = NULL;
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
#define luax_checktypeof(L, i, T) \
|
#define luax_checktypeof(L, i, T) \
|
||||||
*(T**) (luaL_argcheck(L, lua_touserdata(L, i), i, "Expected " STRINGIFY(T)), \
|
*(T**) (luaL_argcheck(L, lua_touserdata(L, i), i, "Expected " STRINGIFY(T)), \
|
||||||
lua_getmetatable(L, i), \
|
lua_getmetatable(L, i), \
|
||||||
lua_getfield(L, -1, "super"), \
|
lua_getfield(L, -1, "name"), \
|
||||||
|
lua_getfield(L, -2, "super"), \
|
||||||
lua_pushstring(L, #T), \
|
lua_pushstring(L, #T), \
|
||||||
luaL_argcheck(L, lua_equal(L, -1, -2), i, "Expected " STRINGIFY(T)), \
|
luaL_argcheck(L, lua_equal(L, -1, -2) || lua_equal(L, -1, -3), i, "Expected " STRINGIFY(T)), \
|
||||||
lua_pop(L, 3), \
|
lua_pop(L, 4), \
|
||||||
lua_touserdata(L, i))
|
lua_touserdata(L, i))
|
||||||
#define luax_newobject(L, T, x) \
|
#define luax_newobject(L, T, x) \
|
||||||
T** u = (T**) lua_newuserdata(L, sizeof(T**)); \
|
T** u = (T**) lua_newuserdata(L, sizeof(T**)); \
|
||||||
|
|
Loading…
Reference in New Issue