mirror of https://github.com/bjornbytes/lovr.git
Update skybox and font rendering;
This commit is contained in:
parent
16915e4fa2
commit
dece1d896f
|
@ -121,6 +121,7 @@ int l_lovrGraphicsInit(lua_State* L) {
|
|||
|
||||
map_init(&MaterialTextures);
|
||||
map_set(&MaterialTextures, "diffuse", TEXTURE_DIFFUSE);
|
||||
map_set(&MaterialTextures, "environment", TEXTURE_ENVIRONMENT_MAP);
|
||||
|
||||
map_init(&MatrixTypes);
|
||||
map_set(&MatrixTypes, "model", MATRIX_MODEL);
|
||||
|
|
|
@ -900,10 +900,18 @@ void lovrGraphicsSkybox(Texture* texture, float angle, float ax, float ay, float
|
|||
};
|
||||
|
||||
lovrGraphicsSetShapeData(cube, 78);
|
||||
lovrGraphicsPrepare();
|
||||
lovrGraphicsSetDefaultShader(SHADER_SKYBOX);
|
||||
Material* material = lovrGraphicsGetMaterial();
|
||||
Texture* lastTexture = lovrMaterialGetTexture(material, TEXTURE_ENVIRONMENT_MAP);
|
||||
lovrMaterialSetTexture(material, TEXTURE_ENVIRONMENT_MAP, texture);
|
||||
lovrGraphicsDrawPrimitive(GL_TRIANGLE_STRIP, 0, 0, 0);
|
||||
lovrMaterialSetTexture(material, TEXTURE_ENVIRONMENT_MAP, lastTexture);
|
||||
} else if (texture->type == TEXTURE_2D) {
|
||||
Material* material = lovrGraphicsGetMaterial();
|
||||
Texture* lastTexture = lovrMaterialGetTexture(material, TEXTURE_DIFFUSE);
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
||||
lovrGraphicsSphere(NULL, 30);
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, lastTexture);
|
||||
}
|
||||
|
||||
lovrGraphicsSetCullingEnabled(wasCulling);
|
||||
|
@ -922,9 +930,13 @@ void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAl
|
|||
lovrGraphicsScale(MATRIX_MODEL, scale, scale, scale);
|
||||
lovrGraphicsTranslate(MATRIX_MODEL, 0, offsety, 0);
|
||||
lovrGraphicsSetDefaultShader(SHADER_FONT);
|
||||
Material* material = lovrGraphicsGetMaterial();
|
||||
Texture* lastTexture = lovrMaterialGetTexture(material, TEXTURE_DIFFUSE);
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, font->texture);
|
||||
glDepthMask(GL_FALSE);
|
||||
lovrGraphicsDrawPrimitive(GL_TRIANGLES, 0, 1, 0);
|
||||
glDepthMask(GL_TRUE);
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, lastTexture);
|
||||
lovrGraphicsPop();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ const char* lovrShaderColorUniforms[] = {
|
|||
};
|
||||
|
||||
const char* lovrShaderTextureUniforms[] = {
|
||||
"lovrDiffuseTexture"
|
||||
"lovrDiffuseTexture",
|
||||
"lovrEnvironmentTexture"
|
||||
};
|
||||
|
||||
const char* lovrShaderVertexPrefix = ""
|
||||
|
@ -37,7 +38,8 @@ const char* lovrShaderFragmentPrefix = ""
|
|||
"out vec4 lovrFragColor; \n"
|
||||
"uniform vec4 lovrColor; \n"
|
||||
"uniform vec4 lovrDiffuseColor; \n"
|
||||
"uniform sampler2D lovrDiffuseTexture; \n";
|
||||
"uniform sampler2D lovrDiffuseTexture; \n"
|
||||
"uniform samplerCube lovrEnvironmentTexture; \n";
|
||||
|
||||
const char* lovrShaderVertexSuffix = ""
|
||||
"void main() { \n"
|
||||
|
@ -69,9 +71,8 @@ const char* lovrSkyboxVertexShader = ""
|
|||
|
||||
const char* lovrSkyboxFragmentShader = ""
|
||||
"in vec3 texturePosition; \n"
|
||||
"uniform samplerCube cube; \n"
|
||||
"vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) { \n"
|
||||
" return graphicsColor * texture(cube, texturePosition); \n"
|
||||
" return graphicsColor * texture(lovrEnvironmentTexture, texturePosition); \n"
|
||||
"}";
|
||||
|
||||
const char* lovrFontFragmentShader = ""
|
||||
|
|
|
@ -9,6 +9,7 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
TEXTURE_DIFFUSE,
|
||||
TEXTURE_ENVIRONMENT_MAP,
|
||||
MAX_MATERIAL_TEXTURES
|
||||
} MaterialTexture;
|
||||
|
||||
|
|
Loading…
Reference in New Issue