mirror of https://github.com/bjornbytes/lovr.git
Fix background colors;
This commit is contained in:
parent
cb59f64a7b
commit
fcbeccdfb1
|
@ -14,7 +14,7 @@ function lovr.load()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
lovr.graphics.getWindowPass():setClear(0x20232c)
|
lovr.graphics.setBackground(0x20232c)
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
logo = lovr.graphics.newShader([[
|
logo = lovr.graphics.newShader([[
|
||||||
|
|
|
@ -805,6 +805,23 @@ static int l_lovrGraphicsIsFormatSupported(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_lovrGraphicsGetBackground(lua_State* L) {
|
||||||
|
float color[4];
|
||||||
|
lovrGraphicsGetBackground(color);
|
||||||
|
lua_pushnumber(L, color[0]);
|
||||||
|
lua_pushnumber(L, color[1]);
|
||||||
|
lua_pushnumber(L, color[2]);
|
||||||
|
lua_pushnumber(L, color[3]);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int l_lovrGraphicsSetBackground(lua_State* L) {
|
||||||
|
float color[4];
|
||||||
|
luax_readcolor(L, 1, color);
|
||||||
|
lovrGraphicsSetBackground(color);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_lovrGraphicsGetWindowPass(lua_State* L) {
|
static int l_lovrGraphicsGetWindowPass(lua_State* L) {
|
||||||
Pass* pass = lovrGraphicsGetWindowPass();
|
Pass* pass = lovrGraphicsGetWindowPass();
|
||||||
luax_pushtype(L, Pass, pass);
|
luax_pushtype(L, Pass, pass);
|
||||||
|
@ -1481,6 +1498,8 @@ static const luaL_Reg lovrGraphics[] = {
|
||||||
{ "getFeatures", l_lovrGraphicsGetFeatures },
|
{ "getFeatures", l_lovrGraphicsGetFeatures },
|
||||||
{ "getLimits", l_lovrGraphicsGetLimits },
|
{ "getLimits", l_lovrGraphicsGetLimits },
|
||||||
{ "isFormatSupported", l_lovrGraphicsIsFormatSupported },
|
{ "isFormatSupported", l_lovrGraphicsIsFormatSupported },
|
||||||
|
{ "getBackground", l_lovrGraphicsGetBackground },
|
||||||
|
{ "setBackground", l_lovrGraphicsSetBackground },
|
||||||
{ "getWindowPass", l_lovrGraphicsGetWindowPass },
|
{ "getWindowPass", l_lovrGraphicsGetWindowPass },
|
||||||
{ "getDefaultFont", l_lovrGraphicsGetDefaultFont },
|
{ "getDefaultFont", l_lovrGraphicsGetDefaultFont },
|
||||||
{ "getBuffer", l_lovrGraphicsGetBuffer },
|
{ "getBuffer", l_lovrGraphicsGetBuffer },
|
||||||
|
|
|
@ -362,6 +362,7 @@ static struct {
|
||||||
gpu_device_info device;
|
gpu_device_info device;
|
||||||
gpu_features features;
|
gpu_features features;
|
||||||
gpu_limits limits;
|
gpu_limits limits;
|
||||||
|
float background[4];
|
||||||
Texture* window;
|
Texture* window;
|
||||||
Pass* windowPass;
|
Pass* windowPass;
|
||||||
Font* defaultFont;
|
Font* defaultFont;
|
||||||
|
@ -754,6 +755,20 @@ void lovrGraphicsGetShaderCache(void* data, size_t* size) {
|
||||||
gpu_pipeline_get_cache(data, size);
|
gpu_pipeline_get_cache(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lovrGraphicsGetBackground(float background[4]) {
|
||||||
|
background[0] = lovrMathLinearToGamma(state.background[0]);
|
||||||
|
background[1] = lovrMathLinearToGamma(state.background[1]);
|
||||||
|
background[2] = lovrMathLinearToGamma(state.background[2]);
|
||||||
|
background[3] = state.background[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
void lovrGraphicsSetBackground(float background[4]) {
|
||||||
|
state.background[0] = lovrMathGammaToLinear(background[0]);
|
||||||
|
state.background[1] = lovrMathGammaToLinear(background[1]);
|
||||||
|
state.background[2] = lovrMathGammaToLinear(background[2]);
|
||||||
|
state.background[3] = background[3];
|
||||||
|
}
|
||||||
|
|
||||||
void lovrGraphicsSubmit(Pass** passes, uint32_t count) {
|
void lovrGraphicsSubmit(Pass** passes, uint32_t count) {
|
||||||
if (!state.active) {
|
if (!state.active) {
|
||||||
return;
|
return;
|
||||||
|
@ -3409,6 +3424,10 @@ void lovrPassReset(Pass* pass) {
|
||||||
} else {
|
} else {
|
||||||
pass->target.color[i].texture = lovrGraphicsGetWindowTexture()->gpu;
|
pass->target.color[i].texture = lovrGraphicsGetWindowTexture()->gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The window pass always uses the global clear color. The intent is that exposing a global
|
||||||
|
// clear color that applies to the window/headset is more friendly than messing with passes.
|
||||||
|
lovrGraphicsGetBackground(pass->target.color[0].clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canvas->mipmap) {
|
if (canvas->mipmap) {
|
||||||
|
|
|
@ -103,6 +103,9 @@ void lovrGraphicsGetLimits(GraphicsLimits* limits);
|
||||||
bool lovrGraphicsIsFormatSupported(uint32_t format, uint32_t features);
|
bool lovrGraphicsIsFormatSupported(uint32_t format, uint32_t features);
|
||||||
void lovrGraphicsGetShaderCache(void* data, size_t* size);
|
void lovrGraphicsGetShaderCache(void* data, size_t* size);
|
||||||
|
|
||||||
|
void lovrGraphicsGetBackground(float background[4]);
|
||||||
|
void lovrGraphicsSetBackground(float background[4]);
|
||||||
|
|
||||||
void lovrGraphicsSubmit(Pass** passes, uint32_t count);
|
void lovrGraphicsSubmit(Pass** passes, uint32_t count);
|
||||||
void lovrGraphicsPresent(void);
|
void lovrGraphicsPresent(void);
|
||||||
void lovrGraphicsWait(void);
|
void lovrGraphicsWait(void);
|
||||||
|
|
|
@ -1697,6 +1697,10 @@ static Pass* openxr_getPass(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float color[4][4], depth, stencil;
|
||||||
|
lovrPassGetClear(state.pass, color, &depth, &stencil);
|
||||||
|
lovrGraphicsGetBackground(color[0]);
|
||||||
|
lovrPassSetClear(state.pass, color, depth, stencil);
|
||||||
lovrPassSetTarget(state.pass, &texture, NULL);
|
lovrPassSetTarget(state.pass, &texture, NULL);
|
||||||
lovrPassReset(state.pass);
|
lovrPassReset(state.pass);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue