aboutsummaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-01-22 15:36:56 +0100
committervictorfisac <victorfisac@gmail.com>2016-01-22 15:36:56 +0100
commitf874fdc1addf2cb6aba788bc8879b76269c7a29d (patch)
tree9f64acf4616f47b285b5022656c0d0aad8d0a053 /src/core.c
parentfcd30c5649f28d0d9c867712898fc5537f176c85 (diff)
parent4e57bd1f18996990546920f2242a58894c6cec81 (diff)
downloadraylib-f874fdc1addf2cb6aba788bc8879b76269c7a29d.tar.gz
raylib-f874fdc1addf2cb6aba788bc8879b76269c7a29d.zip
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index f55dba50..9b068300 100644
--- a/src/core.c
+++ b/src/core.c
@@ -54,8 +54,18 @@
#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
+
+ #define GLAD_EXTENSIONS_LOADER
+ #if defined(GLEW_EXTENSIONS_LOADER)
+ #define GLEW_STATIC
+ #include <GL/glew.h> // GLEW extensions loading lib
+ #elif defined(GLAD_EXTENSIONS_LOADER)
+ #include "glad.h" // GLAD library: Manage OpenGL headers and extensions
+ #endif
+
//#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
#include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management
+
#ifdef __linux
#define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting
#define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window
@@ -1378,6 +1388,38 @@ static void InitDisplay(int width, int height)
glfwMakeContextCurrent(window);
+ // Extensions initialization for OpenGL 3.3
+ if (rlGetVersion() == OPENGL_33)
+ {
+ #if defined(GLEW_EXTENSIONS_LOADER)
+ // Initialize extensions using GLEW
+ glewExperimental = 1; // Needed for core profile
+ GLenum error = glewInit();
+
+ if (error != GLEW_OK) TraceLog(ERROR, "Failed to initialize GLEW - Error Code: %s\n", glewGetErrorString(error));
+
+ if (glewIsSupported("GL_VERSION_3_3")) TraceLog(INFO, "OpenGL 3.3 Core profile supported");
+ else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
+
+ // With GLEW, we can check if an extension has been loaded in two ways:
+ //if (GLEW_ARB_vertex_array_object) { }
+ //if (glewIsSupported("GL_ARB_vertex_array_object")) { }
+
+ // NOTE: GLEW is a big library that loads ALL extensions, we can use some alternative to load only required ones
+ // Alternatives: glLoadGen, glad, libepoxy
+ #elif defined(GLAD_EXTENSIONS_LOADER)
+ // NOTE: glad is generated and contains only required OpenGL version and Core extensions
+ //if (!gladLoadGL()) TraceLog(ERROR, "Failed to initialize glad\n");
+ if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) TraceLog(ERROR, "Failed to initialize glad\n"); // No GLFW3 in this module...
+
+ 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
+ }
+
// Enables GPU v-sync, so frames are not limited to screen refresh rate (60Hz -> 60 FPS)
// If not set, swap interval uses GPU v-sync configuration
// Framerate can be setup using SetTargetFPS()