diff --git a/examples/Makefile b/examples/Makefile index fde0dd2ec..67f7c8241 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -298,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) # Reset everything. # Precedence: immediately local, installed version, raysan5 provided libs - LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src + LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) endif endif @@ -505,3 +505,4 @@ ifeq ($(PLATFORM),PLATFORM_WEB) del *.o *.html *.js endif @echo Cleaning done + diff --git a/examples/audio/audio_music_stream.c b/examples/audio/audio_music_stream.c index 26450a869..80dc6f5a9 100644 --- a/examples/audio/audio_music_stream.c +++ b/examples/audio/audio_music_stream.c @@ -4,7 +4,7 @@ * * NOTE: This example requires OpenAL Soft library installed * -* This example has been created using raylib 1.3 (www.raylib.com) +* This example has been created using raylib 1.7 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2015 Ramon Santamaria (@raysan5) diff --git a/examples/audio/audio_sound_loading.c b/examples/audio/audio_sound_loading.c index 00e583264..f66a3afd2 100644 --- a/examples/audio/audio_sound_loading.c +++ b/examples/audio/audio_sound_loading.c @@ -4,10 +4,10 @@ * * NOTE: This example requires OpenAL Soft library installed * -* This example has been created using raylib 1.0 (www.raylib.com) +* This example has been created using raylib 1.3 (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) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/audio/resources/applause.mp3 b/examples/audio/resources/applause.mp3 deleted file mode 100644 index 084a7d1f8..000000000 Binary files a/examples/audio/resources/applause.mp3 and /dev/null differ diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c index fa0bafaf8..4d6514121 100644 --- a/examples/shaders/shaders_palette_switch.c +++ b/examples/shaders/shaders_palette_switch.c @@ -81,7 +81,7 @@ int main() // Load shader to be used on some parts drawing // NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version // NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/palette-switch.fs", GLSL_VERSION)); + Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/palette_switch.fs", GLSL_VERSION)); // Get variable (uniform) location on the shader to connect with the program // NOTE: If uniform variable could not be found in the shader, function returns -1 diff --git a/examples/shaders/shaders_palette_switch.png b/examples/shaders/shaders_palette_switch.png new file mode 100644 index 000000000..7eb3eaf39 Binary files /dev/null and b/examples/shaders/shaders_palette_switch.png differ diff --git a/examples/shaders/shaders_texture_waves.c b/examples/shaders/shaders_texture_waves.c index bc677c788..e0026d36c 100644 --- a/examples/shaders/shaders_texture_waves.c +++ b/examples/shaders/shaders_texture_waves.c @@ -38,22 +38,19 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves"); - // Load space texture to apply shaders - Texture2D space = LoadTexture("resources/space.png"); + // Load texture texture to apply shaders + Texture2D texture = LoadTexture("resources/space.png"); // Load shader and setup location points and values - Shader wave = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION)); + Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION)); - float screenSizeLoc = GetShaderLocation(wave, "size"); - float secondsLoc = GetShaderLocation(wave, "secondes"); - float freqXLoc = GetShaderLocation(wave, "freqX"); - float freqYLoc = GetShaderLocation(wave, "freqY"); - float ampXLoc = GetShaderLocation(wave, "ampX"); - float ampYLoc = GetShaderLocation(wave, "ampY"); - float speedXLoc = GetShaderLocation(wave, "speedX"); - float speedYLoc = GetShaderLocation(wave, "speedY"); - - float screenSize[2] = { 800, 450 }; + int secondsLoc = GetShaderLocation(shader, "secondes"); + int freqXLoc = GetShaderLocation(shader, "freqX"); + int freqYLoc = GetShaderLocation(shader, "freqY"); + int ampXLoc = GetShaderLocation(shader, "ampX"); + int ampYLoc = GetShaderLocation(shader, "ampY"); + int speedXLoc = GetShaderLocation(shader, "speedX"); + int speedYLoc = GetShaderLocation(shader, "speedY"); // Shader uniform values that can be updated at any time float freqX = 25.0f; @@ -63,13 +60,14 @@ int main() float speedX = 8.0f; float speedY = 8.0f; - SetShaderValue(wave, screenSizeLoc, &screenSize, UNIFORM_VEC2); - SetShaderValue(wave, freqXLoc, &freqX, UNIFORM_FLOAT); - SetShaderValue(wave, freqYLoc, &freqY, UNIFORM_FLOAT); - SetShaderValue(wave, ampXLoc, &X, UNIFORM_FLOAT); - SetShaderValue(wave, ampYLoc, &Y, UNIFORM_FLOAT); - SetShaderValue(wave, speedXLoc, &speedX, UNIFORM_FLOAT); - SetShaderValue(wave, speedYLoc, &speedY, UNIFORM_FLOAT); + float screenSize[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() }; + SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, UNIFORM_VEC2); + SetShaderValue(shader, freqXLoc, &freqX, UNIFORM_FLOAT); + SetShaderValue(shader, freqYLoc, &freqY, UNIFORM_FLOAT); + SetShaderValue(shader, ampXLoc, &X, UNIFORM_FLOAT); + SetShaderValue(shader, ampYLoc, &Y, UNIFORM_FLOAT); + SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT); + SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT); float seconds = 0.0f; @@ -83,7 +81,7 @@ int main() //---------------------------------------------------------------------------------- seconds += GetFrameTime(); - SetShaderValue(wave, secondsLoc, &seconds, UNIFORM_FLOAT); + SetShaderValue(shader, secondsLoc, &seconds, UNIFORM_FLOAT); //---------------------------------------------------------------------------------- // Draw @@ -92,10 +90,10 @@ int main() ClearBackground(RAYWHITE); - BeginShaderMode(wave); + BeginShaderMode(shader); - DrawTexture(space, 0, 0, WHITE); - DrawTexture(space, space.width, 0, WHITE); + DrawTexture(texture, 0, 0, WHITE); + DrawTexture(texture, texture.width, 0, WHITE); EndShaderMode(); @@ -105,8 +103,8 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadShader(wave); // Unload shader - UnloadTexture(space); // Unload texture + UnloadShader(shader); // Unload shader + UnloadTexture(texture); // Unload texture CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/resources/emoji.fnt b/examples/text/resources/emoji.fnt index cabbdf6c8..85c71968e 100644 --- a/examples/text/resources/emoji.fnt +++ b/examples/text/resources/emoji.fnt @@ -1,6 +1,6 @@ info face="Symbola" size=-64 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=2 common lineHeight=81 base=59 scaleW=1024 scaleH=1024 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="emoji_0.png" +page id=0 file="emoji.png" chars count=187 char id=9749 x=135 y=333 width=63 height=61 xoffset=1 yoffset=9 xadvance=65 page=0 chnl=15 char id=9752 x=366 y=396 width=57 height=59 xoffset=0 yoffset=10 xadvance=58 page=0 chnl=15 diff --git a/examples/text/resources/emoji_0.png b/examples/text/resources/emoji.png similarity index 100% rename from examples/text/resources/emoji_0.png rename to examples/text/resources/emoji.png diff --git a/examples/text/resources/notoCJK.fnt b/examples/text/resources/notoCJK.fnt index 235ee7712..2edfb61ed 100644 --- a/examples/text/resources/notoCJK.fnt +++ b/examples/text/resources/notoCJK.fnt @@ -1,6 +1,6 @@ info face="Noto Serif CJK JP" size=-16 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=1 common lineHeight=23 base=18 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="notoCJK_0.png" +page id=0 file="notoCJK.png" chars count=576 char id=32 x=507 y=185 width=3 height=3 xoffset=-1 yoffset=-1 xadvance=4 page=0 chnl=15 char id=33 x=449 y=285 width=5 height=14 xoffset=0 yoffset=5 xadvance=5 page=0 chnl=15 diff --git a/examples/text/resources/notoCJK_0.png b/examples/text/resources/notoCJK.png similarity index 100% rename from examples/text/resources/notoCJK_0.png rename to examples/text/resources/notoCJK.png diff --git a/examples/text/resources/shaders/glsl100/sdf.fs b/examples/text/resources/shaders/glsl100/sdf.fs new file mode 100644 index 000000000..b4214d92c --- /dev/null +++ b/examples/text/resources/shaders/glsl100/sdf.fs @@ -0,0 +1,23 @@ +#version 100 + +// 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 smoothing = 1.0/16.0; + +void main() +{ + // Texel color fetching from texture sampler + // NOTE: Calculate alpha using signed distance field (SDF) + float distance = texture2D(texture0, fragTexCoord).a; + float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance); + + // Calculate final fragment color + gl_FragColor = vec4(fragColor.rgb, fragColor.a*alpha); +} diff --git a/examples/text/resources/shaders/sdf.fs b/examples/text/resources/shaders/glsl330/sdf.fs similarity index 100% rename from examples/text/resources/shaders/sdf.fs rename to examples/text/resources/shaders/glsl330/sdf.fs diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index 755b642dd..69cff4719 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -11,6 +11,12 @@ #include "raylib.h" +#if defined(PLATFORM_DESKTOP) + #define GLSL_VERSION 330 +#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB + #define GLSL_VERSION 100 +#endif + int main() { // Initialization @@ -47,7 +53,7 @@ int main() UnloadImage(atlas); // Load SDF required shader (we use default vertex shader) - Shader shader = LoadShader(0, "resources/shaders/sdf.fs"); + Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/sdf.fs", GLSL_VERSION)); SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font Vector2 fontPosition = { 40, screenHeight/2 - 50 }; diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index 6b456a75d..f3c2612c0 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -156,7 +156,7 @@ int main(int argc, char **argv) const int screenHeight = 450; SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); - InitWindow(screenWidth, screenHeight, "raylib - unicode test"); + InitWindow(screenWidth, screenHeight, "raylib [text] example - unicode"); // Load the font resources // NOTE: fontAsian is for asian languages, diff --git a/examples/textures/textures_bunnymark.png b/examples/textures/textures_bunnymark.png new file mode 100644 index 000000000..4431ccec4 Binary files /dev/null and b/examples/textures/textures_bunnymark.png differ diff --git a/examples/textures/textures_sprite_button.png b/examples/textures/textures_sprite_button.png new file mode 100644 index 000000000..dac519d4c Binary files /dev/null and b/examples/textures/textures_sprite_button.png differ diff --git a/examples/textures/textures_sprite_explosion.c b/examples/textures/textures_sprite_explosion.c index aa10a76cf..47c994b00 100644 --- a/examples/textures/textures_sprite_explosion.c +++ b/examples/textures/textures_sprite_explosion.c @@ -29,7 +29,7 @@ int main() Sound fxBoom = LoadSound("resources/boom.wav"); // Load explosion texture - Texture2D explosion = LoadTexture("resources/explosion2.png"); + Texture2D explosion = LoadTexture("resources/explosion.png"); // Init variables for animation int frameWidth = explosion.width/NUM_FRAMES; // Sprite one frame rectangle width diff --git a/examples/textures/textures_sprite_explosion.png b/examples/textures/textures_sprite_explosion.png new file mode 100644 index 000000000..8a439c35d Binary files /dev/null and b/examples/textures/textures_sprite_explosion.png differ