|
|
@ -85,18 +85,18 @@ |
|
|
|
#define WINGDIAPI __declspec(dllimport) |
|
|
|
#endif |
|
|
|
|
|
|
|
#include <GL/gl.h> // OpenGL 1.1 library |
|
|
|
#include <GL/gl.h> // OpenGL 1.1 library |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
|
#define GRAPHICS_API_OPENGL_33 |
|
|
|
#define GRAPHICS_API_OPENGL_33 // OpenGL 2.1 uses mostly OpenGL 3.3 Core functionality |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
|
#if defined(__APPLE__) |
|
|
|
#include <OpenGL/gl3.h> // OpenGL 3 library for OSX |
|
|
|
#include <OpenGL/gl3ext.h> |
|
|
|
#include <OpenGL/gl3.h> // OpenGL 3 library for OSX |
|
|
|
#include <OpenGL/gl3ext.h> // OpenGL 3 extensions library for OSX |
|
|
|
#else |
|
|
|
#define GLAD_IMPLEMENTATION |
|
|
|
#if defined(RLGL_STANDALONE) |
|
|
@ -108,17 +108,17 @@ |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
#include <EGL/egl.h> // EGL library |
|
|
|
#include <GLES2/gl2.h> // OpenGL ES 2.0 library |
|
|
|
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library |
|
|
|
#include <EGL/egl.h> // EGL library |
|
|
|
#include <GLES2/gl2.h> // OpenGL ES 2.0 library |
|
|
|
#include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(RLGL_STANDALONE) |
|
|
|
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()] |
|
|
|
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()] |
|
|
|
#endif |
|
|
|
|
|
|
|
#if !defined(GRAPHICS_API_OPENGL_11) && defined(SUPPORT_DISTORTION_SHADER) |
|
|
|
#include "shader_distortion.h" // Distortion shader to be embedded |
|
|
|
#include "shader_distortion.h" // Distortion shader to be embedded |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -307,17 +307,17 @@ static bool vrStereoRender = false; // VR stereo rendering enabled/disabled |
|
|
|
|
|
|
|
// Extension supported flag: Anisotropic filtering |
|
|
|
static bool texAnisotropicFilterSupported = false; // Anisotropic texture filtering support |
|
|
|
static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supported (minimum is 2.0f) |
|
|
|
static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supported (minimum is 2.0f) |
|
|
|
|
|
|
|
// Extension supported flag: Clamp mirror wrap mode |
|
|
|
static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported |
|
|
|
static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
// NOTE: VAO functionality is exposed through extensions (OES) |
|
|
|
static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays; |
|
|
|
static PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray; |
|
|
|
static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays; |
|
|
|
//static PFNGLISVERTEXARRAYOESPROC glIsVertexArray; // NOTE: Fails in WebGL, omitted |
|
|
|
//static PFNGLISVERTEXARRAYOESPROC glIsVertexArray; // NOTE: Fails in WebGL, omitted |
|
|
|
#endif |
|
|
|
|
|
|
|
static bool debugMarkerSupported = false; |
|
|
@ -658,13 +658,11 @@ void rlEnd(void) |
|
|
|
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits) |
|
|
|
currentDepth += (1.0f/20000.0f); |
|
|
|
|
|
|
|
// TODO: Verify internal buffers limits |
|
|
|
// NOTE: Before launching draw, verify no matrix are left in the stack! |
|
|
|
// NOTE: Probably a lines/triangles margin should be left, rlEnd could be called |
|
|
|
// after an undetermined number of triangles buffered (check shapes::DrawPoly()) |
|
|
|
// Verify internal buffers limits |
|
|
|
// NOTE: This check is combined with usage of rlCheckBufferLimit() |
|
|
|
if ((lines.vCounter/2 >= MAX_LINES_BATCH - 2) || |
|
|
|
(triangles.vCounter/3 >= MAX_TRIANGLES_BATCH - 16) || |
|
|
|
(quads.vCounter/4 >= MAX_QUADS_BATCH - 2)) rlglDraw(); |
|
|
|
(triangles.vCounter/3 >= MAX_TRIANGLES_BATCH - 3) || |
|
|
|
(quads.vCounter/4 >= MAX_QUADS_BATCH - 4)) rlglDraw(); |
|
|
|
} |
|
|
|
|
|
|
|
// Define one vertex (position) |
|
|
@ -1313,6 +1311,22 @@ int rlGetVersion(void) |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
// Check internal buffer overflow for a given number of vertex |
|
|
|
bool rlCheckBufferLimit(int type, int vCount) |
|
|
|
{ |
|
|
|
bool overflow = false; |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
switch (type) |
|
|
|
{ |
|
|
|
case RL_LINES: overflow = ((lines.vCounter + vCount)/2 >= MAX_LINES_BATCH); break; |
|
|
|
case RL_TRIANGLES: overflow = ((triangles.vCounter + vCount)/3 >= MAX_TRIANGLES_BATCH); break; |
|
|
|
case RL_QUADS: overflow = ((quads.vCounter + vCount)/4 >= MAX_QUADS_BATCH); break; |
|
|
|
default: break; |
|
|
|
} |
|
|
|
#endif |
|
|
|
return overflow; |
|
|
|
} |
|
|
|
|
|
|
|
// Set debug marker |
|
|
|
void rlSetDebugMarker(const char *text) |
|
|
|
{ |
|
|
@ -1325,7 +1339,7 @@ void rlSetDebugMarker(const char *text) |
|
|
|
// NOTE: External loader function could be passed as a pointer |
|
|
|
void rlLoadExtensions(void *loader) |
|
|
|
{ |
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
|
// NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) |
|
|
|
#if !defined(__APPLE__) |
|
|
|
if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(LOG_WARNING, "GLAD: Cannot load OpenGL extensions"); |
|
|
@ -1448,7 +1462,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
|
else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, (unsigned char *)data + mipOffset); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
|
if (format == UNCOMPRESSED_GRAYSCALE) |
|
|
|
{ |
|
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE }; |
|
|
|