|
@ -136,7 +136,8 @@ |
|
|
// This is the maximum amount of elements (quads) per batch |
|
|
// This is the maximum amount of elements (quads) per batch |
|
|
// NOTE: Be careful with text, every letter maps to a quad |
|
|
// NOTE: Be careful with text, every letter maps to a quad |
|
|
#define DEFAULT_BATCH_BUFFER_ELEMENTS 8192 |
|
|
#define DEFAULT_BATCH_BUFFER_ELEMENTS 8192 |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
// We reduce memory sizes for embedded systems (RPI and HTML5) |
|
|
// We reduce memory sizes for embedded systems (RPI and HTML5) |
|
|
// NOTE: On HTML5 (emscripten) this is allocated on heap, |
|
|
// NOTE: On HTML5 (emscripten) this is allocated on heap, |
|
|
// by default it's only 16MB!...just take care... |
|
|
// by default it's only 16MB!...just take care... |
|
@ -811,7 +812,8 @@ typedef struct VertexBuffer { |
|
|
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) |
|
|
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
|
unsigned int *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
|
unsigned int *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
unsigned short *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
|
unsigned short *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
|
#endif |
|
|
#endif |
|
|
unsigned int vaoId; // OpenGL Vertex Array Object id |
|
|
unsigned int vaoId; // OpenGL Vertex Array Object id |
|
@ -970,7 +972,6 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight); |
|
|
//---------------------------------------------------------------------------------- |
|
|
//---------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
|
|
|
|
|
|
// Fallback to OpenGL 1.1 function calls |
|
|
// Fallback to OpenGL 1.1 function calls |
|
|
//--------------------------------------- |
|
|
//--------------------------------------- |
|
|
void rlMatrixMode(int mode) |
|
|
void rlMatrixMode(int mode) |
|
@ -1001,9 +1002,8 @@ void rlTranslatef(float x, float y, float z) { glTranslatef(x, y, z); } |
|
|
void rlRotatef(float angleDeg, float x, float y, float z) { glRotatef(angleDeg, x, y, z); } |
|
|
void rlRotatef(float angleDeg, float x, float y, float z) { glRotatef(angleDeg, x, y, z); } |
|
|
void rlScalef(float x, float y, float z) { glScalef(x, y, z); } |
|
|
void rlScalef(float x, float y, float z) { glScalef(x, y, z); } |
|
|
void rlMultMatrixf(float *matf) { glMultMatrixf(matf); } |
|
|
void rlMultMatrixf(float *matf) { glMultMatrixf(matf); } |
|
|
|
|
|
|
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
// Choose the current matrix to be transformed |
|
|
// Choose the current matrix to be transformed |
|
|
void rlMatrixMode(int mode) |
|
|
void rlMatrixMode(int mode) |
|
|
{ |
|
|
{ |
|
@ -1124,7 +1124,6 @@ void rlViewport(int x, int y, int width, int height) |
|
|
// Module Functions Definition - Vertex level operations |
|
|
// Module Functions Definition - Vertex level operations |
|
|
//---------------------------------------------------------------------------------- |
|
|
//---------------------------------------------------------------------------------- |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
|
|
|
|
|
|
// Fallback to OpenGL 1.1 function calls |
|
|
// Fallback to OpenGL 1.1 function calls |
|
|
//--------------------------------------- |
|
|
//--------------------------------------- |
|
|
void rlBegin(int mode) |
|
|
void rlBegin(int mode) |
|
@ -1147,9 +1146,8 @@ void rlNormal3f(float x, float y, float z) { glNormal3f(x, y, z); } |
|
|
void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { glColor4ub(r, g, b, a); } |
|
|
void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { glColor4ub(r, g, b, a); } |
|
|
void rlColor3f(float x, float y, float z) { glColor3f(x, y, z); } |
|
|
void rlColor3f(float x, float y, float z) { glColor3f(x, y, z); } |
|
|
void rlColor4f(float x, float y, float z, float w) { glColor4f(x, y, z, w); } |
|
|
void rlColor4f(float x, float y, float z, float w) { glColor4f(x, y, z, w); } |
|
|
|
|
|
|
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
// Initialize drawing mode (how to organize vertex) |
|
|
// Initialize drawing mode (how to organize vertex) |
|
|
void rlBegin(int mode) |
|
|
void rlBegin(int mode) |
|
|
{ |
|
|
{ |
|
@ -1898,15 +1896,18 @@ int rlGetVersion(void) |
|
|
{ |
|
|
{ |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
return OPENGL_11; |
|
|
return OPENGL_11; |
|
|
#elif defined(GRAPHICS_API_OPENGL_21) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(__APPLE__) |
|
|
#if defined(__APPLE__) |
|
|
return OPENGL_33; // NOTE: Force OpenGL 3.3 on OSX |
|
|
return OPENGL_33; // NOTE: Force OpenGL 3.3 on OSX |
|
|
#else |
|
|
#else |
|
|
return OPENGL_21; |
|
|
return OPENGL_21; |
|
|
#endif |
|
|
#endif |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
return OPENGL_33; |
|
|
return OPENGL_33; |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
return OPENGL_ES_20; |
|
|
return OPENGL_ES_20; |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -1951,7 +1952,8 @@ void rlLoadExtensions(void *loader) |
|
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
if (GLAD_GL_VERSION_2_1) TRACELOG(LOG_INFO, "GL: OpenGL 2.1 profile supported"); |
|
|
if (GLAD_GL_VERSION_2_1) TRACELOG(LOG_INFO, "GL: OpenGL 2.1 profile supported"); |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
if (GLAD_GL_VERSION_3_3) TRACELOG(LOG_INFO, "GL: OpenGL 3.3 Core profile supported"); |
|
|
if (GLAD_GL_VERSION_3_3) TRACELOG(LOG_INFO, "GL: OpenGL 3.3 Core profile supported"); |
|
|
else TRACELOG(LOG_ERROR, "GL: OpenGL 3.3 Core profile not supported"); |
|
|
else TRACELOG(LOG_ERROR, "GL: OpenGL 3.3 Core profile not supported"); |
|
|
#endif |
|
|
#endif |
|
@ -2051,7 +2053,8 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
{ |
|
|
{ |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
|
#endif |
|
|
#endif |
|
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
@ -2218,7 +2221,8 @@ unsigned int rlLoadTextureCubemap(void *data, int size, int format) |
|
|
{ |
|
|
{ |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
|
GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
|
#endif |
|
|
#endif |
|
|
glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
|
glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
@ -2284,7 +2288,8 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned |
|
|
case UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
|
case UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
|
case UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
|
case UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
|
#endif |
|
|
#endif |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
case UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_R8; *glFormat = GL_RED; *glType = GL_UNSIGNED_BYTE; break; |
|
|
case UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_R8; *glFormat = GL_RED; *glType = GL_UNSIGNED_BYTE; break; |
|
|
case UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_RG8; *glFormat = GL_RG; *glType = GL_UNSIGNED_BYTE; break; |
|
|
case UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_RG8; *glFormat = GL_RG; *glType = GL_UNSIGNED_BYTE; break; |
|
|
case UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB565; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break; |
|
|
case UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB565; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break; |
|
@ -2296,7 +2301,7 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned |
|
|
case UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F; *glFormat = GL_RGB; *glType = GL_FLOAT; break; |
|
|
case UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F; *glFormat = GL_RGB; *glType = GL_FLOAT; break; |
|
|
case UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; |
|
|
case UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; |
|
|
#endif |
|
|
#endif |
|
|
#if !defined(GRAPHICS_API_OPENGL_11) |
|
|
|
|
|
|
|
|
#if !defined(GRAPHICS_API_OPENGL_11) |
|
|
case COMPRESSED_DXT1_RGB: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; |
|
|
case COMPRESSED_DXT1_RGB: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; |
|
|
case COMPRESSED_DXT1_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break; |
|
|
case COMPRESSED_DXT1_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break; |
|
|
case COMPRESSED_DXT3_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break; |
|
|
case COMPRESSED_DXT3_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break; |
|
@ -2308,7 +2313,7 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned |
|
|
case COMPRESSED_PVRT_RGBA: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU |
|
|
case COMPRESSED_PVRT_RGBA: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU |
|
|
case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
#endif |
|
|
|
|
|
|
|
|
#endif |
|
|
default: TRACELOG(LOG_WARNING, "TEXTURE: Current format not supported (%i)", format); break; |
|
|
default: TRACELOG(LOG_WARNING, "TEXTURE: Current format not supported (%i)", format); break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -2456,7 +2461,8 @@ void rlGenerateMipmaps(Texture2D *texture) |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps for provided texture format", texture->id); |
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps for provided texture format", texture->id); |
|
|
} |
|
|
} |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) |
|
|
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) |
|
|
{ |
|
|
{ |
|
|
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE |
|
|
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE |
|
@ -4140,7 +4146,8 @@ static Shader LoadShaderDefault(void) |
|
|
const char *defaultVShaderStr = |
|
|
const char *defaultVShaderStr = |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
"#version 120 \n" |
|
|
"#version 120 \n" |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
"#version 100 \n" |
|
|
"#version 100 \n" |
|
|
#endif |
|
|
#endif |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
@ -4149,7 +4156,8 @@ static Shader LoadShaderDefault(void) |
|
|
"attribute vec4 vertexColor; \n" |
|
|
"attribute vec4 vertexColor; \n" |
|
|
"varying vec2 fragTexCoord; \n" |
|
|
"varying vec2 fragTexCoord; \n" |
|
|
"varying vec4 fragColor; \n" |
|
|
"varying vec4 fragColor; \n" |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
"#version 330 \n" |
|
|
"#version 330 \n" |
|
|
"in vec3 vertexPosition; \n" |
|
|
"in vec3 vertexPosition; \n" |
|
|
"in vec2 vertexTexCoord; \n" |
|
|
"in vec2 vertexTexCoord; \n" |
|
@ -4169,14 +4177,16 @@ static Shader LoadShaderDefault(void) |
|
|
const char *defaultFShaderStr = |
|
|
const char *defaultFShaderStr = |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
"#version 120 \n" |
|
|
"#version 120 \n" |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
"#version 100 \n" |
|
|
"#version 100 \n" |
|
|
"precision mediump float; \n" // precision required for OpenGL ES2 (WebGL) |
|
|
"precision mediump float; \n" // precision required for OpenGL ES2 (WebGL) |
|
|
#endif |
|
|
#endif |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
"varying vec2 fragTexCoord; \n" |
|
|
"varying vec2 fragTexCoord; \n" |
|
|
"varying vec4 fragColor; \n" |
|
|
"varying vec4 fragColor; \n" |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
"#version 330 \n" |
|
|
"#version 330 \n" |
|
|
"in vec2 fragTexCoord; \n" |
|
|
"in vec2 fragTexCoord; \n" |
|
|
"in vec4 fragColor; \n" |
|
|
"in vec4 fragColor; \n" |
|
@ -4189,7 +4199,8 @@ static Shader LoadShaderDefault(void) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
" vec4 texelColor = texture2D(texture0, fragTexCoord); \n" // NOTE: texture2D() is deprecated on OpenGL 3.3 and ES 3.0 |
|
|
" vec4 texelColor = texture2D(texture0, fragTexCoord); \n" // NOTE: texture2D() is deprecated on OpenGL 3.3 and ES 3.0 |
|
|
" gl_FragColor = texelColor*colDiffuse*fragColor; \n" |
|
|
" gl_FragColor = texelColor*colDiffuse*fragColor; \n" |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
" vec4 texelColor = texture(texture0, fragTexCoord); \n" |
|
|
" vec4 texelColor = texture(texture0, fragTexCoord); \n" |
|
|
" finalColor = texelColor*colDiffuse*fragColor; \n" |
|
|
" finalColor = texelColor*colDiffuse*fragColor; \n" |
|
|
#endif |
|
|
#endif |
|
@ -4289,7 +4300,8 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
batch.vertexBuffer[i].colors = (unsigned char *)RL_MALLOC(bufferElements*4*4*sizeof(unsigned char)); // 4 float by color, 4 colors by quad |
|
|
batch.vertexBuffer[i].colors = (unsigned char *)RL_MALLOC(bufferElements*4*4*sizeof(unsigned char)); // 4 float by color, 4 colors by quad |
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
batch.vertexBuffer[i].indices = (unsigned int *)RL_MALLOC(bufferElements*6*sizeof(unsigned int)); // 6 int by quad (indices) |
|
|
batch.vertexBuffer[i].indices = (unsigned int *)RL_MALLOC(bufferElements*6*sizeof(unsigned int)); // 6 int by quad (indices) |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
batch.vertexBuffer[i].indices = (unsigned short *)RL_MALLOC(bufferElements*6*sizeof(unsigned short)); // 6 int by quad (indices) |
|
|
batch.vertexBuffer[i].indices = (unsigned short *)RL_MALLOC(bufferElements*6*sizeof(unsigned short)); // 6 int by quad (indices) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -4358,7 +4370,8 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[3]); |
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[3]); |
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(int), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(int), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(short), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(short), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -4519,7 +4532,8 @@ static void DrawRenderBatch(RenderBatch *batch) |
|
|
// NOTE: The final parameter tells the GPU the offset in bytes from the |
|
|
// NOTE: The final parameter tells the GPU the offset in bytes from the |
|
|
// start of the index buffer to the location of the first index to process |
|
|
// start of the index buffer to the location of the first index to process |
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint))); |
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint))); |
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(vertexOffset/4*6*sizeof(GLushort))); |
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(vertexOffset/4*6*sizeof(GLushort))); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|