Merge pull request #28 from raysan5/develop

Integrating Develop branch
This commit is contained in:
Ray 2015-09-03 01:49:58 +02:00
commit 77558eec0c
75 changed files with 2100 additions and 259 deletions

View file

@ -1,7 +1,7 @@
changelog changelog
--------- ---------
Current Release: raylib 1.3.0 (01 September 2015) Current Release: raylib 1.3.0 (03 September 2015)
NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source. NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
NOTE: Current Release includes all previous updates. NOTE: Current Release includes all previous updates.
@ -13,14 +13,14 @@ NOTE:
This version supposed a big boost for raylib, new modules have been added with lots of features. This version supposed a big boost for raylib, new modules have been added with lots of features.
Most of the modules have been completely reviewed to accomodate to the new features. Most of the modules have been completely reviewed to accomodate to the new features.
Over 50 new functions have been added to previous raylib version. Over 50 new functions have been added to previous raylib version.
Most of the examples have been redone and 10 new advanced examples have been added. Most of the examples have been redone and +10 new advanced examples have been added.
BIG changes: BIG changes:
[rlgl] SHADERS: Support for model shaders and postprocessing shaders (multiple functions)
[textures] FORMATS: Support for multiple internal formats, including compressed formats
[camera] NEW MODULE: Set of cameras for 3d view: Free, Orbital, 1st person, 3rd person [camera] NEW MODULE: Set of cameras for 3d view: Free, Orbital, 1st person, 3rd person
[gestures] NEW MODULE: Gestures system for Android and HTML5 platforms [gestures] NEW MODULE: Gestures system for Android and HTML5 platforms
[raygui] NEW MODULE: Set of IMGUI elements for tools development [raygui] NEW MODULE: Set of IMGUI elements for tools development (experimental)
[rlgl] SHADERS: Support for model shaders and postprocessing shaders (multiple functions)
[textures] FORMATS: Added support for multiple internal formats, including compressed formats
smaller changes: smaller changes:
[rlgl] Added check for OpenGL supported extensions [rlgl] Added check for OpenGL supported extensions

View file

@ -8,10 +8,9 @@ raylib is a simple and easy-to-use library to learn videogames programming.
raylib is highly inspired by Borland BGI graphics lib and by XNA framework. raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
Allegro and SDL have also been analyzed for reference. Allegro and SDL have also been analyzed for reference.
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.htm) NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
Since version 1.2.2 raylib can compile directly for web (html5) using emscripten and asm.js, pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.htm)
to see a demo of raylib features working on web, [check here!](http://www.raylib.com/raylib_demo.html)
history history
------- -------
@ -79,21 +78,24 @@ notes on raylib 1.3
------------------- -------------------
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality,
improves textures module and provides some new modules (camera system, gestures system, IMGUI). improves tremendously textures module and also provides some new modules (camera system, gestures system, IMGUI).
Shaders, the biggest addition to raylib, with support for simple and easy shaders loading and use. Loaded shaders can be Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be
assigned to models or used as fullscreen postrocessing shaders. attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included
in this release, check raylib/shaders folder.
Textures module has been improved to support most of the internal texture formats available in OpenGL Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.),
(RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT). including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
New camera module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
Camera modes are very easy to use, just calling functions: SetCameraMode() and UpdateCamera(). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c).
New gestures module simplifies gestures detection on Android and HTML5 programs. New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
New IMGUI (Immediate Mode GUI) module: raygui, offers a set of functions to create simple user interfaces, [raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
primary intended for tools development, still in experimental state but already fully functional. primary intended for tools development. It's still in experimental state but already fully functional.
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3. Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3.
@ -102,13 +104,11 @@ features
* Written in plain C code (C99) * Written in plain C code (C99)
* Uses C# PascalCase/camelCase notation * Uses C# PascalCase/camelCase notation
* Hardware accelerated with OpenGL (1.1, 3.3+ or ES2)
* Unique OpenGL abstraction layer: [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2) * Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
* Unique OpenGL abstraction layer [rlgl] * Unique OpenGL abstraction layer: [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
* Powerful fonts module with SpriteFonts support * Powerful fonts module with SpriteFonts support
* Multiple textures support, including DDS, PKM and mipmaps generation * Outstanding texture formats support, including compressed formats
* Basic 3d support for Shapes, Models, Heightmaps and Billboards * Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c) * Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
* Audio loading and playing with streaming support (WAV and OGG) * Audio loading and playing with streaming support (WAV and OGG)
* Custom color palette for fancy visuals on raywhite background * Custom color palette for fancy visuals on raywhite background

View file

@ -10,11 +10,12 @@ raylib v1.4
- TTF fonts support (using stb_truetype) - TTF fonts support (using stb_truetype)
- Raycast system for 3D picking (including collisions detection) - Raycast system for 3D picking (including collisions detection)
- Remove GLEW dependency (use another solution...) - Remove GLEW dependency (use another solution... glad?)
- Floyd-Steinberg dithering on 16bit image format conversion - Floyd-Steinberg dithering on 16bit image format conversion
- Basic image manipulation functions (crop, resize, draw...) - Basic image manipulation functions (crop, resize, draw...)
- Basic image procedural generation (spot, gradient, noise...) - Basic image procedural generation (spot, gradient, noise...)
- Basic GPU stats sytem (memory, draws, time...) - Basic GPU stats sytem (memory, draws, time...)
- LUA scripting support (wrapper to lua lib)
Check [GITHUB ISSUES][issues] for further details on implementation status for this features! Check [GITHUB ISSUES][issues] for further details on implementation status for this features!

View file

@ -4,10 +4,10 @@
* *
* NOTE: This example requires OpenAL Soft library installed * NOTE: This example requires OpenAL Soft library installed
* *
* This example has been created using raylib 1.1 (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) * 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)
* *
********************************************************************************************/ ********************************************************************************************/
@ -61,9 +61,9 @@ int main()
if (IsWindowMinimized()) PauseMusicStream(); if (IsWindowMinimized()) PauseMusicStream();
else ResumeMusicStream(); else ResumeMusicStream();
timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; // We scale by 4 to fit 400 pixels timePlayed = GetMusicTimePlayed()/GetMusicTimeLength()*100*4; // We scale by 4 to fit 400 pixels
UpdateMusicStream(); UpdateMusicStream(); // Update music buffer with new stream data
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -27,7 +27,7 @@ int main()
// Generates some random columns // Generates some random columns
float heights[MAX_COLUMNS]; float heights[MAX_COLUMNS];
Vector3 positions[MAX_COLUMNS] = { 0.0, 2.5, 0.0 }; Vector3 positions[MAX_COLUMNS];
Color colors[MAX_COLUMNS]; Color colors[MAX_COLUMNS];
for (int i = 0; i < MAX_COLUMNS; i++) for (int i = 0; i < MAX_COLUMNS; i++)
@ -76,7 +76,7 @@ int main()
DrawText("First person camera default controls:", 20, 20, 10, GRAY); DrawText("First person camera default controls:", 20, 20, 10, GRAY);
DrawText("- Move with keys: W, A, S, D", 40, 50, 10, DARKGRAY); DrawText("- Move with keys: W, A, S, D", 40, 50, 10, DARKGRAY);
DrawText("- Mouse move to lokk around", 40, 70, 10, DARKGRAY); DrawText("- Mouse move to look around", 40, 70, 10, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -5,7 +5,7 @@
* This example has been created using raylib 1.3 (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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View file

@ -1,26 +1,22 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - Basic window * raylib [core] example - Basic window (adapted for HTML5 platform)
* *
* Welcome to raylib! * This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
* As you will notice, code structure is slightly diferent to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
* *
* To test examples, just press F6 and execute raylib_compile_execute script * This example has been created using raylib 1.3 (www.raylib.com)
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* 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) * 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)
* *
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
//#define PLATFORM_WEB
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif

View file

@ -2,10 +2,12 @@
* *
* raylib [core] example - Windows drop files * raylib [core] example - Windows drop files
* *
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
*
* This example has been created using raylib 1.3 (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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View file

@ -2,7 +2,7 @@
# #
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) # raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2015 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # 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. # will the authors be held liable for any damages arising from the use of this software.
@ -154,9 +154,14 @@ EXAMPLES = \
core_input_keys \ core_input_keys \
core_input_mouse \ core_input_mouse \
core_mouse_wheel \ core_mouse_wheel \
core_input_gamepad \
core_random_values \ core_random_values \
core_color_select \ core_color_select \
core_drop_files \
core_3d_mode \ core_3d_mode \
core_3d_picking \
core_3d_camera_free \
core_3d_camera_first_person \
shapes_logo_raylib \ shapes_logo_raylib \
shapes_basic_shapes \ shapes_basic_shapes \
shapes_colors_palette \ shapes_colors_palette \
@ -165,16 +170,24 @@ EXAMPLES = \
textures_image_loading \ textures_image_loading \
textures_rectangle \ textures_rectangle \
textures_srcrec_dstrec \ textures_srcrec_dstrec \
textures_to_image \
textures_raw_data \
textures_formats_loading \
textures_particles_trail_blending \
text_sprite_fonts \ text_sprite_fonts \
text_rbmf_fonts \ text_rbmf_fonts \
text_format_text \ text_format_text \
text_font_select \ text_font_select \
models_geometric_shapes \ models_geometric_shapes \
models_planes \ models_box_collisions \
models_billboard \ models_billboard \
models_obj_loading \ models_obj_loading \
models_heightmap \ models_heightmap \
models_cubicmap \ models_cubicmap \
shaders_model_shader \
shaders_shapes_textures \
shaders_custom_uniform \
shaders_postprocessing \
audio_sound_loading \ audio_sound_loading \
audio_music_stream \ audio_music_stream \
fix_dylib \ fix_dylib \
@ -201,16 +214,26 @@ core_input_keys: core_input_keys.c
core_input_mouse: core_input_mouse.c core_input_mouse: core_input_mouse.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# compile [core] example - gamepad input # compile [core] example - gamepad input
core_input_gamepad: core_input_gamepad.c core_input_gamepad: core_input_gamepad.c
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
else
@echo core_input_gamepad: Only supported on desktop platform
endif endif
# compile [core] example - mouse wheel # compile [core] example - mouse wheel
core_mouse_wheel: core_mouse_wheel.c core_mouse_wheel: core_mouse_wheel.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - drop files
core_drop_files: core_drop_files.c
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
else
@echo core_drop_files: Only supported on desktop platform
endif
# compile [core] example - generate random values # compile [core] example - generate random values
core_random_values: core_random_values.c core_random_values: core_random_values.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -223,6 +246,18 @@ core_color_select: core_color_select.c
core_3d_mode: core_3d_mode.c core_3d_mode: core_3d_mode.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - 3d picking
core_3d_picking: core_3d_picking.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - 3d camera free
core_3d_camera_free: core_3d_camera_free.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - 3d camera first person
core_3d_camera_first_person: core_3d_camera_first_person.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shapes] example - raylib logo (with basic shapes) # compile [shapes] example - raylib logo (with basic shapes)
shapes_logo_raylib: shapes_logo_raylib.c shapes_logo_raylib: shapes_logo_raylib.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -255,6 +290,22 @@ textures_rectangle: textures_rectangle.c
textures_srcrec_dstrec: textures_srcrec_dstrec.c textures_srcrec_dstrec: textures_srcrec_dstrec.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture to image
textures_to_image: textures_to_image.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture raw data
textures_raw_data: textures_raw_data.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture formats loading
textures_formats_loading: textures_formats_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture particles trail blending
textures_particles_trail_blending: textures_particles_trail_blending.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - sprite fonts loading # compile [text] example - sprite fonts loading
text_sprite_fonts: text_sprite_fonts.c text_sprite_fonts: text_sprite_fonts.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -275,6 +326,10 @@ text_font_select: text_font_select.c
models_geometric_shapes: models_geometric_shapes.c models_geometric_shapes: models_geometric_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - box collisions
models_box_collisions: models_box_collisions.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic window # compile [models] example - basic window
models_planes: models_planes.c models_planes: models_planes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -295,6 +350,22 @@ models_heightmap: models_heightmap.c
models_cubicmap: models_cubicmap.c models_cubicmap: models_cubicmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - model shader
shaders_model_shader: shaders_model_shader.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - shapes texture shader
shaders_shapes_textures: shaders_shapes_textures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - custom uniform in shader
shaders_custom_uniform: shaders_custom_uniform.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - postprocessing shader
shaders_postprocessing: shaders_postprocessing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [audio] example - sound loading and playing (WAV and OGG) # compile [audio] example - sound loading and playing (WAV and OGG)
audio_sound_loading: audio_sound_loading.c audio_sound_loading: audio_sound_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)

View file

@ -0,0 +1,119 @@
/*******************************************************************************************
*
* raylib [models] example - Detect basic 3d collisions (box vs sphere vs box)
*
* 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) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
Vector3 playerPosition = { 0, 1, 2 };
Vector3 playerSize = { 1, 2, 1 };
Color playerColor = GREEN;
Vector3 enemyBoxPos = { -4, 1, 0 };
Vector3 enemyBoxSize = { 2, 2, 2 };
Vector3 enemySpherePos = { 4, 0, 0 };
float enemySphereSize = 1.5f;
bool collision = false;
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
//----------------------------------------------------------------------------------
// Move player
if (IsKeyDown(KEY_RIGHT)) playerPosition.x += 0.2f;
else if (IsKeyDown(KEY_LEFT)) playerPosition.x -= 0.2f;
else if (IsKeyDown(KEY_DOWN)) playerPosition.z += 0.2f;
else if (IsKeyDown(KEY_UP)) playerPosition.z -= 0.2f;
collision = false;
// Check collisions player vs enemy-box
if (CheckCollisionBoxes((Vector3){ playerPosition.x - playerSize.x/2,
playerPosition.y - playerSize.y/2,
playerPosition.z - playerSize.z/2 },
(Vector3){ playerPosition.x + playerSize.x/2,
playerPosition.y + playerSize.y/2,
playerPosition.z + playerSize.z/2 },
(Vector3){ enemyBoxPos.x - enemyBoxSize.x/2,
enemyBoxPos.y - enemyBoxSize.y/2,
enemyBoxPos.z - enemyBoxSize.z/2 },
(Vector3){ enemyBoxPos.x + enemyBoxSize.x/2,
enemyBoxPos.y + enemyBoxSize.y/2,
enemyBoxPos.z + enemyBoxSize.z/2 })) collision = true;
// Check collisions player vs enemy-sphere
if (CheckCollisionBoxSphere((Vector3){ playerPosition.x - playerSize.x/2,
playerPosition.y - playerSize.y/2,
playerPosition.z - playerSize.z/2 },
(Vector3){ playerPosition.x + playerSize.x/2,
playerPosition.y + playerSize.y/2,
playerPosition.z + playerSize.z/2 },
enemySpherePos, enemySphereSize)) collision = true;
if (collision) playerColor = RED;
else playerColor = GREEN;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
// Draw enemy-box
DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY);
DrawCubeWires(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, DARKGRAY);
// Draw enemy-sphere
DrawSphere(enemySpherePos, enemySphereSize, GRAY);
DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, DARKGRAY);
// Draw player
DrawCubeV(playerPosition, playerSize, playerColor);
DrawGrid(10.0, 1.0); // Draw a grid
End3dMode();
DrawText("Move player with cursors to collide", 220, 40, 20, GRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -5,7 +5,7 @@
* This example has been created using raylib 1.3 (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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View file

@ -23,8 +23,8 @@ int main()
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
SetModelTexture(&dwarf, texture); // Bind texture to model SetModelTexture(&dwarf, texture); // Bind texture to model
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
@ -36,10 +36,7 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_LEFT)) position.x -= 0.2; //...
if (IsKeyDown(KEY_RIGHT)) position.x += 0.2;
if (IsKeyDown(KEY_UP)) position.z -= 0.2;
if (IsKeyDown(KEY_DOWN)) position.z += 0.2;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -54,7 +51,7 @@ int main()
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10.0, 1.0); // Draw a grid
DrawGizmo(position); // Draw gizmo DrawGizmo(position); // Draw gizmo
End3dMode(); End3dMode();

View file

@ -1,19 +1,19 @@
#version 110 #version 330
attribute vec3 vertexPosition; in vec3 vertexPosition;
attribute vec2 vertexTexCoord; in vec2 vertexTexCoord;
attribute vec4 vertexColor; in vec3 vertexNormal;
out vec2 fragTexCoord;
uniform mat4 projectionMatrix; uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix; uniform mat4 modelviewMatrix;
varying vec2 fragTexCoord; // NOTE: Add here your custom variables
varying vec4 fragColor;
void main() void main()
{ {
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0); gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
} }

View file

@ -0,0 +1,42 @@
#version 330
in vec2 fragTexCoord;
out vec4 fragColor;
uniform sampler2D texture0;
uniform vec4 tintColor;
// NOTE: Add here your custom variables
void main()
{
vec4 sum = vec4(0);
vec4 tc = vec4(0);
for (int i = -4; i < 4; i++)
{
for (int j = -3; j < 3; j++)
{
sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25;
}
}
if (texture2D(texture0, fragTexCoord).r < 0.3)
{
tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord);
}
else
{
if (texture2D(texture0, fragTexCoord).r < 0.5)
{
tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord);
}
else
{
tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord);
}
}
fragColor = tc;
}

View file

@ -1,15 +1,20 @@
#version 110 #version 330
in vec2 fragTexCoord;
out vec4 fragColor;
uniform sampler2D texture0; uniform sampler2D texture0;
varying vec2 fragTexCoord; uniform vec4 tintColor;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main() void main()
{ {
vec4 base = texture2D(texture0, fragTexCoord)*fragColor; vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
// Convert to grayscale using NTSC conversion weights // Convert to grayscale using NTSC conversion weights
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, base.a); fragColor = vec4(gray, gray, gray, tintColor.a);
} }

View file

@ -0,0 +1,19 @@
#version 110
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec4 vertexColor;
uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;
varying vec2 fragTexCoord;
varying vec4 fragColor;
void main()
{
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
}

View file

@ -0,0 +1,15 @@
#version 110
uniform sampler2D texture0;
varying vec2 fragTexCoord;
varying vec4 fragColor;
void main()
{
vec4 base = texture2D(texture0, fragTexCoord)*fragColor;
// Convert to grayscale using NTSC conversion weights
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, base.a);
}

View file

@ -0,0 +1,41 @@
#version 330
in vec2 fragTexCoord;
out vec4 fragColor;
uniform sampler2D texture0;
uniform vec4 tintColor;
// NOTE: Add here your custom variables
const float renderWidth = 800; // HARDCODED for example!
const float renderHeight = 480; // Use uniforms instead...
float radius = 250.0;
float angle = 0.8;
uniform vec2 center = vec2(200, 200);
void main (void)
{
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;
vec3 color = texture2D(texture0, tc/texSize).rgb;
fragColor = vec4(color, 1.0);;
}

View file

@ -0,0 +1,108 @@
/*******************************************************************************************
*
* raylib [shaders] example - Apply a postprocessing shader and connect a custom uniform variable
*
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
*
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
*
* 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) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
// Define the camera to look into our 3d world
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
SetModelTexture(&dwarf, texture); // Bind texture to model
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
Shader shader = LoadShader("resources/shaders/base.vs",
"resources/shaders/swirl.fs"); // Load postpro shader
// 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
int swirlCenterLoc = GetShaderLocation(shader, "center");
float swirlCenter[2] = { screenWidth/2, screenHeight/2 };
SetPostproShader(shader); // Set fullscreen postprocessing shader
// Setup orbital camera
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
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
//----------------------------------------------------------------------------------
Vector2 mousePosition = GetMousePosition();
swirlCenter[0] = mousePosition.x;
swirlCenter[1] = screenHeight - mousePosition.y;
// Send new value to the shader to be used on drawing
SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2);
UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
DrawGrid(10.0, 1.0); // Draw a grid
End3dMode();
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadShader(shader); // Unload shader
UnloadTexture(texture); // Unload texture
UnloadModel(dwarf); // Unload model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Some files were not shown because too many files have changed in this diff Show more