summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders
diff options
context:
space:
mode:
authorbohonghuang <[email protected]>2024-04-23 20:22:29 +0800
committerGitHub <[email protected]>2024-04-23 14:22:29 +0200
commitd80febde7de940d74a37a47729a15ad29b40cafb (patch)
tree2da32dd36d2f01b30f64c89f543e08e982593574 /examples/shaders
parente0f6faa151589a185a04c2c723c01daff1b0a78f (diff)
downloadraylib-d80febde7de940d74a37a47729a15ad29b40cafb.tar.gz
raylib-d80febde7de940d74a37a47729a15ad29b40cafb.zip
[rlgl] Implement vertex normals for RLGL immediate drawing mode (#3866)
* Fix several non-functional `target_compile_definitions` * Avoid hardcoding the default vertex attribute locations * Implement functional `rlNormal3f` * Add normal definitions for `DrawCube` * Update the basic lighting example to use `DrawCube` and `DrawPlane`
Diffstat (limited to 'examples/shaders')
-rw-r--r--examples/shaders/shaders_basic_lighting.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/examples/shaders/shaders_basic_lighting.c b/examples/shaders/shaders_basic_lighting.c
index 5b567f65..77fedfeb 100644
--- a/examples/shaders/shaders_basic_lighting.c
+++ b/examples/shaders/shaders_basic_lighting.c
@@ -52,10 +52,6 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
- // Load plane model from a generated mesh
- Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
- Model cube = LoadModelFromMesh(GenMeshCube(2.0f, 4.0f, 2.0f));
-
// Load basic lighting shader
Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/lighting.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
@@ -69,10 +65,6 @@ int main(void)
int ambientLoc = GetShaderLocation(shader, "ambient");
SetShaderValue(shader, ambientLoc, (float[4]){ 0.1f, 0.1f, 0.1f, 1.0f }, SHADER_UNIFORM_VEC4);
- // Assign out lighting shader to model
- model.materials[0].shader = shader;
- cube.materials[0].shader = shader;
-
// Create lights
Light lights[MAX_LIGHTS] = { 0 };
lights[0] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, -2 }, Vector3Zero(), YELLOW, shader);
@@ -112,8 +104,12 @@ int main(void)
BeginMode3D(camera);
- DrawModel(model, Vector3Zero(), 1.0f, WHITE);
- DrawModel(cube, Vector3Zero(), 1.0f, WHITE);
+ BeginShaderMode(shader);
+
+ DrawPlane(Vector3Zero(), (Vector2) { 10.0, 10.0 }, WHITE);
+ DrawCube(Vector3Zero(), 2.0, 4.0, 2.0, WHITE);
+
+ EndShaderMode();
// Draw spheres to show where the lights are
for (int i = 0; i < MAX_LIGHTS; i++)
@@ -136,8 +132,6 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadModel(model); // Unload the model
- UnloadModel(cube); // Unload the model
UnloadShader(shader); // Unload shader
CloseWindow(); // Close window and OpenGL context