From 788bb78989415a2890bc1d902bcc957b12860341 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 20 Dec 2018 10:40:28 +0100 Subject: [PATCH] Some tweaks --- examples/CMakeLists.txt | 2 ++ examples/Makefile | 2 ++ examples/shaders/shaders_raymarching.c | 18 +++++++++--------- src/rlgl.h | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8ccbc935..1c0c935c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -46,10 +46,12 @@ if(${PLATFORM} MATCHES "Android") list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c) elseif(${PLATFORM} MATCHES "Web") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1") diff --git a/examples/Makefile b/examples/Makefile index 14639b12..53e8555d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -407,6 +407,7 @@ EXAMPLES = \ models/models_box_collisions \ models/models_billboard \ models/models_obj_loading \ + models/models_obj_viewing \ models/models_heightmap \ models/models_cubicmap \ models/models_mesh_picking \ @@ -418,6 +419,7 @@ EXAMPLES = \ shaders/shaders_shapes_textures \ shaders/shaders_custom_uniform \ shaders/shaders_postprocessing \ + shaders/shaders_raymarching \ audio/audio_sound_loading \ audio/audio_music_stream \ audio/audio_module_playing \ diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c index e90cbc29..d1f9d5f8 100644 --- a/examples/shaders/shaders_raymarching.c +++ b/examples/shaders/shaders_raymarching.c @@ -32,9 +32,9 @@ int main() camera.target = (Vector3){ 0.0f, 0.0f, 0.7f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 65.0f; // Camera field-of-view Y - + SetCameraMode(camera, CAMERA_FREE); // Set camera mode - + // Load raymarching shader // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader Shader shader = LoadShader(0, "resources/shaders/glsl330/raymarching.fs"); @@ -46,12 +46,12 @@ int main() int deltaTimeLoc = GetShaderLocation(shader, "deltaTime"); int runTimeLoc = GetShaderLocation(shader, "runTime"); int resolutionLoc = GetShaderLocation(shader, "resolution"); - + float resolution[2] = { screenWidth, screenHeight }; SetShaderValue(shader, resolutionLoc, resolution, 2); - + float runTime = 0.0f; - + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -61,14 +61,14 @@ int main() // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera - + float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z }; float cameraUp[3] = { camera.up.x, camera.up.y, camera.up.z }; float deltaTime = GetFrameTime(); runTime += deltaTime; - + // Set shader required uniform values SetShaderValue(shader, viewEyeLoc, cameraPos, 3); SetShaderValue(shader, viewCenterLoc, cameraTarget, 3); @@ -86,9 +86,9 @@ int main() // We only draw a white full-screen rectangle, // frame is generated in shader using raymarching BeginShaderMode(shader); - DrawRectangle(0, 0, screenWidth, screenHeight, WHITE); + DrawRectangle(0, 0, screenWidth, screenHeight, WHITE); EndShaderMode(); - + DrawText("(c) Raymarching shader by IƱigo Quilez. MIT License.", screenWidth - 280, screenHeight - 20, 10, GRAY); EndDrawing(); diff --git a/src/rlgl.h b/src/rlgl.h index f8b5ac11..e1b9a98b 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -2891,8 +2891,8 @@ int GetShaderLocation(Shader shader, const char *uniformName) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) location = glGetUniformLocation(shader.id, uniformName); - if (location == -1) TraceLog(LOG_WARNING, "[SHDR ID %i] Shader uniform [%s] COULD NOT BE FOUND", shader.id, uniformName); - else TraceLog(LOG_INFO, "[SHDR ID %i] Shader uniform [%s] set at location: %i", shader.id, uniformName, location); + if (location == -1) TraceLog(LOG_WARNING, "[SHDR ID %i][%s] Shader uniform could not be found", shader.id, uniformName); + else TraceLog(LOG_INFO, "[SHDR ID %i][%s] Shader uniform set at location: %i", shader.id, uniformName, location); #endif return location; }