Browse Source

Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop

pull/79/head
victorfisac 9 years ago
parent
commit
f874fdc1ad
6 changed files with 21987 additions and 67 deletions
  1. +42
    -0
      src/core.c
  2. +7684
    -0
      src/glad.c
  3. +14241
    -0
      src/glad.h
  4. +1
    -2
      src/raymath.h
  5. +6
    -56
      src/rlgl.c
  6. +13
    -9
      src/rlgl.h

+ 42
- 0
src/core.c View File

@ -54,8 +54,18 @@
#include <errno.h> // Macros for reporting and retrieving error conditions through error codes #include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #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 //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
#include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management #include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management
#ifdef __linux #ifdef __linux
#define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting
#define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window
@ -1378,6 +1388,38 @@ static void InitDisplay(int width, int height)
glfwMakeContextCurrent(window); 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) // 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 // If not set, swap interval uses GPU v-sync configuration
// Framerate can be setup using SetTargetFPS() // Framerate can be setup using SetTargetFPS()

+ 7684
- 0
src/glad.c
File diff suppressed because it is too large
View File


+ 14241
- 0
src/glad.h
File diff suppressed because it is too large
View File


+ 1
- 2
src/raymath.h View File

@ -170,6 +170,7 @@ RMDEF void QuaternionTransform(Quaternion *q, Matrix mat); // Transfo
#endif // notdef RAYMATH_EXTERN_INLINE #endif // notdef RAYMATH_EXTERN_INLINE
#endif // RAYMATH_H
//////////////////////////////////////////////////////////////////// end of header file //////////////////////////////////////////////////////////////////// end of header file
#if defined(RAYMATH_IMPLEMENTATION) || defined(RAYMATH_EXTERN_INLINE) #if defined(RAYMATH_IMPLEMENTATION) || defined(RAYMATH_EXTERN_INLINE)
@ -1096,5 +1097,3 @@ RMDEF void QuaternionTransform(Quaternion *q, Matrix mat)
} }
#endif // RAYMATH_IMPLEMENTATION #endif // RAYMATH_IMPLEMENTATION
#endif // RAYMATH_H

+ 6
- 56
src/rlgl.c View File

@ -43,13 +43,12 @@
#endif #endif
#if defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_33)
#define GLEW_STATIC
#ifdef __APPLE__ // OpenGL include for OSX #ifdef __APPLE__ // OpenGL include for OSX
#include <OpenGL/gl3.h> #include <OpenGL/gl3.h>
#else #else
cp">#include <GL/glew.h> // GLEW extensions loading lib o">//#define GLEW_STATIC
//#include sa">"glad.h" // glad extensions loading lib: ERRORS: windows.h //#include o"><GL/glew.h> // GLEW header, includes OpenGL headers
o">//#include "gl_core_3_3.h" // glLoadGen extension loading lib: ERRORS: windows.h cp">#include "glad.h" // glad header, includes OpenGL headers
#endif #endif
#endif #endif
@ -896,59 +895,10 @@ void rlglInit(void)
#if defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_33)
#define GLEW_EXTENSIONS_LOADER // NOTE: On OpenGL 3.3 VAO and NPOT are supported by default
#if defined(GLEW_EXTENSIONS_LOADER) vaoSupported = true;
// Initialize extensions using GLEW npotSupported = true;
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");
vaoSupported = true;
npotSupported = true;
}
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");
vaoSupported = true;
npotSupported = true;
}
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
#elif defined(GLLOADGEN_EXTENSIONS_LOADER)
// NOTE: glLoadGen already generates a header with required OpenGL version and core extensions
if (ogl_LoadFunctions() != ogl_LOAD_FAILED)
{
TraceLog(INFO, "OpenGL 3.3 Core profile supported");
vaoSupported = true;
npotSupported = true;
}
else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
#endif
// NOTE: We don't need to check again supported extensions but we do (in case GLEW is replaced sometime) // NOTE: We don't need to check again supported extensions but we do (in case GLEW is replaced sometime)
// We get a list of available extensions and we check for some of them (compressed textures) // We get a list of available extensions and we check for some of them (compressed textures)
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt); glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);

+ 13
- 9
src/rlgl.h View File

@ -36,12 +36,7 @@
#include "utils.h" // Required for function TraceLog() #include "utils.h" // Required for function TraceLog()
#endif #endif
#if defined(RLGL_STANDALONE) #include "raymath.h"
#define RAYMATH_IMPLEMENTATION // Use raymath as a header-only library (includes implementation)
#define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint)
#define RAYMATH_STANDALONE // Not dependent on raylib.h structs: Vector3, Matrix
#include "raymath.h" // Required for Vector3 and Matrix functions
#endif
// Select desired OpenGL version // Select desired OpenGL version
// NOTE: Those preprocessor defines are only used on rlgl module, // NOTE: Those preprocessor defines are only used on rlgl module,
@ -131,6 +126,12 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
COMPRESSED_ASTC_8x8_RGBA // 2 bpp COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} TextureFormat; } TextureFormat;
// Bounding box type
typedef struct BoundingBox {
Vector3 min;
Vector3 max;
} BoundingBox;
// Mesh with vertex data type // Mesh with vertex data type
// NOTE: If using OpenGL 1.1, data loaded in CPU; if OpenGL 3.3+ data loaded in GPU (vaoId) // NOTE: If using OpenGL 1.1, data loaded in CPU; if OpenGL 3.3+ data loaded in GPU (vaoId)
@ -177,10 +178,13 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
} Shader; } Shader;
// Texture2D type // Texture2D type
// NOTE: Data stored in GPU memory
typedef struct Texture2D { typedef struct Texture2D {
unsigned int id; // Texture id unsigned int id; // OpenGL texture id
int width; int width; // Texture base width
int height; int height; // Texture base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (TextureFormat)
} Texture2D; } Texture2D;
// 3d Model type // 3d Model type

||||||
x
 
000:0
Loading…
Cancel
Save