diff options
| author | Ray <[email protected]> | 2023-11-02 18:13:37 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-11-02 18:13:37 +0100 |
| commit | 807516a991deef0eae23980b9a829721028ab8c8 (patch) | |
| tree | be17f3ecbb778df572e6f56d0d7a5b94703eae1a | |
| parent | b40f93b9e35ca8b2aa2e897eadb90187c2f93d4a (diff) | |
| download | raylib-807516a991deef0eae23980b9a829721028ab8c8.tar.gz raylib-807516a991deef0eae23980b9a829721028ab8c8.zip | |
Support OpenGL ES 3.0 building on Web
For some reason, the equivalent requested context (WebGL 2.0) is not provided, despite being properly requested.
| -rw-r--r-- | src/platforms/rcore_web.c | 5 | ||||
| -rw-r--r-- | src/rlgl.h | 17 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index c5bd5536..23361618 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -45,7 +45,9 @@ * **********************************************************************************************/ -#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management +#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 + // NOTE: Already provided by rlgl implementation (on glad.h) +#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management #include <emscripten/emscripten.h> // Emscripten functionality for C #include <emscripten/html5.h> // Emscripten HTML5 library @@ -759,6 +761,7 @@ int InitPlatform(void) } else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context { + // TODO: It seems WebGL 2.0 context is not set despite being requested glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); @@ -799,10 +799,14 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #define GLAD_FREE RL_FREE #define GLAD_GL_IMPLEMENTATION - #include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers + #include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers #endif -#if defined(GRAPHICS_API_OPENGL_ES2) +#if defined(GRAPHICS_API_OPENGL_ES3) + #include <GLES3/gl3.h> // OpenGL ES 3.0 library + #define GL_GLEXT_PROTOTYPES + #include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library +#elif defined(GRAPHICS_API_OPENGL_ES2) // NOTE: OpenGL ES 2.0 can be enabled on PLATFORM_DESKTOP, // in that case, functions are loaded from a custom glad for OpenGL ES 2.0 #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL) @@ -823,9 +827,6 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); #endif #endif -#if defined(GRAPHICS_API_OPENGL_ES3) - #include <GLES3/gl3.h> -#endif #include <stdlib.h> // Required for: malloc(), free() #include <string.h> // Required for: strcmp(), strlen() [Used in rlglInit(), on extensions loading] @@ -902,8 +903,10 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #if defined(GRAPHICS_API_OPENGL_ES2) #define glClearDepth glClearDepthf - #define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER - #define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER + #if !defined(GRAPHICS_API_OPENGL_ES3) + #define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER + #define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER + #endif #endif // Default shader vertex attribute names to set location points |
