Reviewed makefile and examples building

This commit is contained in:
raysan5 2021-10-17 21:00:52 +02:00
parent cf12992b6a
commit f437f7b405
5 changed files with 127 additions and 71 deletions

View File

@ -514,7 +514,6 @@ PHYSICS = \
physics/physics_restitution \
physics/physics_shatter
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Default target entry
@ -533,6 +532,9 @@ physics: $(PHYSICS)
core/core_basic_window: core/core_basic_window.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_basic_screen_manager: core/core_basic_screen_manager.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_input_keys: core/core_input_keys.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -596,6 +598,7 @@ core/core_vr_simulator: core/core_vr_simulator.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file core/resources/distortion100.fs@resources/distortion100.fs
# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1)
core/core_loading_thread: core/core_loading_thread.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s USE_PTHREADS=1
@ -605,6 +608,15 @@ core/core_quat_conversion: core/core_quat_conversion.c
core/core_window_flags: core/core_window_flags.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_split_screen: core/core_split_screen.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_smooth_pixelperfect: core/core_smooth_pixelperfect.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
core/core_custom_frame_control: core/core_custom_frame_control.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile SHAPES examples
shapes/shapes_basic_shapes: shapes/shapes_basic_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -734,6 +746,10 @@ textures/textures_draw_tiled: textures/textures_draw_tiled.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s ASYNCIFY \
--preload-file textures/resources/patterns.png@resources/patterns.png
textures/textures_polygon: textures/textures_polygon.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/cat.png@resources/cat.png
# Compile TEXT examples
text/text_raylib_fonts: text/text_raylib_fonts.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -788,12 +804,16 @@ text/text_unicode: text/text_unicode.c
--preload-file text/resources/symbola.fnt@resources/symbola.fnt \
--preload-file text/resources/symbola.png@resources/symbola.png
text/text_draw_3d: text/text_draw_3d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file text/resources/shaders/glsl100/alpha_discard.fs@resources/shaders/glsl100/alpha_discard.fs
# Compile MODELS examples
models/models_animation: models/models_animation.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file models/resources/iqm/guy/guy.iqm@resources/iqm/guy/guy.iqm \
--preload-file models/resources/iqm/guy/guytex.png@resources/iqm/guy/guytex.png \
--preload-file models/resources/iqm/guy/guyanim.iqm@resources/iqm/guy/guyanim.iqm
--preload-file models/resources/models/iqm/guy.iqm@resources/models/iqm/guy.iqm \
--preload-file models/resources/models/iqm/guytex.png@resources/models/iqm/guytex.png \
--preload-file models/resources/models/iqm/guyanim.iqm@resources/models/iqm/guyanim.iqm
models/models_billboard: models/models_billboard.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -837,7 +857,13 @@ models/models_loading_vox: models/models_loading_vox.c
models/models_loading_gltf: models/models_loading_gltf.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file models/resources/models/gltf/raylib_32x32.glb@resources/models/gltf/raylib_32x32.glb \
--preload-file models/resources/models/gltf/girl.glb@resources/models/gltf/girl.glb
--preload-file models/resources/models/gltf/girl.glb@resources/models/gltf/girl.glb \
--preload-file models/resources/models/gltf/rigged_figure.glb@resources/models/gltf/rigged_figure.glb \
--preload-file models/resources/models/gltf/GearboxAssy.glb@resources/models/gltf/GearboxAssy.glb \
--preload-file models/resources/models/gltf/BoxAnimated.glb@resources/models/gltf/BoxAnimated.glb \
--preload-file models/resources/models/gltf/AnimatedTriangle.gltf@resources/models/gltf/AnimatedTriangle.gltf \
--preload-file models/resources/models/gltf/AnimatedMorphCube.glb@resources/models/gltf/AnimatedMorphCube.glb \
--preload-file models/resources/models/gltf/vertex_colored_object.glb@resources/models/gltf/vertex_colored_object.glb
models/models_orthographic_projection: models/models_orthographic_projection.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
@ -868,8 +894,8 @@ models/models_waving_cubes: models/models_waving_cubes.c
# Compile SHADER examples
shaders/shaders_model_shader: shaders/shaders_model_shader.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file shaders/resources/models/obj/watermill.obj@resources/models/obj/watermill.obj \
--preload-file shaders/resources/models/obj/watermill_diffuse.png@resources/models/obj/watermill_diffuse.png \
--preload-file shaders/resources/models/watermill.obj@resources/models/watermill.obj \
--preload-file shaders/resources/models/watermill_diffuse.png@resources/models/watermill_diffuse.png \
--preload-file shaders/resources/shaders/glsl100/grayscale.fs@resources/shaders/glsl100/grayscale.fs
shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
@ -880,14 +906,14 @@ shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
shaders/shaders_custom_uniform: shaders/shaders_custom_uniform.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file shaders/resources/models/obj/barracks.obj@resources/models/obj/barracks.obj \
--preload-file shaders/resources/models/obj/barracks_diffuse.png@resources/models/obj/barracks_diffuse.png \
--preload-file shaders/resources/models/barracks.obj@resources/models/barracks.obj \
--preload-file shaders/resources/models/barracks_diffuse.png@resources/models/barracks_diffuse.png \
--preload-file shaders/resources/shaders/glsl100/swirl.fs@resources/shaders/glsl100/swirl.fs
shaders/shaders_postprocessing: shaders/shaders_postprocessing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s TOTAL_MEMORY=67108864 \
--preload-file shaders/resources/models/obj/church.obj@resources/models/obj/church.obj \
--preload-file shaders/resources/models/obj/church_diffuse.png@resources/models/obj/church_diffuse.png \
--preload-file shaders/resources/models/church.obj@resources/models/church.obj \
--preload-file shaders/resources/models/church_diffuse.png@resources/models/church_diffuse.png \
--preload-file shaders/resources/shaders/glsl100@resources/shaders/glsl100
shaders/shaders_palette_switch: shaders/shaders_palette_switch.c
@ -942,7 +968,7 @@ shaders/shaders_hot_reloading: shaders/shaders_hot_reloading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s FORCE_FILESYSTEM=1 \
--preload-file shaders/resources/shaders/glsl100/reload.fs@resources/shaders/glsl100/reload.fs
shaders/shaders_rlgl_mesh_instanced: shaders/shaders_rlgl_mesh_instanced.c
shaders/shaders_mesh_instancing: shaders/shaders_mesh_instancing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs \
--preload-file shaders/resources/shaders/glsl100/base_lighting_instanced.vs@resources/shaders/glsl100/base_lighting_instanced.vs
@ -951,6 +977,11 @@ shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
shaders/shaders_texture_outline: shaders/shaders_texture_outline.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/outline.fs@resources/shaders/glsl100/outline.fs \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png
# Compile AUDIO examples
audio/audio_module_playing: audio/audio_module_playing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
@ -974,6 +1005,7 @@ audio/audio_multichannel_sound: audio/audio_multichannel_sound.c
--preload-file audio/resources/target.ogg@resources/target.ogg
# Compile PHYSICS examples
# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1)
physics/physics_demo: physics/physics_demo.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -static -lpthread -D$(PLATFORM) -s USE_PTHREADS=1

View File

@ -9,27 +9,29 @@ varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
uniform vec2 texScale;
// Function for drawing outlines on alpha-blended textures
vec4 DrawOutline(sampler2D tex, vec2 uv, vec2 lineScale, vec3 lineCol)
{
vec2 texelScale = 1.0 / lineScale;
vec4 center = texture2D(tex, uv); // We sample the center texel, (with all color data)
// Next we sample four corner texels, but only for the alpha channel (this is for the outline)
vec4 corners;
corners.x = texture2D(tex, uv+vec2( texelScale.x, texelScale.y)).a;
corners.y = texture2D(tex, uv+vec2( texelScale.x,-texelScale.y)).a;
corners.z = texture2D(tex, uv+vec2(-texelScale.x, texelScale.y)).a;
corners.w = texture2D(tex, uv+vec2(-texelScale.x,-texelScale.y)).a;
uniform vec2 textureSize;
uniform float outlineSize;
uniform vec4 outlineColor;
float outline = min(dot(corners, vec4(1.0)), 1.0);
vec4 col = mix(vec4(0.0), vec4(lineCol, 1.0), outline);
col = mix(col, center, center.a);
return col;
}
// Output fragment color
out vec4 finalColor;
void main()
{
gl_FragColor = DrawOutline(texture0, fragTexCoord, texScale, vec3(0.0));
vec4 texel = texture2D(texture0, fragTexCoord); // Get texel color
vec2 texelScale = vec2(0.0);
texelScale.x = outlineSize/textureSize.x;
texelScale.y = outlineSize/textureSize.y;
// We sample four corner texels, but only for the alpha channel (this is for the outline)
vec4 corners = vec4(0.0);
corners.x = texture2D(texture0, fragTexCoord + vec2(texelScale.x, texelScale.y)).a;
corners.y = texture2D(texture0, fragTexCoord + vec2(texelScale.x, -texelScale.y)).a;
corners.z = texture2D(texture0, fragTexCoord + vec2(-texelScale.x, texelScale.y)).a;
corners.w = texture2D(texture0, fragTexCoord + vec2(-texelScale.x, -texelScale.y)).a;
float outline = min(dot(corners, vec4(1.0)), 1.0);
vec4 color = mix(vec4(0.0), outlineColor, outline);
gl_FragColor = mix(color, texel, texel.a);
}

View File

@ -0,0 +1,20 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
void main()
{
vec4 texelColor = texture2D(texture0, fragTexCoord);
if (texelColor.a == 0.0) discard;
gl_FragColor = texelColor*fragColor*colDiffuse;
}

View File

@ -1,5 +1,7 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;

View File

@ -43,8 +43,8 @@
.PHONY: all clean install uninstall
# Define required raylib variables
RAYLIB_VERSION = 3.8.1
RAYLIB_API_VERSION = 381
RAYLIB_VERSION = 4.0.0
RAYLIB_API_VERSION = 400
# Define raylib source code path
RAYLIB_SRC_PATH ?= ../src