aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-06-14 15:42:04 +0200
committerraysan5 <raysan5@gmail.com>2016-06-14 15:42:04 +0200
commitc25b4cdc69999c851594f7644ce89556be039c70 (patch)
tree50df9e6a47b825671ff6fc662d1acf923ee0d77e /src
parent3a5fc0c32042714efde93c72903d2cd89c4cff50 (diff)
downloadraylib-c25b4cdc69999c851594f7644ce89556be039c70.tar.gz
raylib-c25b4cdc69999c851594f7644ce89556be039c70.zip
Move OpenGL extensions loading to rlgl
Diffstat (limited to 'src')
-rw-r--r--src/core.c20
-rw-r--r--src/rlgl.c21
-rw-r--r--src/rlgl.h3
3 files changed, 25 insertions, 19 deletions
diff --git a/src/core.c b/src/core.c
index 122453e3..bd49b549 100644
--- a/src/core.c
+++ b/src/core.c
@@ -58,10 +58,6 @@
#define PLATFORM_DESKTOP // Enable PLATFORM_DESKTOP code-base
#endif
-#if defined(PLATFORM_DESKTOP)
- #include "external/glad.h" // GLAD library: Manage OpenGL headers and extensions
-#endif
-
#if defined(PLATFORM_OCULUS)
#include "../examples/oculus_glfw_sample/OculusSDK/LibOVR/Include/OVR_CAPI_GL.h" // Oculus SDK for OpenGL
#endif
@@ -1747,19 +1743,9 @@ static void InitDisplay(int width, int height)
#endif
#if defined(PLATFORM_DESKTOP)
- // Load OpenGL 3.3 extensions using GLAD
- if (rlGetVersion() == OPENGL_33)
- {
- // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
- else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully");
-
- if (GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported");
- else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
-
- // With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans
- //if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object
- }
+ // Load OpenGL 3.3 extensions
+ // NOTE: GLFW loader function is passed as parameter
+ rlglLoadExtensions(glfwGetProcAddress);
#endif
// Enables GPU v-sync, so frames are not limited to screen refresh rate (60Hz -> 60 FPS)
diff --git a/src/rlgl.c b/src/rlgl.c
index e69ff983..26961ca9 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -872,6 +872,23 @@ int rlGetVersion(void)
#endif
}
+// Load OpenGL extensions
+// NOTE: External loader function could be passed as a pointer
+void rlglLoadExtensions(void *loader)
+{
+#if defined(GRAPHICS_API_OPENGL_33)
+ // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions
+ if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
+ else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully");
+
+ if (GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported");
+ else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
+
+ // With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans
+ //if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object
+#endif
+}
+
//----------------------------------------------------------------------------------
// Module Functions Definition - rlgl Functions
//----------------------------------------------------------------------------------
@@ -1184,11 +1201,13 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int textureForma
GLuint id = 0;
// Check texture format support by OpenGL 1.1 (compressed textures not supported)
- if ((rlGetVersion() == OPENGL_11) && (textureFormat >= 8))
+#if defined(GRAPHICS_API_OPENGL_11)
+ if (textureFormat >= 8)
{
TraceLog(WARNING, "OpenGL 1.1 does not support GPU compressed texture formats");
return id;
}
+#endif
if ((!texCompDXTSupported) && ((textureFormat == COMPRESSED_DXT1_RGB) || (textureFormat == COMPRESSED_DXT1_RGBA) ||
(textureFormat == COMPRESSED_DXT3_RGBA) || (textureFormat == COMPRESSED_DXT5_RGBA)))
diff --git a/src/rlgl.h b/src/rlgl.h
index 9c25f710..28c50b8f 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -48,7 +48,7 @@
// Choose opengl version here or just define it at compile time: -DGRAPHICS_API_OPENGL_33
//#define GRAPHICS_API_OPENGL_11 // Only available on PLATFORM_DESKTOP
-//#define GRAPHICS_API_OPENGL_33 // Only available on PLATFORM_DESKTOP
+//#define GRAPHICS_API_OPENGL_33 // Only available on PLATFORM_DESKTOP or PLATFORM_OCULUS
//#define GRAPHICS_API_OPENGL_ES2 // Only available on PLATFORM_ANDROID or PLATFORM_RPI or PLATFORM_WEB
// Security check in case no GRAPHICS_API_OPENGL_* defined
@@ -296,6 +296,7 @@ void rlglInit(void); // Initialize rlgl (shaders, VAO
void rlglClose(void); // De-init rlgl
void rlglDraw(void); // Draw VAO/VBO
void rlglInitGraphics(int offsetX, int offsetY, int width, int height); // Initialize Graphics (OpenGL stuff)
+void rlglLoadExtensions(void *loader); // Load OpenGL extensions
unsigned int rlglLoadTexture(void *data, int width, int height, int textureFormat, int mipmapCount); // Load texture in GPU
RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)