commit
77558eec0c
10
CHANGELOG
10
CHANGELOG
@ -1,7 +1,7 @@
|
||||
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: 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.
|
||||
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.
|
||||
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:
|
||||
[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
|
||||
[gestures] NEW MODULE: Gestures system for Android and HTML5 platforms
|
||||
[raygui] NEW MODULE: Set of IMGUI elements for tools development
|
||||
[rlgl] SHADERS: Support for model shaders and postprocessing shaders (multiple functions)
|
||||
[textures] FORMATS: Added support for multiple internal formats, including compressed formats
|
||||
[raygui] NEW MODULE: Set of IMGUI elements for tools development (experimental)
|
||||
|
||||
smaller changes:
|
||||
[rlgl] Added check for OpenGL supported extensions
|
||||
|
38
README.md
38
README.md
@ -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.
|
||||
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)
|
||||
|
||||
Since version 1.2.2 raylib can compile directly for web (html5) using emscripten and asm.js,
|
||||
to see a demo of raylib features working on web, [check here!](http://www.raylib.com/raylib_demo.html)
|
||||
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)
|
||||
|
||||
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,
|
||||
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
|
||||
assigned to models or used as fullscreen postrocessing shaders.
|
||||
Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be
|
||||
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
|
||||
(RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT).
|
||||
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.),
|
||||
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).
|
||||
Camera modes are very easy to use, just calling functions: SetCameraMode() and UpdateCamera().
|
||||
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 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,
|
||||
primary intended for tools development, still in experimental state but already fully functional.
|
||||
[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. 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.
|
||||
|
||||
@ -102,13 +104,11 @@ features
|
||||
|
||||
* Written in plain C code (C99)
|
||||
* 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)
|
||||
* 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
|
||||
* Multiple textures support, including DDS, PKM and mipmaps generation
|
||||
* Basic 3d support for Shapes, Models, Heightmaps and Billboards
|
||||
* Outstanding texture formats support, including compressed formats
|
||||
* 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)
|
||||
* Audio loading and playing with streaming support (WAV and OGG)
|
||||
* Custom color palette for fancy visuals on raywhite background
|
||||
|
@ -10,11 +10,12 @@ raylib v1.4
|
||||
|
||||
- TTF fonts support (using stb_truetype)
|
||||
- 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
|
||||
- Basic image manipulation functions (crop, resize, draw...)
|
||||
- Basic image procedural generation (spot, gradient, noise...)
|
||||
- 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!
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@ -61,9 +61,9 @@ int main()
|
||||
if (IsWindowMinimized()) PauseMusicStream();
|
||||
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
|
||||
|
@ -27,7 +27,7 @@ int main()
|
||||
|
||||
// Generates some random columns
|
||||
float heights[MAX_COLUMNS];
|
||||
Vector3 positions[MAX_COLUMNS] = { 0.0, 2.5, 0.0 };
|
||||
Vector3 positions[MAX_COLUMNS];
|
||||
Color colors[MAX_COLUMNS];
|
||||
|
||||
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("- 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -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
|
||||
* 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)
|
||||
* 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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
//#define PLATFORM_WEB
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
@ -2,10 +2,12 @@
|
||||
*
|
||||
* 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)
|
||||
* 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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# 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
|
||||
# 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_mouse \
|
||||
core_mouse_wheel \
|
||||
core_input_gamepad \
|
||||
core_random_values \
|
||||
core_color_select \
|
||||
core_drop_files \
|
||||
core_3d_mode \
|
||||
core_3d_picking \
|
||||
core_3d_camera_free \
|
||||
core_3d_camera_first_person \
|
||||
shapes_logo_raylib \
|
||||
shapes_basic_shapes \
|
||||
shapes_colors_palette \
|
||||
@ -165,16 +170,24 @@ EXAMPLES = \
|
||||
textures_image_loading \
|
||||
textures_rectangle \
|
||||
textures_srcrec_dstrec \
|
||||
textures_to_image \
|
||||
textures_raw_data \
|
||||
textures_formats_loading \
|
||||
textures_particles_trail_blending \
|
||||
text_sprite_fonts \
|
||||
text_rbmf_fonts \
|
||||
text_format_text \
|
||||
text_font_select \
|
||||
models_geometric_shapes \
|
||||
models_planes \
|
||||
models_box_collisions \
|
||||
models_billboard \
|
||||
models_obj_loading \
|
||||
models_heightmap \
|
||||
models_cubicmap \
|
||||
shaders_model_shader \
|
||||
shaders_shapes_textures \
|
||||
shaders_custom_uniform \
|
||||
shaders_postprocessing \
|
||||
audio_sound_loading \
|
||||
audio_music_stream \
|
||||
fix_dylib \
|
||||
@ -201,16 +214,26 @@ core_input_keys: core_input_keys.c
|
||||
core_input_mouse: core_input_mouse.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# compile [core] example - gamepad input
|
||||
core_input_gamepad: core_input_gamepad.c
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
else
|
||||
@echo core_input_gamepad: Only supported on desktop platform
|
||||
endif
|
||||
|
||||
# compile [core] example - mouse wheel
|
||||
core_mouse_wheel: core_mouse_wheel.c
|
||||
$(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
|
||||
core_random_values: core_random_values.c
|
||||
$(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
|
||||
$(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)
|
||||
shapes_logo_raylib: shapes_logo_raylib.c
|
||||
$(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
|
||||
$(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
|
||||
text_sprite_fonts: text_sprite_fonts.c
|
||||
$(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
|
||||
$(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
|
||||
models_planes: models_planes.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@ -295,6 +350,22 @@ models_heightmap: models_heightmap.c
|
||||
models_cubicmap: models_cubicmap.c
|
||||
$(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)
|
||||
audio_sound_loading: audio_sound_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
119
examples/models_box_collisions.c
Normal file
119
examples/models_box_collisions.c
Normal 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;
|
||||
}
|
BIN
examples/models_box_collisions.png
Normal file
BIN
examples/models_box_collisions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -5,7 +5,7 @@
|
||||
* 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 (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -23,8 +23,8 @@ int main()
|
||||
// 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 }};
|
||||
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
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
|
||||
|
||||
@ -36,10 +36,7 @@ int main()
|
||||
{
|
||||
// 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
|
||||
@ -54,7 +51,7 @@ int main()
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
DrawGizmo(position); // Draw gizmo
|
||||
DrawGizmo(position); // Draw gizmo
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
#version 110
|
||||
#version 330
|
||||
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec4 vertexColor;
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
42
examples/resources/shaders/bloom.fs
Normal file
42
examples/resources/shaders/bloom.fs
Normal 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;
|
||||
}
|
@ -1,15 +1,20 @@
|
||||
#version 110
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*fragColor;
|
||||
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||
|
||||
// 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);
|
||||
fragColor = vec4(gray, gray, gray, tintColor.a);
|
||||
}
|
19
examples/resources/shaders/shapes_base.vs
Normal file
19
examples/resources/shaders/shapes_base.vs
Normal 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);
|
||||
}
|
15
examples/resources/shaders/shapes_grayscale.fs
Normal file
15
examples/resources/shaders/shapes_grayscale.fs
Normal 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);
|
||||
}
|
41
examples/resources/shaders/swirl.fs
Normal file
41
examples/resources/shaders/swirl.fs
Normal 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);;
|
||||
}
|
108
examples/shaders_custom_uniform.c
Normal file
108
examples/shaders_custom_uniform.c
Normal 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;
|
||||
}
|
BIN
examples/shaders_custom_uniform.png
Normal file
BIN
examples/shaders_custom_uniform.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 249 KiB |
93
examples/shaders_model_shader.c
Normal file
93
examples/shaders_model_shader.c
Normal file
@ -0,0 +1,93 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Apply a shader to a 3d model
|
||||
*
|
||||
* 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) 2014 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 - model shader");
|
||||
|
||||
// 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
|
||||
Shader shader = LoadShader("resources/shaders/base.vs",
|
||||
"resources/shaders/grayscale.fs"); // Load model shader
|
||||
|
||||
SetModelShader(&dwarf, shader); // Set shader effect to 3d model
|
||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
|
||||
// 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
|
||||
//----------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
BIN
examples/shaders_model_shader.png
Normal file
BIN
examples/shaders_model_shader.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
94
examples/shaders_postprocessing.c
Normal file
94
examples/shaders_postprocessing.c
Normal file
@ -0,0 +1,94 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Apply a postprocessing shader to a scene
|
||||
*
|
||||
* 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 - postprocessing shader");
|
||||
|
||||
// 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/bloom.fs"); // Load postpro shader
|
||||
|
||||
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
|
||||
//----------------------------------------------------------------------------------
|
||||
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, BLACK);
|
||||
|
||||
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;
|
||||
}
|
BIN
examples/shaders_postprocessing.png
Normal file
BIN
examples/shaders_postprocessing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 217 KiB |
113
examples/shaders_shapes_textures.c
Normal file
113
examples/shaders_shapes_textures.c
Normal file
@ -0,0 +1,113 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Apply a shader to some shape or texture
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
|
||||
|
||||
Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png");
|
||||
|
||||
// NOTE: This shader is a bit different than model/postprocessing shaders,
|
||||
// it requires the color data for every vertice to use it in every shape or texture independently
|
||||
Shader shader = LoadShader("resources/shaders/shapes_base.vs",
|
||||
"resources/shaders/shapes_grayscale.fs");
|
||||
|
||||
// Shader usage is also different than models/postprocessing, shader is just activated when required
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Start drawing with default shader
|
||||
|
||||
DrawText("USING DEFAULT SHADER", 20, 40, 10, RED);
|
||||
|
||||
DrawCircle(80, 120, 35, DARKBLUE);
|
||||
DrawCircleGradient(80, 220, 60, GREEN, SKYBLUE);
|
||||
DrawCircleLines(80, 340, 80, DARKBLUE);
|
||||
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
SetCustomShader(shader);
|
||||
|
||||
DrawText("USING CUSTOM SHADER", 190, 40, 10, RED);
|
||||
|
||||
DrawRectangle(250 - 60, 90, 120, 60, RED);
|
||||
DrawRectangleGradient(250 - 90, 170, 180, 130, MAROON, GOLD);
|
||||
DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE);
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
SetDefaultShader();
|
||||
|
||||
DrawText("USING DEFAULT SHADER", 370, 40, 10, RED);
|
||||
|
||||
DrawTriangle((Vector2){430, 80},
|
||||
(Vector2){430 - 60, 150},
|
||||
(Vector2){430 + 60, 150}, VIOLET);
|
||||
|
||||
DrawTriangleLines((Vector2){430, 160},
|
||||
(Vector2){430 - 20, 230},
|
||||
(Vector2){430 + 20, 230}, DARKBLUE);
|
||||
|
||||
DrawPoly((Vector2){430, 320}, 6, 80, 0, BROWN);
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
SetCustomShader(shader);
|
||||
|
||||
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
SetDefaultShader();
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(sonic); // Unload texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/shaders_shapes_textures.png
Normal file
BIN
examples/shaders_shapes_textures.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 108 KiB |
@ -4,10 +4,10 @@
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#define MAX_PARTICLES 200
|
||||
|
||||
// Particle structure with basic data
|
||||
typedef struct {
|
||||
Vector2 position;
|
||||
Color color;
|
||||
|
@ -35,6 +35,7 @@ int main()
|
||||
int width = 1024;
|
||||
int height = 1024;
|
||||
|
||||
// Dynamic memory allocation to store pixels data (Color type)
|
||||
Color *pixels = (Color *)malloc(width*height*sizeof(Color));
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
@ -50,6 +51,8 @@ int main()
|
||||
Image checkedIm = LoadImageEx(pixels, width, height);
|
||||
Texture2D checked = LoadTextureFromImage(checkedIm);
|
||||
UnloadImage(checkedIm); // Unload CPU (RAM) image data
|
||||
|
||||
// Dynamic memory must be freed after using it
|
||||
free(pixels); // Unload CPU (RAM) pixels data
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* raylib [textures] example - Texture loading and drawing a part defined by a rectangle
|
||||
*
|
||||
* 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)
|
||||
|
@ -2,10 +2,10 @@
|
||||
*
|
||||
* raylib [textures] example - Texture source and destination rectangles
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
19
shaders/gl330/base.vs
Normal file
19
shaders/gl330/base.vs
Normal file
@ -0,0 +1,19 @@
|
||||
#version 330
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
42
shaders/gl330/bloom.fs
Normal file
42
shaders/gl330/bloom.fs
Normal 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;
|
||||
}
|
29
shaders/gl330/blur.fs
Normal file
29
shaders/gl330/blur.fs
Normal file
@ -0,0 +1,29 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
float offset[3] = float[](0.0, 1.3846153846, 3.2307692308);
|
||||
float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
tc += texture2D(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
tc += texture2D(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
}
|
||||
|
||||
fragColor = vec4(tc, 1.0);
|
||||
}
|
44
shaders/gl330/cross_hatching.fs
Normal file
44
shaders/gl330/cross_hatching.fs
Normal file
@ -0,0 +1,44 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
float hatchOffsetY = 5.0f;
|
||||
float lumThreshold01 = 0.9f;
|
||||
float lumThreshold02 = 0.7f;
|
||||
float lumThreshold03 = 0.5f;
|
||||
float lumThreshold04 = 0.3f;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
fragColor = vec4(tc, 1.0);
|
||||
}
|
54
shaders/gl330/cross_stitching.fs
Normal file
54
shaders/gl330/cross_stitching.fs
Normal file
@ -0,0 +1,54 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
float stitchingSize = 6.0f;
|
||||
|
||||
uniform 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(void)
|
||||
{
|
||||
vec3 tc = PostFX(texture0, fragTexCoord).rgb;
|
||||
|
||||
fragColor = vec4(tc, 1.0);
|
||||
}
|
34
shaders/gl330/dream_vision.fs
Normal file
34
shaders/gl330/dream_vision.fs
Normal file
@ -0,0 +1,34 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// 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;
|
||||
|
||||
fragColor = color;
|
||||
}
|
40
shaders/gl330/fisheye.fs
Normal file
40
shaders/gl330/fisheye.fs
Normal file
@ -0,0 +1,40 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float PI = 3.1415926535;
|
||||
|
||||
void main()
|
||||
{
|
||||
float aperture = 178.0f;
|
||||
float apertureHalf = 0.5 * aperture * (PI / 180.0);
|
||||
float maxFactor = sin(apertureHalf);
|
||||
|
||||
vec2 uv = vec2(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;
|
||||
}
|
||||
|
||||
fragColor = texture2D(texture0, uv);
|
||||
}
|
20
shaders/gl330/grayscale.fs
Normal file
20
shaders/gl330/grayscale.fs
Normal file
@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||
|
||||
// Convert to grayscale using NTSC conversion weights
|
||||
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
fragColor = vec4(gray, gray, gray, tintColor.a);
|
||||
}
|
28
shaders/gl330/pixel.fs
Normal file
28
shaders/gl330/pixel.fs
Normal file
@ -0,0 +1,28 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
uniform float pixelWidth = 5.0f;
|
||||
uniform float pixelHeight = 5.0f;
|
||||
|
||||
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;
|
||||
|
||||
fragColor = vec4(tc, 1.0);
|
||||
}
|
26
shaders/gl330/posterization.fs
Normal file
26
shaders/gl330/posterization.fs
Normal file
@ -0,0 +1,26 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
float gamma = 0.6f;
|
||||
float numColors = 8.0f;
|
||||
|
||||
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));
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
}
|
27
shaders/gl330/predator.fs
Normal file
27
shaders/gl330/predator.fs
Normal file
@ -0,0 +1,27 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// 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;
|
||||
|
||||
int ix = (lum < 0.5)? 0:1;
|
||||
|
||||
vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5);
|
||||
|
||||
fragColor = vec4(tc, 1.0);
|
||||
}
|
41
shaders/gl330/scanlines.fs
Normal file
41
shaders/gl330/scanlines.fs
Normal 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
|
||||
|
||||
float offset = 0;
|
||||
float frequency = 720/3.0;
|
||||
|
||||
uniform float time;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
/*
|
||||
// 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);
|
||||
|
||||
fragColor = mix(vec4(0, 0.3, 0, 0), color, wavePos);
|
||||
}
|
41
shaders/gl330/swirl.fs
Normal file
41
shaders/gl330/swirl.fs
Normal 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 = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
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);;
|
||||
}
|
19
shaders/gl330/template.fs
Normal file
19
shaders/gl330/template.fs
Normal file
@ -0,0 +1,19 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
fragColor = texelColor*tintColor;
|
||||
}
|
@ -1,16 +1,21 @@
|
||||
#version 330
|
||||
#version 100
|
||||
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = vertexNormal;
|
||||
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
42
shaders/gles100/bloom.fs
Normal file
42
shaders/gles100/bloom.fs
Normal file
@ -0,0 +1,42 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = tc;
|
||||
}
|
28
shaders/gles100/blur.fs
Normal file
28
shaders/gles100/blur.fs
Normal file
@ -0,0 +1,28 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
|
||||
float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
tc += texture2D(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
tc += texture2D(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(tc, 1.0);
|
||||
}
|
44
shaders/gles100/cross_hatching.fs
Normal file
44
shaders/gles100/cross_hatching.fs
Normal file
@ -0,0 +1,44 @@
|
||||
# version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
float hatchOffsetY = 5.0f;
|
||||
float lumThreshold01 = 0.9f;
|
||||
float lumThreshold02 = 0.7f;
|
||||
float lumThreshold03 = 0.5f;
|
||||
float lumThreshold04 = 0.3f;
|
||||
|
||||
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);
|
||||
}
|
54
shaders/gles100/cross_stitching.fs
Normal file
54
shaders/gles100/cross_stitching.fs
Normal file
@ -0,0 +1,54 @@
|
||||
# version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
float stitchingSize = 6.0f;
|
||||
|
||||
uniform 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(void)
|
||||
{
|
||||
vec3 tc = PostFX(texture0, fragTexCoord).rgb;
|
||||
|
||||
gl_FragColor = vec4(tc, 1.0);
|
||||
}
|
34
shaders/gles100/dream_vision.fs
Normal file
34
shaders/gles100/dream_vision.fs
Normal file
@ -0,0 +1,34 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// 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;
|
||||
}
|
40
shaders/gles100/fisheye.fs
Normal file
40
shaders/gles100/fisheye.fs
Normal file
@ -0,0 +1,40 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float PI = 3.1415926535;
|
||||
|
||||
void main()
|
||||
{
|
||||
float aperture = 178.0f;
|
||||
float apertureHalf = 0.5 * aperture * (PI / 180.0);
|
||||
float maxFactor = sin(apertureHalf);
|
||||
|
||||
vec2 uv = vec2(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);
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
#version 330
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
28
shaders/gles100/pixel.fs
Normal file
28
shaders/gles100/pixel.fs
Normal file
@ -0,0 +1,28 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
uniform float pixelWidth = 5.0f;
|
||||
uniform float pixelHeight = 5.0f;
|
||||
|
||||
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);
|
||||
}
|
26
shaders/gles100/posterization.fs
Normal file
26
shaders/gles100/posterization.fs
Normal file
@ -0,0 +1,26 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// 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);
|
||||
}
|
27
shaders/gles100/predator.fs
Normal file
27
shaders/gles100/predator.fs
Normal file
@ -0,0 +1,27 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// 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;
|
||||
|
||||
int ix = (lum < 0.5)? 0:1;
|
||||
|
||||
vec3 tc = mix(colors[ix], colors[ix+1], (lum-float(ix)*0.5)/0.5);
|
||||
|
||||
gl_FragColor = vec4(tc, 1.0);
|
||||
}
|
41
shaders/gles100/scanlines.fs
Normal file
41
shaders/gles100/scanlines.fs
Normal file
@ -0,0 +1,41 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
float offset = 0;
|
||||
float frequency = 720/3.0;
|
||||
|
||||
uniform float time;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
/*
|
||||
// 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.3, 0, 0), color, wavePos);
|
||||
}
|
41
shaders/gles100/swirl.fs
Normal file
41
shaders/gles100/swirl.fs
Normal file
@ -0,0 +1,41 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
|
||||
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;
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);;
|
||||
}
|
19
shaders/gles100/template.fs
Normal file
19
shaders/gles100/template.fs
Normal file
@ -0,0 +1,19 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
gl_FragColor = texelColor*tintColor;
|
||||
}
|
@ -514,4 +514,4 @@ static void ProcessCamera(Camera *camera, Vector3 *playerPosition)
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
src/core.c
20
src/core.c
@ -1024,7 +1024,7 @@ static void InitDisplay(int width, int height)
|
||||
if (configFlags & FLAG_MSAA_4X_HINT)
|
||||
{
|
||||
glfwWindowHint(GLFW_SAMPLES, 4); // Enables multisampling x4 (MSAA), default is 0
|
||||
TraceLog(INFO, "Enabled MSAA x4");
|
||||
TraceLog(INFO, "Trying to enable MSAA x4");
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
|
||||
@ -1115,6 +1115,7 @@ static void InitDisplay(int width, int height)
|
||||
{
|
||||
samples = 4;
|
||||
sampleBuffer = 1;
|
||||
TraceLog(INFO, "Trying to enable MSAA x4");
|
||||
}
|
||||
|
||||
const EGLint framebufferAttribs[] =
|
||||
@ -1627,7 +1628,7 @@ static void PollInputEvents(void)
|
||||
else if (key == 0x7f) currentKeyState[259] = 1;
|
||||
else
|
||||
{
|
||||
TraceLog(INFO, "Pressed key (ASCII): 0x%02x", key);
|
||||
TraceLog(DEBUG, "Pressed key (ASCII): 0x%02x", key);
|
||||
|
||||
currentKeyState[key] = 1;
|
||||
}
|
||||
@ -1637,7 +1638,7 @@ static void PollInputEvents(void)
|
||||
}
|
||||
else if (keyboardMode == 1)
|
||||
{
|
||||
TraceLog(INFO, "Pressed key (keycode): 0x%02x", key);
|
||||
TraceLog(DEBUG, "Pressed key (keycode): 0x%02x", key);
|
||||
|
||||
int asciiKey = -1;
|
||||
|
||||
@ -1724,7 +1725,7 @@ static void InitMouse(void)
|
||||
|
||||
// Mouse reading thread
|
||||
// NOTE: We need a separate thread to avoid loosing mouse events,
|
||||
// if too much time passes between reads, queue gets full and new events override older wants...
|
||||
// if too much time passes between reads, queue gets full and new events override older ones...
|
||||
static void *MouseThread(void *arg)
|
||||
{
|
||||
struct input_event mouseEvent;
|
||||
@ -1807,8 +1808,12 @@ static void InitKeyboard(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
// We reconfigure keyboard mode to get scancodes (K_RAW) or keycodes (K_MEDIUMRAW)
|
||||
ioctl(STDIN_FILENO, KDSKBMODE, K_MEDIUMRAW); // ASCII chars (K_XLATE), UNICODE chars (K_UNICODE)
|
||||
// We reconfigure keyboard mode to get:
|
||||
// - scancodes (K_RAW)
|
||||
// - keycodes (K_MEDIUMRAW)
|
||||
// - ASCII chars (K_XLATE)
|
||||
// - UNICODE chars (K_UNICODE)
|
||||
ioctl(STDIN_FILENO, KDSKBMODE, K_MEDIUMRAW);
|
||||
|
||||
keyboardMode = 1; // keycodes
|
||||
}
|
||||
@ -1820,7 +1825,10 @@ static void InitKeyboard(void)
|
||||
// Restore default keyboard input
|
||||
static void RestoreKeyboard(void)
|
||||
{
|
||||
// Reset to default keyboard settings
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &defaultKeyboardSettings);
|
||||
|
||||
// Reconfigure keyboard to default mode
|
||||
ioctl(STDIN_FILENO, KDSKBMODE, defaultKeyboardMode);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
|
||||
#
|
||||
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
# Copyright (c) 2014 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.
|
||||
@ -80,7 +80,7 @@ endif
|
||||
|
||||
# define any directories containing required header files
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
INCLUDES = -I. -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
|
||||
INCLUDES = -I. -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
|
||||
else
|
||||
INCLUDES = -I. -I../src
|
||||
# external libraries headers
|
||||
|
42
src/models.c
42
src/models.c
@ -584,6 +584,7 @@ Model LoadModel(const char *fileName)
|
||||
free(vData.vertices);
|
||||
free(vData.texcoords);
|
||||
free(vData.normals);
|
||||
free(vData.colors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,10 +620,10 @@ Model LoadHeightmap(Image heightmap, float maxHeight)
|
||||
|
||||
vData.vertexCount = numTriangles*3;
|
||||
|
||||
vData.vertices = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount * 2 * sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount * 4 * sizeof(unsigned char)); // Not used...
|
||||
vData.vertices = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount*2*sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount*4*sizeof(unsigned char)); // Not used...
|
||||
|
||||
int vCounter = 0; // Used to count vertices float by float
|
||||
int tcCounter = 0; // Used to count texcoords float by float
|
||||
@ -722,6 +723,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight)
|
||||
free(vData.vertices);
|
||||
free(vData.texcoords);
|
||||
free(vData.normals);
|
||||
free(vData.colors);
|
||||
}
|
||||
|
||||
return model;
|
||||
@ -1038,10 +1040,10 @@ Model LoadCubicmap(Image cubicmap)
|
||||
// Move data from mapVertices temp arays to vertices float array
|
||||
vData.vertexCount = vCounter;
|
||||
|
||||
vData.vertices = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount * 2 * sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount * 4 * sizeof(unsigned char)); // Not used...
|
||||
vData.vertices = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount*2*sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount*4*sizeof(unsigned char)); // Not used...
|
||||
|
||||
// Fill color data
|
||||
// NOTE: Not used any more... just one plain color defined at DrawModel()
|
||||
@ -1096,6 +1098,7 @@ Model LoadCubicmap(Image cubicmap)
|
||||
free(vData.vertices);
|
||||
free(vData.texcoords);
|
||||
free(vData.normals);
|
||||
free(vData.colors);
|
||||
}
|
||||
|
||||
return model;
|
||||
@ -1117,7 +1120,8 @@ void UnloadModel(Model model)
|
||||
|
||||
rlDeleteVertexArrays(model.mesh.vaoId);
|
||||
|
||||
TraceLog(INFO, "Unloaded model data");
|
||||
if (model.mesh.vaoId > 0) TraceLog(INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", model.mesh.vaoId);
|
||||
else TraceLog(INFO, "[VBO ID %i][VBO ID %i][VBO ID %i] Unloaded model data from VRAM (GPU)", model.mesh.vboId[0], model.mesh.vboId[1], model.mesh.vboId[2]);
|
||||
}
|
||||
|
||||
// Link a texture to a model
|
||||
@ -1718,16 +1722,16 @@ static VertexData LoadOBJ(const char *fileName)
|
||||
vData.vertexCount = numTriangles*3;
|
||||
|
||||
// Additional arrays to store vertex data as floats
|
||||
vData.vertices = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount * 2 * sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount * 3 * sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount * 4 * sizeof(unsigned char));
|
||||
vData.vertices = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.texcoords = (float *)malloc(vData.vertexCount*2*sizeof(float));
|
||||
vData.normals = (float *)malloc(vData.vertexCount*3*sizeof(float));
|
||||
vData.colors = (unsigned char *)malloc(vData.vertexCount*4*sizeof(unsigned char));
|
||||
|
||||
int vCounter = 0; // Used to count vertices float by float
|
||||
int tcCounter = 0; // Used to count texcoords float by float
|
||||
int nCounter = 0; // Used to count normals float by float
|
||||
|
||||
int vNum[3], vtNum[3], vnNum[3];
|
||||
int vNum[3], vtNum[3], vnNum[3]; // Used to store triangle indices for v, vt, vn
|
||||
|
||||
rewind(objFile); // Return to the beginning of the file, to read again
|
||||
|
||||
@ -1799,14 +1803,16 @@ static VertexData LoadOBJ(const char *fileName)
|
||||
|
||||
if (numTexCoords > 0)
|
||||
{
|
||||
// NOTE: If using negative texture coordinates with a texture filter of GL_CLAMP_TO_EDGE doesn't work!
|
||||
// NOTE: Texture coordinates are Y flipped upside-down
|
||||
vData.texcoords[tcCounter] = midTexCoords[vtNum[0]-1].x;
|
||||
vData.texcoords[tcCounter + 1] = -midTexCoords[vtNum[0]-1].y;
|
||||
vData.texcoords[tcCounter + 1] = 1.0f - midTexCoords[vtNum[0]-1].y;
|
||||
tcCounter += 2;
|
||||
vData.texcoords[tcCounter] = midTexCoords[vtNum[1]-1].x;
|
||||
vData.texcoords[tcCounter + 1] = -midTexCoords[vtNum[1]-1].y;
|
||||
vData.texcoords[tcCounter + 1] = 1.0f - midTexCoords[vtNum[1]-1].y;
|
||||
tcCounter += 2;
|
||||
vData.texcoords[tcCounter] = midTexCoords[vtNum[2]-1].x;
|
||||
vData.texcoords[tcCounter + 1] = -midTexCoords[vtNum[2]-1].y;
|
||||
vData.texcoords[tcCounter + 1] = 1.0f - midTexCoords[vtNum[2]-1].y;
|
||||
tcCounter += 2;
|
||||
}
|
||||
} break;
|
||||
@ -1818,7 +1824,7 @@ static VertexData LoadOBJ(const char *fileName)
|
||||
|
||||
// Security check, just in case no normals or no texcoords defined in OBJ
|
||||
if (numTexCoords == 0) for (int i = 0; i < (2*vData.vertexCount); i++) vData.texcoords[i] = 0.0f;
|
||||
|
||||
|
||||
// NOTE: We set all vertex colors to white
|
||||
// NOTE: Not used any more... just one plain color defined at DrawModel()
|
||||
for (int i = 0; i < (4*vData.vertexCount); i++) vData.colors[i] = 255;
|
||||
|
@ -614,7 +614,8 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
|
||||
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, Vector3 maxBBox2); // Detect collision between two boxes
|
||||
bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
|
||||
Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Return the normal vector of the impacted surface
|
||||
Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
|
||||
// NOTE: Return the normal vector of the impacted surface
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Shaders System Functions (Module: rlgl)
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Some useful functions to work with Vector3, Matrix and Quaternions
|
||||
*
|
||||
* 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
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Some useful functions to work with Vector3, Matrix and Quaternions
|
||||
*
|
||||
* 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
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
|
200
src/rlgl.c
200
src/rlgl.c
@ -283,14 +283,24 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
|
||||
static pixel *GenNextMipmap(pixel *srcData, int srcWidth, int srcHeight);
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
static char** StringSplit(char *baseString, const char delimiter, int *numExt);
|
||||
#endif
|
||||
|
||||
#if defined(RLGL_STANDALONE)
|
||||
static void TraceLog(int msgType, const char *text, ...);
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// NOTE: strdup() functions replacement (not C99, POSIX function, not available on emscripten)
|
||||
// Duplicates a string, returning an identical malloc'd string
|
||||
char *mystrdup(const char *str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
void *newstr = malloc(len);
|
||||
|
||||
if (newstr == NULL) return NULL;
|
||||
|
||||
return (char *)memcpy(newstr, str, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Matrix operations
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -863,7 +873,7 @@ void rlglInit(void)
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// Get supported extensions list
|
||||
GLint numExt;
|
||||
GLint numExt = 0;
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
|
||||
@ -923,21 +933,39 @@ void rlglInit(void)
|
||||
// NOTE: We don't need to check again supported extensions but we do (in case GLEW is replaced sometime)
|
||||
// We get a list of available extensions and we check for some of them (compressed textures)
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
|
||||
const char *ext[numExt];
|
||||
const char *extList[numExt];
|
||||
|
||||
for (int i = 0; i < numExt; i++) ext[i] = (char *)glGetStringi(GL_EXTENSIONS, i);
|
||||
for (int i = 0; i < numExt; i++) extList[i] = (char *)glGetStringi(GL_EXTENSIONS, i);
|
||||
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
char *extensions = (char *)glGetString(GL_EXTENSIONS); // One big string
|
||||
char *extensions = (char *)glGetString(GL_EXTENSIONS); // One big const string
|
||||
|
||||
// NOTE: We have to duplicate string because glGetString() returns a const value
|
||||
// If not duplicated, it fails in some systems (Raspberry Pi)
|
||||
char *extensionsDup = mystrdup(extensions);
|
||||
|
||||
// NOTE: String could be splitted using strtok() function (string.h)
|
||||
char **ext = StringSplit(extensions, ' ', &numExt);
|
||||
// NOTE: strtok() modifies the received string, it can not be const
|
||||
|
||||
char *extList[512]; // Allocate 512 strings pointers (2 KB)
|
||||
|
||||
extList[numExt] = strtok(extensionsDup, " ");
|
||||
|
||||
while (extList[numExt] != NULL)
|
||||
{
|
||||
numExt++;
|
||||
extList[numExt] = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
free(extensionsDup); // Duplicated string must be deallocated
|
||||
|
||||
numExt -= 1;
|
||||
#endif
|
||||
|
||||
TraceLog(INFO, "Number of supported extensions: %i", numExt);
|
||||
|
||||
// Show supported extensions
|
||||
//for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", ext[i]);
|
||||
//for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", extList[i]);
|
||||
|
||||
// Check required extensions
|
||||
for (int i = 0; i < numExt; i++)
|
||||
@ -945,7 +973,7 @@ void rlglInit(void)
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// Check VAO support
|
||||
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has VAO support as core feature
|
||||
if (strcmp(ext[i], (const char *)"GL_OES_vertex_array_object") == 0)
|
||||
if (strcmp(extList[i], (const char *)"GL_OES_vertex_array_object") == 0)
|
||||
{
|
||||
vaoSupported = true;
|
||||
|
||||
@ -959,23 +987,23 @@ void rlglInit(void)
|
||||
|
||||
// Check NPOT textures support
|
||||
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature
|
||||
if (strcmp(ext[i], (const char *)"GL_OES_texture_npot") == 0) npotSupported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) npotSupported = true;
|
||||
#endif
|
||||
|
||||
// DDS texture compression support
|
||||
if (strcmp(ext[i], (const char *)"GL_EXT_texture_compression_s3tc") == 0) texCompDXTSupported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_EXT_texture_compression_s3tc") == 0) texCompDXTSupported = true;
|
||||
|
||||
// ETC1 texture compression support
|
||||
if (strcmp(ext[i], (const char *)"GL_OES_compressed_ETC1_RGB8_texture") == 0) texCompETC1Supported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_OES_compressed_ETC1_RGB8_texture") == 0) texCompETC1Supported = true;
|
||||
|
||||
// ETC2/EAC texture compression support
|
||||
if (strcmp(ext[i], (const char *)"GL_ARB_ES3_compatibility") == 0) texCompETC2Supported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_ARB_ES3_compatibility") == 0) texCompETC2Supported = true;
|
||||
|
||||
// PVR texture compression support
|
||||
if (strcmp(ext[i], (const char *)"GL_IMG_texture_compression_pvrtc") == 0) texCompPVRTSupported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_IMG_texture_compression_pvrtc") == 0) texCompPVRTSupported = true;
|
||||
|
||||
// ASTC texture compression support
|
||||
if (strcmp(ext[i], (const char *)"GL_KHR_texture_compression_astc_hdr") == 0) texCompASTCSupported = true;
|
||||
if (strcmp(extList[i], (const char *)"GL_KHR_texture_compression_astc_hdr") == 0) texCompASTCSupported = true;
|
||||
}
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
@ -984,9 +1012,6 @@ void rlglInit(void)
|
||||
|
||||
if (npotSupported) TraceLog(INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported");
|
||||
else TraceLog(WARNING, "[EXTENSION] NPOT textures extension not found, NPOT textures not supported");
|
||||
|
||||
// Once supported extensions have been checked, we should free strings memory
|
||||
free(ext);
|
||||
#endif
|
||||
|
||||
if (texCompDXTSupported) TraceLog(INFO, "[EXTENSION] DXT compressed textures supported");
|
||||
@ -1008,8 +1033,16 @@ void rlglInit(void)
|
||||
|
||||
// Initialize matrix stack
|
||||
for (int i = 0; i < MATRIX_STACK_SIZE; i++) stack[i] = MatrixIdentity();
|
||||
|
||||
// Create default white texture for plain colors (required by shader)
|
||||
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
||||
|
||||
// Init default Shader (GLSL 110) -> Common for GL 3.3+ and ES2
|
||||
whiteTexture = rlglLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1);
|
||||
|
||||
if (whiteTexture != 0) TraceLog(INFO, "[TEX ID %i] Base white texture loaded successfully", whiteTexture);
|
||||
else TraceLog(WARNING, "Base white texture could not be loaded");
|
||||
|
||||
// Init default Shader (Custom for GL 3.3 and ES2)
|
||||
defaultShader = LoadDefaultShader();
|
||||
simpleShader = LoadSimpleShader();
|
||||
//customShader = LoadShader("custom.vs", "custom.fs"); // Works ok
|
||||
@ -1024,14 +1057,6 @@ void rlglInit(void)
|
||||
|
||||
for (int i = 0; i < TEMP_VERTEX_BUFFER_SIZE; i++) tempBuffer[i] = VectorZero();
|
||||
|
||||
// Create default white texture for plain colors (required by shader)
|
||||
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
||||
|
||||
whiteTexture = rlglLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1);
|
||||
|
||||
if (whiteTexture != 0) TraceLog(INFO, "[TEX ID %i] Base white texture loaded successfully", whiteTexture);
|
||||
else TraceLog(WARNING, "Base white texture could not be loaded");
|
||||
|
||||
// Init draw calls tracking system
|
||||
draws = (DrawCall *)malloc(sizeof(DrawCall)*MAX_DRAWS_BY_TEXTURE);
|
||||
|
||||
@ -1189,6 +1214,7 @@ void rlglClose(void)
|
||||
|
||||
// Free GPU texture
|
||||
glDeleteTextures(1, &whiteTexture);
|
||||
TraceLog(INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
|
||||
|
||||
if (fbo != 0)
|
||||
{
|
||||
@ -1207,7 +1233,7 @@ void rlglClose(void)
|
||||
|
||||
rlDeleteVertexArrays(postproQuad.mesh.vaoId);
|
||||
|
||||
TraceLog(INFO, "Unloaded postpro quad data");
|
||||
TraceLog(INFO, "[FBO %i] Unloaded postprocessing data", fbo);
|
||||
}
|
||||
|
||||
free(draws);
|
||||
@ -1768,8 +1794,17 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int textureForma
|
||||
// NOTE: glTexParameteri does NOT affect texture uploading, just the way it's used
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// NOTE: OpenGL ES 2.0 with no GL_OES_texture_npot support (i.e. WebGL) has limited NPOT support, so CLAMP_TO_EDGE must be used
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Set texture to clamp on x-axis
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Set texture to clamp on y-axis
|
||||
if (npotSupported)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: If using negative texture coordinates (LoadOBJ()), it does not work!
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Set texture to clamp on x-axis
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Set texture to clamp on y-axis
|
||||
}
|
||||
#else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis
|
||||
@ -1869,12 +1904,12 @@ Model rlglLoadModel(VertexData mesh)
|
||||
|
||||
model.mesh = mesh;
|
||||
model.transform = MatrixIdentity();
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
model.mesh.vaoId = 0; // Vertex Array Object
|
||||
model.mesh.vboId[0] = 0; // Vertex position VBO
|
||||
model.mesh.vboId[1] = 0; // Texcoords VBO
|
||||
model.mesh.vboId[2] = 0; // Normals VBO
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
model.texture.id = 0; // No texture required
|
||||
model.shader.id = 0; // No shader used
|
||||
|
||||
@ -1882,8 +1917,9 @@ Model rlglLoadModel(VertexData mesh)
|
||||
model.texture.id = whiteTexture; // Default whiteTexture
|
||||
model.texture.width = 1; // Default whiteTexture width
|
||||
model.texture.height = 1; // Default whiteTexture height
|
||||
model.texture.format = UNCOMPRESSED_R8G8B8A8; // Default whiteTexture format
|
||||
model.shader = simpleShader; // Default model shader
|
||||
|
||||
|
||||
GLuint vaoModel = 0; // Vertex Array Objects (VAO)
|
||||
GLuint vertexBuffer[3]; // Vertex Buffer Objects (VBO)
|
||||
|
||||
@ -2019,6 +2055,8 @@ void *rlglReadTexturePixels(unsigned int textureId, unsigned int format)
|
||||
Shader LoadShader(char *vsFileName, char *fsFileName)
|
||||
{
|
||||
Shader shader;
|
||||
|
||||
shader.id = 0; // Default value in case of loading failure
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// Shaders loading from external text file
|
||||
@ -2180,9 +2218,11 @@ unsigned int LoadShaderProgram(char *vShaderStr, char *fShaderStr)
|
||||
// Unload a custom shader from memory
|
||||
void UnloadShader(Shader shader)
|
||||
{
|
||||
rlDeleteShader(shader.id);
|
||||
|
||||
TraceLog(INFO, "[SHDR ID %i] Unloaded shader program data", shader.id);
|
||||
if (shader.id != 0)
|
||||
{
|
||||
rlDeleteShader(shader.id);
|
||||
TraceLog(INFO, "[SHDR ID %i] Unloaded shader program data", shader.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Set custom shader to be used on batch draw
|
||||
@ -2242,7 +2282,7 @@ void SetPostproShader(Shader shader)
|
||||
//TraceLog(DEBUG, "Postproquad shader diffuse map id: %i", postproQuad.shader.texDiffuseId);
|
||||
//TraceLog(DEBUG, "Shader diffuse map id: %i", shader.texDiffuseId);
|
||||
#elif defined(GRAPHICS_API_OPENGL_11)
|
||||
TraceLog(WARNING, "Postprocessing shaders not supported on OpenGL 1.1");
|
||||
TraceLog(WARNING, "Shaders not supported on OpenGL 1.1");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2287,6 +2327,8 @@ void SetModelShader(Model *model, Shader shader)
|
||||
|
||||
// NOTE: If SetModelTexture() is called previously, texture is not assigned to new shader
|
||||
if (model->texture.id > 0) model->shader.texDiffuseId = model->texture.id;
|
||||
#elif (GRAPHICS_API_OPENGL_11)
|
||||
TraceLog(WARNING, "Shaders not supported on OpenGL 1.1");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2527,14 +2569,14 @@ static Shader LoadDefaultShader(void)
|
||||
|
||||
// Vertex shader directly defined, no external file required
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
char vShaderStr[] = " #version 330 \n"
|
||||
char vShaderStr[] = "#version 330 \n"
|
||||
"in vec3 vertexPosition; \n"
|
||||
"in vec2 vertexTexCoord; \n"
|
||||
"in vec4 vertexColor; \n"
|
||||
"out vec2 fragTexCoord; \n"
|
||||
"out vec4 tintColor; \n"
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
char vShaderStr[] = " #version 100 \n"
|
||||
char vShaderStr[] = "#version 100 \n"
|
||||
"attribute vec3 vertexPosition; \n"
|
||||
"attribute vec2 vertexTexCoord; \n"
|
||||
"attribute vec4 vertexColor; \n"
|
||||
@ -2552,11 +2594,11 @@ static Shader LoadDefaultShader(void)
|
||||
|
||||
// Fragment shader directly defined, no external file required
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
char fShaderStr[] = " #version 330 \n"
|
||||
char fShaderStr[] = "#version 330 \n"
|
||||
"in vec2 fragTexCoord; \n"
|
||||
"in vec4 tintColor; \n"
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
char fShaderStr[] = " #version 100 \n"
|
||||
char fShaderStr[] = "#version 100 \n"
|
||||
"precision mediump float; \n" // precision required for OpenGL ES2 (WebGL)
|
||||
"varying vec2 fragTexCoord; \n"
|
||||
"varying vec4 tintColor; \n"
|
||||
@ -2590,6 +2632,10 @@ static Shader LoadDefaultShader(void)
|
||||
shader.mapDiffuseLoc = glGetUniformLocation(shader.id, "texture0");
|
||||
shader.mapNormalLoc = -1; // It can be set later
|
||||
shader.mapSpecularLoc = -1; // It can be set later
|
||||
|
||||
shader.texDiffuseId = whiteTexture; // Default white texture
|
||||
shader.texNormalId = 0;
|
||||
shader.texSpecularId = 0;
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return shader;
|
||||
@ -2607,13 +2653,13 @@ static Shader LoadSimpleShader(void)
|
||||
|
||||
// Vertex shader directly defined, no external file required
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
char vShaderStr[] = " #version 330 \n"
|
||||
char vShaderStr[] = "#version 330 \n"
|
||||
"in vec3 vertexPosition; \n"
|
||||
"in vec2 vertexTexCoord; \n"
|
||||
"in vec3 vertexNormal; \n"
|
||||
"out vec2 fragTexCoord; \n"
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
char vShaderStr[] = " #version 100 \n"
|
||||
char vShaderStr[] = "#version 100 \n"
|
||||
"attribute vec3 vertexPosition; \n"
|
||||
"attribute vec2 vertexTexCoord; \n"
|
||||
"attribute vec3 vertexNormal; \n"
|
||||
@ -2629,10 +2675,10 @@ static Shader LoadSimpleShader(void)
|
||||
|
||||
// Fragment shader directly defined, no external file required
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
char fShaderStr[] = " #version 330 \n"
|
||||
"in vec2 fragTexCoord; \n"
|
||||
char fShaderStr[] = "#version 330 \n"
|
||||
"in vec2 fragTexCoord; \n"
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
char fShaderStr[] = " #version 100 \n"
|
||||
char fShaderStr[] = "#version 100 \n"
|
||||
"precision mediump float; \n" // precision required for OpenGL ES2 (WebGL)
|
||||
"varying vec2 fragTexCoord; \n"
|
||||
#endif
|
||||
@ -2666,6 +2712,10 @@ static Shader LoadSimpleShader(void)
|
||||
shader.mapDiffuseLoc = glGetUniformLocation(shader.id, "texture0");
|
||||
shader.mapNormalLoc = -1; // It can be set later
|
||||
shader.mapSpecularLoc = -1; // It can be set later
|
||||
|
||||
shader.texDiffuseId = whiteTexture; // Default white texture
|
||||
shader.texNormalId = 0;
|
||||
shader.texSpecularId = 0;
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return shader;
|
||||
@ -2692,7 +2742,7 @@ static char *TextFileRead(char *fileName)
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
text = (char *)malloc(sizeof(char) * (count + 1));
|
||||
text = (char *)malloc(sizeof(char)*(count + 1));
|
||||
count = fread(text, sizeof(char), count, textFile);
|
||||
text[count] = '\0';
|
||||
}
|
||||
@ -3085,55 +3135,3 @@ static void TraceLog(int msgType, const char *text, ...)
|
||||
if (msgType == ERROR) exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
static char **StringSplit(char *baseString, const char delimiter, int *numExt)
|
||||
{
|
||||
char **result = 0;
|
||||
int count = 0;
|
||||
char *tmp = baseString;
|
||||
char *lastComma = 0;
|
||||
char delim[2];
|
||||
|
||||
delim[0] = delimiter;
|
||||
delim[1] = 0;
|
||||
|
||||
// Count how many elements will be extracted
|
||||
while (*tmp)
|
||||
{
|
||||
if (delimiter == *tmp)
|
||||
{
|
||||
count++;
|
||||
lastComma = tmp;
|
||||
}
|
||||
|
||||
tmp++;
|
||||
}
|
||||
|
||||
// Add space for trailing token
|
||||
count += lastComma < (baseString + strlen(baseString) - 1);
|
||||
|
||||
// Add space for terminating null string
|
||||
count++;
|
||||
|
||||
result = malloc(sizeof(char *)*count);
|
||||
|
||||
if (result)
|
||||
{
|
||||
int idx = 0;
|
||||
char *token = strtok(baseString, delim);
|
||||
|
||||
while (token)
|
||||
{
|
||||
*(result + idx++) = token;
|
||||
token = strtok(0, delim);
|
||||
}
|
||||
|
||||
*(result + idx) = 0;
|
||||
}
|
||||
|
||||
*numExt = (count - 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
@ -221,8 +221,6 @@ extern void UnloadDefaultFont(void)
|
||||
UnloadTexture(defaultFont.texture);
|
||||
free(defaultFont.charValues);
|
||||
free(defaultFont.charRecs);
|
||||
|
||||
TraceLog(INFO, "Unloaded default font data");
|
||||
}
|
||||
|
||||
// Get the default font, useful to be used with extended parameters
|
||||
@ -243,7 +241,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
||||
{
|
||||
Image image = LoadImage(fileName);
|
||||
|
||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
#if defined(PLATFORM_WEB)
|
||||
ImageConvertToPOT(&image, MAGENTA);
|
||||
#endif
|
||||
// Process bitmap font pixel data to get characters measures
|
||||
|
@ -321,7 +321,7 @@ Texture2D LoadTexture(const char *fileName)
|
||||
|
||||
Image image = LoadImage(fileName);
|
||||
|
||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
#if defined(PLATFORM_WEB)
|
||||
ImageConvertToPOT(&image, BLANK);
|
||||
#endif
|
||||
|
||||
@ -404,7 +404,7 @@ void UnloadTexture(Texture2D texture)
|
||||
{
|
||||
rlDeleteTextures(texture.id);
|
||||
|
||||
TraceLog(INFO, "[TEX ID %i] Unloaded texture data", texture.id);
|
||||
TraceLog(INFO, "[TEX ID %i] Unloaded texture data from VRAM (GPU)", texture.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -501,7 +501,10 @@ Image GetTextureData(Texture2D texture)
|
||||
{
|
||||
Image image;
|
||||
image.data = NULL;
|
||||
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
TraceLog(WARNING, "Texture data retrieval not supported on OpenGL ES 2.0");
|
||||
#else
|
||||
if (texture.format < 8)
|
||||
{
|
||||
image.data = rlglReadTexturePixels(texture.id, texture.format);
|
||||
@ -518,7 +521,7 @@ Image GetTextureData(Texture2D texture)
|
||||
else TraceLog(WARNING, "Texture pixel data could not be obtained");
|
||||
}
|
||||
else TraceLog(WARNING, "Compressed texture data could not be obtained");
|
||||
|
||||
#endif
|
||||
return image;
|
||||
}
|
||||
|
||||
@ -695,6 +698,8 @@ void ImageConvertToPOT(Image *image, Color fillColor)
|
||||
|
||||
int format = image->format; // Store image data format to reconvert later
|
||||
|
||||
// TODO: Image width and height changes... do we want to store new values or keep the old ones?
|
||||
// NOTE: Issues when using image.width and image.height for sprite animations...
|
||||
*image = LoadImageEx(pixelsPOT, potWidth, potHeight);
|
||||
|
||||
free(pixelsPOT); // Free POT pixels data
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Some utility functions: rRES files data decompression
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2014 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.
|
||||
|
@ -47,6 +47,7 @@ LOCAL_SRC_FILES :=\
|
||||
../../src/utils.c \
|
||||
../../src/audio.c \
|
||||
../../src/stb_vorbis.c \
|
||||
../../src/gestures.c \
|
||||
|
||||
# Required includes paths (.h)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/include $(LOCAL_PATH)/../../src
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* raylib 1.2 (www.raylib.com)
|
||||
* raylib 1.3.0 (www.raylib.com)
|
||||
*
|
||||
* A simple and easy-to-use library to learn videogames programming
|
||||
*
|
||||
@ -14,7 +14,7 @@
|
||||
* Basic 3d support for Shapes, Models, Heightmaps and Billboards
|
||||
* Powerful math module for Vector and Matrix operations [raymath]
|
||||
* Audio loading and playing with streaming support (WAV and OGG)
|
||||
* Multiplatform support, including Android devices and Raspberry Pi
|
||||
* Multiplatform support, including Android devices, Raspberry Pi and HTML5
|
||||
*
|
||||
* Used external libs:
|
||||
* GLFW3 (www.glfw.org) for window/context management and input
|
||||
@ -27,7 +27,6 @@
|
||||
*
|
||||
* Some design decisions:
|
||||
* 32bit Colors - All defined color are always RGBA
|
||||
* 32bit Textures - All loaded images are converted automatically to RGBA textures
|
||||
* SpriteFonts - All loaded sprite-font images are converted to RGBA and POT textures
|
||||
* One custom default font is loaded automatically when InitWindow()
|
||||
* If using OpenGL 3.3+ or ES2, one default shader is loaded automatically (internally defined)
|
||||
@ -37,7 +36,7 @@
|
||||
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2013 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.
|
||||
@ -63,6 +62,12 @@
|
||||
//#define PLATFORM_DESKTOP // Windows, Linux or OSX
|
||||
//#define PLATFORM_ANDROID // Android device
|
||||
//#define PLATFORM_RPI // Raspberry Pi
|
||||
//#define PLATFORM_WEB // HTML5 (emscripten, asm.js)
|
||||
|
||||
// Security check in case no PLATFORM_* defined
|
||||
#if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEB)
|
||||
#define PLATFORM_DESKTOP
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
#include <android_native_app_glue.h> // Defines android_app struct
|
||||
@ -72,13 +77,21 @@
|
||||
// Some basic Defines
|
||||
//----------------------------------------------------------------------------------
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define DEG2RAD (PI / 180.0f)
|
||||
#define RAD2DEG (180.0f / PI)
|
||||
|
||||
// Keyboard Function Keys
|
||||
// raylib Config Flags
|
||||
#define FLAG_FULLSCREEN_MODE 1
|
||||
#define FLAG_SHOW_LOGO 2
|
||||
#define FLAG_SHOW_MOUSE_CURSOR 4
|
||||
#define FLAG_CENTERED_MODE 8
|
||||
#define FLAG_MSAA_4X_HINT 16
|
||||
#define FLAG_VSYNC_HINT 32
|
||||
|
||||
// Keyboard Function Keys
|
||||
#define KEY_SPACE 32
|
||||
#define KEY_ESCAPE 256
|
||||
#define KEY_ENTER 257
|
||||
@ -163,9 +176,13 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#ifndef __cplusplus
|
||||
// Boolean type
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
|
||||
// byte type
|
||||
typedef unsigned char byte;
|
||||
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
@ -180,6 +197,14 @@ typedef struct Vector3 {
|
||||
float z;
|
||||
} Vector3;
|
||||
|
||||
// Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||
typedef struct Matrix {
|
||||
float m0, m4, m8, m12;
|
||||
float m1, m5, m9, m13;
|
||||
float m2, m6, m10, m14;
|
||||
float m3, m7, m11, m15;
|
||||
} Matrix;
|
||||
|
||||
// Color type, RGBA (32bit)
|
||||
typedef struct Color {
|
||||
unsigned char r;
|
||||
@ -199,28 +224,30 @@ typedef struct Rectangle {
|
||||
// Image type, bpp always RGBA (32bit)
|
||||
// NOTE: Data stored in CPU memory (RAM)
|
||||
typedef struct Image {
|
||||
Color *pixels;
|
||||
int width;
|
||||
int height;
|
||||
void *data; // Image raw data
|
||||
int width; // Image base width
|
||||
int height; // Image base height
|
||||
int mipmaps; // Mipmap levels, 1 by default
|
||||
int format; // Data format (TextureFormat)
|
||||
} Image;
|
||||
|
||||
// Texture2D type, bpp always RGBA (32bit)
|
||||
// NOTE: Data stored in GPU memory
|
||||
typedef struct Texture2D {
|
||||
unsigned int id; // OpenGL id
|
||||
int width;
|
||||
int height;
|
||||
unsigned int id; // OpenGL texture id
|
||||
int width; // Texture base width
|
||||
int height; // Texture base height
|
||||
int mipmaps; // Mipmap levels, 1 by default
|
||||
int format; // Data format (TextureFormat)
|
||||
} Texture2D;
|
||||
|
||||
// Character type (one font glyph)
|
||||
// NOTE: Defined in module: text
|
||||
typedef struct Character Character;
|
||||
|
||||
// SpriteFont type, includes texture and charSet array data
|
||||
typedef struct SpriteFont {
|
||||
Texture2D texture;
|
||||
int numChars;
|
||||
Character *charSet;
|
||||
Texture2D texture; // Font texture
|
||||
int size; // Base size (default chars height)
|
||||
int numChars; // Number of characters
|
||||
int *charValues; // Characters values array
|
||||
Rectangle *charRecs; // Characters rectangles within the texture
|
||||
} SpriteFont;
|
||||
|
||||
// Camera type, defines a camera position/orientation in 3d space
|
||||
@ -231,30 +258,116 @@ typedef struct Camera {
|
||||
} Camera;
|
||||
|
||||
// Vertex data definning a mesh
|
||||
// NOTE: If using OpenGL 1.1, data loaded in CPU; if OpenGL 3.3+ data loaded in GPU (vaoId)
|
||||
typedef struct VertexData {
|
||||
int vertexCount;
|
||||
float *vertices; // 3 components per vertex
|
||||
float *texcoords; // 2 components per vertex
|
||||
float *normals; // 3 components per vertex
|
||||
unsigned char *colors; // 4 components per vertex
|
||||
} VertexData;
|
||||
|
||||
// 3d Model type
|
||||
// NOTE: If using OpenGL 1.1, loaded in CPU (mesh); if OpenGL 3.3+ loaded in GPU (vaoId)
|
||||
typedef struct Model {
|
||||
VertexData mesh;
|
||||
unsigned int vaoId;
|
||||
unsigned int vboId[4];
|
||||
unsigned int textureId;
|
||||
//Matrix transform;
|
||||
} VertexData;
|
||||
|
||||
// Shader type (generic shader)
|
||||
typedef struct Shader {
|
||||
unsigned int id; // Shader program id
|
||||
|
||||
// TODO: This should be Texture2D objects
|
||||
unsigned int texDiffuseId; // Diffuse texture id
|
||||
unsigned int texNormalId; // Normal texture id
|
||||
unsigned int texSpecularId; // Specular texture id
|
||||
|
||||
// Variable attributes
|
||||
int vertexLoc; // Vertex attribute location point (vertex shader)
|
||||
int texcoordLoc; // Texcoord attribute location point (vertex shader)
|
||||
int normalLoc; // Normal attribute location point (vertex shader)
|
||||
int colorLoc; // Color attibute location point (vertex shader)
|
||||
|
||||
// Uniforms
|
||||
int projectionLoc; // Projection matrix uniform location point (vertex shader)
|
||||
int modelviewLoc; // ModeView matrix uniform location point (vertex shader)
|
||||
int tintColorLoc; // Color uniform location point (fragment shader)
|
||||
|
||||
int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
|
||||
int mapNormalLoc; // Normal map texture uniform location point (fragment shader)
|
||||
int mapSpecularLoc; // Specular map texture uniform location point (fragment shader)
|
||||
} Shader;
|
||||
|
||||
// 3d Model type
|
||||
typedef struct Model {
|
||||
VertexData mesh;
|
||||
Matrix transform;
|
||||
Texture2D texture; // Only for OpenGL 1.1, on newer versions this should be in the shader
|
||||
Shader shader;
|
||||
} Model;
|
||||
|
||||
// Ray type (useful for raycast)
|
||||
typedef struct Ray {
|
||||
Vector3 position;
|
||||
Vector3 direction;
|
||||
} Ray;
|
||||
|
||||
// Sound source type
|
||||
typedef struct Sound {
|
||||
unsigned int source;
|
||||
unsigned int buffer;
|
||||
} Sound;
|
||||
|
||||
// Wave type, defines audio wave data
|
||||
typedef struct Wave {
|
||||
void *data; // Buffer data pointer
|
||||
unsigned int dataSize; // Data size in bytes
|
||||
unsigned int sampleRate;
|
||||
short bitsPerSample;
|
||||
short channels;
|
||||
} Wave;
|
||||
|
||||
// Texture formats
|
||||
// NOTE: Support depends on OpenGL version and platform
|
||||
typedef enum {
|
||||
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
||||
UNCOMPRESSED_GRAY_ALPHA, // 16 bpp (2 channels)
|
||||
UNCOMPRESSED_R5G6B5, // 16 bpp
|
||||
UNCOMPRESSED_R8G8B8, // 24 bpp
|
||||
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
|
||||
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
|
||||
UNCOMPRESSED_R8G8B8A8, // 32 bpp
|
||||
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
|
||||
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
|
||||
COMPRESSED_DXT3_RGBA, // 8 bpp
|
||||
COMPRESSED_DXT5_RGBA, // 8 bpp
|
||||
COMPRESSED_ETC1_RGB, // 4 bpp
|
||||
COMPRESSED_ETC2_RGB, // 4 bpp
|
||||
COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
|
||||
COMPRESSED_PVRT_RGB, // 4 bpp
|
||||
COMPRESSED_PVRT_RGBA, // 4 bpp
|
||||
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
|
||||
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
|
||||
} TextureFormat;
|
||||
|
||||
// Color blending modes (pre-defined)
|
||||
typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
|
||||
|
||||
// Gestures type
|
||||
// NOTE: It could be used as flags to enable only some gestures
|
||||
typedef enum {
|
||||
GESTURE_NONE = 1,
|
||||
GESTURE_TAP = 2,
|
||||
GESTURE_DOUBLETAP = 4,
|
||||
GESTURE_HOLD = 8,
|
||||
GESTURE_DRAG = 16,
|
||||
GESTURE_SWIPE_RIGHT = 32,
|
||||
GESTURE_SWIPE_LEFT = 64,
|
||||
GESTURE_SWIPE_UP = 128,
|
||||
GESTURE_SWIPE_DOWN = 256,
|
||||
GESTURE_PINCH_IN = 512,
|
||||
GESTURE_PINCH_OUT = 1024
|
||||
} Gestures;
|
||||
|
||||
// Camera system modes
|
||||
typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
@ -268,13 +381,14 @@ extern "C" { // Prevents name mangling of functions
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
void InitWindow(int width, int height, struct android_app *state); // Init Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||
void InitWindow(int width, int height, struct android_app *state); // Init Android Activity and OpenGL Graphics
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
|
||||
#endif
|
||||
|
||||
void CloseWindow(void); // Close Window and Terminate Context
|
||||
bool WindowShouldClose(void); // Detect if KEY_ESCAPE pressed or Close icon pressed
|
||||
bool IsWindowMinimized(void); // Detect if window has been minimized (or lost focus)
|
||||
void ToggleFullscreen(void); // Fullscreen toggle (only PLATFORM_DESKTOP)
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||
void SetCustomCursor(const char *cursorImage); // Set a custom cursor icon/image
|
||||
@ -290,6 +404,8 @@ void EndDrawing(void); // End canvas drawin
|
||||
void Begin3dMode(Camera cam); // Initializes 3D mode for drawing (Camera setup)
|
||||
void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode
|
||||
|
||||
Ray GetMouseRay(Vector2 mousePosition, Camera camera); // TODO: Returns a ray trace from mouse position
|
||||
|
||||
void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
float GetFPS(void); // Returns current FPS
|
||||
float GetFrameTime(void); // Returns time in seconds for one frame
|
||||
@ -300,16 +416,22 @@ int GetHexValue(Color color); // Returns hexadecim
|
||||
int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
void ShowLogo(void); // Activates raylib logo at startup
|
||||
void SetConfigFlags(char flags); // Setup some window configuration flags
|
||||
void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
|
||||
|
||||
bool IsFileDropped(void); // Check if a file have been dropped into window
|
||||
char **GetDroppedFiles(int *count); // Retrieve dropped files into window
|
||||
void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
bool IsKeyUp(int key); // Detect if a key is NOT being pressed
|
||||
int GetKeyPressed(void); // Get latest key pressed
|
||||
|
||||
bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
@ -318,8 +440,15 @@ bool IsMouseButtonUp(int button); // Detect if a mouse but
|
||||
int GetMouseX(void); // Returns mouse position X
|
||||
int GetMouseY(void); // Returns mouse position Y
|
||||
Vector2 GetMousePosition(void); // Returns mouse position XY
|
||||
void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
void ShowCursor(void); // Shows cursor
|
||||
void HideCursor(void); // Hides cursor
|
||||
bool IsCursorHidden(void); // Returns true if cursor is not visible
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
Vector2 GetGamepadMovement(int gamepad); // Return axis movement vector for a gamepad
|
||||
bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
|
||||
@ -328,12 +457,50 @@ bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad b
|
||||
bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
bool IsScreenTouched(void); // Detect screen touch event
|
||||
int GetTouchX(void); // Returns touch position X
|
||||
int GetTouchY(void); // Returns touch position Y
|
||||
Vector2 GetTouchPosition(void); // Returns touch position XY
|
||||
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB)
|
||||
//------------------------------------------------------------------------------------
|
||||
// Gestures and Touch Handling Functions (Module: gestures)
|
||||
//------------------------------------------------------------------------------------
|
||||
int GetTouchX(void); // Returns touch position X (relative to screen size)
|
||||
int GetTouchY(void); // Returns touch position Y (relative to screen size)
|
||||
Vector2 GetTouchPosition(void); // Returns touch position XY (relative to screen size)
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
void InitGesturesSystem(void); // Init gestures system (web)
|
||||
#elif defined(PLATFORM_ANDROID)
|
||||
void InitGesturesSystem(struct android_app *app); // Init gestures system (android)
|
||||
#endif
|
||||
void UpdateGestures(void); // Update gestures detected (must be called every frame)
|
||||
bool IsGestureDetected(void); // Check if a gesture have been detected
|
||||
int GetGestureType(void); // Get latest detected gesture
|
||||
void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags
|
||||
|
||||
float GetGestureDragIntensity(void); // Get gesture drag intensity
|
||||
float GetGestureDragAngle(void); // Get gesture drag angle
|
||||
Vector2 GetGestureDragVector(void); // Get gesture drag vector
|
||||
int GetGestureHoldDuration(void); // Get gesture hold time in frames
|
||||
float GetGesturePinchDelta(void); // Get gesture pinch delta
|
||||
float GetGesturePinchAngle(void); // Get gesture pinch angle
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Camera System Functions (Module: camera)
|
||||
//------------------------------------------------------------------------------------
|
||||
void SetCameraMode(int mode); // Set camera mode (multiple camera modes available)
|
||||
void UpdateCamera(Camera *camera); // Update camera (player position is ignored)
|
||||
void UpdateCameraPlayer(Camera *camera, Vector3 *position); // Update camera and player position (1st person and 3rd person cameras)
|
||||
|
||||
void SetCameraPosition(Vector3 position); // Set internal camera position
|
||||
void SetCameraTarget(Vector3 target); // Set internal camera target
|
||||
|
||||
void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
|
||||
void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
|
||||
void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
|
||||
|
||||
void SetCameraMoveControls(int frontKey, int backKey,
|
||||
int leftKey, int rightKey,
|
||||
int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
|
||||
void SetCameraMouseSensitivity(float sensitivity); // Set camera mouse sensitivity (1st person and 3rd person cameras)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
@ -369,12 +536,20 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
Image LoadImage(const char *fileName); // Load an image into CPU memory (RAM)
|
||||
Image LoadImageEx(Color *pixels, int width, int height); // Load image data from Color array data (RGBA - 32bit)
|
||||
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image data from RAW file
|
||||
Image LoadImageFromRES(const char *rresName, int resId); // Load an image from rRES file (raylib Resource)
|
||||
Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory
|
||||
Texture2D LoadTextureEx(void *data, int width, int height, int textureFormat, int mipmapCount); // Load a texture from raw data into GPU memory
|
||||
Texture2D LoadTextureFromRES(const char *rresName, int resId); // Load an image as texture from rRES file (raylib Resource)
|
||||
Texture2D CreateTexture(Image image, bool genMipmaps); // Create a Texture2D from Image data (and generate mipmaps)
|
||||
Texture2D LoadTextureFromImage(Image image); // Load a texture from image data
|
||||
void UnloadImage(Image image); // Unload image from CPU memory (RAM)
|
||||
void UnloadTexture(Texture2D texture); // Unload texture from GPU memory
|
||||
Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
void ImageConvertToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
void ImageConvertFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture
|
||||
|
||||
void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
@ -395,7 +570,7 @@ void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position,
|
||||
int fontSize, int spacing, Color tint);
|
||||
int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int spacing); // Measure string size for SpriteFont
|
||||
int GetFontBaseSize(SpriteFont spriteFont); // Returns the base size for a SpriteFont (chars height)
|
||||
|
||||
void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner
|
||||
const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
|
||||
@ -411,30 +586,60 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
|
||||
void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
|
||||
void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone
|
||||
void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires
|
||||
void DrawPlane(Vector3 centerPos, Vector2 size, Vector3 rotation, Color color); // Draw a plane
|
||||
void DrawPlaneEx(Vector3 centerPos, Vector2 size, Vector3 rotation, int slicesX, int slicesZ, Color color); // Draw a plane with divisions
|
||||
void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ
|
||||
void DrawQuad(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, Color color); // Draw a quad
|
||||
void DrawRay(Ray ray, Color color); // Draw a ray line
|
||||
void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
|
||||
void DrawGizmo(Vector3 position); // Draw simple gizmo
|
||||
void DrawGizmoEx(Vector3 position, Vector3 rotation, float scale); // Draw gizmo with extended parameters
|
||||
//DrawTorus(), DrawTeapot() are useless...
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
Model LoadModel(const char *fileName); // Load a 3d model (.OBJ)
|
||||
Model LoadModelEx(VertexData data); // Load a 3d model (from vertex data)
|
||||
//Model LoadModelFromRES(const char *rresName, int resId); // TODO: Load a 3d model from rRES file (raylib Resource)
|
||||
Model LoadHeightmap(Image heightmap, float maxHeight); // Load a heightmap image as a 3d model
|
||||
Model LoadCubesmap(Image cubesmap); // Load a map image as a 3d model (cubes based)
|
||||
Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based)
|
||||
void UnloadModel(Model model); // Unload 3d model from memory
|
||||
void SetModelTexture(Model *model, Texture2D texture); // Link a texture to a model
|
||||
|
||||
void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
void DrawModelEx(Model model, Vector3 position, Vector3 rotation, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
void DrawModelEx(Model model, Vector3 position, float rotationAngle, Vector3 rotationAxis, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
void DrawModelWires(Model model, Vector3 position, float scale, Color color); // Draw a model wires (with texture if set)
|
||||
|
||||
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, Vector3 maxBBox2); // Detect collision between two boxes
|
||||
bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
|
||||
Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
|
||||
// NOTE: Return the normal vector of the impacted surface
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
||||
unsigned int LoadShaderProgram(char *vShaderStr, char *fShaderStr); // Load custom shaders strings and return program id
|
||||
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
||||
void SetPostproShader(Shader shader); // Set fullscreen postproduction shader
|
||||
void SetCustomShader(Shader shader); // Set custom shader to be used in batch draw
|
||||
void SetDefaultShader(void); // Set default shader to be used in batch draw
|
||||
void SetModelShader(Model *model, Shader shader); // Link a shader to a model
|
||||
bool IsPosproShaderEnabled(void); // Check if postprocessing shader is enabled
|
||||
|
||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
void SetShaderMapDiffuse(Shader *shader, Texture2D texture); // Default diffuse shader map texture assignment
|
||||
void SetShaderMapNormal(Shader *shader, const char *uniformName, Texture2D texture); // Normal map texture shader assignment
|
||||
void SetShaderMapSpecular(Shader *shader, const char *uniformName, Texture2D texture); // Specular map texture shader assignment
|
||||
void SetShaderMap(Shader *shader, int mapLocation, Texture2D texture, int textureUnit); // TODO: Generic shader map assignment
|
||||
|
||||
void SetBlendMode(int mode); // Set blending mode (alpha, additive, multiplied)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -442,6 +647,7 @@ void InitAudioDevice(void); // Initialize au
|
||||
void CloseAudioDevice(void); // Close the audio device and context (and music stream)
|
||||
|
||||
Sound LoadSound(char *fileName); // Load sound to memory
|
||||
Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
|
||||
Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
|
||||
void UnloadSound(Sound sound); // Unload sound
|
||||
void PlaySound(Sound sound); // Play a sound
|
||||
@ -452,6 +658,7 @@ void SetSoundVolume(Sound sound, float volume); // Set volume fo
|
||||
void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
|
||||
|
||||
void PlayMusicStream(char *fileName); // Start music playing (open stream)
|
||||
void UpdateMusicStream(void); // Updates buffers for music streaming
|
||||
void StopMusicStream(void); // Stop music playing (close stream)
|
||||
void PauseMusicStream(void); // Pause music playing
|
||||
void ResumeMusicStream(void); // Resume playing paused music
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user