From 82b7002bbfd829f248d8192e1fccf99eb84313e8 Mon Sep 17 00:00:00 2001 From: Jean-nicolas STRAUSS Date: Fri, 17 May 2024 22:08:30 +0200 Subject: [PATCH 1/3] Fixes emscripten compilation #2 --- library/cgp/13_opengl/fbo/fbo.cpp | 9 +++++++-- library/cgp/opengl_include.hpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library/cgp/13_opengl/fbo/fbo.cpp b/library/cgp/13_opengl/fbo/fbo.cpp index 76f434c..3b27eb1 100644 --- a/library/cgp/13_opengl/fbo/fbo.cpp +++ b/library/cgp/13_opengl/fbo/fbo.cpp @@ -43,8 +43,13 @@ namespace cgp{ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture.id, 0); // No color buffer is used in depth mode - glDrawBuffer(GL_NONE); - glReadBuffer(GL_NONE); + #ifdef __EMSCRIPTEN__ + // associate the depth-buffer + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buffer_id); + #else + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + #endif } // Reset the standard framebuffer to output on the screen diff --git a/library/cgp/opengl_include.hpp b/library/cgp/opengl_include.hpp index e33acc3..64a7fab 100644 --- a/library/cgp/opengl_include.hpp +++ b/library/cgp/opengl_include.hpp @@ -49,7 +49,7 @@ // Special case for EMScripten (don't rely on glad) #ifdef __EMSCRIPTEN__ #include -#include // OpenGL ES 3 +#include // OpenGL ES 3 #endif From efd570496fb71f775d78b8bc729c0536e58ea465 Mon Sep 17 00:00:00 2001 From: Jean-nicolas STRAUSS Date: Fri, 17 May 2024 22:17:53 +0200 Subject: [PATCH 2/3] proper indent --- library/cgp/13_opengl/fbo/fbo.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/cgp/13_opengl/fbo/fbo.cpp b/library/cgp/13_opengl/fbo/fbo.cpp index 3b27eb1..36f3174 100644 --- a/library/cgp/13_opengl/fbo/fbo.cpp +++ b/library/cgp/13_opengl/fbo/fbo.cpp @@ -34,7 +34,7 @@ namespace cgp{ // Initialize texture texture.initialize_texture_2d_on_gpu(width, height, GL_DEPTH_COMPONENT, GL_TEXTURE_2D,GL_REPEAT,GL_REPEAT,GL_NEAREST,GL_NEAREST); float borderColor[] = { 1.0, 1.0, 1.0, 1.0 }; - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); // Create frame buffer glGenFramebuffers(1, &id); @@ -44,12 +44,12 @@ namespace cgp{ // No color buffer is used in depth mode #ifdef __EMSCRIPTEN__ - // associate the depth-buffer + // associate the depth-buffer glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buffer_id); - #else - glDrawBuffer(GL_NONE); - glReadBuffer(GL_NONE); - #endif + #else + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + #endif } // Reset the standard framebuffer to output on the screen From cf413e6ad5af2565e39e7c935fc5fa76a0b73dc1 Mon Sep 17 00:00:00 2001 From: Jean-nicolas STRAUSS Date: Sat, 18 May 2024 01:36:00 +0200 Subject: [PATCH 3/3] error --- library/cgp/13_opengl/fbo/fbo.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/cgp/13_opengl/fbo/fbo.cpp b/library/cgp/13_opengl/fbo/fbo.cpp index 36f3174..1122137 100644 --- a/library/cgp/13_opengl/fbo/fbo.cpp +++ b/library/cgp/13_opengl/fbo/fbo.cpp @@ -43,10 +43,7 @@ namespace cgp{ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture.id, 0); // No color buffer is used in depth mode - #ifdef __EMSCRIPTEN__ - // associate the depth-buffer - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buffer_id); - #else + #ifndef __EMSCRIPTEN__ glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); #endif