WARNING: VERY BREAKING CHANGE: Renamed some enum values for consistency

Some enums values have been renamed to be more consistent and also provide a more detailed description:
 - ShaderLocationIndex:    LOC_VERTEX_POSITION -> SHADER_SHADER_LOC_VERTEX_POSITION
 - ShaderUniformDataType:  UNIFORM_VEC2 -> SHADER_UNIFORM_VEC2
 - MaterialMapType: MAP_ALBEDO -> MATERIAL_MAP_ALBEDO
 - PixelFormat: UNCOMPRESSED_GRAYSCALE -> PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
This commit is contained in:
Ray 2021-03-14 11:05:51 +01:00
parent 75038baf71
commit 01e28263be
33 changed files with 723 additions and 721 deletions

View file

@ -163,21 +163,21 @@ Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shade
void UpdateLightValues(Shader shader, Light light)
{
// Send to shader light enabled state and type
SetShaderValue(shader, light.enabledLoc, &light.enabled, UNIFORM_INT);
SetShaderValue(shader, light.typeLoc, &light.type, UNIFORM_INT);
SetShaderValue(shader, light.enabledLoc, &light.enabled, SHADER_UNIFORM_INT);
SetShaderValue(shader, light.typeLoc, &light.type, SHADER_UNIFORM_INT);
// Send to shader light position values
float position[3] = { light.position.x, light.position.y, light.position.z };
SetShaderValue(shader, light.posLoc, position, UNIFORM_VEC3);
SetShaderValue(shader, light.posLoc, position, SHADER_UNIFORM_VEC3);
// Send to shader light target position values
float target[3] = { light.target.x, light.target.y, light.target.z };
SetShaderValue(shader, light.targetLoc, target, UNIFORM_VEC3);
SetShaderValue(shader, light.targetLoc, target, SHADER_UNIFORM_VEC3);
// Send to shader light color values
float color[4] = { (float)light.color.r/(float)255, (float)light.color.g/(float)255,
(float)light.color.b/(float)255, (float)light.color.a/(float)255 };
SetShaderValue(shader, light.colorLoc, color, UNIFORM_VEC4);
SetShaderValue(shader, light.colorLoc, color, SHADER_UNIFORM_VEC4);
}
#endif // RLIGHTS_IMPLEMENTATION

View file

@ -65,20 +65,20 @@ int main(void)
Texture texture = LoadTexture("resources/texel_checker.png");
// Assign texture to default model material
modelA.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelB.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelC.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelA.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
modelB.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
modelC.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
// Get some shader loactions
shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
// ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, UNIFORM_VEC4);
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
float angle = 6.282f;
@ -133,7 +133,7 @@ int main(void)
// Update the light shader with the camera view position
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(shader, shader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3);
SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3);
//----------------------------------------------------------------------------------
// Draw

View file

@ -45,7 +45,7 @@ int main(void)
Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map)
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
@ -79,7 +79,7 @@ int main(void)
swirlCenter[1] = screenHeight - mousePosition.y;
// Send new value to the shader to be used on drawing
SetShaderValue(shader, swirlCenterLoc, swirlCenter, UNIFORM_VEC2);
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
UpdateCamera(&camera); // Update camera
//----------------------------------------------------------------------------------

View file

@ -62,23 +62,23 @@ int main(void)
Texture texture = LoadTexture("resources/texel_checker.png");
// Assign texture to default model material
modelA.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelB.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelC.materials[0].maps[MAP_DIFFUSE].texture = texture;
modelA.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
modelB.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
modelC.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
// Load shader and set up some uniforms
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/fog.fs", GLSL_VERSION));
shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
// Ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, UNIFORM_VEC4);
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
float fogDensity = 0.15f;
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
SetShaderValue(shader, fogDensityLoc, &fogDensity, UNIFORM_FLOAT);
SetShaderValue(shader, fogDensityLoc, &fogDensity, SHADER_UNIFORM_FLOAT);
// NOTE: All models share the same shader
modelA.materials[0].shader = shader;
@ -112,14 +112,14 @@ int main(void)
if (fogDensity < 0.0) fogDensity = 0.0;
}
SetShaderValue(shader, fogDensityLoc, &fogDensity, UNIFORM_FLOAT);
SetShaderValue(shader, fogDensityLoc, &fogDensity, SHADER_UNIFORM_FLOAT);
// Rotate the torus
modelA.transform = MatrixMultiply(modelA.transform, MatrixRotateX(-0.025));
modelA.transform = MatrixMultiply(modelA.transform, MatrixRotateZ(0.012));
// Update the light shader with the camera view position
SetShaderValue(shader, shader.locs[LOC_VECTOR_VIEW], &camera.position.x, UNIFORM_VEC3);
SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], &camera.position.x, SHADER_UNIFORM_VEC3);
//----------------------------------------------------------------------------------
// Draw

View file

@ -44,7 +44,7 @@ int main(void)
int timeLoc = GetShaderLocation(shader, "time");
float resolution[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2);
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
float totalTime = 0.0f;
bool shaderAutoReloading = false;
@ -62,8 +62,8 @@ int main(void)
float mousePos[2] = { mouse.x, mouse.y };
// Set shader required uniform values
SetShaderValue(shader, timeLoc, &totalTime, UNIFORM_FLOAT);
SetShaderValue(shader, mouseLoc, mousePos, UNIFORM_VEC2);
SetShaderValue(shader, timeLoc, &totalTime, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, mouseLoc, mousePos, SHADER_UNIFORM_VEC2);
// Hot shader reloading
if (shaderAutoReloading || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
@ -87,7 +87,7 @@ int main(void)
timeLoc = GetShaderLocation(shader, "time");
// Reset required uniforms
SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2);
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
}
fragShaderFileModTime = currentFragShaderModTime;

View file

@ -65,11 +65,11 @@ int main(void)
// Tell the shader what the screen dimensions, zoom, offset and c are
float screenDims[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2);
SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, SHADER_UNIFORM_VEC2);
SetShaderValue(shader, cLoc, c, UNIFORM_VEC2);
SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT);
SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2);
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
@ -101,7 +101,7 @@ int main(void)
else if (IsKeyPressed(KEY_FIVE)) c[0] = POINTS_OF_INTEREST[4][0], c[1] = POINTS_OF_INTEREST[4][1];
else if (IsKeyPressed(KEY_SIX)) c[0] = POINTS_OF_INTEREST[5][0], c[1] = POINTS_OF_INTEREST[5][1];
SetShaderValue(shader, cLoc, c, UNIFORM_VEC2);
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
}
if (IsKeyPressed(KEY_SPACE)) pause = !pause; // Pause animation (c change)
@ -130,15 +130,15 @@ int main(void)
}
else offsetSpeed = (Vector2){ 0.0f, 0.0f };
SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT);
SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2);
SetShaderValue(shader, zoomLoc, &zoom, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, offsetLoc, offset, SHADER_UNIFORM_VEC2);
// Increment c value with time
float amount = GetFrameTime()*incrementSpeed*0.0005f;
c[0] += amount;
c[1] += amount;
SetShaderValue(shader, cLoc, c, UNIFORM_VEC2);
SetShaderValue(shader, cLoc, c, SHADER_UNIFORM_VEC2);
}
//----------------------------------------------------------------------------------

View file

@ -51,7 +51,7 @@ int main(void)
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
model.materials[0].shader = shader; // Set shader effect to 3d model
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Bind texture to model
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -106,7 +106,7 @@ int main(void)
// Send new value to the shader to be used on drawing.
// NOTE: We are sending RGB triplets w/o the alpha channel
SetShaderValueV(shader, paletteLoc, palettes[currentPalette], UNIFORM_IVEC3, COLORS_PER_PALETTE);
SetShaderValueV(shader, paletteLoc, palettes[currentPalette], SHADER_UNIFORM_IVEC3, COLORS_PER_PALETTE);
//----------------------------------------------------------------------------------
// Draw

View file

@ -74,7 +74,7 @@ int main(void)
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -49,7 +49,7 @@ int main(void)
int resolutionLoc = GetShaderLocation(shader, "resolution");
float resolution[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2);
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
float runTime = 0.0f;
@ -70,9 +70,9 @@ int main(void)
runTime += deltaTime;
// Set shader required uniform values
SetShaderValue(shader, viewEyeLoc, cameraPos, UNIFORM_VEC3);
SetShaderValue(shader, viewCenterLoc, cameraTarget, UNIFORM_VEC3);
SetShaderValue(shader, runTimeLoc, &runTime, UNIFORM_FLOAT);
SetShaderValue(shader, viewEyeLoc, cameraPos, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, viewCenterLoc, cameraTarget, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, runTimeLoc, &runTime, SHADER_UNIFORM_FLOAT);
// Check if screen is resized
if (IsWindowResized())
@ -80,7 +80,7 @@ int main(void)
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
float resolution[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2);
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
}
//----------------------------------------------------------------------------------

View file

@ -77,19 +77,19 @@ int main(void)
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
// Get some shader loactions
shader.locs[LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp");
shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.locs[LOC_MATRIX_MODEL] = GetShaderLocationAttrib(shader, "instance");
shader.locs[SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp");
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(shader, "instance");
// Ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, UNIFORM_VEC4);
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 50, 50, 0 }, Vector3Zero(), WHITE, shader);
Material material = LoadMaterialDefault();
material.shader = shader;
material.maps[MAP_DIFFUSE].color = RED;
material.maps[MATERIAL_MAP_DIFFUSE].color = RED;
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
@ -105,7 +105,7 @@ int main(void)
// Update the light shader with the camera view position
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(shader, shader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3);
SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3);
// Apply per-instance rotations
for (int i = 0; i < count; i++)

View file

@ -60,15 +60,15 @@ int main(void)
// Load and apply the diffuse texture (colour map)
Texture texDiffuse = LoadTexture("resources/plasma.png");
model1.materials[0].maps[MAP_DIFFUSE].texture = texDiffuse;
model2.materials[0].maps[MAP_DIFFUSE].texture = texDiffuse;
model1.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texDiffuse;
model2.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texDiffuse;
// Using MAP_EMISSION as a spare slot to use for 2nd texture
// NOTE: Don't use MAP_IRRADIANCE, MAP_PREFILTER or MAP_CUBEMAP as they are bound as cube maps
// Using MATERIAL_MAP_EMISSION as a spare slot to use for 2nd texture
// NOTE: Don't use MATERIAL_MAP_IRRADIANCE, MATERIAL_MAP_PREFILTER or MATERIAL_MAP_CUBEMAP as they are bound as cube maps
Texture texMask = LoadTexture("resources/mask.png");
model1.materials[0].maps[MAP_EMISSION].texture = texMask;
model2.materials[0].maps[MAP_EMISSION].texture = texMask;
shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(shader, "mask");
model1.materials[0].maps[MATERIAL_MAP_EMISSION].texture = texMask;
model2.materials[0].maps[MATERIAL_MAP_EMISSION].texture = texMask;
shader.locs[SHADER_LOC_MAP_EMISSION] = GetShaderLocation(shader, "mask");
// Frame is incremented each frame to animate the shader
int shaderFrame = GetShaderLocation(shader, "frame");
@ -94,7 +94,7 @@ int main(void)
rotation.z -= 0.0025f;
// Send frames counter to shader for animation
SetShaderValue(shader, shaderFrame, &framesCounter, UNIFORM_INT);
SetShaderValue(shader, shaderFrame, &framesCounter, SHADER_UNIFORM_INT);
// Rotate one of the models
model1.transform = MatrixRotateXYZ(rotation);

View file

@ -114,7 +114,7 @@ int main(void)
// a pitch black half and a dimly lit half.
unsigned int wLoc = GetShaderLocation(shdrSpot, "screenWidth");
float sw = (float)GetScreenWidth();
SetShaderValue(shdrSpot, wLoc, &sw, UNIFORM_FLOAT);
SetShaderValue(shdrSpot, wLoc, &sw, SHADER_UNIFORM_FLOAT);
// Randomise the locations and velocities of the spotlights
// and initialise the shader locations
@ -133,9 +133,9 @@ int main(void)
spots[i].inner = 28 * (i + 1);
spots[i].radius = 48 * (i + 1);
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
}
SetTargetFPS(60); // Set to run at 60 frames-per-second
@ -171,7 +171,7 @@ int main(void)
if (spots[i].pos.y > (screenHeight - 64)) spots[i].vel.y = -spots[i].vel.y;
}
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
}
// Draw

View file

@ -39,7 +39,7 @@ int main(void)
float time = 0.0f;
int timeLoc = GetShaderLocation(shader, "uTime");
SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT);
SetShaderValue(shader, timeLoc, &time, SHADER_UNIFORM_FLOAT);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
// -------------------------------------------------------------------------------------------------------------
@ -50,7 +50,7 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
time = GetTime();
SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT);
SetShaderValue(shader, timeLoc, &time, SHADER_UNIFORM_FLOAT);
//----------------------------------------------------------------------------------
// Draw

View file

@ -58,13 +58,13 @@ int main(void)
float speedY = 8.0f;
float screenSize[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, UNIFORM_VEC2);
SetShaderValue(shader, freqXLoc, &freqX, UNIFORM_FLOAT);
SetShaderValue(shader, freqYLoc, &freqY, UNIFORM_FLOAT);
SetShaderValue(shader, ampXLoc, &ampX, UNIFORM_FLOAT);
SetShaderValue(shader, ampYLoc, &ampY, UNIFORM_FLOAT);
SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT);
SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT);
SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, SHADER_UNIFORM_VEC2);
SetShaderValue(shader, freqXLoc, &freqX, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, freqYLoc, &freqY, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, ampXLoc, &ampX, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, ampYLoc, &ampY, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, speedXLoc, &speedX, SHADER_UNIFORM_FLOAT);
SetShaderValue(shader, speedYLoc, &speedY, SHADER_UNIFORM_FLOAT);
float seconds = 0.0f;
@ -78,7 +78,7 @@ int main(void)
//----------------------------------------------------------------------------------
seconds += GetFrameTime();
SetShaderValue(shader, secondsLoc, &seconds, UNIFORM_FLOAT);
SetShaderValue(shader, secondsLoc, &seconds, SHADER_UNIFORM_FLOAT);
//----------------------------------------------------------------------------------
// Draw