mirror of https://github.com/bjornbytes/lovr.git
lovr.graphics.isGammaCorrect; conf.lua t.gammacorrect;
This commit is contained in:
parent
8bda7a9ed8
commit
3c6437fb20
|
@ -172,10 +172,16 @@ int l_lovrGraphicsInit(lua_State* L) {
|
||||||
|
|
||||||
lovrGraphicsInit();
|
lovrGraphicsInit();
|
||||||
|
|
||||||
// Create window
|
|
||||||
luax_pushconf(L);
|
luax_pushconf(L);
|
||||||
lua_getfield(L, -1, "window");
|
|
||||||
|
|
||||||
|
// Set gamma correct
|
||||||
|
lua_getfield(L, -1, "gammacorrect");
|
||||||
|
bool gammaCorrect = lua_toboolean(L, -1);
|
||||||
|
lovrGraphicsSetGammaCorrect(gammaCorrect);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
// Create window if needed
|
||||||
|
lua_getfield(L, -1, "window");
|
||||||
if (!lua_isnil(L, -1)) {
|
if (!lua_isnil(L, -1)) {
|
||||||
lua_getfield(L, -1, "width");
|
lua_getfield(L, -1, "width");
|
||||||
int width = luaL_checkinteger(L, -1);
|
int width = luaL_checkinteger(L, -1);
|
||||||
|
@ -360,6 +366,12 @@ int l_lovrGraphicsSetFont(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_lovrGraphicsIsGammaCorrect(lua_State* L) {
|
||||||
|
bool gammaCorrect = lovrGraphicsIsGammaCorrect();
|
||||||
|
lua_pushboolean(L, gammaCorrect);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsGetSystemLimits(lua_State* L) {
|
int l_lovrGraphicsGetSystemLimits(lua_State* L) {
|
||||||
GraphicsLimits limits = lovrGraphicsGetLimits();
|
GraphicsLimits limits = lovrGraphicsGetLimits();
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
@ -855,6 +867,7 @@ const luaL_Reg lovrGraphics[] = {
|
||||||
{ "setDepthTest", l_lovrGraphicsSetDepthTest },
|
{ "setDepthTest", l_lovrGraphicsSetDepthTest },
|
||||||
{ "getFont", l_lovrGraphicsGetFont },
|
{ "getFont", l_lovrGraphicsGetFont },
|
||||||
{ "setFont", l_lovrGraphicsSetFont },
|
{ "setFont", l_lovrGraphicsSetFont },
|
||||||
|
{ "isGammaCorrect", l_lovrGraphicsIsGammaCorrect },
|
||||||
{ "getSystemLimits", l_lovrGraphicsGetSystemLimits },
|
{ "getSystemLimits", l_lovrGraphicsGetSystemLimits },
|
||||||
{ "getLineWidth", l_lovrGraphicsGetLineWidth },
|
{ "getLineWidth", l_lovrGraphicsGetLineWidth },
|
||||||
{ "setLineWidth", l_lovrGraphicsSetLineWidth },
|
{ "setLineWidth", l_lovrGraphicsSetLineWidth },
|
||||||
|
|
|
@ -8,6 +8,7 @@ local conf = {
|
||||||
physics = true,
|
physics = true,
|
||||||
timer = true
|
timer = true
|
||||||
},
|
},
|
||||||
|
gammacorrect = false,
|
||||||
headset = {
|
headset = {
|
||||||
mirror = true,
|
mirror = true,
|
||||||
offset = 1.7
|
offset = 1.7
|
||||||
|
|
|
@ -196,6 +196,11 @@ void lovrGraphicsCreateWindow(int w, int h, bool fullscreen, int msaa, const cha
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
if (state.gammaCorrect) {
|
||||||
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
}
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
@ -358,6 +363,14 @@ void lovrGraphicsSetFont(Font* font) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lovrGraphicsIsGammaCorrect() {
|
||||||
|
return state.gammaCorrect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lovrGraphicsSetGammaCorrect(bool gammaCorrect) {
|
||||||
|
state.gammaCorrect = gammaCorrect;
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsLimits lovrGraphicsGetLimits() {
|
GraphicsLimits lovrGraphicsGetLimits() {
|
||||||
if (!state.limits.initialized) {
|
if (!state.limits.initialized) {
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
|
|
|
@ -92,6 +92,7 @@ typedef struct {
|
||||||
TextureFilter defaultFilter;
|
TextureFilter defaultFilter;
|
||||||
CompareMode depthTest;
|
CompareMode depthTest;
|
||||||
Font* font;
|
Font* font;
|
||||||
|
bool gammaCorrect;
|
||||||
GraphicsLimits limits;
|
GraphicsLimits limits;
|
||||||
float lineWidth;
|
float lineWidth;
|
||||||
Material* material;
|
Material* material;
|
||||||
|
@ -139,6 +140,8 @@ CompareMode lovrGraphicsGetDepthTest();
|
||||||
void lovrGraphicsSetDepthTest(CompareMode depthTest);
|
void lovrGraphicsSetDepthTest(CompareMode depthTest);
|
||||||
Font* lovrGraphicsGetFont();
|
Font* lovrGraphicsGetFont();
|
||||||
void lovrGraphicsSetFont(Font* font);
|
void lovrGraphicsSetFont(Font* font);
|
||||||
|
bool lovrGraphicsIsGammaCorrect();
|
||||||
|
void lovrGraphicsSetGammaCorrect(bool gammaCorrect);
|
||||||
GraphicsLimits lovrGraphicsGetLimits();
|
GraphicsLimits lovrGraphicsGetLimits();
|
||||||
float lovrGraphicsGetLineWidth();
|
float lovrGraphicsGetLineWidth();
|
||||||
void lovrGraphicsSetLineWidth(float width);
|
void lovrGraphicsSetLineWidth(float width);
|
||||||
|
|
Loading…
Reference in New Issue