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();
|
||||
|
||||
// Create window
|
||||
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)) {
|
||||
lua_getfield(L, -1, "width");
|
||||
int width = luaL_checkinteger(L, -1);
|
||||
|
@ -360,6 +366,12 @@ int l_lovrGraphicsSetFont(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrGraphicsIsGammaCorrect(lua_State* L) {
|
||||
bool gammaCorrect = lovrGraphicsIsGammaCorrect();
|
||||
lua_pushboolean(L, gammaCorrect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrGraphicsGetSystemLimits(lua_State* L) {
|
||||
GraphicsLimits limits = lovrGraphicsGetLimits();
|
||||
lua_newtable(L);
|
||||
|
@ -855,6 +867,7 @@ const luaL_Reg lovrGraphics[] = {
|
|||
{ "setDepthTest", l_lovrGraphicsSetDepthTest },
|
||||
{ "getFont", l_lovrGraphicsGetFont },
|
||||
{ "setFont", l_lovrGraphicsSetFont },
|
||||
{ "isGammaCorrect", l_lovrGraphicsIsGammaCorrect },
|
||||
{ "getSystemLimits", l_lovrGraphicsGetSystemLimits },
|
||||
{ "getLineWidth", l_lovrGraphicsGetLineWidth },
|
||||
{ "setLineWidth", l_lovrGraphicsSetLineWidth },
|
||||
|
|
|
@ -8,6 +8,7 @@ local conf = {
|
|||
physics = true,
|
||||
timer = true
|
||||
},
|
||||
gammacorrect = false,
|
||||
headset = {
|
||||
mirror = true,
|
||||
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_PROGRAM_POINT_SIZE);
|
||||
#endif
|
||||
if (state.gammaCorrect) {
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
} else {
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
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() {
|
||||
if (!state.limits.initialized) {
|
||||
#ifdef EMSCRIPTEN
|
||||
|
|
|
@ -92,6 +92,7 @@ typedef struct {
|
|||
TextureFilter defaultFilter;
|
||||
CompareMode depthTest;
|
||||
Font* font;
|
||||
bool gammaCorrect;
|
||||
GraphicsLimits limits;
|
||||
float lineWidth;
|
||||
Material* material;
|
||||
|
@ -139,6 +140,8 @@ CompareMode lovrGraphicsGetDepthTest();
|
|||
void lovrGraphicsSetDepthTest(CompareMode depthTest);
|
||||
Font* lovrGraphicsGetFont();
|
||||
void lovrGraphicsSetFont(Font* font);
|
||||
bool lovrGraphicsIsGammaCorrect();
|
||||
void lovrGraphicsSetGammaCorrect(bool gammaCorrect);
|
||||
GraphicsLimits lovrGraphicsGetLimits();
|
||||
float lovrGraphicsGetLineWidth();
|
||||
void lovrGraphicsSetLineWidth(float width);
|
||||
|
|
Loading…
Reference in New Issue