mirror of https://github.com/bjornbytes/lovr.git
Resolve MSAA properly;
This commit is contained in:
parent
2cbd565522
commit
8bcaacd63c
|
@ -94,6 +94,14 @@ void lovrCanvasDestroy(void* ref) {
|
|||
lovrTextureDestroy(ref);
|
||||
}
|
||||
|
||||
void lovrCanvasResolve(Canvas* canvas) {
|
||||
int width = canvas->texture.width;
|
||||
int height = canvas->texture.height;
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, canvas->framebuffer);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, canvas->resolveFramebuffer);
|
||||
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
}
|
||||
|
||||
TextureFormat lovrCanvasGetFormat(Canvas* canvas) {
|
||||
return canvas->texture.slices[0]->format;
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@ bool lovrCanvasSupportsFormat(TextureFormat format);
|
|||
|
||||
Canvas* lovrCanvasCreate(int width, int height, TextureFormat format, int msaa, bool depth, bool stencil);
|
||||
void lovrCanvasDestroy(void* ref);
|
||||
void lovrCanvasResolve(Canvas* canvas);
|
||||
TextureFormat lovrCanvasGetFormat(Canvas* canvas);
|
||||
int lovrCanvasGetMSAA(Canvas* canvas);
|
||||
|
|
|
@ -355,11 +355,7 @@ void lovrGraphicsSetCanvas(Canvas** canvas, int count) {
|
|||
lovrAssert(count <= MAX_CANVASES, "Attempt to simultaneously render to %d canvases (the maximum is %d)", count, MAX_CANVASES);
|
||||
|
||||
if (state.canvasCount > 0 && state.canvas[0]->msaa > 0) {
|
||||
int width = state.canvas[0]->texture.width;
|
||||
int height = state.canvas[0]->texture.height;
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, state.canvas[0]->framebuffer);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, state.canvas[0]->resolveFramebuffer);
|
||||
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
lovrCanvasResolve(state.canvas[0]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -1108,6 +1104,10 @@ void lovrGraphicsPushLayer(Layer layer) {
|
|||
}
|
||||
|
||||
void lovrGraphicsPopLayer() {
|
||||
if (state.canvasCount == 0 && state.layers[state.layer].canvas) {
|
||||
lovrCanvasResolve(state.layers[state.layer].canvas);
|
||||
}
|
||||
|
||||
if (--state.layer < 0) {
|
||||
lovrThrow("Layer underflow");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue