summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-05-31 18:36:33 +0200
committerRay <[email protected]>2023-05-31 18:36:33 +0200
commite497603678823dc93f01dd9686819a92d780ad67 (patch)
treea07846b9f57b7cd42e27fd221d50dc972d9c6bf5 /src
parenta18667c2e9a3a815ab37a915e582e8906ff9cace (diff)
downloadraylib-e497603678823dc93f01dd9686819a92d780ad67.tar.gz
raylib-e497603678823dc93f01dd9686819a92d780ad67.zip
ADDED: Experimental support for OpenGL ES 3.0 -WIP-
Just added the required flags to request the OpenGL ES 3.0 context but it has not been tested...
Diffstat (limited to 'src')
-rw-r--r--src/rcore.c16
-rw-r--r--src/rlgl.h19
2 files changed, 28 insertions, 7 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 7a31b5ed..af65cebf 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -291,6 +291,7 @@
#if defined(PLATFORM_WEB)
#define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL)
+ //#define GLFW_INCLUDE_ES3 // GLFW3: Enable OpenGL ES 3.0 (transalted to WebGL2?)
#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
@@ -2451,7 +2452,7 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
{
VrStereoConfig config = { 0 };
- if ((rlGetVersion() == RL_OPENGL_33) || (rlGetVersion() == RL_OPENGL_ES_20))
+ if ((rlGetVersion() == RL_OPENGL_33) || (rlGetVersion() >= RL_OPENGL_ES_20))
{
// Compute aspect ratio
float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution;
@@ -4174,6 +4175,17 @@ static bool InitGraphicsDevice(int width, int height)
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
#endif
}
+ else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context
+ {
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
+#if defined(PLATFORM_DESKTOP)
+ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
+#else
+ glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
+#endif
+ }
#if defined(PLATFORM_DESKTOP)
// NOTE: GLFW 3.4+ defers initialization of the Joystick subsystem on the first call to any Joystick related functions.
@@ -4543,7 +4555,7 @@ static bool InitGraphicsDevice(int width, int height)
const EGLint framebufferAttribs[] =
{
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Type of context support -> Required on RPI?
+ EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
#if defined(PLATFORM_DRM)
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android!
#endif
diff --git a/src/rlgl.h b/src/rlgl.h
index 85a8ec36..f0bdf3cd 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -26,6 +26,7 @@
* #define GRAPHICS_API_OPENGL_33
* #define GRAPHICS_API_OPENGL_43
* #define GRAPHICS_API_OPENGL_ES2
+* #define GRAPHICS_API_OPENGL_ES3
* Use selected OpenGL graphics backend, should be supported by platform
* Those preprocessor defines are only used on rlgl module, if OpenGL version is
* required by any other module, use rlGetVersion() to check it
@@ -178,6 +179,11 @@
#define GRAPHICS_API_OPENGL_33
#endif
+// OpenGL ES 3.0 uses OpenGL ES 2.0 functionality (and more)
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ #define GRAPHICS_API_OPENGL_ES2
+#endif
+
// Support framebuffer objects by default
// NOTE: Some driver implementation do not support it, despite they should
#define RLGL_RENDER_TEXTURES_HINT
@@ -382,7 +388,8 @@ typedef enum {
RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
- RL_OPENGL_ES_20 // OpenGL ES 2.0 (GLSL 100)
+ RL_OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100)
+ RL_OPENGL_ES_30 // OpenGL ES 3.0 (GLSL 300 es)
} rlGlVersion;
// Trace log level
@@ -2389,15 +2396,17 @@ int rlGetVersion(void)
#endif
#if defined(GRAPHICS_API_OPENGL_21)
glVersion = RL_OPENGL_21;
+#elif defined(GRAPHICS_API_OPENGL_43)
+ glVersion = RL_OPENGL_43;
#elif defined(GRAPHICS_API_OPENGL_33)
glVersion = RL_OPENGL_33;
#endif
-#if defined(GRAPHICS_API_OPENGL_43)
- glVersion = RL_OPENGL_43;
-#endif
-#if defined(GRAPHICS_API_OPENGL_ES2)
+#if defined(GRAPHICS_API_OPENGL_ES3)
+ glVersion = RL_OPENGL_ES_30;
+#elif defined(GRAPHICS_API_OPENGL_ES2)
glVersion = RL_OPENGL_ES_20;
#endif
+
return glVersion;
}