mirror of https://github.com/bjornbytes/lovr.git
Canvas mipmaps flag;
This commit is contained in:
parent
06fa846680
commit
74fec01e60
|
@ -944,7 +944,7 @@ int l_lovrGraphicsNewShaderBlock(lua_State* L) {
|
|||
int l_lovrGraphicsNewCanvas(lua_State* L) {
|
||||
int width = luaL_checkinteger(L, 1);
|
||||
int height = luaL_checkinteger(L, 2);
|
||||
CanvasFlags flags = { .depth = DEPTH_D16, .stereo = true, .msaa = 0 };
|
||||
CanvasFlags flags = { .depth = DEPTH_D16, .stereo = true, .msaa = 0, .mipmaps = true };
|
||||
|
||||
if (lua_istable(L, 3)) {
|
||||
lua_getfield(L, 3, "depth");
|
||||
|
@ -962,6 +962,10 @@ int l_lovrGraphicsNewCanvas(lua_State* L) {
|
|||
lua_getfield(L, 3, "msaa");
|
||||
flags.msaa = lua_isnil(L, -1) ? flags.msaa : luaL_checkinteger(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 3, "mipmaps");
|
||||
flags.mipmaps = lua_isnil(L, -1) ? flags.mipmaps : lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
Canvas* canvas = lovrCanvasCreate(width, height, flags);
|
||||
|
|
|
@ -21,6 +21,7 @@ typedef struct {
|
|||
DepthFormat depth;
|
||||
bool stereo;
|
||||
int msaa;
|
||||
bool mipmaps;
|
||||
} CanvasFlags;
|
||||
|
||||
typedef struct Canvas Canvas;
|
||||
|
|
|
@ -1421,6 +1421,16 @@ void lovrCanvasResolve(Canvas* canvas) {
|
|||
glReadBuffer(0);
|
||||
glDrawBuffers(canvas->count, buffers);
|
||||
}
|
||||
|
||||
if (canvas->flags.mipmaps) {
|
||||
for (int i = 0; i < canvas->count; i++) {
|
||||
Texture* texture = canvas->attachments[i].texture;
|
||||
if (texture->mipmapCount > 1) {
|
||||
lovrGpuBindTexture(texture, 0);
|
||||
glGenerateMipmap(texture->target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lovrCanvasBlit(Canvas* canvas) {
|
||||
|
|
Loading…
Reference in New Issue