REVIEWED: rlgl defines for consistency
This commit is contained in:
parent
3e75a2109d
commit
5b6d83b533
6 changed files with 74 additions and 68 deletions
|
@ -48,6 +48,16 @@
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
// NOTE: rlgl can be configured just re-defining the following values:
|
||||||
|
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
|
||||||
|
//#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||||
|
//#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||||
|
//#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||||
|
//#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||||
|
//#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
|
//#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
||||||
|
//#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
||||||
|
|
||||||
#define RLGL_IMPLEMENTATION
|
#define RLGL_IMPLEMENTATION
|
||||||
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
|
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
|
||||||
|
|
||||||
|
@ -57,7 +67,6 @@
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
#define GLFW_INCLUDE_ES2
|
#define GLFW_INCLUDE_ES2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "GLFW/glfw3.h" // Windows/Context and inputs management
|
#include "GLFW/glfw3.h" // Windows/Context and inputs management
|
||||||
|
|
||||||
#include <stdio.h> // Required for: printf()
|
#include <stdio.h> // Required for: printf()
|
||||||
|
|
25
src/config.h
25
src/config.h
|
@ -87,22 +87,17 @@
|
||||||
// Show OpenGL extensions and capabilities detailed logs on init
|
// Show OpenGL extensions and capabilities detailed logs on init
|
||||||
//#define SUPPORT_GL_DETAILS_INFO 1
|
//#define SUPPORT_GL_DETAILS_INFO 1
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
|
||||||
#define DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch limits
|
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||||
#define DEFAULT_BATCH_BUFFER_ELEMENTS 2048 // Default internal render batch limits
|
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||||
#define DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
|
||||||
|
|
||||||
#define MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
|
||||||
#define MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
|
||||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
|
||||||
|
|
||||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
||||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
||||||
|
|
||||||
// Default shader vertex attribute names to set location points
|
// Default shader vertex attribute names to set location points
|
||||||
// NOTE: When a new shader is loaded, the following locations are tried to be set for convenience
|
// NOTE: When a new shader is loaded, the following locations are tried to be set for convenience
|
||||||
|
@ -191,6 +186,10 @@
|
||||||
// NOTE: Some generated meshes DO NOT include generated texture coordinates
|
// NOTE: Some generated meshes DO NOT include generated texture coordinates
|
||||||
#define SUPPORT_MESH_GENERATION 1
|
#define SUPPORT_MESH_GENERATION 1
|
||||||
|
|
||||||
|
// models: Configuration values
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
||||||
|
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module: audio - Configuration Flags
|
// Module: audio - Configuration Flags
|
||||||
|
|
|
@ -2296,10 +2296,10 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
|
||||||
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
|
RLAPI Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
|
||||||
{
|
{
|
||||||
Shader shader = { 0 };
|
Shader shader = { 0 };
|
||||||
shader.locs = (int *)RL_CALLOC(MAX_SHADER_LOCATIONS, sizeof(int));
|
shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
|
||||||
|
|
||||||
// NOTE: All locations must be reseted to -1 (no location)
|
// NOTE: All locations must be reseted to -1 (no location)
|
||||||
for (int i = 0; i < MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
|
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
|
||||||
|
|
||||||
shader.id = rlLoadShaderCode(vsCode, fsCode);
|
shader.id = rlLoadShaderCode(vsCode, fsCode);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,12 @@
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// ...
|
#ifndef MAX_MATERIAL_MAPS
|
||||||
|
#define MAX_MATERIAL_MAPS 12 // Maximum number of maps supported
|
||||||
|
#endif
|
||||||
|
#ifndef MAX_MESH_VERTEX_BUFFERS
|
||||||
|
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
||||||
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
|
|
|
@ -348,7 +348,7 @@ typedef struct Mesh {
|
||||||
// Shader
|
// Shader
|
||||||
typedef struct Shader {
|
typedef struct Shader {
|
||||||
unsigned int id; // Shader program id
|
unsigned int id; // Shader program id
|
||||||
int *locs; // Shader locations array (MAX_SHADER_LOCATIONS)
|
int *locs; // Shader locations array (RL_MAX_SHADER_LOCATIONS)
|
||||||
} Shader;
|
} Shader;
|
||||||
|
|
||||||
// MaterialMap
|
// MaterialMap
|
||||||
|
|
93
src/rlgl.h
93
src/rlgl.h
|
@ -40,15 +40,15 @@
|
||||||
* rlgl capabilities could be customized just defining some internal
|
* rlgl capabilities could be customized just defining some internal
|
||||||
* values before library inclusion (default values listed):
|
* values before library inclusion (default values listed):
|
||||||
*
|
*
|
||||||
* #define DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch limits
|
* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits
|
||||||
* #define DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||||
* #define DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||||
* #define MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||||
* #define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
*
|
||||||
* #define MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||||
* #define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance
|
||||||
* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
|
||||||
*
|
*
|
||||||
* When loading a shader, the following vertex attribute and uniform
|
* When loading a shader, the following vertex attribute and uniform
|
||||||
* location names are tried to be set automatically:
|
* location names are tried to be set automatically:
|
||||||
|
@ -163,54 +163,47 @@
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Default internal render batch limits
|
|
||||||
#ifndef DEFAULT_BATCH_BUFFER_ELEMENTS
|
// Default internal render batch elements limits
|
||||||
|
#ifndef RL_DEFAULT_BATCH_BUFFER_ELEMENTS
|
||||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
||||||
// 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 RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192
|
||||||
#endif
|
#endif
|
||||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
#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...
|
||||||
#define DEFAULT_BATCH_BUFFER_ELEMENTS 2048
|
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 2048
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef DEFAULT_BATCH_BUFFERS
|
#ifndef RL_DEFAULT_BATCH_BUFFERS
|
||||||
#define DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||||
#endif
|
#endif
|
||||||
#ifndef DEFAULT_BATCH_DRAWCALLS
|
#ifndef RL_DEFAULT_BATCH_DRAWCALLS
|
||||||
#define DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||||
#endif
|
#endif
|
||||||
#ifndef MAX_BATCH_ACTIVE_TEXTURES
|
#ifndef RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS
|
||||||
#define MAX_BATCH_ACTIVE_TEXTURES 4 // Maximum number of additional textures that can be activated on batch drawing (SetShaderValueTexture())
|
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Internal Matrix stack
|
// Internal Matrix stack
|
||||||
#ifndef MAX_MATRIX_STACK_SIZE
|
#ifndef RL_MAX_MATRIX_STACK_SIZE
|
||||||
#define MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
|
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Vertex buffers id limit
|
// Shader limits
|
||||||
#ifndef MAX_MESH_VERTEX_BUFFERS
|
#ifndef RL_MAX_SHADER_LOCATIONS
|
||||||
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||||
#endif
|
|
||||||
|
|
||||||
// Shader and material limits
|
|
||||||
#ifndef MAX_SHADER_LOCATIONS
|
|
||||||
#define MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
|
||||||
#endif
|
|
||||||
#ifndef MAX_MATERIAL_MAPS
|
|
||||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Projection matrix culling
|
// Projection matrix culling
|
||||||
#ifndef RL_CULL_DISTANCE_NEAR
|
#ifndef RL_CULL_DISTANCE_NEAR
|
||||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance
|
#define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance
|
||||||
#endif
|
#endif
|
||||||
#ifndef RL_CULL_DISTANCE_FAR
|
#ifndef RL_CULL_DISTANCE_FAR
|
||||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance
|
#define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Texture parameters (equivalent to OpenGL defines)
|
// Texture parameters (equivalent to OpenGL defines)
|
||||||
|
@ -848,11 +841,11 @@ typedef struct rlglData {
|
||||||
Matrix projection; // Default projection matrix
|
Matrix projection; // Default projection matrix
|
||||||
Matrix transform; // Transform matrix to be used with rlTranslate, rlRotate, rlScale
|
Matrix transform; // Transform matrix to be used with rlTranslate, rlRotate, rlScale
|
||||||
bool transformRequired; // Require transform matrix application to current draw-call vertex (if required)
|
bool transformRequired; // Require transform matrix application to current draw-call vertex (if required)
|
||||||
Matrix stack[MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
|
Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
|
||||||
int stackCounter; // Matrix stack counter
|
int stackCounter; // Matrix stack counter
|
||||||
|
|
||||||
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
|
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
|
||||||
unsigned int activeTextureId[MAX_BATCH_ACTIVE_TEXTURES]; // Active texture ids to be enabled on batch drawing (0 active by default)
|
unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default)
|
||||||
unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
|
unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
|
||||||
unsigned int defaultFShaderId; // Default fragment shader id (used by default shader program)
|
unsigned int defaultFShaderId; // Default fragment shader id (used by default shader program)
|
||||||
unsigned int defaultShaderId; // Default shader program id, supports vertex color and diffuse texture
|
unsigned int defaultShaderId; // Default shader program id, supports vertex color and diffuse texture
|
||||||
|
@ -985,7 +978,7 @@ void rlMatrixMode(int mode)
|
||||||
// Push the current matrix into RLGL.State.stack
|
// Push the current matrix into RLGL.State.stack
|
||||||
void rlPushMatrix(void)
|
void rlPushMatrix(void)
|
||||||
{
|
{
|
||||||
if (RLGL.State.stackCounter >= MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (MAX_MATRIX_STACK_SIZE)");
|
if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)");
|
||||||
|
|
||||||
if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
|
if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
|
||||||
{
|
{
|
||||||
|
@ -1231,7 +1224,7 @@ void rlBegin(int mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RLGL.currentBatch->drawsCounter >= DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
if (RLGL.currentBatch->drawsCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
||||||
|
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode = mode;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].mode = mode;
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0;
|
||||||
|
@ -1422,7 +1415,7 @@ void rlSetTexture(unsigned int id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RLGL.currentBatch->drawsCounter >= DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
if (RLGL.currentBatch->drawsCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
|
||||||
|
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].textureId = id;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].textureId = id;
|
||||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0;
|
RLGL.currentBatch->draws[RLGL.currentBatch->drawsCounter - 1].vertexCount = 0;
|
||||||
|
@ -1746,11 +1739,11 @@ void rlglInit(int width, int height)
|
||||||
RLGL.State.currentShaderLocs = RLGL.State.defaultShaderLocs;
|
RLGL.State.currentShaderLocs = RLGL.State.defaultShaderLocs;
|
||||||
|
|
||||||
// Init default vertex arrays buffers
|
// Init default vertex arrays buffers
|
||||||
RLGL.defaultBatch = rlLoadRenderBatch(DEFAULT_BATCH_BUFFERS, DEFAULT_BATCH_BUFFER_ELEMENTS);
|
RLGL.defaultBatch = rlLoadRenderBatch(RL_DEFAULT_BATCH_BUFFERS, RL_DEFAULT_BATCH_BUFFER_ELEMENTS);
|
||||||
RLGL.currentBatch = &RLGL.defaultBatch;
|
RLGL.currentBatch = &RLGL.defaultBatch;
|
||||||
|
|
||||||
// Init stack matrices (emulating OpenGL 1.1)
|
// Init stack matrices (emulating OpenGL 1.1)
|
||||||
for (int i = 0; i < MAX_MATRIX_STACK_SIZE; i++) RLGL.State.stack[i] = rlMatrixIdentity();
|
for (int i = 0; i < RL_MAX_MATRIX_STACK_SIZE; i++) RLGL.State.stack[i] = rlMatrixIdentity();
|
||||||
|
|
||||||
// Init internal matrices
|
// Init internal matrices
|
||||||
RLGL.State.transform = rlMatrixIdentity();
|
RLGL.State.transform = rlMatrixIdentity();
|
||||||
|
@ -2217,9 +2210,9 @@ rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements)
|
||||||
|
|
||||||
// Init draw calls tracking system
|
// Init draw calls tracking system
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
batch.draws = (rlDrawCall *)RL_MALLOC(DEFAULT_BATCH_DRAWCALLS*sizeof(rlDrawCall));
|
batch.draws = (rlDrawCall *)RL_MALLOC(RL_DEFAULT_BATCH_DRAWCALLS*sizeof(rlDrawCall));
|
||||||
|
|
||||||
for (int i = 0; i < DEFAULT_BATCH_DRAWCALLS; i++)
|
for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++)
|
||||||
{
|
{
|
||||||
batch.draws[i].mode = RL_QUADS;
|
batch.draws[i].mode = RL_QUADS;
|
||||||
batch.draws[i].vertexCount = 0;
|
batch.draws[i].vertexCount = 0;
|
||||||
|
@ -2391,7 +2384,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
||||||
|
|
||||||
// Activate additional sampler textures
|
// Activate additional sampler textures
|
||||||
// Those additional textures will be common for all draw calls of the batch
|
// Those additional textures will be common for all draw calls of the batch
|
||||||
for (int i = 0; i < MAX_BATCH_ACTIVE_TEXTURES; i++)
|
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
|
||||||
{
|
{
|
||||||
if (RLGL.State.activeTextureId[i] > 0)
|
if (RLGL.State.activeTextureId[i] > 0)
|
||||||
{
|
{
|
||||||
|
@ -2456,7 +2449,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
||||||
RLGL.State.modelview = matModelView;
|
RLGL.State.modelview = matModelView;
|
||||||
|
|
||||||
// Reset RLGL.currentBatch->draws array
|
// Reset RLGL.currentBatch->draws array
|
||||||
for (int i = 0; i < DEFAULT_BATCH_DRAWCALLS; i++)
|
for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++)
|
||||||
{
|
{
|
||||||
batch->draws[i].mode = RL_QUADS;
|
batch->draws[i].mode = RL_QUADS;
|
||||||
batch->draws[i].vertexCount = 0;
|
batch->draws[i].vertexCount = 0;
|
||||||
|
@ -2464,7 +2457,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset active texture units for next batch
|
// Reset active texture units for next batch
|
||||||
for (int i = 0; i < MAX_BATCH_ACTIVE_TEXTURES; i++) RLGL.State.activeTextureId[i] = 0;
|
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0;
|
||||||
|
|
||||||
// Reset draws counter to one draw for the batch
|
// Reset draws counter to one draw for the batch
|
||||||
batch->drawsCounter = 1;
|
batch->drawsCounter = 1;
|
||||||
|
@ -3605,11 +3598,11 @@ void rlSetUniformSampler(int locIndex, unsigned int textureId)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// Check if texture is already active
|
// Check if texture is already active
|
||||||
for (int i = 0; i < MAX_BATCH_ACTIVE_TEXTURES; i++) if (RLGL.State.activeTextureId[i] == textureId) return;
|
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) if (RLGL.State.activeTextureId[i] == textureId) return;
|
||||||
|
|
||||||
// Register a new active texture for the internal batch system
|
// Register a new active texture for the internal batch system
|
||||||
// NOTE: Default texture is always activated as GL_TEXTURE0
|
// NOTE: Default texture is always activated as GL_TEXTURE0
|
||||||
for (int i = 0; i < MAX_BATCH_ACTIVE_TEXTURES; i++)
|
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
|
||||||
{
|
{
|
||||||
if (RLGL.State.activeTextureId[i] == 0)
|
if (RLGL.State.activeTextureId[i] == 0)
|
||||||
{
|
{
|
||||||
|
@ -3920,10 +3913,10 @@ const char *rlGetPixelFormatName(unsigned int format)
|
||||||
// NOTE: Loaded: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs
|
// NOTE: Loaded: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs
|
||||||
static void rlLoadShaderDefault(void)
|
static void rlLoadShaderDefault(void)
|
||||||
{
|
{
|
||||||
RLGL.State.defaultShaderLocs = (int *)RL_CALLOC(MAX_SHADER_LOCATIONS, sizeof(int));
|
RLGL.State.defaultShaderLocs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
|
||||||
|
|
||||||
// NOTE: All locations must be reseted to -1 (no location)
|
// NOTE: All locations must be reseted to -1 (no location)
|
||||||
for (int i = 0; i < MAX_SHADER_LOCATIONS; i++) RLGL.State.defaultShaderLocs[i] = -1;
|
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) RLGL.State.defaultShaderLocs[i] = -1;
|
||||||
|
|
||||||
// Vertex shader directly defined, no external file required
|
// Vertex shader directly defined, no external file required
|
||||||
const char *defaultVShaderCode =
|
const char *defaultVShaderCode =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue