From 9668f546d3d97d6ee364c5322cf3d64a7998cf55 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 23 Oct 2017 22:41:06 +0200 Subject: Example shader correction --- examples/others/resources/shaders/glsl100/standard.vs | 4 ++-- examples/others/resources/shaders/glsl330/standard.vs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/others/resources/shaders/glsl100/standard.vs b/examples/others/resources/shaders/glsl100/standard.vs index 49c5a3eb..2b958938 100644 --- a/examples/others/resources/shaders/glsl100/standard.vs +++ b/examples/others/resources/shaders/glsl100/standard.vs @@ -10,7 +10,7 @@ varying vec2 fragTexCoord; varying vec4 fragColor; varying vec3 fragNormal; -uniform mat4 mvpMatrix; +uniform mat4 mvp; void main() { @@ -19,5 +19,5 @@ void main() fragColor = vertexColor; fragNormal = vertexNormal; - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); + gl_Position = mvp*vec4(vertexPosition, 1.0); } \ No newline at end of file diff --git a/examples/others/resources/shaders/glsl330/standard.vs b/examples/others/resources/shaders/glsl330/standard.vs index fc0a5ff4..7fbdbf5e 100644 --- a/examples/others/resources/shaders/glsl330/standard.vs +++ b/examples/others/resources/shaders/glsl330/standard.vs @@ -10,7 +10,7 @@ out vec2 fragTexCoord; out vec4 fragColor; out vec3 fragNormal; -uniform mat4 mvpMatrix; +uniform mat4 mvp; void main() { @@ -19,5 +19,5 @@ void main() fragColor = vertexColor; fragNormal = vertexNormal; - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); + gl_Position = mvp*vec4(vertexPosition, 1.0); } \ No newline at end of file -- cgit v1.2.3 From 47c7f3624f187db057cd5a05a46247f99730c7b2 Mon Sep 17 00:00:00 2001 From: Martinfx Date: Sat, 28 Oct 2017 18:41:29 +0200 Subject: Added support FreeBSD for example --- examples/Makefile | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index edcff807..cc8e0e01 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -54,12 +54,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(UNAMEOS),Linux) PLATFORM_OS=LINUX LIBPATH=linux - else + endif + UNAMEOS=$(shell uname) + ifeq ($(UNAMEOS),FreeBSD) + PLATFORM_OS=FREEBSD + LIBPATH=linux + endif ifeq ($(UNAMEOS),Darwin) PLATFORM_OS=OSX LIBPATH=osx endif - endif endif endif @@ -90,6 +94,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),OSX) RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx endif + ifeq ($(PLATFORM_OS),FREEBSD) + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/freebsd + endif endif ifeq ($(PLATFORM),PLATFORM_WEB) RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5 @@ -106,6 +113,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # OSX default compiler CC = clang endif + ifeq ($(PLATFORM_OS),FREEBSD) + # FreeBSD default compiler + CC = clang + endif endif ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(RPI_CROSS_COMPILE),YES) @@ -150,6 +161,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) CFLAGS += -no-pie -D_DEFAULT_SOURCE endif + #ifeq ($(PLATFORM_OS),FREEBSD) + # CFLAGS += -D_DEFAULT_SOURCE + #endif endif ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS += -std=gnu99 @@ -178,6 +192,13 @@ endif # Define library paths containing required libs LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),FREEBSD) + INCLUDE_PATHS += -I/usr/local/include + LDFLAGS += -L. -Lsrc -L/usr/local/lib + endif +endif + ifeq ($(PLATFORM),PLATFORM_RPI) LDFLAGS += -L/opt/vc/lib endif @@ -215,6 +236,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa endif + ifeq ($(PLATFORM_OS),FREEBSD) + # Libraries for FreeBSD desktop compiling + # NOTE: Required packages: glfw openal-soft mesa-libs + LDLIBS = -lraylib -lglfw -lGL -lopenal -lpthread -lm + + # On XWindow requires also below libraries + LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + endif endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling -- cgit v1.2.3 From f8971691603aa1d5379ed623d22e2138f6b353cd Mon Sep 17 00:00:00 2001 From: Martinfx Date: Sat, 28 Oct 2017 18:53:32 +0200 Subject: Removed comment --- examples/Makefile | 3 --- 1 file changed, 3 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index cc8e0e01..1557da92 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -161,9 +161,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) CFLAGS += -no-pie -D_DEFAULT_SOURCE endif - #ifeq ($(PLATFORM_OS),FREEBSD) - # CFLAGS += -D_DEFAULT_SOURCE - #endif endif ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS += -std=gnu99 -- cgit v1.2.3 From f460b3842e76e110daf0d1e81c39fb9f1b44e95e Mon Sep 17 00:00:00 2001 From: Ray San Date: Mon, 30 Oct 2017 09:37:16 +0100 Subject: Added new example: text drawing on image --- examples/Makefile | 2 +- examples/textures/resources/KAISG.ttf | Bin 0 -> 79912 bytes examples/textures/textures_image_text.c | 83 ++++++++++++++++++++++++++++++ examples/textures/textures_image_text.png | Bin 0 -> 556322 bytes 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 examples/textures/resources/KAISG.ttf create mode 100644 examples/textures/textures_image_text.c create mode 100644 examples/textures/textures_image_text.png (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 1557da92..2942f110 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -292,6 +292,7 @@ EXAMPLES = \ textures/textures_image_processing \ textures/textures_image_drawing \ textures/textures_image_generation \ + textures/textures_image_text \ text/text_sprite_fonts \ text/text_bmfont_ttf \ text/text_raylib_fonts \ @@ -368,4 +369,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB) del *.o *.html *.js endif @echo Cleaning done - diff --git a/examples/textures/resources/KAISG.ttf b/examples/textures/resources/KAISG.ttf new file mode 100644 index 00000000..04478b25 Binary files /dev/null and b/examples/textures/resources/KAISG.ttf differ diff --git a/examples/textures/textures_image_text.c b/examples/textures/textures_image_text.c new file mode 100644 index 00000000..1d4231f7 --- /dev/null +++ b/examples/textures/textures_image_text.c @@ -0,0 +1,83 @@ +/******************************************************************************************* +* +* raylib [texture] example - Image text drawing using TTF generated spritefont +* +* This example has been created using raylib 1.8 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2017 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); + + // TTF SpriteFont loading with custom generation parameters + SpriteFont font = LoadSpriteFontEx("resources/KAISG.ttf", 64, 0, 0); + + Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) + + // Draw over image using custom font + ImageDrawTextEx(&parrots, (Vector2){ 20, 20 }, font, "[Parrots font drawing]", font.baseSize, 0, WHITE); + + Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) + UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM + + Vector2 position = { screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 20 }; + + bool showFont = false; + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (IsKeyDown(KEY_SPACE)) showFont = true; + else showFont = false; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + if (!showFont) + { + // Draw texture with text already drawn inside + DrawTextureV(texture, position, WHITE); + + // Draw text directly using sprite font + DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20, + position.y + 20 + 280 }, font.baseSize, 0, WHITE); + } + else DrawTexture(font.texture, screenWidth/2 - font.texture.width/2, 50, BLACK); + + DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, DARKGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(texture); // Texture unloading + + UnloadSpriteFont(font); // Unload custom spritefont + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/textures/textures_image_text.png b/examples/textures/textures_image_text.png new file mode 100644 index 00000000..dafbabfb Binary files /dev/null and b/examples/textures/textures_image_text.png differ -- cgit v1.2.3 From 415e7e972c920cbf3194c4dfbbfe402d7c4406c5 Mon Sep 17 00:00:00 2001 From: Ray San Date: Mon, 30 Oct 2017 13:51:46 +0100 Subject: Review some issues, view description - Review RPI compilation (core_drop_files not supported) - Review ImageFormat(), some issues - GetTextureData() reviewed for RPI --- examples/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 2942f110..485368c4 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -267,7 +267,6 @@ EXAMPLES = \ core/core_input_gamepad \ core/core_random_values \ core/core_color_select \ - core/core_drop_files \ core/core_storage_values \ core/core_gestures_detection \ core/core_3d_mode \ @@ -326,6 +325,10 @@ EXAMPLES = \ physac/physics_restitution \ physac/physics_shatter \ fix_dylib \ + +ifneq ($(PLATFORM),PLATFORM_RPI) + EXAMPLES += core/core_drop_files +endif CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) -- cgit v1.2.3 From 3d755d617ab6f2a86c272ffb8ecddc2621269c19 Mon Sep 17 00:00:00 2001 From: Ray San Date: Thu, 2 Nov 2017 20:08:52 +0100 Subject: Some code tweaks... --- examples/text/text_ttf_loading.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c index c9c2fb27..fedfbfb8 100644 --- a/examples/text/text_ttf_loading.c +++ b/examples/text/text_ttf_loading.c @@ -32,7 +32,7 @@ int main() GenTextureMipmaps(&font.texture); float fontSize = font.baseSize; - Vector2 fontPosition = { 40, screenHeight/2 + 50 }; + Vector2 fontPosition = { 40, screenHeight/2 - 50 }; Vector2 textSize; SetTextureFilter(font.texture, FILTER_POINT); -- cgit v1.2.3 From 24657ca78938469e77fc765e44dc70537dfe0e1a Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 5 Nov 2017 17:06:50 +0100 Subject: Review textures to be POT Could correct possible issues on OpenGL 1.1 --- examples/models/models_yaw_pitch_roll.c | 14 +++++++------- examples/models/resources/angle_gauge.png | Bin 11761 -> 12919 bytes examples/models/resources/plane.png | Bin 4872 -> 4810 bytes 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index 2bae2bf8..625fc554 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -119,17 +119,17 @@ int main() BeginBlendMode(BLEND_ALPHA); - DrawTexturePro(texBackground, (Rectangle){0,0,texBackground.width, texBackground.height}, + DrawTexturePro(texBackground, (Rectangle){ 0, 0, texBackground.width, texBackground.height }, (Rectangle){ centerX, centerY, texBackground.width*scaleFactor, texBackground.height*scaleFactor}, - (Vector2){texBackground.width/2*scaleFactor, texBackground.height/2*scaleFactor + pitchOffset*scaleFactor}, roll, WHITE); + (Vector2){ texBackground.width/2*scaleFactor, texBackground.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height }, (Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor }, (Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); - DrawTexturePro(texPlane, (Rectangle){0,0,texPlane.width, texPlane.height }, + DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height }, (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, - (Vector2){texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE); + (Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE); EndBlendMode(); @@ -144,9 +144,9 @@ int main() End3dMode(); // Draw 2D GUI stuff - DrawAngleGauge(texAngleGauge, 80, 80, roll, "roll", RED); - DrawAngleGauge(texAngleGauge, 190, 80, pitch, "pitch", GREEN); - DrawAngleGauge(texAngleGauge, 300, 80, yaw, "yaw", SKYBLUE); + DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); + DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN); + DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE); DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f)); diff --git a/examples/models/resources/angle_gauge.png b/examples/models/resources/angle_gauge.png index 120f3601..f7871de6 100644 Binary files a/examples/models/resources/angle_gauge.png and b/examples/models/resources/angle_gauge.png differ diff --git a/examples/models/resources/plane.png b/examples/models/resources/plane.png index 9f28ddb0..58951ea3 100644 Binary files a/examples/models/resources/plane.png and b/examples/models/resources/plane.png differ -- cgit v1.2.3 From 085779707f4116eb28f91dcb1f9c8ea58a959424 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 5 Nov 2017 17:13:17 +0100 Subject: Uploaded shaders for GLSL 120 --- examples/shaders/resources/shaders/glsl120/base.fs | 24 +++++++++ examples/shaders/resources/shaders/glsl120/base.vs | 26 ++++++++++ .../shaders/resources/shaders/glsl120/bloom.fs | 39 +++++++++++++++ examples/shaders/resources/shaders/glsl120/blur.fs | 34 +++++++++++++ .../resources/shaders/glsl120/cross_hatching.fs | 47 ++++++++++++++++++ .../resources/shaders/glsl120/cross_stitching.fs | 57 ++++++++++++++++++++++ .../resources/shaders/glsl120/distortion.fs | 54 ++++++++++++++++++++ .../resources/shaders/glsl120/dream_vision.fs | 37 ++++++++++++++ .../shaders/resources/shaders/glsl120/fisheye.fs | 43 ++++++++++++++++ .../shaders/resources/shaders/glsl120/grayscale.fs | 25 ++++++++++ .../shaders/resources/shaders/glsl120/pixelizer.fs | 32 ++++++++++++ .../resources/shaders/glsl120/posterization.fs | 29 +++++++++++ .../shaders/resources/shaders/glsl120/predator.fs | 31 ++++++++++++ .../shaders/resources/shaders/glsl120/scanlines.fs | 44 +++++++++++++++++ .../shaders/resources/shaders/glsl120/sobel.fs | 40 +++++++++++++++ .../shaders/resources/shaders/glsl120/swirl.fs | 46 +++++++++++++++++ 16 files changed, 608 insertions(+) create mode 100644 examples/shaders/resources/shaders/glsl120/base.fs create mode 100644 examples/shaders/resources/shaders/glsl120/base.vs create mode 100644 examples/shaders/resources/shaders/glsl120/bloom.fs create mode 100644 examples/shaders/resources/shaders/glsl120/blur.fs create mode 100644 examples/shaders/resources/shaders/glsl120/cross_hatching.fs create mode 100644 examples/shaders/resources/shaders/glsl120/cross_stitching.fs create mode 100644 examples/shaders/resources/shaders/glsl120/distortion.fs create mode 100644 examples/shaders/resources/shaders/glsl120/dream_vision.fs create mode 100644 examples/shaders/resources/shaders/glsl120/fisheye.fs create mode 100644 examples/shaders/resources/shaders/glsl120/grayscale.fs create mode 100644 examples/shaders/resources/shaders/glsl120/pixelizer.fs create mode 100644 examples/shaders/resources/shaders/glsl120/posterization.fs create mode 100644 examples/shaders/resources/shaders/glsl120/predator.fs create mode 100644 examples/shaders/resources/shaders/glsl120/scanlines.fs create mode 100644 examples/shaders/resources/shaders/glsl120/sobel.fs create mode 100644 examples/shaders/resources/shaders/glsl120/swirl.fs (limited to 'examples') diff --git a/examples/shaders/resources/shaders/glsl120/base.fs b/examples/shaders/resources/shaders/glsl120/base.fs new file mode 100644 index 00000000..9c685eb9 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/base.fs @@ -0,0 +1,24 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables +uniform vec2 resolution = vec2(800, 450); + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord); + + // NOTE: Implement here your fragment shader code + + gl_FragColor = texelColor*colDiffuse; +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/base.vs b/examples/shaders/resources/shaders/glsl120/base.vs new file mode 100644 index 00000000..674153d8 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/base.vs @@ -0,0 +1,26 @@ +#version 120 + +// Input vertex attributes +attribute vec3 vertexPosition; +attribute vec2 vertexTexCoord; +attribute vec3 vertexNormal; +attribute vec4 vertexColor; + +// Input uniform values +uniform mat4 mvp; + +// Output vertex attributes (to fragment shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Send vertex attributes to fragment shader + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + // Calculate final vertex position + gl_Position = mvp*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/bloom.fs b/examples/shaders/resources/shaders/glsl120/bloom.fs new file mode 100644 index 00000000..cd9f8cbe --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/bloom.fs @@ -0,0 +1,39 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +const vec2 size = vec2(800, 450); // render size +const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance +const float quality = 2.5; // lower = smaller glow, better quality + +void main() +{ + vec4 sum = vec4(0); + vec2 sizeFactor = vec2(1)/size*quality; + + // Texel color fetching from texture sampler + vec4 source = texture2D(texture0, fragTexCoord); + + const int range = 2; // should be = (samples - 1)/2; + + for (int x = -range; x <= range; x++) + { + for (int y = -range; y <= range; y++) + { + sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor); + } + } + + // Calculate final fragment color + gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse; +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/blur.fs b/examples/shaders/resources/shaders/glsl120/blur.fs new file mode 100644 index 00000000..e2b04ad1 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/blur.fs @@ -0,0 +1,34 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +// NOTE: Render size values must be passed from code +const float renderWidth = 800.0; +const float renderHeight = 450.0; + +vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); +vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); + +void main() +{ + // Texel color fetching from texture sampler + vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x; + + tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; + tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; + + tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; + tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/cross_hatching.fs b/examples/shaders/resources/shaders/glsl120/cross_hatching.fs new file mode 100644 index 00000000..17d9c6a3 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/cross_hatching.fs @@ -0,0 +1,47 @@ +# version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +float hatchOffsetY = 5.0; +float lumThreshold01 = 0.9; +float lumThreshold02 = 0.7; +float lumThreshold03 = 0.5; +float lumThreshold04 = 0.3; + +void main() +{ + vec3 tc = vec3(1.0, 1.0, 1.0); + float lum = length(texture2D(texture0, fragTexCoord).rgb); + + if (lum < lumThreshold01) + { + if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + if (lum < lumThreshold02) + { + if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + if (lum < lumThreshold03) + { + if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + if (lum < lumThreshold04) + { + if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/cross_stitching.fs b/examples/shaders/resources/shaders/glsl120/cross_stitching.fs new file mode 100644 index 00000000..fe60675a --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/cross_stitching.fs @@ -0,0 +1,57 @@ +# version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +// NOTE: Render size values must be passed from code +const float renderWidth = 800.0; +const float renderHeight = 450.0; + +float stitchingSize = 6.0; +int invert = 0; + +vec4 PostFX(sampler2D tex, vec2 uv) +{ + vec4 c = vec4(0.0); + float size = stitchingSize; + vec2 cPos = uv * vec2(renderWidth, renderHeight); + vec2 tlPos = floor(cPos / vec2(size, size)); + tlPos *= size; + + int remX = int(mod(cPos.x, size)); + int remY = int(mod(cPos.y, size)); + + if (remX == 0 && remY == 0) tlPos = cPos; + + vec2 blPos = tlPos; + blPos.y += (size - 1.0); + + if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) + { + if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0); + else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; + } + else + { + if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; + else c = vec4(0.0, 0.0, 0.0, 1.0); + } + + return c; +} + +void main() +{ + vec3 tc = PostFX(texture0, fragTexCoord).rgb; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/distortion.fs b/examples/shaders/resources/shaders/glsl120/distortion.fs new file mode 100644 index 00000000..568c50bf --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/distortion.fs @@ -0,0 +1,54 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; + +// Input uniform values +uniform sampler2D texture0; + +// NOTE: Default parameters for Oculus Rift DK2 device +const vec2 LeftLensCenter = vec2(0.2863248, 0.5); +const vec2 RightLensCenter = vec2(0.7136753, 0.5); +const vec2 LeftScreenCenter = vec2(0.25, 0.5); +const vec2 RightScreenCenter = vec2(0.75, 0.5); +const vec2 Scale = vec2(0.25, 0.45); +const vec2 ScaleIn = vec2(4.0, 2.5); +const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); +const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); + +void main() +{ + // The following two variables need to be set per eye + vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter; + vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; + + // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) + vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + //vec2 tc = LensCenter + Scale*theta1; + + // Detect whether blue texture coordinates are out of range since these will scaled out the furthest + vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); + vec2 tcBlue = LensCenter + Scale*thetaBlue; + + if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + else + { + // Do blue texture lookup + float blue = texture2D(texture0, tcBlue).b; + + // Do green lookup (no scaling) + vec2 tcGreen = LensCenter + Scale*theta1; + float green = texture2D(texture0, tcGreen).g; + + // Do red scale and lookup + vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); + vec2 tcRed = LensCenter + Scale*thetaRed; + float red = texture2D(texture0, tcRed).r; + + gl_FragColor = vec4(red, green, blue, 1.0); + } +} diff --git a/examples/shaders/resources/shaders/glsl120/dream_vision.fs b/examples/shaders/resources/shaders/glsl120/dream_vision.fs new file mode 100644 index 00000000..93cec8fb --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/dream_vision.fs @@ -0,0 +1,37 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +void main() +{ + vec4 color = texture2D(texture0, fragTexCoord); + + color += texture2D(texture0, fragTexCoord + 0.001); + color += texture2D(texture0, fragTexCoord + 0.003); + color += texture2D(texture0, fragTexCoord + 0.005); + color += texture2D(texture0, fragTexCoord + 0.007); + color += texture2D(texture0, fragTexCoord + 0.009); + color += texture2D(texture0, fragTexCoord + 0.011); + + color += texture2D(texture0, fragTexCoord - 0.001); + color += texture2D(texture0, fragTexCoord - 0.003); + color += texture2D(texture0, fragTexCoord - 0.005); + color += texture2D(texture0, fragTexCoord - 0.007); + color += texture2D(texture0, fragTexCoord - 0.009); + color += texture2D(texture0, fragTexCoord - 0.011); + + color.rgb = vec3((color.r + color.g + color.b)/3.0); + color = color/9.5; + + gl_FragColor = color; +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/fisheye.fs b/examples/shaders/resources/shaders/glsl120/fisheye.fs new file mode 100644 index 00000000..afac3d4a --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/fisheye.fs @@ -0,0 +1,43 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +const float PI = 3.1415926535; + +void main() +{ + float aperture = 178.0; + float apertureHalf = 0.5 * aperture * (PI / 180.0); + float maxFactor = sin(apertureHalf); + + vec2 uv = vec2(0.0); + vec2 xy = 2.0 * fragTexCoord.xy - 1.0; + float d = length(xy); + + if (d < (2.0 - maxFactor)) + { + d = length(xy * maxFactor); + float z = sqrt(1.0 - d * d); + float r = atan(d, z) / PI; + float phi = atan(xy.y, xy.x); + + uv.x = r * cos(phi) + 0.5; + uv.y = r * sin(phi) + 0.5; + } + else + { + uv = fragTexCoord.xy; + } + + gl_FragColor = texture2D(texture0, uv); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/grayscale.fs b/examples/shaders/resources/shaders/glsl120/grayscale.fs new file mode 100644 index 00000000..470a4222 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/grayscale.fs @@ -0,0 +1,25 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor; + + // Convert texel color to grayscale using NTSC conversion weights + float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); + + // Calculate final fragment color + gl_FragColor = vec4(gray, gray, gray, texelColor.a); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/pixelizer.fs b/examples/shaders/resources/shaders/glsl120/pixelizer.fs new file mode 100644 index 00000000..cea6b5e0 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/pixelizer.fs @@ -0,0 +1,32 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +// NOTE: Render size values must be passed from code +const float renderWidth = 800.0; +const float renderHeight = 450.0; + +float pixelWidth = 5.0; +float pixelHeight = 5.0; + +void main() +{ + float dx = pixelWidth*(1.0/renderWidth); + float dy = pixelHeight*(1.0/renderHeight); + + vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy)); + + vec3 tc = texture2D(texture0, coord).rgb; + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/posterization.fs b/examples/shaders/resources/shaders/glsl120/posterization.fs new file mode 100644 index 00000000..a9a5f246 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/posterization.fs @@ -0,0 +1,29 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +float gamma = 0.6; +float numColors = 8.0; + +void main() +{ + vec3 color = texture2D(texture0, fragTexCoord.xy).rgb; + + color = pow(color, vec3(gamma, gamma, gamma)); + color = color*numColors; + color = floor(color); + color = color/numColors; + color = pow(color, vec3(1.0/gamma)); + + gl_FragColor = vec4(color, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/predator.fs b/examples/shaders/resources/shaders/glsl120/predator.fs new file mode 100644 index 00000000..c471f89d --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/predator.fs @@ -0,0 +1,31 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +void main() +{ + vec3 color = texture2D(texture0, fragTexCoord).rgb; + vec3 colors[3]; + colors[0] = vec3(0.0, 0.0, 1.0); + colors[1] = vec3(1.0, 1.0, 0.0); + colors[2] = vec3(1.0, 0.0, 0.0); + + float lum = (color.r + color.g + color.b)/3.0; + + vec3 tc = vec3(0.0, 0.0, 0.0); + + if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5); + else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5); + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/scanlines.fs b/examples/shaders/resources/shaders/glsl120/scanlines.fs new file mode 100644 index 00000000..f279f347 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/scanlines.fs @@ -0,0 +1,44 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +float offset = 0.0; +float frequency = 450.0/3.0; + +uniform float time; + +void main() +{ +/* + // Scanlines method 1 + float tval = 0; //time + vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval)); + + vec4 color = texture2D(texture0, fragTexCoord); + + color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0); + color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y); + color *= vec4(0.8, 1.0, 0.7, 1); + color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0); + color *= 0.97 + 0.03*sin(110.0*tval); + + fragColor = color; +*/ + // Scanlines method 2 + float globalPos = (fragTexCoord.y + offset) * frequency; + float wavePos = cos((fract(globalPos) - 0.5)*3.14); + + vec4 color = texture2D(texture0, fragTexCoord); + + gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/sobel.fs b/examples/shaders/resources/shaders/glsl120/sobel.fs new file mode 100644 index 00000000..128ca423 --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/sobel.fs @@ -0,0 +1,40 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables +vec2 resolution = vec2(800.0, 450.0); + +void main() +{ + float x = 1.0/resolution.x; + float y = 1.0/resolution.y; + + vec4 horizEdge = vec4(0.0); + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; + horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; + horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec4 vertEdge = vec4(0.0); + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; + vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; + vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; + + vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); + + gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); +} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl120/swirl.fs b/examples/shaders/resources/shaders/glsl120/swirl.fs new file mode 100644 index 00000000..7cb24e2a --- /dev/null +++ b/examples/shaders/resources/shaders/glsl120/swirl.fs @@ -0,0 +1,46 @@ +#version 120 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +// NOTE: Render size values should be passed from code +const float renderWidth = 800; +const float renderHeight = 450; + +float radius = 250.0; +float angle = 0.8; + +uniform vec2 center; + +void main() +{ + vec2 texSize = vec2(renderWidth, renderHeight); + vec2 tc = fragTexCoord*texSize; + tc -= center; + + float dist = length(tc); + + if (dist < radius) + { + float percent = (radius - dist)/radius; + float theta = percent*percent*angle*8.0; + float s = sin(theta); + float c = cos(theta); + + tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); + } + + tc += center; + vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; + + gl_FragColor = vec4(color.rgb, 1.0);; +} \ No newline at end of file -- cgit v1.2.3 From 4fe8e05a7fcaa7223e41414407b9de251ba42676 Mon Sep 17 00:00:00 2001 From: Ray San Date: Mon, 6 Nov 2017 13:49:33 +0100 Subject: Review GLSL 120 shaders Not tested, could have errors --- examples/shaders/resources/shaders/glsl120/base.fs | 2 -- examples/shaders/resources/shaders/glsl120/bloom.fs | 2 -- examples/shaders/resources/shaders/glsl120/blur.fs | 2 -- examples/shaders/resources/shaders/glsl120/cross_hatching.fs | 2 -- examples/shaders/resources/shaders/glsl120/cross_stitching.fs | 2 -- examples/shaders/resources/shaders/glsl120/distortion.fs | 2 -- examples/shaders/resources/shaders/glsl120/dream_vision.fs | 2 -- examples/shaders/resources/shaders/glsl120/fisheye.fs | 2 -- examples/shaders/resources/shaders/glsl120/grayscale.fs | 2 -- examples/shaders/resources/shaders/glsl120/pixelizer.fs | 2 -- examples/shaders/resources/shaders/glsl120/posterization.fs | 2 -- examples/shaders/resources/shaders/glsl120/predator.fs | 2 -- examples/shaders/resources/shaders/glsl120/scanlines.fs | 2 -- examples/shaders/resources/shaders/glsl120/sobel.fs | 2 -- examples/shaders/resources/shaders/glsl120/swirl.fs | 2 -- 15 files changed, 30 deletions(-) (limited to 'examples') diff --git a/examples/shaders/resources/shaders/glsl120/base.fs b/examples/shaders/resources/shaders/glsl120/base.fs index 9c685eb9..18799f95 100644 --- a/examples/shaders/resources/shaders/glsl120/base.fs +++ b/examples/shaders/resources/shaders/glsl120/base.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/bloom.fs b/examples/shaders/resources/shaders/glsl120/bloom.fs index cd9f8cbe..c28836b0 100644 --- a/examples/shaders/resources/shaders/glsl120/bloom.fs +++ b/examples/shaders/resources/shaders/glsl120/bloom.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/blur.fs b/examples/shaders/resources/shaders/glsl120/blur.fs index e2b04ad1..99cddfc9 100644 --- a/examples/shaders/resources/shaders/glsl120/blur.fs +++ b/examples/shaders/resources/shaders/glsl120/blur.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/cross_hatching.fs b/examples/shaders/resources/shaders/glsl120/cross_hatching.fs index 17d9c6a3..46514120 100644 --- a/examples/shaders/resources/shaders/glsl120/cross_hatching.fs +++ b/examples/shaders/resources/shaders/glsl120/cross_hatching.fs @@ -1,7 +1,5 @@ # version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/cross_stitching.fs b/examples/shaders/resources/shaders/glsl120/cross_stitching.fs index fe60675a..dee4617e 100644 --- a/examples/shaders/resources/shaders/glsl120/cross_stitching.fs +++ b/examples/shaders/resources/shaders/glsl120/cross_stitching.fs @@ -1,7 +1,5 @@ # version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/distortion.fs b/examples/shaders/resources/shaders/glsl120/distortion.fs index 568c50bf..f9d7f1e5 100644 --- a/examples/shaders/resources/shaders/glsl120/distortion.fs +++ b/examples/shaders/resources/shaders/glsl120/distortion.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; diff --git a/examples/shaders/resources/shaders/glsl120/dream_vision.fs b/examples/shaders/resources/shaders/glsl120/dream_vision.fs index 93cec8fb..4ca2a863 100644 --- a/examples/shaders/resources/shaders/glsl120/dream_vision.fs +++ b/examples/shaders/resources/shaders/glsl120/dream_vision.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/fisheye.fs b/examples/shaders/resources/shaders/glsl120/fisheye.fs index afac3d4a..6f376ba3 100644 --- a/examples/shaders/resources/shaders/glsl120/fisheye.fs +++ b/examples/shaders/resources/shaders/glsl120/fisheye.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/grayscale.fs b/examples/shaders/resources/shaders/glsl120/grayscale.fs index 470a4222..4de60d22 100644 --- a/examples/shaders/resources/shaders/glsl120/grayscale.fs +++ b/examples/shaders/resources/shaders/glsl120/grayscale.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/pixelizer.fs b/examples/shaders/resources/shaders/glsl120/pixelizer.fs index cea6b5e0..6f741faf 100644 --- a/examples/shaders/resources/shaders/glsl120/pixelizer.fs +++ b/examples/shaders/resources/shaders/glsl120/pixelizer.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/posterization.fs b/examples/shaders/resources/shaders/glsl120/posterization.fs index a9a5f246..475b93a1 100644 --- a/examples/shaders/resources/shaders/glsl120/posterization.fs +++ b/examples/shaders/resources/shaders/glsl120/posterization.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/predator.fs b/examples/shaders/resources/shaders/glsl120/predator.fs index c471f89d..2999cc8d 100644 --- a/examples/shaders/resources/shaders/glsl120/predator.fs +++ b/examples/shaders/resources/shaders/glsl120/predator.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/scanlines.fs b/examples/shaders/resources/shaders/glsl120/scanlines.fs index f279f347..929c79eb 100644 --- a/examples/shaders/resources/shaders/glsl120/scanlines.fs +++ b/examples/shaders/resources/shaders/glsl120/scanlines.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/sobel.fs b/examples/shaders/resources/shaders/glsl120/sobel.fs index 128ca423..a3f3f2bf 100644 --- a/examples/shaders/resources/shaders/glsl120/sobel.fs +++ b/examples/shaders/resources/shaders/glsl120/sobel.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; diff --git a/examples/shaders/resources/shaders/glsl120/swirl.fs b/examples/shaders/resources/shaders/glsl120/swirl.fs index 7cb24e2a..0618e013 100644 --- a/examples/shaders/resources/shaders/glsl120/swirl.fs +++ b/examples/shaders/resources/shaders/glsl120/swirl.fs @@ -1,7 +1,5 @@ #version 120 -precision mediump float; - // Input vertex attributes (from vertex shader) varying vec2 fragTexCoord; varying vec4 fragColor; -- cgit v1.2.3 From 0eb222bda163fab2e70ac0b2dbe27547e490c46c Mon Sep 17 00:00:00 2001 From: Ray San Date: Tue, 7 Nov 2017 13:02:15 +0100 Subject: Issue with libraries renamed on Raspbian Stretch libEGL and libGLESv2 have been renamed on latest Raspbian Stretch version (also included on latest Jessie upgrade). It seems to be done to avoid conflicts between official Mesa libs and Broadcomm provided ones. --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 485368c4..a3b3d9be 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -245,7 +245,7 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling # NOTE: Required packages: libopenal1 - LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal + LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -lopenal endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling -- cgit v1.2.3 From 7ef604fbf5c3ba03d72b1559656e209f929e442d Mon Sep 17 00:00:00 2001 From: Wilhem Barbier Date: Thu, 9 Nov 2017 20:47:22 +0100 Subject: Store the default shaders --- examples/shaders/shaders_postprocessing.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'examples') diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index 4aac5f91..f6ed8205 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -20,10 +20,8 @@ #if defined(PLATFORM_DESKTOP) #define GLSL_VERSION 330 - #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl330/base.vs" #else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB #define GLSL_VERSION 100 - #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl100/base.vs" #endif #define MAX_POSTPRO_SHADERS 12 @@ -85,18 +83,18 @@ int main() // NOTE 2: We load the correct shader depending on GLSL version Shader shaders[MAX_POSTPRO_SHADERS]; - shaders[FX_GRAYSCALE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); - shaders[FX_POSTERIZATION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION)); - shaders[FX_DREAM_VISION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION)); - shaders[FX_PIXELIZER] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION)); - shaders[FX_CROSS_HATCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION)); - shaders[FX_CROSS_STITCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION)); - shaders[FX_PREDATOR_VIEW] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION)); - shaders[FX_SCANLINES] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION)); - shaders[FX_FISHEYE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION)); - shaders[FX_SOBEL] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION)); - shaders[FX_BLOOM] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION)); - shaders[FX_BLUR] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION)); + shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); + shaders[FX_POSTERIZATION] = LoadShader(0, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION)); + shaders[FX_DREAM_VISION] = LoadShader(0, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION)); + shaders[FX_PIXELIZER] = LoadShader(0, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION)); + shaders[FX_CROSS_HATCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION)); + shaders[FX_CROSS_STITCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION)); + shaders[FX_PREDATOR_VIEW] = LoadShader(0, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION)); + shaders[FX_SCANLINES] = LoadShader(0, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION)); + shaders[FX_FISHEYE] = LoadShader(0, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION)); + shaders[FX_SOBEL] = LoadShader(0, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION)); + shaders[FX_BLOOM] = LoadShader(0, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION)); + shaders[FX_BLUR] = LoadShader(0, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION)); int currentShader = FX_GRAYSCALE; @@ -177,4 +175,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From 09228752ce2695baf79cbc2edccc60fabb38f783 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 12 Nov 2017 10:33:44 +0100 Subject: Review default shaders usage on loading --- examples/shaders/shaders_postprocessing.c | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index f6ed8205..b8b5f6ae 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -83,6 +83,7 @@ int main() // NOTE 2: We load the correct shader depending on GLSL version Shader shaders[MAX_POSTPRO_SHADERS]; + // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); shaders[FX_POSTERIZATION] = LoadShader(0, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION)); shaders[FX_DREAM_VISION] = LoadShader(0, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION)); -- cgit v1.2.3 From 398d793dbbc1ad5723f80706d9d091427be095c4 Mon Sep 17 00:00:00 2001 From: Martinfx Date: Tue, 21 Nov 2017 19:30:52 +0100 Subject: Added FreeBSD clean for Makefile --- examples/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 1557da92..a2411c3f 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -359,6 +359,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) find . -type f -perm +ugo+x -delete rm -f *.o endif + ifeq ($(PLATFORM_OS),FREEBSD) + find . -type f -perm +ugo+x -delete + rm -f *.o + endif endif ifeq ($(PLATFORM),PLATFORM_RPI) find . -type f -executable -delete -- cgit v1.2.3 From f991a075e18df5e58bd6f6f90c1b02b5b353cbe3 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 25 Nov 2017 20:27:53 +0100 Subject: Build examples and games on Travis CI They were disabled because they failed to build, but this patch set fixes the build on Linux and macOS. This doesn't apply to the AppVeyor build on Windows yet; it currently fails at linking with OpenAL. --- examples/CMakeLists.txt | 21 ++++++++++++++++++++- examples/others/audio_standalone.c | 7 ++----- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 354a1373..96ce37e0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,9 +7,20 @@ include("../utils.cmake") # TODO `build` directory should maybe be something else... # TODO place somewhere else? include_directories("../build/release") +include_directories("../src/external") +include_directories("../src/external/glfw/include") # Get the sources together -set(example_dirs audio core models others physac shaders text texutures) +set(example_dirs audio core models others shaders text texutures) +set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L) + include(CheckSymbolExists) + check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC) + check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC) +set(CMAKE_REQUIRED_DEFINITIONS) +if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC) + set(example_dirs ${example_dirs} physac) +endif() + set(example_sources) set(example_resources) foreach(example_dir ${example_dirs}) @@ -22,6 +33,14 @@ foreach(example_dir ${example_dirs}) list(APPEND example_resources ${resources}) endforeach() +include(CheckIncludeFiles) +check_include_files(OVR_CAPI_GL.h HAVE_OCULUS_CAPI) +if(NOT HAVE_OCULUS_CAPI) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/oculus_rift.c) +endif() +list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) + + # Do each example foreach(example_source ${example_sources}) # Create the basename for the example diff --git a/examples/others/audio_standalone.c b/examples/others/audio_standalone.c index 0a09c988..97c3fd0d 100644 --- a/examples/others/audio_standalone.c +++ b/examples/others/audio_standalone.c @@ -26,14 +26,11 @@ ********************************************************************************************/ #include +#include "audio.h" #if defined(_WIN32) #include // Windows only, no stardard library -#endif - -#include "audio.h" - -#if defined(__linux__) +#else #include #include #include -- cgit v1.2.3 From 3b5a26099e0cde67084481eb6048058578b30a0c Mon Sep 17 00:00:00 2001 From: Ray San Date: Tue, 5 Dec 2017 14:01:35 +0100 Subject: Removed OpenAL Soft dependency on building OpenAL Soft backend is still available in audio module, I'm thinking if exposing it for building in some way or just left it there for advance users to switch to it manually in case of necessity... --- examples/Makefile | 55 ++++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index c5629090..44fd6ac3 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. @@ -33,15 +33,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI) RAYLIB_PATH ?= /home/pi/raylib endif -# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) -# NOTE: Libraries should be provided in the selected form +# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC -OPENAL_LIBTYPE ?= STATIC - -# On PLATFORM_WEB force OpenAL Soft shared library -ifeq ($(PLATFORM),PLATFORM_WEB) - OPENAL_LIBTYPE = SHARED -endif # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -66,6 +59,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif endif endif +ifeq ($(PLATFORM),PLATFORM_RPI) + UNAMEOS=$(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS=LINUX + endif +endif ifeq ($(PLATFORM),PLATFORM_RPI) # RPI cross-compiler @@ -140,7 +139,7 @@ endif # Define compiler flags: # -O1 defines optimization level -# -Og enable debugging +# -g enable debugging # -s strip unnecessary data from build # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) @@ -148,7 +147,7 @@ endif # -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces +CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces # Additional flags for compiler (if desired) #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes @@ -176,7 +175,7 @@ endif # Define include paths for required headers # NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external +INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) @@ -205,38 +204,28 @@ endif ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # Libraries for Windows desktop compiling - # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32 - - # Define required flags and libs for OpenAL Soft STATIC/SHARED usage - # NOTE: ALLIBS flag only required for raylib Win32 SHARED library building - ifeq ($(OPENAL_LIBTYPE),STATIC) - LDLIBS += -lopenal32 -lwinmm - CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition - else - LDLIBS += -lopenal32dll - endif + LDLIBS = -lraylib -lopengl32 -lgdi32 # Required for physac examples LDLIBS += -static -lpthread endif ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling - # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl + # NOTE: Required packages: libegl1-mesa-dev + LDLIBS = -lraylib -lGL -lm -lpthread -ldl # On XWindow requires also below libraries LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor endif ifeq ($(PLATFORM_OS),OSX) # Libraries for OSX 10.9 desktop compiling - # NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev - LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + # NOTE: Required packages: libopenal-dev libegl1-mesa-dev + LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa endif ifeq ($(PLATFORM_OS),FREEBSD) # Libraries for FreeBSD desktop compiling - # NOTE: Required packages: glfw openal-soft mesa-libs - LDLIBS = -lraylib -lglfw -lGL -lopenal -lpthread -lm + # NOTE: Required packages: mesa-libs + LDLIBS = -lraylib -lGL -lpthread -lm # On XWindow requires also below libraries LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor @@ -244,8 +233,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling - # NOTE: Required packages: libopenal1 - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -lopenal + # NOTE: Required packages: libasound2-dev (ALSA) + LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling @@ -363,10 +352,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) find . -type f -perm +ugo+x -delete rm -f *.o endif - ifeq ($(PLATFORM_OS),FREEBSD) - find . -type f -perm +ugo+x -delete - rm -f *.o - endif endif ifeq ($(PLATFORM),PLATFORM_RPI) find . -type f -executable -delete -- cgit v1.2.3 From 5ae2c0d15b349ce59425c319165505bda8298a6c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 9 Dec 2017 19:05:42 +0100 Subject: Added Wayland support Updated to latest GLFW library and working on Wayland support, still looking how to implement it on raylib because it just exposes PLATFORM_DESKTOP and defaults to X11 windowing system on Linux... --- examples/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 44fd6ac3..2c627459 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -212,10 +212,15 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling # NOTE: Required packages: libegl1-mesa-dev - LDLIBS = -lraylib -lGL -lm -lpthread -ldl + LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - # On XWindow requires also below libraries - LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + # On X11 requires also below libraries + LDLIBS += -lX11 + # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them + #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor + + # On Wayland windowing system, additional libraries requires + #LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon endif ifeq ($(PLATFORM_OS),OSX) # Libraries for OSX 10.9 desktop compiling -- cgit v1.2.3 From dae426d9c6591b95f7d468af69e3d6bbe411d9dc Mon Sep 17 00:00:00 2001 From: Martinfx Date: Sat, 23 Dec 2017 18:29:44 +0100 Subject: Fixed path for FreeBSD --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 2c627459..fe3ff205 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -51,7 +51,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) UNAMEOS=$(shell uname) ifeq ($(UNAMEOS),FreeBSD) PLATFORM_OS=FREEBSD - LIBPATH=linux + LIBPATH=freebsd endif ifeq ($(UNAMEOS),Darwin) PLATFORM_OS=OSX -- cgit v1.2.3 From c93bca8c272af83ae752afb46db2b54d85dca454 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 28 Dec 2017 17:58:09 +0100 Subject: Review Makefile config flags Support external GLFW usage Renamed some flags for consistency --- examples/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index fe3ff205..c9081b2e 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -33,6 +33,9 @@ ifeq ($(PLATFORM),PLATFORM_RPI) RAYLIB_PATH ?= /home/pi/raylib endif +# Use external GLFW library instead of rglfw module +USE_EXTERNAL_GLFW ?= FALSE + # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC @@ -235,6 +238,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # On XWindow requires also below libraries LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor endif + ifeq ($(USE_EXTERNAL_GLFW),TRUE) + LDLIBS += -lglfw + endif endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling -- cgit v1.2.3 From 7965f983baa91afa7ac8019574a14e4814c91cf2 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 28 Dec 2017 18:14:39 +0100 Subject: Support Wayland display on Linux desktop --- examples/Makefile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index c9081b2e..2eff1133 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -29,15 +29,19 @@ PLATFORM ?= PLATFORM_DESKTOP RAYLIB_PATH ?= .. PROJECT_NAME ?= raylib_example -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif +# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) +RAYLIB_LIBTYPE ?= STATIC # Use external GLFW library instead of rglfw module USE_EXTERNAL_GLFW ?= FALSE -# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC +# Use Wayland display server protocol on Linux desktop +# by default it uses X11 windowing system +USE_WAYLAND_DISPLAY ?= FALSE + +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_PATH ?= /home/pi/raylib +endif # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -223,7 +227,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor # On Wayland windowing system, additional libraries requires - #LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon + ifeq ($(USE_WAYLAND_DISPLAY),TRUE) + LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon + endif endif ifeq ($(PLATFORM_OS),OSX) # Libraries for OSX 10.9 desktop compiling -- cgit v1.2.3 From e69424c86fb2e754ebf5dcb95c9bdb2ebd4f0dbc Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 31 Dec 2017 23:50:22 +0100 Subject: Reviewed text input --- examples/text/text_input_box.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/text/text_input_box.c b/examples/text/text_input_box.c index 54eebf40..5f8d1c01 100644 --- a/examples/text/text_input_box.c +++ b/examples/text/text_input_box.c @@ -52,7 +52,7 @@ int main() letterCount++; } - if (key == KEY_BACKSPACE) + if (IsKeyPressed(KEY_BACKSPACE)) { letterCount--; name[letterCount] = '\0'; -- cgit v1.2.3 From ddf6c65d00fb956dbec407a09d217ffee491b731 Mon Sep 17 00:00:00 2001 From: - <-> Date: Mon, 15 Jan 2018 12:52:58 +0100 Subject: Review Makefiles and templates --- examples/Makefile | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 2eff1133..a5acbf3a 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -29,6 +29,11 @@ PLATFORM ?= PLATFORM_DESKTOP RAYLIB_PATH ?= .. PROJECT_NAME ?= raylib_example +# Default path for raylib on Raspberry Pi, if installed in different path, update it! +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_PATH ?= /home/pi/raylib +endif + # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC @@ -39,9 +44,8 @@ USE_EXTERNAL_GLFW ?= FALSE # by default it uses X11 windowing system USE_WAYLAND_DISPLAY ?= FALSE -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif +# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile) + # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -81,8 +85,8 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH = C:/emsdk - EMSCRIPTEN_VERSION = 1.37.21 - CLANG_VERSION=e1.37.21_64bit + EMSCRIPTEN_VERSION = 1.37.28 + CLANG_VERSION=e1.37.28_64bit PYTHON_VERSION=2.7.5.3_64bit NODE_VERSION=4.1.1_64bit export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH) @@ -154,7 +158,7 @@ endif # -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces +CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces # Additional flags for compiler (if desired) #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes @@ -177,12 +181,17 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support - CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources + # --preload-file resources # specify a resources folder for data compilation + CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources + + # Define a custom shell .html and output extension + CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + EXT = .html endif # Define include paths for required headers # NOTE: Several external required libraries (stb and others) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external +INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) @@ -210,7 +219,7 @@ endif # if you want to link libraries (libname.so or libname.a), use the -lname ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) - # Libraries for Windows desktop compiling + # Libraries for Windows desktop compilation LDLIBS = -lraylib -lopengl32 -lgdi32 # Required for physac examples @@ -258,12 +267,6 @@ ifeq ($(PLATFORM),PLATFORM_WEB) LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc endif -# Define output extension to generate a .html file using provided shell -ifeq ($(PLATFORM),PLATFORM_WEB) - EXT = .html - WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html -endif - # Define all object files required EXAMPLES = \ core/core_basic_window \ @@ -273,6 +276,7 @@ EXAMPLES = \ core/core_input_gamepad \ core/core_random_values \ core/core_color_select \ + core/core_drop_files \ core/core_storage_values \ core/core_gestures_detection \ core/core_3d_mode \ @@ -314,9 +318,9 @@ EXAMPLES = \ models/models_cubicmap \ models/models_mesh_picking \ models/models_mesh_generation \ - models/models_yaw_pitch_roll \ models/models_material_pbr \ models/models_skybox \ + models/models_yaw_pitch_roll \ shaders/shaders_model_shader \ shaders/shaders_shapes_textures \ shaders/shaders_custom_uniform \ @@ -330,11 +334,7 @@ EXAMPLES = \ physac/physics_movement \ physac/physics_restitution \ physac/physics_shatter \ - fix_dylib \ - -ifneq ($(PLATFORM),PLATFORM_RPI) - EXAMPLES += core/core_drop_files -endif + CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) @@ -378,3 +378,4 @@ ifeq ($(PLATFORM),PLATFORM_WEB) del *.o *.html *.js endif @echo Cleaning done + -- cgit v1.2.3 From f2a675ae53321b5909e9324d3bb81250e704e4f2 Mon Sep 17 00:00:00 2001 From: - <-> Date: Mon, 15 Jan 2018 13:54:06 +0100 Subject: Reviewed Makefiles... - Renamed VERSION to RAYLIB_VERSION - Renamed API_VERSION to RAYLIB_API_VERSION - Renamed RAYLIB_RELEASE to RAYLIB_RELEASE_PATH - Support Web Assembly compilation on PLATFORM_WEB --- examples/Makefile | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index a5acbf3a..7ca2dc60 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -49,24 +49,20 @@ USE_WAYLAND_DISPLAY ?= FALSE # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows + # No uname.exe on MinGW!, but OS=Windows_NT on Windows! + # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) PLATFORM_OS=WINDOWS - LIBPATH=win32 else UNAMEOS=$(shell uname) ifeq ($(UNAMEOS),Linux) PLATFORM_OS=LINUX - LIBPATH=linux endif - UNAMEOS=$(shell uname) ifeq ($(UNAMEOS),FreeBSD) PLATFORM_OS=FREEBSD - LIBPATH=freebsd endif ifeq ($(UNAMEOS),Darwin) PLATFORM_OS=OSX - LIBPATH=osx endif endif endif @@ -77,11 +73,6 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif endif -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI cross-compiler - RPI_CROSS_COMPILE ?= NO -endif - ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH = C:/emsdk @@ -93,29 +84,32 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) endif +RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs + # Define raylib release directory for compiled library ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32 endif ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux endif ifeq ($(PLATFORM_OS),OSX) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx endif ifeq ($(PLATFORM_OS),FREEBSD) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/freebsd + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd endif endif -ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5 -endif ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5 endif # Define default C compiler: gcc +# NOTE: define g++ compiler if using C++ CC = gcc ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -129,9 +123,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif endif ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(RPI_CROSS_COMPILE),YES) - # RPI cross-compiler - CC = armv6j-hardfloat-linux-gnueabi-gcc + ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) + # Define RPI cross-compiler + #CC = armv6j-hardfloat-linux-gnueabi-gcc + CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc endif endif ifeq ($(PLATFORM),PLATFORM_WEB) @@ -181,8 +176,9 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support + # -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources + CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources # Define a custom shell .html and output extension CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html @@ -202,7 +198,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif # Define library paths containing required libs -LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src +LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),FREEBSD) @@ -254,6 +250,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor endif ifeq ($(USE_EXTERNAL_GLFW),TRUE) + # NOTE: It could require additional packages installed: libglfw3-dev LDLIBS += -lglfw endif endif @@ -264,7 +261,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc + LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc endif # Define all object files required -- cgit v1.2.3 From c8e97df233f50b0bc1cba07e014aca93c5c0f15c Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 17 Jan 2018 00:43:30 +0100 Subject: Reviewed function GenImagePerlinNoise() Added support for noise image offset --- examples/textures/textures_image_generation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c index 7d8e017e..790c34f1 100644 --- a/examples/textures/textures_image_generation.c +++ b/examples/textures/textures_image_generation.c @@ -24,10 +24,10 @@ int main() Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, RED, BLUE); Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE); - Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.f, WHITE, BLACK); + Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK); Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE); Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f); - Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 8.f); + Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f); Image cellular = GenImageCellular(screenWidth, screenHeight, 32); Texture2D textures[NUM_TEXTURES]; -- cgit v1.2.3 From bdb61306aca39f8c92e6b5406af348f34171cdd0 Mon Sep 17 00:00:00 2001 From: kai Date: Wed, 17 Jan 2018 20:14:14 +0100 Subject: CMake: build shape and texture examples (#432) --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 96ce37e0..1f05d529 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ include_directories("../src/external") include_directories("../src/external/glfw/include") # Get the sources together -set(example_dirs audio core models others shaders text texutures) +set(example_dirs audio core models others shaders shapes text textures) set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L) include(CheckSymbolExists) check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC) -- cgit v1.2.3 From e86b4d4e03a91bfe37cb525b155af48724664e97 Mon Sep 17 00:00:00 2001 From: RDR8 Date: Sun, 11 Feb 2018 22:58:15 +0000 Subject: Update Makefiles for Linux installation. --- examples/Makefile | 90 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 21 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 7ca2dc60..fb704d87 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -24,29 +24,59 @@ .PHONY: all clean # Define required raylib variables -# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() -PLATFORM ?= PLATFORM_DESKTOP -RAYLIB_PATH ?= .. -PROJECT_NAME ?= raylib_example +PROJECT_NAME ?= raylib_examples +RAYLIB_VERSION ?= 1.9.4 +RAYLIB_API_VERSION ?= 1 +RAYLIB_PATH ?= .. + +# Define default options # Default path for raylib on Raspberry Pi, if installed in different path, update it! ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib + RAYLIB_PATH ?= /home/pi/raylib endif +# RAYLIB_RELEASE_PATH points to provided binaries or your immediate build of libraylib. +# See below for additions. +RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs + +# Locations of your newly installed library and associated headers. See ../src/Makefile +# On Linux, if you have installed raylib but cannot compile the examples, check that the +# *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. +# To enable system-wide runtime linking to libraylib.so, run sudo ldconfig $(RAYLIB_INSTALL_PATH). +# ldconfig is not necessary if using RAYLIB_RUNTIME_PATH below. +RAYLIB_INSTALL_PATH ?= /usr/local/lib/raysan5 +RAYLIB_H_INSTALL_PATH ?= /usr/local/include/raysan5 + +# Set runtime path to custom location of shared library if desired, avoiding sudo ldconfig. +# If you have compiled the examples but cannot run them, examine both RAYLIB_INSTALL_PATH and +# RAYLIB_RUNTIME_PATH. To see which libraries a built example is using, ldd core/core_basic_window; +# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 +# or libraylib.so.1 => $(RAYLIB_RUNTIME_PATH)/libraylib.so.1 or similar listing. +# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(RAYLIB_RUNTIME_PATH) +# This should be a fully qualified path. RAYLIB_RELEASE_PATH doesn't work here +# because it's a relative path. You must spell it out if needed. +# To see the result, run readelf -d ./core_basic_window +RAYLIB_RUNTIME_PATH ?= $(RAYLIB_INSTALL_PATH) + +# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB +PLATFORM ?= PLATFORM_DESKTOP + # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) -RAYLIB_LIBTYPE ?= STATIC +RAYLIB_LIBTYPE ?= STATIC + +# Build mode for project: DEBUG or RELEASE +RAYLIB_BUILD_MODE ?= RELEASE # Use external GLFW library instead of rglfw module -USE_EXTERNAL_GLFW ?= FALSE +USE_EXTERNAL_GLFW ?= FALSE # Use Wayland display server protocol on Linux desktop # by default it uses X11 windowing system -USE_WAYLAND_DISPLAY ?= FALSE +USE_WAYLAND_DISPLAY ?= FALSE # NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile) - # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! @@ -84,8 +114,6 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) endif -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs - # Define raylib release directory for compiled library ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) @@ -130,6 +158,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif endif ifeq ($(PLATFORM),PLATFORM_WEB) + # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() # HTML5 emscripten compiler CC = emcc endif @@ -164,7 +193,13 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) + ifeq ($(RAYLIB_LIBTYPE),STATIC) CFLAGS += -no-pie -D_DEFAULT_SOURCE + endif + ifeq ($(RAYLIB_LIBTYPE),SHARED) + # Explicitly enable runtime link to libraylib + CFLAGS += -Wl,-rpath,$(RAYLIB_RUNTIME_PATH) + endif endif endif ifeq ($(PLATFORM),PLATFORM_RPI) @@ -179,32 +214,40 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly) # --preload-file resources # specify a resources folder for data compilation CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources - + # Define a custom shell .html and output extension CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html EXT = .html endif -# Define include paths for required headers +# Define include paths for required headers. +# Precedence: immediately local, raysan5 provided sources # NOTE: Several external required libraries (stb and others) INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI requried libraries + # RPI required libraries INCLUDE_PATHS += -I/opt/vc/include INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads endif -# Define library paths containing required libs -LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src +# Define library paths containing required libs. +# Precedence: immediately local, then raysan5 provided libs +LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),FREEBSD) INCLUDE_PATHS += -I/usr/local/include LDFLAGS += -L. -Lsrc -L/usr/local/lib endif + ifeq ($(PLATFORM_OS),LINUX) + # Reset everything. + # Precedence: immediately local, installed version, raysan5 provided libs + INCLUDE_PATHS = -I. -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external + LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src + endif endif ifeq ($(PLATFORM),PLATFORM_RPI) @@ -217,7 +260,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # Libraries for Windows desktop compilation LDLIBS = -lraylib -lopengl32 -lgdi32 - + # Required for physac examples LDLIBS += -static -lpthread endif @@ -225,16 +268,21 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Debian GNU/Linux desktop compiling # NOTE: Required packages: libegl1-mesa-dev LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - + # On X11 requires also below libraries LDLIBS += -lX11 # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - + # On Wayland windowing system, additional libraries requires ifeq ($(USE_WAYLAND_DISPLAY),TRUE) LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon endif + + # Explicit link to libc + ifeq ($(RAYLIB_LIBTYPE),SHARED) + LDLIBS += -lc + endif endif ifeq ($(PLATFORM_OS),OSX) # Libraries for OSX 10.9 desktop compiling @@ -360,7 +408,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) del *.o *.exe /s endif ifeq ($(PLATFORM_OS),LINUX) - find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f + find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv endif ifeq ($(PLATFORM_OS),OSX) find . -type f -perm +ugo+x -delete @@ -369,7 +417,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif ifeq ($(PLATFORM),PLATFORM_RPI) find . -type f -executable -delete - rm -f *.o + rm -fv *.o endif ifeq ($(PLATFORM),PLATFORM_WEB) del *.o *.html *.js -- cgit v1.2.3 From 0be4d802ee291099619ab35193107945e2aa5939 Mon Sep 17 00:00:00 2001 From: RDR8 Date: Mon, 12 Feb 2018 01:25:08 +0000 Subject: Update Makefile --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index fb704d87..62ae4036 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -56,7 +56,7 @@ RAYLIB_H_INSTALL_PATH ?= /usr/local/include/raysan5 # Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(RAYLIB_RUNTIME_PATH) # This should be a fully qualified path. RAYLIB_RELEASE_PATH doesn't work here # because it's a relative path. You must spell it out if needed. -# To see the result, run readelf -d ./core_basic_window +# To see the result, run readelf -d core/core_basic_window, looking at the RPATH attribute. RAYLIB_RUNTIME_PATH ?= $(RAYLIB_INSTALL_PATH) # One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -- cgit v1.2.3 From 97f8b854297bfdd6ab62e12d8f9e2e2cd7230b87 Mon Sep 17 00:00:00 2001 From: RDR8 Date: Mon, 12 Feb 2018 09:19:24 +0000 Subject: Update Makefile --- examples/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 62ae4036..db08a36f 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -31,6 +31,9 @@ RAYLIB_PATH ?= .. # Define default options +# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB +PLATFORM ?= PLATFORM_DESKTOP + # Default path for raylib on Raspberry Pi, if installed in different path, update it! ifeq ($(PLATFORM),PLATFORM_RPI) RAYLIB_PATH ?= /home/pi/raylib @@ -59,9 +62,6 @@ RAYLIB_H_INSTALL_PATH ?= /usr/local/include/raysan5 # To see the result, run readelf -d core/core_basic_window, looking at the RPATH attribute. RAYLIB_RUNTIME_PATH ?= $(RAYLIB_INSTALL_PATH) -# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB -PLATFORM ?= PLATFORM_DESKTOP - # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC -- cgit v1.2.3 From 97bf2706c497f90ea4e3ead4e69819bc7a1f6083 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 21 Feb 2018 23:28:34 +0100 Subject: Removed flag -fgnu89-inline --- examples/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index db08a36f..c672b5d0 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -179,10 +179,9 @@ endif # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision) -# -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec -CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces +CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces # Additional flags for compiler (if desired) #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes -- cgit v1.2.3 From 6ffc8cb7990fb4ff40f205cb53bec797b10e48a2 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 22 Feb 2018 02:05:00 +0100 Subject: raymath.h: Use C99 inline semantics RAYMATH_EXTERN_INLINE was renamed to RAYMATH_HEADER_ONLY, which user code may define if they want to use it as header-only library. If multiple files in the same project define RAYMATH_HEADER_ONLY, they might each have duplicate out-of-line definitions of the same functions. By default, raymath.h exposes inline definitions, which instructs the compiler _not_ to generate out-of-line definitons, if out-of-line definitions are required, those of the file defined with RAYLIB_IMPLEMENTATION are used instead. There may be only one such file. In C++ mode, the compiler will select only one out-of-line definition automatically, so no need to define a RAYLIB_IMPLEMENTATION. Unfortunately, we have to remove raymath function declaration from raylib.h as those declarations would lead to duplicate out-of-line definitions which would yield linker errors. This problem didn't exist with GNU89 or C++, because there multiple defintions are ok, but in C99 they aren't. --- examples/models/models_skybox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 46297e41..9f0d8c17 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -62,7 +62,7 @@ int main() Begin3dMode(camera); - DrawModel(skybox, Vector3Zero(), 1.0f, WHITE); + DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); DrawGrid(10, 1.0f); -- cgit v1.2.3 From a5881fb9ccaf60ea0ff4f6afd7f3925e24330cac Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 24 Feb 2018 15:38:54 +0100 Subject: Revert "raymath.h: Use C99 inline semantics" This reverts commit 6ffc8cb7990fb4ff40f205cb53bec797b10e48a2. and commit e4d7bbec1ef08279495ac41f5f8c4be359c58cf0. which I pushed by mistake... --- examples/models/models_skybox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 9f0d8c17..46297e41 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -62,7 +62,7 @@ int main() Begin3dMode(camera); - DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); + DrawModel(skybox, Vector3Zero(), 1.0f, WHITE); DrawGrid(10, 1.0f); -- cgit v1.2.3 From 2b5fc120360baae6903c4d4c8b411b726927cbce Mon Sep 17 00:00:00 2001 From: RDR8 Date: Wed, 21 Feb 2018 19:34:08 -0600 Subject: Update Makefiles. Enable example usage of staged libraylib.so. --- examples/Makefile | 100 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 37 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index c672b5d0..6902803e 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -34,33 +34,19 @@ RAYLIB_PATH ?= .. # One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB PLATFORM ?= PLATFORM_DESKTOP -# Default path for raylib on Raspberry Pi, if installed in different path, update it! -ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH ?= /home/pi/raylib -endif - -# RAYLIB_RELEASE_PATH points to provided binaries or your immediate build of libraylib. -# See below for additions. -RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs - # Locations of your newly installed library and associated headers. See ../src/Makefile -# On Linux, if you have installed raylib but cannot compile the examples, check that the -# *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. -# To enable system-wide runtime linking to libraylib.so, run sudo ldconfig $(RAYLIB_INSTALL_PATH). -# ldconfig is not necessary if using RAYLIB_RUNTIME_PATH below. -RAYLIB_INSTALL_PATH ?= /usr/local/lib/raysan5 -RAYLIB_H_INSTALL_PATH ?= /usr/local/include/raysan5 - -# Set runtime path to custom location of shared library if desired, avoiding sudo ldconfig. -# If you have compiled the examples but cannot run them, examine both RAYLIB_INSTALL_PATH and -# RAYLIB_RUNTIME_PATH. To see which libraries a built example is using, ldd core/core_basic_window; -# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 -# or libraylib.so.1 => $(RAYLIB_RUNTIME_PATH)/libraylib.so.1 or similar listing. -# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(RAYLIB_RUNTIME_PATH) -# This should be a fully qualified path. RAYLIB_RELEASE_PATH doesn't work here -# because it's a relative path. You must spell it out if needed. -# To see the result, run readelf -d core/core_basic_window, looking at the RPATH attribute. -RAYLIB_RUNTIME_PATH ?= $(RAYLIB_INSTALL_PATH) +# On Linux, if you have installed raylib but cannot compile the examples, check that +# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations. +# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED. +# To enable compile-time linking to a special version of libraylib.so, change these variables here. +# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below. +# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime, +# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH. +# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths. +DESTDIR ?= /usr/local +RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib +# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files. +RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC @@ -69,6 +55,7 @@ RAYLIB_LIBTYPE ?= STATIC RAYLIB_BUILD_MODE ?= RELEASE # Use external GLFW library instead of rglfw module +# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 USE_EXTERNAL_GLFW ?= FALSE # Use Wayland display server protocol on Linux desktop @@ -103,6 +90,22 @@ ifeq ($(PLATFORM),PLATFORM_RPI) endif endif +# RAYLIB_PATH adjustment for different platforms. +# If using GNU make, we can get the full path to the top of the tree. Windows? BSD? +# Required for ldconfig or other tools that do not perform path expansion. +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_PREFIX ?= .. + RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX)) + endif +endif +# Default path for raylib on Raspberry Pi, if installed in different path, update it! +# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki. +# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX. +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_PATH ?= /home/pi/raylib +endif + ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH = C:/emsdk @@ -114,7 +117,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) endif -# Define raylib release directory for compiled library +# Define raylib release directory for compiled library. +# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version. ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32 @@ -136,6 +140,20 @@ ifeq ($(PLATFORM),PLATFORM_WEB) RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5 endif +# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries +# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH +# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux +# without formal installation from ../src/Makefile. It aids portability and is useful if you have +# multiple versions of raylib, have raylib installed to a non-standard location, or want to +# bundle libraylib.so with your game. Change it to your liking. +# Note: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, +# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH, +# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) +# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute. +# To see which libraries a built example is linking to, ldd core/core_basic_window; +# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing. +EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH) + # Define default C compiler: gcc # NOTE: define g++ compiler if using C++ CC = gcc @@ -192,12 +210,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) + ifeq ($(RAYLIB_BUILD_MODE),DEBUG) + CFLAGS += -g + #CC = clang + endif ifeq ($(RAYLIB_LIBTYPE),STATIC) CFLAGS += -no-pie -D_DEFAULT_SOURCE endif ifeq ($(RAYLIB_LIBTYPE),SHARED) - # Explicitly enable runtime link to libraylib - CFLAGS += -Wl,-rpath,$(RAYLIB_RUNTIME_PATH) + # Explicitly enable runtime link to libraylib.so + CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH) endif endif endif @@ -231,6 +253,17 @@ ifeq ($(PLATFORM),PLATFORM_RPI) INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads endif +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),FREEBSD) + # Consider -L$(RAYLIB_H_INSTALL_PATH) + INCLUDE_PATHS += -I/usr/local/include + endif + ifeq ($(PLATFORM_OS),LINUX) + # Reset everything. + # Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include + INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external + endif +endif # Define library paths containing required libs. # Precedence: immediately local, then raysan5 provided libs @@ -238,13 +271,12 @@ LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),FREEBSD) - INCLUDE_PATHS += -I/usr/local/include + # Consider -L$(RAYLIB_INSTALL_PATH) LDFLAGS += -L. -Lsrc -L/usr/local/lib endif ifeq ($(PLATFORM_OS),LINUX) # Reset everything. # Precedence: immediately local, installed version, raysan5 provided libs - INCLUDE_PATHS = -I. -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src endif endif @@ -259,7 +291,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # Libraries for Windows desktop compilation LDLIBS = -lraylib -lopengl32 -lgdi32 - # Required for physac examples LDLIBS += -static -lpthread endif @@ -267,17 +298,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Debian GNU/Linux desktop compiling # NOTE: Required packages: libegl1-mesa-dev LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt - # On X11 requires also below libraries LDLIBS += -lX11 # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor - # On Wayland windowing system, additional libraries requires ifeq ($(USE_WAYLAND_DISPLAY),TRUE) LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon endif - # Explicit link to libc ifeq ($(RAYLIB_LIBTYPE),SHARED) LDLIBS += -lc @@ -292,7 +320,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for FreeBSD desktop compiling # NOTE: Required packages: mesa-libs LDLIBS = -lraylib -lGL -lpthread -lm - # On XWindow requires also below libraries LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor endif @@ -422,4 +449,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB) del *.o *.html *.js endif @echo Cleaning done - -- cgit v1.2.3 From f52d2de582643719814987f7335668b611a4edbd Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 22 Feb 2018 02:05:00 +0100 Subject: raymath.h: Use C99 inline semantics RAYMATH_EXTERN_INLINE was renamed to RAYMATH_HEADER_ONLY, which user code may define if they want to use it as header-only library. If multiple files in the same project define RAYMATH_HEADER_ONLY, they might each have duplicate out-of-line definitions of the same functions. By default, raymath.h exposes inline definitions, which instructs the compiler _not_ to generate out-of-line definitons, if out-of-line definitions are required, those of the file defined with RAYLIB_IMPLEMENTATION are used instead. There may be only one such file. In C++ mode, the compiler will select only one out-of-line definition automatically, so no need to define a RAYLIB_IMPLEMENTATION. Unfortunately, we have to remove raymath function declaration from raylib.h as those declarations would lead to duplicate out-of-line definitions which would yield linker errors. This problem didn't exist with GNU89 or C++, because there multiple defintions are ok, but in C99 they aren't. --- examples/models/models_skybox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 46297e41..9f0d8c17 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -62,7 +62,7 @@ int main() Begin3dMode(camera); - DrawModel(skybox, Vector3Zero(), 1.0f, WHITE); + DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); DrawGrid(10, 1.0f); -- cgit v1.2.3 From fd2adbe62ded6cb91ae7684331381afe0675df69 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 26 Feb 2018 12:10:45 +0100 Subject: Renamed CalculateBoundingBox() to MeshBoundingBox() Renamed function for consistency with a possible Mesh manipulation functions (maybe added in a future). Naming follows Image*() manipulation functions. --- examples/models/models_mesh_picking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index e150fe92..1cc38b45 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -38,7 +38,7 @@ int main() tower.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position - BoundingBox towerBBox = CalculateBoundingBox(tower.mesh); + BoundingBox towerBBox = MeshBoundingBox(tower.mesh); // Get mesh bounding box bool hitMeshBBox = false; bool hitTriangle = false; -- cgit v1.2.3 From 8cb324b2da063fb4dac29b4d2a5495fdbe78351a Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Sun, 4 Mar 2018 16:26:49 +0100 Subject: Fix result of operation is garbage or undefined --- examples/others/audio_standalone.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'examples') diff --git a/examples/others/audio_standalone.c b/examples/others/audio_standalone.c index 97c3fd0d..38fe9935 100644 --- a/examples/others/audio_standalone.c +++ b/examples/others/audio_standalone.c @@ -76,13 +76,13 @@ int main() { // Initialization //-------------------------------------------------------------------------------------- - unsigned char key; - + static unsigned char key; + InitAudioDevice(); - + Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file - + Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg"); PlayMusicStream(music); @@ -99,23 +99,23 @@ int main() PlaySound(fxWav); key = 0; } - + if (key == 'd') { PlaySound(fxOgg); key = 0; } - + UpdateMusicStream(music); } - + // De-Initialization //-------------------------------------------------------------------------------------- UnloadSound(fxWav); // Unload sound data UnloadSound(fxOgg); // Unload sound data - + UnloadMusicStream(music); // Unload music stream data - + CloseAudioDevice(); //-------------------------------------------------------------------------------------- -- cgit v1.2.3 From 276847eca9290e71baf40c3e9e890efe441aac41 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 4 Mar 2018 23:24:30 +0100 Subject: Correct issue with tangents --- examples/models/resources/shaders/pbr.vs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/models/resources/shaders/pbr.vs b/examples/models/resources/shaders/pbr.vs index e852ac1a..885cb199 100644 --- a/examples/models/resources/shaders/pbr.vs +++ b/examples/models/resources/shaders/pbr.vs @@ -12,7 +12,7 @@ in vec3 vertexPosition; in vec2 vertexTexCoord; in vec3 vertexNormal; -in vec3 vertexTangent; +in vec4 vertexTangent; // Input uniform values uniform mat4 mvp; @@ -28,7 +28,7 @@ out vec3 fragBinormal; void main() { // Calculate binormal from vertex normal and tangent - vec3 vertexBinormal = cross(vertexNormal, vertexTangent); + vec3 vertexBinormal = cross(vertexNormal, vec3(vertexTangent)); // Calculate fragment normal based on normal transformations mat3 normalMatrix = transpose(inverse(mat3(mMatrix))); @@ -39,7 +39,7 @@ void main() // Send vertex attributes to fragment shader fragTexCoord = vertexTexCoord; fragNormal = normalize(normalMatrix*vertexNormal); - fragTangent = normalize(normalMatrix*vertexTangent); + fragTangent = normalize(normalMatrix*vec3(vertexTangent)); fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal); fragBinormal = normalize(normalMatrix*vertexBinormal); fragBinormal = cross(fragNormal, fragTangent); -- cgit v1.2.3 From 3201bad65a8584c2fa587ff4e0df2c0c310d66c3 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sat, 10 Mar 2018 19:25:17 +0100 Subject: Fixed memory leaks in physics step operations --- examples/physac/physics_demo.c | 13 ++++++++++--- examples/physac/physics_shatter.c | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/physac/physics_demo.c b/examples/physac/physics_demo.c index 1b54d51b..220c5672 100644 --- a/examples/physac/physics_demo.c +++ b/examples/physac/physics_demo.c @@ -32,6 +32,7 @@ int main() // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; int logoY = 15; + bool needsReset = false; // Initialize physics and default physics bodies InitPhysics(); @@ -52,10 +53,9 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed('R')) // Reset physics input + // Delay initialization of variables due to physics reset async + if (needsReset) { - ResetPhysics(); - floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); floor->enabled = false; @@ -63,6 +63,13 @@ int main() circle->enabled = false; } + // Reset physics input + if (IsKeyPressed('R')) + { + ResetPhysics(); + needsReset = true; + } + // Physics body creation inputs if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10); else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10); diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index 6b474cd3..f4291cac 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -32,6 +32,7 @@ int main() // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; int logoY = 15; + bool needsReset = false; // Initialize physics and default physics bodies InitPhysics(); @@ -48,14 +49,19 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed('R')) // Reset physics input + // Delay initialization of variables due to physics reset asynchronous + if (needsReset) { - ResetPhysics(); - // Create random polygon physics body to shatter body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); } + if (IsKeyPressed('R')) // Reset physics input + { + ResetPhysics(); + needsReset = true; + } + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input { // Note: some values need to be stored in variables due to asynchronous changes during main thread -- cgit v1.2.3 From 5b4197afebe29bdd9795507d440d048bb8cb7c0b Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sat, 10 Mar 2018 21:14:11 +0100 Subject: Updated copyright years --- examples/physac/physics_demo.c | 2 +- examples/physac/physics_friction.c | 2 +- examples/physac/physics_movement.c | 2 +- examples/physac/physics_restitution.c | 2 +- examples/physac/physics_shatter.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/physac/physics_demo.c b/examples/physac/physics_demo.c index 220c5672..d66d2fbe 100644 --- a/examples/physac/physics_demo.c +++ b/examples/physac/physics_demo.c @@ -10,7 +10,7 @@ * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * -* Copyright (c) 2017 Victor Fisac +* Copyright (c) 2016-2018 Victor Fisac * ********************************************************************************************/ diff --git a/examples/physac/physics_friction.c b/examples/physac/physics_friction.c index 9472729a..4c81e8c8 100644 --- a/examples/physac/physics_friction.c +++ b/examples/physac/physics_friction.c @@ -10,7 +10,7 @@ * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * -* Copyright (c) 2017 Victor Fisac +* Copyright (c) 2016-2018 Victor Fisac * ********************************************************************************************/ diff --git a/examples/physac/physics_movement.c b/examples/physac/physics_movement.c index 4b2c9ab0..f828c054 100644 --- a/examples/physac/physics_movement.c +++ b/examples/physac/physics_movement.c @@ -10,7 +10,7 @@ * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * -* Copyright (c) 2017 Victor Fisac +* Copyright (c) 2016-2018 Victor Fisac * ********************************************************************************************/ diff --git a/examples/physac/physics_restitution.c b/examples/physac/physics_restitution.c index 2be8f42e..93939ebb 100644 --- a/examples/physac/physics_restitution.c +++ b/examples/physac/physics_restitution.c @@ -10,7 +10,7 @@ * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * -* Copyright (c) 2017 Victor Fisac +* Copyright (c) 2016-2018 Victor Fisac * ********************************************************************************************/ diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index f4291cac..19c3cb6d 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -10,7 +10,7 @@ * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * -* Copyright (c) 2017 Victor Fisac +* Copyright (c) 2016-2018 Victor Fisac * ********************************************************************************************/ -- cgit v1.2.3 From d6c1159fce69c556fefebb945fd857b3c761bfab Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 11 Mar 2018 11:01:58 +0100 Subject: Corrected typo --- examples/models/models_material_pbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index 9f576348..d98d7eac 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -113,7 +113,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness) mat.shader.locs[LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler"); mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler"); mat.shader.locs[LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler"); - mat.shader.locs[LOC_MAP_OCCUSION] = GetShaderLocation(mat.shader, "occlusion.sampler"); + mat.shader.locs[LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler"); //mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler"); //mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler"); mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap"); -- cgit v1.2.3 From d91179f8ab50b608b2dfc04bccbddbd2cd9b68e5 Mon Sep 17 00:00:00 2001 From: Max Danielsson Date: Sun, 25 Mar 2018 18:49:15 +0200 Subject: Add orthographic projection example --- examples/models/models_orthographic_projection.c | 109 +++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 examples/models/models_orthographic_projection.c (limited to 'examples') diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c new file mode 100644 index 00000000..214fc969 --- /dev/null +++ b/examples/models/models_orthographic_projection.c @@ -0,0 +1,109 @@ +/******************************************************************************************* +* +* raylib [models] example - Show the difference between perspective and orthographic projection +* +* This program is heavily based on the geometric objects example +* +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + bool view_ortho = true; + + InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); + + // Define the camera to look into our 3d world + Camera camera; + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + // + + // Input + //---------------------------------------------------------------------------------- + if(IsKeyPressed(KEY_SPACE)) + { + view_ortho = !view_ortho; + } + + + // Draw + //---------------------------------------------------------------------------------- + + if(view_ortho) + { + camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; + } + else + { + camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; + } + + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); + DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); + DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); + + DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); + DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); + + DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); + DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); + DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); + + DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); + DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); + + DrawGrid(10, 1.0f); // Draw a grid + + End3dMode(); + + DrawFPS(10, 10); + + DrawText("Press Spacebar to switch camera type", 10, 40, 24, BLACK); + + if(view_ortho) + { + DrawText("Orthographic", 10, 65, 24, BLACK); + } + else + { + DrawText("Perspective", 10, 65, 24, BLACK); + } + + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} -- cgit v1.2.3 From e38d28543a6bcb451a3b1176a159d4fc0ff15326 Mon Sep 17 00:00:00 2001 From: Max Danielsson Date: Tue, 27 Mar 2018 19:58:42 +0200 Subject: Remove state bool in camera projection type example. Changes made based on commentary in pull request 513 --- examples/models/models_orthographic_projection.c | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index 214fc969..b28aa0ae 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -19,12 +19,13 @@ int main() //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; - bool view_ortho = true; InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); + const Camera perspective_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; + const Camera orthographic_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; // Define the camera to look into our 3d world - Camera camera; + Camera camera = perspective_camera; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -42,21 +43,20 @@ int main() //---------------------------------------------------------------------------------- if(IsKeyPressed(KEY_SPACE)) { - view_ortho = !view_ortho; + if(camera.type == CAMERA_PERSPECTIVE) + { + camera = orthographic_camera; + } + else + { + camera = perspective_camera; + } } // Draw //---------------------------------------------------------------------------------- - if(view_ortho) - { - camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; - } - else - { - camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; - } BeginDrawing(); @@ -86,11 +86,11 @@ int main() DrawText("Press Spacebar to switch camera type", 10, 40, 24, BLACK); - if(view_ortho) + if(camera.type == CAMERA_ORTHOGRAPHIC) { DrawText("Orthographic", 10, 65, 24, BLACK); } - else + else if(camera.type == CAMERA_PERSPECTIVE) { DrawText("Perspective", 10, 65, 24, BLACK); } -- cgit v1.2.3 From 42e64e931b27a27795f471817dc93551f4f752e8 Mon Sep 17 00:00:00 2001 From: Max Danielsson Date: Tue, 27 Mar 2018 21:16:25 +0200 Subject: Simplify camera data switch in orthographic 3d example --- examples/models/models_orthographic_projection.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index b28aa0ae..2c2a89d1 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -13,6 +13,9 @@ #include "raylib.h" +#define FOVY_PERSPECTIVE 45.0f +#define WIDTH_ORTHOGRAPHIC 10.0f + int main() { // Initialization @@ -22,10 +25,8 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); - const Camera perspective_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; - const Camera orthographic_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; // Define the camera to look into our 3d world - Camera camera = perspective_camera; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -45,11 +46,13 @@ int main() { if(camera.type == CAMERA_PERSPECTIVE) { - camera = orthographic_camera; + camera.fovy = WIDTH_ORTHOGRAPHIC; + camera.type = CAMERA_ORTHOGRAPHIC; } else { - camera = perspective_camera; + camera.fovy = FOVY_PERSPECTIVE; + camera.type = CAMERA_PERSPECTIVE; } } -- cgit v1.2.3 From df7460747926e3330886af2698994fa05b2595a9 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Tue, 13 Mar 2018 17:04:49 +0100 Subject: Fix warning: illegal character encoding in string literal --- examples/models/models_yaw_pitch_roll.c | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index 625fc554..4fdbd4d7 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.8 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Example based on Berni work on Raspberry Pi: +* Example based on Berni work on Raspberry Pi: * http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order * * Copyright (c) 2017 Ramon Santamaria (@raysan5) @@ -30,25 +30,25 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)"); - Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png"); + Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png"); Texture2D texBackground = LoadTexture("resources/background.png"); - Texture2D texPitch = LoadTexture("resources/pitch.png"); + Texture2D texPitch = LoadTexture("resources/pitch.png"); Texture2D texPlane = LoadTexture("resources/plane.png"); RenderTexture2D framebuffer = LoadRenderTexture(192, 192); - + // Model loading Model model = LoadModel("resources/plane.obj"); // Load OBJ model model.material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/plane_diffuse.png"); // Set map diffuse texture - + GenTextureMipmaps(&model.material.maps[MAP_DIFFUSE].texture); - + Camera camera = { 0 }; camera.position = (Vector3){ 0.0f, 60.0f, -120.0f };// Camera position perspective camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 30.0f; // Camera field-of-view Y - + float pitch = 0.0f; float roll = 0.0f; float yaw = 0.0f; @@ -61,7 +61,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - + // Plane roll (x-axis) controls if (IsKeyDown(KEY_LEFT)) roll += 1.0f; else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f; @@ -70,7 +70,7 @@ int main() if (roll > 0.0f) roll -= 0.5f; else if (roll < 0.0f) roll += 0.5f; } - + // Plane yaw (y-axis) controls if (IsKeyDown(KEY_S)) yaw += 1.0f; else if (IsKeyDown(KEY_A)) yaw -= 1.0f; @@ -79,7 +79,7 @@ int main() if (yaw > 0.0f) yaw -= 0.5f; else if (yaw < 0.0f) yaw += 0.5f; } - + // Plane pitch (z-axis) controls if (IsKeyDown(KEY_DOWN)) pitch += 0.6f; else if (IsKeyDown(KEY_UP)) pitch -= 0.6f; @@ -88,7 +88,7 @@ int main() if (pitch > 0.3f) pitch -= 0.3f; else if (pitch < -0.3f) pitch += 0.3f; } - + // Wraps the phase of an angle to fit between -180 and +180 degrees int pitchOffset = pitch; while (pitchOffset > 180) pitchOffset -= 360; @@ -96,20 +96,20 @@ int main() pitchOffset *= 10; Matrix transform = MatrixIdentity(); - + transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll)); transform = MatrixMultiply(transform, MatrixRotateX(DEG2RAD*pitch)); transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw)); - + model.transform = transform; //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + ClearBackground(RAYWHITE); - + // Draw framebuffer texture (Ahrs Display) int centerX = framebuffer.texture.width/2; int centerY = framebuffer.texture.height/2; @@ -126,11 +126,11 @@ int main() DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height }, (Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor }, (Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); - + DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height }, - (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, + (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, (Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE); - + EndBlendMode(); EndTextureMode(); @@ -147,7 +147,7 @@ int main() DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN); DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE); - + DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f)); DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 370, 10, DARKGRAY); @@ -155,31 +155,31 @@ int main() DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 410, 10, DARKGRAY); // Draw framebuffer texture - DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height }, + DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height }, (Vector2){ screenWidth - framebuffer.texture.width - 20, 20 }, Fade(WHITE, 0.8f)); - + DrawRectangleLines(screenWidth - framebuffer.texture.width - 20, 20, framebuffer.texture.width, framebuffer.texture.height, DARKGRAY); - + EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - + // Unload all loaded data UnloadModel(model); - + UnloadRenderTexture(framebuffer); - - UnloadTexture(texAngleGauge); + + UnloadTexture(texAngleGauge); UnloadTexture(texBackground); - UnloadTexture(texPitch); + UnloadTexture(texPitch); UnloadTexture(texPlane); - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - + return 0; } @@ -192,7 +192,7 @@ void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[ int textSize = 20; DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color); - - DrawText(FormatText("%5.1f°", angle), x - MeasureText(FormatText("%5.1f°", angle), textSize) / 2, y + 10, textSize, DARKGRAY); - DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY); -} \ No newline at end of file + + DrawText(FormatText("%5.1f", angle), x - MeasureText(FormatText("%5.1f", angle), textSize) / 2, y + 10, textSize, DARKGRAY); + DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY); +} -- cgit v1.2.3 From 9459186125f2e5f7dca7606acd8b2871c6cde35f Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Tue, 13 Mar 2018 17:13:46 +0100 Subject: Fix call argument is an uninitialized value --- examples/others/bunnymark.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/others/bunnymark.c b/examples/others/bunnymark.c index 1ada54db..8b524b01 100644 --- a/examples/others/bunnymark.c +++ b/examples/others/bunnymark.c @@ -10,7 +10,6 @@ ********************************************************************************************/ #include "raylib.h" - #include // Required for: malloc(), free() #define MAX_BUNNIES 100000 // 100K bunnies @@ -29,15 +28,16 @@ int main() int screenHeight = 960; InitWindow(screenWidth, screenHeight, "raylib example - Bunnymark"); - + Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png"); - + Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array + int bunniesCount = 0; // Bunnies counter SetTargetFPS(60); //-------------------------------------------------------------------------------------- - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -54,7 +54,7 @@ int main() bunniesCount++; } } - + // Update bunnies for (int i = 0; i < bunniesCount; i++) { @@ -65,14 +65,14 @@ int main() if ((bunnies[i].position.y > GetScreenHeight()) || (bunnies[i].position.y < 0)) bunnies[i].speed.y *= -1; } //---------------------------------------------------------------------------------- - + // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); - - for (int i = 0; i <= bunniesCount; i++) + + for (int i = 0; i < bunniesCount; i++) { // NOTE: When internal QUADS batch limit is reached, a draw call is launched and // batching buffer starts being filled again; before launching the draw call, @@ -80,11 +80,10 @@ int main() // a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, RAYWHITE); } - + DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY); DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY); DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED); - DrawFPS(260, 10); EndDrawing(); @@ -94,9 +93,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- free(bunnies); - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From 6a3eca3f9295113db96f6442ec5ad8d465302084 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Thu, 15 Mar 2018 23:51:39 +0100 Subject: Fix value stored to 'body' is never read --- examples/physac/physics_shatter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index 6b474cd3..07c3c4b3 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -38,8 +38,8 @@ int main() SetPhysicsGravity(0, 0); // Create random polygon physics body to shatter - PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - + CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -53,7 +53,7 @@ int main() ResetPhysics(); // Create random polygon physics body to shatter - body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); } if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input -- cgit v1.2.3 From 551cf506855de9f04a713df8380278ccee15bb22 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Fri, 16 Mar 2018 10:19:09 +0100 Subject: Fix Uninitialized argument value --- examples/core/core_3d_picking.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 7658b393..56e80f2a 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -29,11 +29,11 @@ int main() Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; - - Ray ray; // Picking line ray - + + Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray + bool collision = false; - + SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -45,11 +45,11 @@ int main() // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera - + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { ray = GetMouseRay(GetMousePosition(), camera); - + // Check collision between ray and box collision = CheckCollisionRayBox(ray, (BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, @@ -65,7 +65,7 @@ int main() Begin3dMode(camera); - if (collision) + if (collision) { DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON); @@ -77,15 +77,14 @@ int main() DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); } - + DrawRay(ray, MAROON); - DrawGrid(10, 1.0f); End3dMode(); - + DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); - + if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN); DrawFPS(10, 10); @@ -100,4 +99,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From 7bd0f8b28c4cd576ab5c3e7b696d408f0f8045e4 Mon Sep 17 00:00:00 2001 From: lumaio teon Date: Sat, 7 Apr 2018 04:00:06 -0400 Subject: Fix mesh picking example --- examples/models/models_mesh_picking.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index 1cc38b45..e09f9860 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -101,8 +101,8 @@ int main() { hitMeshBBox = true; - // Check ray collision against mesh - meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh); + // Check ray collision against model + meshHitInfo = GetCollisionRayModel(ray, &tower); if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance)) { -- cgit v1.2.3 From cc3b8645df23ed9aeb9d6efc806ab91170a29a89 Mon Sep 17 00:00:00 2001 From: Ray San Date: Tue, 10 Apr 2018 10:37:48 +0200 Subject: Updated release version --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 6902803e..becb91dc 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -25,7 +25,7 @@ # Define required raylib variables PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 1.9.4 +RAYLIB_VERSION ?= 1.9.7 RAYLIB_API_VERSION ?= 1 RAYLIB_PATH ?= .. -- cgit v1.2.3 From 4cc12ef2b32f66f160e4e401e5cd76d1740eaf61 Mon Sep 17 00:00:00 2001 From: Ray San Date: Wed, 11 Apr 2018 10:13:00 +0200 Subject: Review camera definition on examples --- examples/core/core_3d_camera_first_person.c | 7 ++++- examples/core/core_world_screen.c | 7 ++++- examples/models/models_billboard.c | 8 ++++- examples/models/models_box_collisions.c | 2 +- examples/models/models_cubicmap.c | 2 +- examples/models/models_geometric_shapes.c | 7 ++++- examples/models/models_heightmap.c | 2 +- examples/models/models_material_pbr.c | 2 +- examples/models/models_mesh_generation.c | 2 +- examples/models/models_obj_loading.c | 7 ++++- examples/models/models_orthographic_projection.c | 37 +++++++----------------- examples/models/models_skybox.c | 2 +- examples/models/models_yaw_pitch_roll.c | 1 + examples/shaders/shaders_custom_uniform.c | 7 ++++- examples/shaders/shaders_model_shader.c | 7 ++++- examples/shaders/shaders_postprocessing.c | 2 +- 16 files changed, 62 insertions(+), 40 deletions(-) (limited to 'examples') diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 3998af81..775e6c57 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -23,7 +23,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); // Define the camera to look into our 3d world (position, target, up vector) - Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 4.0f, 2.0f, 4.0f }; + camera.target = (Vector3){ 0.0f, 1.8f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 60.0f; + camera.type = CAMERA_PERSPECTIVE; // Generates some random columns float heights[MAX_COLUMNS]; diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c index f8c53c70..78ca6eb4 100644 --- a/examples/core/core_world_screen.c +++ b/examples/core/core_world_screen.c @@ -21,7 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world - Camera camera = {{ 10.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; + camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c index bca9faf8..3b3efc47 100644 --- a/examples/models/models_billboard.c +++ b/examples/models/models_billboard.c @@ -21,7 +21,13 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); // Define the camera to look into our 3d world - Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; + camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; + Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard diff --git a/examples/models/models_box_collisions.c b/examples/models/models_box_collisions.c index 69cec418..eb72c54c 100644 --- a/examples/models/models_box_collisions.c +++ b/examples/models/models_box_collisions.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Vector3 playerPosition = { 0.0f, 1.0f, 2.0f }; Vector3 playerSize = { 1.0f, 2.0f, 1.0f }; diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c index d8be9329..47b88748 100644 --- a/examples/models/models_cubicmap.c +++ b/examples/models/models_cubicmap.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); // Define the camera to look into our 3d world - Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) diff --git a/examples/models/models_geometric_shapes.c b/examples/models/models_geometric_shapes.c index a13a1f3b..7a1e7e48 100644 --- a/examples/models/models_geometric_shapes.c +++ b/examples/models/models_geometric_shapes.c @@ -21,7 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; + camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c index e476d1b7..55474185 100644 --- a/examples/models/models_heightmap.c +++ b/examples/models/models_heightmap.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); // Define our custom camera to look into our 3d world - Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index d98d7eac..4ad2c9e7 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -34,7 +34,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material"); // Define the camera to look into our 3d world - Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; // Load model and PBR material Model model = LoadModel("resources/pbr/trooper.obj"); diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index 72222156..d9c28ac2 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -41,7 +41,7 @@ int main() for (int i = 0; i < NUM_MODELS; i++) models[i].material.maps[MAP_DIFFUSE].texture = texture; // Define the camera to look into our 3d world - Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; // Model drawing position Vector3 position = { 0.0f, 0.0f, 0.0f }; diff --git a/examples/models/models_obj_loading.c b/examples/models/models_obj_loading.c index 70f92168..4f89130f 100644 --- a/examples/models/models_obj_loading.c +++ b/examples/models/models_obj_loading.c @@ -21,7 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; + camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index 2c2a89d1..cb5ea053 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -4,17 +4,17 @@ * * This program is heavily based on the geometric objects example * -* This example has been created using raylib 1.0 (www.raylib.com) +* This example has been created using raylib 1.9.7 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2018 Max Danielsson & Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" -#define FOVY_PERSPECTIVE 45.0f -#define WIDTH_ORTHOGRAPHIC 10.0f +#define FOVY_PERSPECTIVE 45.0f +#define WIDTH_ORTHOGRAPHIC 10.0f int main() { @@ -36,15 +36,9 @@ int main() { // Update //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - // - - // Input - //---------------------------------------------------------------------------------- - if(IsKeyPressed(KEY_SPACE)) + if (IsKeyPressed(KEY_SPACE)) { - if(camera.type == CAMERA_PERSPECTIVE) + if (camera.type == CAMERA_PERSPECTIVE) { camera.fovy = WIDTH_ORTHOGRAPHIC; camera.type = CAMERA_ORTHOGRAPHIC; @@ -55,12 +49,10 @@ int main() camera.type = CAMERA_PERSPECTIVE; } } - + //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- - - BeginDrawing(); ClearBackground(RAYWHITE); @@ -85,19 +77,12 @@ int main() End3dMode(); - DrawFPS(10, 10); + DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY); - DrawText("Press Spacebar to switch camera type", 10, 40, 24, BLACK); - - if(camera.type == CAMERA_ORTHOGRAPHIC) - { - DrawText("Orthographic", 10, 65, 24, BLACK); - } - else if(camera.type == CAMERA_PERSPECTIVE) - { - DrawText("Perspective", 10, 65, 24, BLACK); - } + if (camera.type == CAMERA_ORTHOGRAPHIC) DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK); + else if (camera.type == CAMERA_PERSPECTIVE) DrawText("PERSPECTIVE", 10, 40, 20, BLACK); + DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 9f0d8c17..700824d3 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing"); // Define the camera to look into our 3d world - Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; // Load skybox model Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f); diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index 4fdbd4d7..c559e67b 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -48,6 +48,7 @@ int main() camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 30.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera type float pitch = 0.0f; float roll = 0.0f; diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c index a0f6fd22..4e160455 100644 --- a/examples/shaders/shaders_custom_uniform.c +++ b/examples/shaders/shaders_custom_uniform.c @@ -30,7 +30,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; + camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map) diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c index f1a349c6..51acc836 100644 --- a/examples/shaders/shaders_model_shader.c +++ b/examples/shaders/shaders_model_shader.c @@ -30,7 +30,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = { 0 }; + camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; + camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; + camera.fovy = 45.0f; + camera.type = CAMERA_PERSPECTIVE; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index b8b5f6ae..5eeda896 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -70,7 +70,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map) -- cgit v1.2.3