86 Commits
1.1.1 ... 1.2.2

Author SHA1 Message Date
raysan5
4a7e522d4b Review build system for Android and RPI 2015-01-04 18:05:50 +01:00
raysan5
b2a5390adb Added some last hour features to v1.2.2 2015-01-02 21:06:30 +01:00
raysan5
0bfd283526 Added support for model color tint
Also, added support for normals on models
2015-01-02 20:59:54 +01:00
raysan5
7ea8326b52 makefiles reorganization
Edited to better accomodate to multiple platforms
2015-01-02 20:59:05 +01:00
raysan5
8847602061 Examples review... 2015-01-02 20:58:06 +01:00
Ray
e6bc655d6a Rename models_cubesmap.c to models_cubicmap.c 2015-01-02 20:51:14 +01:00
raysan5
061ee04cb5 Integrated ratalaika pull-request
Added first version of OS X compilation support
Some conflicts manually resolved...
2015-01-02 10:18:43 +01:00
Ray
3c4a91658e Merge pull request #12 from raysan5/develop
Integration from develop branch
2014-12-31 19:28:38 +01:00
raysan5
fad81f36e4 Updated docs 2014-12-31 19:25:50 +01:00
raysan5
b482e26925 Small tweaks 2014-12-31 19:25:39 +01:00
raysan5
7ec6ebb9fa New raylib release, including html5 binaries 2014-12-31 19:25:16 +01:00
raysan5
5a98d2da1f Added raylib game showing raylib features 2014-12-31 19:24:51 +01:00
raysan5
21d8394170 Added small floppy game 2014-12-31 19:18:16 +01:00
raysan5
5e913c31a4 Updated example 2014-12-31 19:17:50 +01:00
raysan5
d51d6a4650 Prepare examples makefile to support emscripten 2014-12-31 19:17:41 +01:00
raysan5
3c57c6afc5 Updated to version 2.00b 2014-12-31 18:03:48 +01:00
raysan5
905b6ec53d Added full support for HTML5 (emscripten)
Corrected some bugs on the way...
Automatically convert textures to POT on RPI and WEB
2014-12-31 18:03:32 +01:00
raysan5
08a4ee34eb [texture] image data initialization 2014-12-17 19:47:17 +01:00
raysan5
1bd592fe67 [texture] image loading small check 2014-12-17 19:33:53 +01:00
raysan5
db1ad74ef2 [models] file open error check 2014-12-17 19:32:54 +01:00
raysan5
2e5f58255a Working on rotation math...
[models] Added DrawQuad()
2014-12-16 11:15:56 +01:00
raysan5
cfa60ab7e6 Added support for emscripten and more
Added PLATFORM_WEB support (emscripten-webgl)
[audio] Added LoadSoundFromWave()
[textures] Added LoadTextureFromImage() to replace CreateTexture()
Some TraceLogs edited...
2014-12-15 01:08:30 +01:00
raysan5
d3cf316e40 Added features and corrected bugs...
[core] Added SetMousePosition()
[models] LoadHeightmap() - Corrected textures bug
[raymath] Functions renaming
[WEB] Prepare environment for emscripten!
2014-12-09 13:21:55 +01:00
Palaui
a2c8ddca13 Revert "Corrected some bugs..."
This reverts commit 29d8b48503.
2014-12-09 13:10:28 +01:00
Palaui
29d8b48503 Corrected some bugs...
[core] Added SetMousePosition()
[models] LoadHeightmap() - Corrected textures bug
[raymath] Functions renaming
[WEB] Prepare environment for emscripten!
2014-12-09 13:10:05 +01:00
Ray
0c60609268 Merge pull request #11 from raysan5/develop
Develop branch integration
2014-11-24 20:14:58 +01:00
Palaui
63ed471ed2 Corrected bug on billboards 2014-11-24 17:23:05 +01:00
Ray
d16519f5de Merge pull request #9 from raysan5/master
Populate master changes to develop branch
2014-11-24 16:05:41 +01:00
raysan5
fcff83e65c Corrected Android bug on Native Activity cycle 2014-11-23 21:58:45 +01:00
raysan5
7375d0460a Updated stb headers 2014-11-23 21:58:17 +01:00
ratalaika
2706fa86cd Cleaned GLFW library for OS X 2014-11-22 00:23:25 +01:00
ratalaika
6bea9d0232 Added first version of OS X compilation support 2014-11-22 00:13:59 +01:00
ratalaika
ab05ace3ce Added first version of OS X compilation support 2014-11-22 00:13:09 +01:00
Ray
05ccc4fd42 Merge pull request #5 from debiatan/support_linux_desktop
Small fixes to support the Debian/GNU Linux distro. Hopefully Ubuntu too.
2014-11-09 13:39:27 +01:00
Miguel Lechón
a471b6197a Renamed the PLATFORM_LINUX_DESKTOP into PLATFORM_DESKTOP_LINUX. 2014-11-09 13:18:32 +01:00
Miguel Lechón
db2ad9648d Small fixes to support a Debian/GNU Linux distro. Hopefully Ubuntu too. 2014-11-09 12:07:03 +01:00
Ray
45b214d83e Merge pull request #3 from debiatan/fix_audio_64
Fixed WAV loading under 64-bit systems.
2014-11-09 11:29:13 +01:00
Miguel Lechón
e6ef3f6e6a Fixed WAV loading under 64-bit systems. 2014-11-09 08:06:58 +01:00
raysan5
9d27bba23f Small Fixes Update (1.2.1)
View CHANGELOG for description on small fixes and add-ons
2014-10-17 21:11:58 +02:00
Ray
063e26c521 Corrected issue with transparent surface in Raspberry Pi 2014-09-30 18:22:21 +02:00
Ray
9b5e66f5ea Added required linker libs 2014-09-30 18:15:04 +02:00
Ray
d025230707 Added required linker libs 2014-09-30 18:14:36 +02:00
Ray
c790891e60 Added required linker libs 2014-09-30 18:14:08 +02:00
Ray
78a660d409 Added required linker libs 2014-09-30 18:13:40 +02:00
Ray
4040f9095d Added required linker libs 2014-09-30 18:13:16 +02:00
Ray
d95f743b6f Added required linker libs 2014-09-30 18:12:27 +02:00
raysan5
5eff7d2642 Updated example filename 2014-09-30 00:00:52 +02:00
raysan5
51688c004c Code cleaning, removed useless spaces 2014-09-29 23:41:05 +02:00
raysan5
e2ff32eb84 Updated example screenshot 2014-09-28 01:53:40 +02:00
Ray
c79a46889f Update makefile 2014-09-28 01:47:40 +02:00
Ray
735bf98945 Update and rename shapes_color_palette.c to shapes_colors_palette.c 2014-09-28 00:45:14 +02:00
Ray
86446c6102 Update CHANGELOG 2014-09-21 18:39:12 +02:00
raysan5
0287319c38 Image renaming 2014-09-21 18:25:19 +02:00
raysan5
5ecb6801fa Examples renaming and test examples merge
Examples have been renamed for coherence with raylib modules and test
examples have been merged into examples folder.
2014-09-21 14:26:42 +02:00
Ray
3a0d164a76 Rename ex07c_3d_models.c to models_obj_loading.c 2014-09-21 14:13:05 +02:00
Ray
c389f62837 Rename ex07b_3d_shapes.c to models_geometric_shapes.c 2014-09-21 14:11:42 +02:00
Ray
b648a9ddee Rename ex07a_3d_mode.c to core_3d_mode.c 2014-09-21 14:11:15 +02:00
Ray
597b143634 Rename ex06c_font_select.c to text_font_select.c 2014-09-21 14:10:53 +02:00
Ray
1b2225a622 Rename ex06b_logo_anim.c to shapes_logo_raylib_anim.c 2014-09-21 14:10:33 +02:00
Ray
0cdeb4e267 Rename ex08_audio.c to audio_sound_loading.c 2014-09-21 14:10:03 +02:00
Ray
d09b9fbbde Rename ex06a_color_select.c to core_color_select.c 2014-09-21 14:09:36 +02:00
Ray
c40b3a287c Rename ex05b_rbmf_fonts.c to text_rbmf_fonts.c 2014-09-21 14:09:11 +02:00
Ray
1195025c4c Rename ex05a_sprite_fonts.c to text_sprite_fonts.c 2014-09-21 14:08:58 +02:00
Ray
a99ce2f306 Rename ex04b_texture_rectangle.c to textures_rectangle.c 2014-09-21 14:08:41 +02:00
Ray
9d47934a02 Rename ex04a_textures.c to textures_logo_raylib.c 2014-09-21 14:08:16 +02:00
Ray
3b6e5119f3 Rename ex03c_input_gamepad.c to core_input_gamepad.c 2014-09-21 14:07:48 +02:00
Ray
42b1cb1aaa Rename ex03b_input_mouse.c to core_input_mouse.c 2014-09-21 14:07:20 +02:00
Ray
1989b9fcd9 Rename ex03a_input_keys.c to core_input_keys.c 2014-09-21 14:07:04 +02:00
Ray
34d0851f79 Rename ex02c_color_palette.c to shapes_color_palette.c 2014-09-21 14:06:47 +02:00
Ray
b6d0e3adb2 Rename ex02b_basic_shapes.c to shapes_basic_shapes.c 2014-09-21 14:06:19 +02:00
Ray
07129b26c3 Rename ex02a_logo_raylib.c to shapes_logo_raylib.c 2014-09-21 14:06:00 +02:00
Ray
d25b56f6d4 Rename ex01_basic_window.c to core_basic_window.c 2014-09-21 14:05:04 +02:00
raysan5
42b7b11710 Android: Added support for Tap gesture 2014-09-19 12:34:25 +02:00
raysan5
e915812730 Updated with latest addition 2014-09-18 19:22:06 +02:00
raysan5
ace185954c Android project template for basic game
A basic Android template is provided to start a game
2014-09-18 19:02:12 +02:00
raysan5
1ef1f3d7ea Multiple templates to start a game
Some basic to advance templates are provided to be use as base code for
new games
2014-09-18 19:00:30 +02:00
raysan5
815f90974c Updated to ignore *.exe 2014-09-18 18:56:22 +02:00
raysan5
a08e0929bc Updated ignorable files 2014-09-18 18:52:28 +02:00
Ray
d86c5e3950 Update README.md 2014-09-16 23:25:31 +02:00
raysan5
278f82e536 Style formatting 2014-09-16 23:12:56 +02:00
raysan5
983cc8d291 Android project to compile raylib src 2014-09-16 23:10:27 +02:00
raysan5
8e2680f41f raylib 1.2 release files
Default libraylib.a uses OpenGL 1.1 to maximize compatibility
2014-09-16 22:54:42 +02:00
raysan5
fc6081fe70 raylib 1.2
This is a huge update. Check CHANGELOG for details
2014-09-16 22:51:31 +02:00
raysan5
01651af08a Update examples and remove .exe 2014-09-16 11:30:25 +02:00
raysan5
c56ef738ed Explicit define of functions prototypes
No-parameters functions use the prototype style FunctionName(void);
2014-09-03 17:06:10 +02:00
raysan5
d2b98fbb5c Removed useless spaces 2014-09-03 16:51:28 +02:00
239 changed files with 22356 additions and 7938 deletions

19
.gitignore vendored
View File

@@ -2,16 +2,17 @@
# ... # ...
# Ignore compiled binaries # Ignore compiled binaries
src/core.o src/*.o
src/shapes.o
src/textures.o
src/text.o
src/models.o
src/audio.o
src/vector3.o
src/stb_image.o
src/*.exe src/*.exe
examples/*.o examples/*.o
examples/*.exe
templates/*.exe
# Ignore Android generated files and folders
src_android/obj/
templates/android_project/bin/
templates/android_project/obj/
templates/android_project/libs/
# Ignore thumbnails created by windows # Ignore thumbnails created by windows
Thumbs.db Thumbs.db
@@ -47,6 +48,8 @@ _ReSharper*/
[Tt]est[Rr]esult* [Tt]est[Rr]esult*
ipch/ ipch/
*.opensdf *.opensdf
*.exe
!tools/rrem.exe
# Ignore files build by xcode # Ignore files build by xcode
*.mode*v* *.mode*v*

View File

@@ -1,11 +1,68 @@
changelog changelog
--------- ---------
Current Release: raylib 1.1.1 (22 July 2014) Current Release: raylib 1.2.2 (31 December 2014)
NOTE: Only versions marked as 'Release' are available on release folder, updates are only available as source. NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
NOTE: Current Release includes all previous updates. NOTE: Current Release includes all previous updates.
-----------------------------------------------
Release: raylib 1.2.2 (31 December 2014)
-----------------------------------------------
[*] Added support for HTML5 compiling (emscripten, asm.js)
[core] Corrected bug on input handling (keyboard and mouse)
[textures] Renamed function CreateTexture() to LoadTextureFromImage()
[textures] Added function ConvertToPOT()
[rlgl] Added support for color tint on models on GL 3.3+ and ES2
[rlgl] Added support for normals on models
[models] Corrected bug on DrawBillboard()
[models] Corrected bug on DrawHeightmap()
[models] Renamed LoadCubesmap() to LoadCubicmap()
[audio] Added function LoadSoundFromWave()
[makefile] Added support for Linux and OSX compiling
[stb] Updated to latest headers versions
[*] Lots of tweaks around
---------------------------------------------------------------
Update: raylib 1.2.1 (17 October 2014) (Small Fixes Update)
---------------------------------------------------------------
[core] Added function SetupFlags() to preconfigure raylib Window
[core] Corrected bug on fullscreen mode
[rlgl] rlglDrawmodel() - Added rotation on Y axis
[text] MeasureTextEx() - Corrected bug on measures for default font
-----------------------------------------------
Release: raylib 1.2 (16 September 2014)
-----------------------------------------------
NOTE:
This version supposed a complete redesign of the [core] module to support Android and Raspberry Pi.
Multiples modules have also been tweaked to accomodate to the new platforms, specially [rlgl]
[core] Added multiple platforms support: Android and Raspberry Pi
[core] InitWindow() - Complete rewrite and split for Android
[core] InitDisplay() - Internal function added to calculate proper display size
[core] InitGraphics() - Internal function where OpenGL graphics are initialized
[core] Complete refactoring of input functions to accomodate to new platforms
[core] Mouse and Keyboard raw data reading functions added for Raspberry Pi
[core] GetTouchX(), GetTouchY() - Added for Android
[core] Added Android callbacks to process inputs and Android activity commands
[rlgl] Adjusted buffers depending on platform
[rlgl] Added security check in case deployed vertex excess buffer size
[rlgl] Adjusted indices type depending on GL version (int or short)
[rlgl] Fallback to VBOs only usage if VAOs not supported on ES2
[rlgl] rlglLoadModel() stores vbo ids on new Model struct
[textures] Added support for PKM files (ETC1, ETC2 compression support)
[shapes] DrawRectangleV() - Modified, depending on OGL version uses TRIANGLES or QUADS
[text] LoadSpriteFont() - Modified to use LoadImage()
[models] Minor changes on models loading to accomodate to new Model struct
[audio] PauseMusicStream(), ResumeMusicStream() - Added
[audio] Reduced music buffer size to avoid stalls on Raspberry Pi
[src] Added makefile for Windows and RPI
[src] Added resources file (raylib icon and executable info)
[examples] Added makefile for Windows and RPI
[examples] Renamed and merged with test examples for coherence with module names
[templates] Added multiple templates to be use as a base-code for games
----------------------------------------------- -----------------------------------------------
Release: raylib 1.1.1 (22 July 2014) Release: raylib 1.1.1 (22 July 2014)
----------------------------------------------- -----------------------------------------------

181
README.md
View File

@@ -5,11 +5,14 @@ about
raylib is a simple and easy-to-use library to learn videogames programming. raylib is a simple and easy-to-use library to learn videogames programming.
raylib is highly inspired by Borland BGI graphics lib (more specifically WinBGI) and by XNA framework. raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
Allegro and SDL have also been analyzed for reference. Allegro and SDL have also been analyzed for reference.
Want to see how easy is making games with raylib? Jump to [code examples!] (http://www.raylib.com/examples.htm) Want to see how easy is making games with raylib? 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)
history history
------- -------
@@ -53,7 +56,22 @@ support of DDS texture files (compressed and uncompressed) along with mipmaps su
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1. Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1.
Enjoy it. notes on raylib 1.2
-------------------
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a
complete internal redesign of [core] (https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android] (http://www.android.com/) and [Raspberry Pi] (http://www.raspberrypi.org/).
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the user.
On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input
system has been written from scratch.
A new display initialization system has been created to support multiple resolutions, adding black bars if required;
user only defines desired screen size and it gets properly displayed.
Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.2.
features features
-------- --------
@@ -63,18 +81,27 @@ features
* Hardware accelerated with OpenGL (1.1, 3.3+ or ES2) * Hardware accelerated with OpenGL (1.1, 3.3+ or ES2)
* Unique OpenGL abstraction layer [rlgl] * Unique OpenGL abstraction layer [rlgl]
* Powerful fonts module with SpriteFonts support * Powerful fonts module with SpriteFonts support
* Multiple textures support, including DDS and mipmaps generation * Multiple textures support, including DDS, PKM and mipmaps generation
* Basic 3d support for Shapes, Models, Heightmaps and Billboards * Basic 3d support for Shapes, Models, Heightmaps and Billboards
* Powerful math module for Vector and Matrix operations [raymath] * Powerful math module for Vector and Matrix operations [raymath]
* Audio loading and playing with streaming support * Audio loading and playing with streaming support (WAV and OGG)
* Custom color palette for fancy visuals on raywhite background * Custom color palette for fancy visuals on raywhite background
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5**
raylib uses on its core module the outstanding [GLFW3] (http://www.glfw.org/) library. The best option by far I found for raylib uses on its core module the outstanding [GLFW3] (http://www.glfw.org/) library. The best option by far I found for
window/context and input management (clean, focused, great license, well documented, modern, ...). multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...).
raylib is licensed under a zlib/libpng license like GLFW3. View [LICENSE] (https://github.com/raysan5/raylib/blob/master/LICENSE.md). raylib uses on its [audio] (https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft] (http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours,
to accomodate to Android and Raspberry Pi.
tool requirements On Android, raylib uses native_app_glue module (provided on Android NDK) and native Android libraries to manage window/context,
inputs and activity cycle.
On Raspberry Pi, raylib uses Videocore API and EGL for window/context management and raw inputs reading.
raylib is licensed under a zlib/libpng license. View [LICENSE] (https://github.com/raysan5/raylib/blob/master/LICENSE.md).
tools requirements
------------------ ------------------
raylib has been developed using exclusively two tools: raylib has been developed using exclusively two tools:
@@ -90,39 +117,119 @@ to allow writing small-mid size programs with a printf-based debugging. All rayl
Since raylib v1.1, you can download a windows Installer package for easy installation and configuration. Check [raylib Webpage](http://www.raylib.com/) Since raylib v1.1, you can download a windows Installer package for easy installation and configuration. Check [raylib Webpage](http://www.raylib.com/)
building building source (generate libraylib.a)
-------- --------------------------------------
raylib could be build with the following command lines (Using GCC compiler): **Building raylib sources on desktop platforms:**
cd raylib/src _Step 1:_ Using MinGW make tool, just navigate from command line to raylib/src/ folder and type:
gcc -c core.c -std=c99 -Wall
gcc -c shapes.c -std=c99 -Wall
gcc -c textures.c -std=c99 -Wall
gcc -c text.c -std=c99 -Wall
gcc -c models.c -std=c99 -Wall
gcc -c raymath.c -std=c99 -Wall
gcc -c rlgl.c -std=c99 -Wall
gcc -c audio.c -std=c99 -Wall
gcc -c utils.c -std=c99 -Wall
gcc -c stb_image.c -std=c99 -Wall
gcc -c stb_vorbis.c -std=c99 -Wall
ar rcs libraylib.a core.o shapes.o textures.o stb_image.o text.o models.o raymath.o rlgl.o utils.o stb_vorbis.o audio.o
To compile examples, make sure raylib.h is placed in the include path and the following libraries are placed in the libraries path: mingw32-make PLATFORM=PLATFORM_DESKTOP
NOTE: By default raylib compiles using OpenGL 1.1 to maximize compatibility; to use OpenGL 3.3 just type:
mingw32-make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_33
**Building raylib sources on Raspberry Pi:**
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
sudo apt-get install openal1
_Step 2._ Navigate from command line to raylib/src/ folder and type:
make
**Building raylib sources for Android:**
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
> Download and decompress on C: [Android SDK r23](http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
> Download and decompress on C: [Android NDK r10b](http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
> Download and decompress on C: [Apache Ant 1.9.4](http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
_Step 2._ Create the following environment variables with the correct paths:
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
ANDROID_NDK_ROOT = C:\android-ndk-r10b
ANT_HOME = C:\apache-ant-1.9.4
_Step 3._ Navigate from command line to folder raylib/template_android/ and type:
%ANDROID_NDK_ROOT%\ndk-build
NOTE: libraylib.a will be generated in folder raylib/src_android/obj/local/armeabi/, it must be copied
to Android project; if using raylib/template_android project, copy it to raylib/template_android/jni/libs/.
**Building raylib sources for Web (HTML5)**
_Step 1._ Make sure you have installed emscripten SDK:
> Download latest version from [here].(http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html) I recommend following the portable version installation instructions.
_Step 2._ TODO
building examples
-----------------
**Building raylib examples on desktop platforms:**
_Step 1:_ Using MinGW make tool, just navigate from command line to raylib/examples/ folder and type:
mingw32-make PLATFORM=PLATFORM_DESKTOP
NOTE: Make sure the following libs (and their headers) are placed on their respectibe MinGW folders:
libraylib.a - raylib
libglfw3.a - GLFW3 (static version) libglfw3.a - GLFW3 (static version)
libglew32.a - GLEW, OpenGL extension loading, only required if using OpenGL 3.3+ or ES2 libglew32.a - GLEW, OpenGL extension loading, only required if using OpenGL 3.3+ or ES2
libopenal32.a - OpenAL, audio device management libopenal32.a - OpenAL Soft, audio device management
It's also recommended to link with file icon.o for fancy raylib icon usage. Linking command:
cd raylib/examples **Building raylib examples on Raspberry Pi:**
gcc -o test_code.exe test_code.c icon.o -lraylib -lglfw3 -lglew32 -lopenal32 -lopengl32 -lgdi32 -std=c99 -Wl,--subsystem,windows
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
If you have any doubt, [let me know][raysan5].
sudo apt-get install openal1
_Step 2._ Navigate from command line to raylib/examples/ folder and type:
make
**Building raylib project for Android (using template):**
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
> Download and decompress on C: [Android SDK r23] (http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
> Download and decompress on C: [Android NDK r10b] (http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
> Download and decompress on C: [Apache Ant 1.9.4] (http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
_Step 2._ Create the following environment variables with the correct paths:
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
ANDROID_NDK_ROOT = C:\android-ndk-r10b
ANT_HOME = C:\apache-ant-1.9.4
_Step 3._ To compile project, navigate from command line to folder raylib/template_android/ and type:
%ANDROID_NDK_ROOT%\ndk-build
_Step 4._ To generate APK, navigate to folder raylib/template_android/ and type:
%ANT_HOME%\bin\ant debug
_Step 5:_ To install APK into connected device (previously intalled drivers and activated USB debug mode on device):
%ANT_HOME%\bin\ant installd
_Step 6:_ To view log output from device:
%ANDROID_SDK_TOOLS%\adb logcat -c
%ANDROID_SDK_TOOLS%\adb -d logcat raylib:V *:S
**If you have any doubt, [just let me know][raysan5].**
contact contact
------- -------
@@ -140,9 +247,9 @@ acknowledgments
The following people have contributed in some way to make raylib project a reality. Big thanks to them! The following people have contributed in some way to make raylib project a reality. Big thanks to them!
- [Zopokx](https://github.com/Zopokx) - [Zopokx](https://github.com/Zopokx) for testing and hosting the web.
- [Elendow](http://www.elendow.com) - [Elendow](http://www.elendow.com) for testing and helping on web development.
- Victor Dual - Victor Dual for implementation and testing of 3D shapes functions.
- Marc Palau - Marc Palau for implementation and testing of 3D shapes functions.
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San" [raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"

View File

@@ -6,16 +6,18 @@ Here it is a list of features I would like to add and functions to improve.
Around the source code there are some TODO points with pending revisions/bugs and here it is a list of features I would like to add. Around the source code there are some TODO points with pending revisions/bugs and here it is a list of features I would like to add.
This roadmap is quite outdated... a full list of all the features we are working on should be listed here at some point...
raylib v1.x raylib v1.x
- [DONE] Review Billboard Drawing functions - [DONE] Review Billboard Drawing functions
- [DONE] Review Heightmap Loading and Drawing functions - Load Heightmap directly as a Model - [DONE] Review Heightmap Loading and Drawing functions - Load Heightmap directly as a Model
- Lighting support (only 3d mode) - Lighting support (only 3d mode)
- [DONE] Simple Collision Detection functions - [DONE] Simple Collision Detection functions
- Default scene Camera controls (zoom, pan, rotate) - [IN PROGRESS] Default scene Camera controls (zoom, pan, rotate)
- Basic Procedural Image Generation (Gradient, Checked, Spot, Noise, Cellular) - Basic Procedural Image Generation (Gradient, Checked, Spot, Noise, Cellular)
- [DONE] Software mipmapping generation and POT conversion (custom implementation) - [DONE] Software mipmapping generation and POT conversion (custom implementation)
- TTF fonts support - [IN PROGRESS] TTF fonts support
Any feature missing? Do you have a request? [Let me know!][raysan5] Any feature missing? Do you have a request? [Let me know!][raysan5]

View File

@@ -1,10 +1,10 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Music playing (streaming) * raylib [audio] example - Music playing (streaming)
* *
* NOTE: This test requires OpenAL32 dll installed (or in the same folder) * NOTE: This example requires OpenAL Soft library installed
* *
* This test has been created using raylib 1.1 (www.raylib.com) * This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -19,58 +19,59 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - music playing (streaming)"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
PlayMusicStream("resources/audio/deserve_to_be_loved.ogg"); // Load Music file PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
int framesCounter = 0; int framesCounter = 0;
float volume = 1.0;
float timePlayed = 0; float timePlayed = 0;
//float volume = 1.0;
SetTargetFPS(60);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
framesCounter++; framesCounter++;
// Testing music fading // Testing music fading from one file to another
/* /*
if (framesCounter > 600) if (framesCounter > 600) // Wait for 10 seconds (600 frames)
{ {
volume -= 0.01; volume -= 0.01; // Decrement music volume level
// When music volume level equal or lower than 0,
// restore volume level and init another music file
if (volume <= 0) if (volume <= 0)
{ {
volume = 1.0; volume = 1.0;
framesCounter = -600; framesCounter = 0;
PlayMusicStream("resources/audio/destiny.ogg"); PlayMusicStream("resources/audio/another_file.ogg");
} }
SetMusicVolume(volume); SetMusicVolume(volume);
} }
*/ */
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
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY); DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY);
DrawRectangle(200, 250, 400, 12, LIGHTGRAY); DrawRectangle(200, 250, 400, 12, LIGHTGRAY);
DrawRectangle(200, 250, (int)timePlayed, 12, MAROON); DrawRectangle(200, 250, (int)timePlayed, 12, MAROON);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -78,9 +79,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,13 +1,13 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 08 - Audio loading and playing * raylib [audio] example - Sound loading and playing
* *
* NOTE: This example requires OpenAL32 dll installed (or in the same folder) * NOTE: This example requires OpenAL Soft library installed
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -19,42 +19,48 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 08 - audio loading and playing"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
Sound fx = LoadSound("resources/audio/weird.wav"); // Load WAV audio file Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound! if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY); DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadSound(fx); // Unload sound data UnloadSound(fxWav); // Unload sound data
UnloadSound(fxOgg); // Unload sound data
CloseAudioDevice(); // Close audio device CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 07a - Initialize 3d mode * raylib [core] example - Initialize 3d mode
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,13 +18,16 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector3 position = { 0.0, 0.0, 0.0 }; InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
// 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 }}; Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib example 07a - 3d mode"); Vector3 cubePosition = { 0.0, 0.0, 0.0 };
//SetTargetFPS(60); // Set our game to run at 60 frames-per-second, but not now...
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -32,25 +35,26 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(WHITE); ClearBackground(WHITE);
Begin3dMode(camera); Begin3dMode(camera);
DrawCube(position, 2, 2, 2, RED); DrawCube(cubePosition, 2, 2, 2, RED);
DrawCubeWires(cubePosition, 2, 2, 2, MAROON);
DrawGrid(10.0, 1.0); DrawGrid(10.0, 1.0);
End3dMode(); End3dMode();
DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY); DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -59,6 +63,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -1,11 +1,21 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 01 - Basic Window * raylib [core] example - Basic window
*
* Welcome to raylib!
*
* 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.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,10 +27,10 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window"); InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -28,15 +38,15 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -45,6 +55,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 06a - Color selection by mouse (collision detection) * raylib [core] example - Color selection by mouse (collision detection)
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,78 +17,78 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 400; int screenHeight = 400;
InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)");
Color colors[21] = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, Color colors[21] = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
GREEN, SKYBLUE, PURPLE, BEIGE }; GREEN, SKYBLUE, PURPLE, BEIGE };
Rectangle recs[21]; // Rectangles array Rectangle colorsRecs[21]; // Rectangles array
// Fills recs data (for every rectangle) // Fills colorsRecs data (for every rectangle)
for (int i = 0; i < 21; i++) for (int i = 0; i < 21; i++)
{ {
recs[i].x = 20 + 100*(i%7) + 10*(i%7); colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7);
recs[i].y = 40 + 100*(i/7) + 10*(i/7); colorsRecs[i].y = 40 + 100*(i/7) + 10*(i/7);
recs[i].width = 100; colorsRecs[i].width = 100;
recs[i].height = 100; colorsRecs[i].height = 100;
} }
bool selected[21] = { false }; // Selected rectangles indicator bool selected[21] = { false }; // Selected rectangles indicator
Vector2 mousePoint; Vector2 mousePoint;
InitWindowEx(screenWidth, screenHeight, "raylib example 06a - color selection", false, "resources/mouse.png"); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
mousePoint = GetMousePosition(); mousePoint = GetMousePosition();
for (int i = 0; i < 21; i++) // Iterate along all the rectangles for (int i = 0; i < 21; i++) // Iterate along all the rectangles
{ {
if (CheckCollisionPointRec(mousePoint, recs[i])) if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
{ {
colors[i].a = 120; colors[i].a = 120;
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i]; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
} }
else colors[i].a = 255; else colors[i].a = 255;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
for (int i = 0; i < 21; i++) // Draw all rectangles for (int i = 0; i < 21; i++) // Draw all rectangles
{ {
DrawRectangleRec(recs[i], colors[i]); DrawRectangleRec(colorsRecs[i], colors[i]);
// Draw four rectangles around selected rectangle // Draw four rectangles around selected rectangle
if (selected[i]) if (selected[i])
{ {
DrawRectangle(recs[i].x, recs[i].y, 100, 10, RAYWHITE); // Square top rectangle DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE); // Square top rectangle
DrawRectangle(recs[i].x, recs[i].y, 10, 100, RAYWHITE); // Square left rectangle DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE); // Square left rectangle
DrawRectangle(recs[i].x + 90, recs[i].y, 10, 100, RAYWHITE); // Square right rectangle DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE); // Square right rectangle
DrawRectangle(recs[i].x, recs[i].y + 90, 100, 10, RAYWHITE); // Square bottom rectangle DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE); // Square bottom rectangle
} }
} }
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,11 +1,14 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 03c - Gamepad input * raylib [core] example - Gamepad input
*
* NOTE: This example requires a Gamepad connected to the system
* raylib is configured to work with Xbox 360 gamepad, check raylib.h for buttons configuration
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,15 +20,15 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 gamepadMove = { 0, 0 }; Vector2 gamepadMovement = { 0, 0 };
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input"); SetTargetFPS(60); // Set target frames-per-second
SetTargetFPS(60); // Set target frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -33,11 +36,11 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsGamepadAvailable(GAMEPAD_PLAYER1)) if (IsGamepadAvailable(GAMEPAD_PLAYER1))
{ {
gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1); gamepadMovement = GetGamepadMovement(GAMEPAD_PLAYER1);
ballPosition.x += gamepadMove.x; ballPosition.x += gamepadMovement.x;
ballPosition.y -= gamepadMove.y; ballPosition.y -= gamepadMovement.y;
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
{ {
ballPosition.x = screenWidth/2; ballPosition.x = screenWidth/2;
@@ -45,17 +48,17 @@ int main()
} }
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY); DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON); DrawCircleV(ballPosition, 50, MAROON);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -64,6 +67,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,51 +1,51 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 03a - Keyboard input * raylib [core] example - Keyboard input
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input");
SetTargetFPS(60); // Set target frames-per-second SetTargetFPS(60); // Set target frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8; if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8;
if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8; if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8;
if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8; if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8;
if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8; if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY); DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON); DrawCircleV(ballPosition, 50, MAROON);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -54,6 +54,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 03b - Mouse input * raylib [core] example - Mouse input
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,14 +17,13 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector2 ballPosition = { -100.0, -100.0 }; InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
int counter = 0;
int mouseX, mouseY; int mouseX, mouseY;
Vector2 ballPosition = { -100.0, -100.0 };
InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input");
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -34,22 +33,22 @@ int main()
{ {
mouseX = GetMouseX(); mouseX = GetMouseX();
mouseY = GetMouseY(); mouseY = GetMouseY();
ballPosition.x = (float)mouseX; ballPosition.x = (float)mouseX;
ballPosition.y = (float)mouseY; ballPosition.y = (float)mouseY;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, 40, GOLD); DrawCircleV(ballPosition, 40, GOLD);
DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY); DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -58,6 +57,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Texture loading with mipmaps, mipmaps generation * raylib [core] examples - Mouse wheel
* *
* This test has been created using raylib 1.1 (www.raylib.com) * This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
@@ -18,42 +18,41 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - texture mipmaps"); InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel");
Image image = LoadImage("resources/raylib_logo.png"); int boxPositionY = screenHeight/2 - 40;
Texture2D texture = CreateTexture(image, true); int scrollSpeed = 4; // Scrolling speed in pixels
// NOTE: With OpenGL 3.3 mipmaps generation works great (automatic generation) SetTargetFPS(60);
// NOTE: With OpenGL 1.1 mipmaps generation works great too! (manual generation)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here boxPositionY -= (GetMouseWheelMove()*scrollSpeed);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTexture(texture, 0, 0, WHITE); DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY);
DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading CloseWindow(); // Close window and OpenGL context
CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,10 +1,8 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - OGG audio loading and playing * raylib [core] example - Generate random values
* *
* NOTE: This test requires OpenAL32 dll installed (or in the same folder) * This example has been created using raylib 1.1 (www.raylib.com)
*
* This test has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -19,42 +17,49 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - ogg audio loading and playing"); InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
InitAudioDevice(); // Initialize audio device int framesCounter = 0; // Variable used to count frames
Sound fx = LoadSound("resources/audio/0564.ogg"); // Load audio file int randValue = GetRandomValue(-8,5); // Get a random integer number between -8 and 5 (both included)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound! framesCounter++;
// Every two seconds (120 frames) a new random value is generated
if (((framesCounter/120)%2) == 1)
{
randValue = GetRandomValue(-8,5);
framesCounter = 0;
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY); DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON);
DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadSound(fx); // Unload sound data CloseWindow(); // Close window and OpenGL context
CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

316
examples/makefile Normal file
View File

@@ -0,0 +1,316 @@
#**************************************************************************************************
#
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
#
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
#
# 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.
#
# Permission is granted to anyone to use this software for any purpose, including commercial
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not claim that you
# wrote the original software. If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
# as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
#
#**************************************************************************************************
# define raylib platform to compile for
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
# WARNING: To compile examples to HTML5, they must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP
# determine SUBPLATFORM in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
SUBPLATFORM=WINDOWS
else
UNAMEOS:=$(shell uname)
ifeq ($(UNAMEOS),Linux)
SUBPLATFORM=LINUX
else
ifeq ($(UNAMEOS),Darwin)
SUBPLATFORM=OSX
endif
endif
endif
endif
# define compiler: gcc for C program, define as g++ for C++
ifeq ($(PLATFORM),PLATFORM_WEB)
# define emscripten compiler
CC = emcc
else
# define default gcc compiler
CC = gcc
endif
# define compiler flags:
# -O2 defines optimization level
# -Wall turns on most, but not all, compiler warnings
# -std=c99 use standard C from 1999 revision
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
else
CFLAGS = -O2 -Wall -std=c99
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# define any directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDES = -I. -I../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
else
INCLUDES = -I. -I../src
endif
# define library paths containing required libs
ifeq ($(PLATFORM),PLATFORM_RPI)
LFLAGS = -L. -L../src -L/opt/vc/lib
else
LFLAGS = -L. -L../src -L../external/glfw3/lib/ -I../external/openal_soft/lib/
endif
# define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(SUBPLATFORM),LINUX)
# libraries for Debian GNU/Linux desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal
endif
ifeq ($(SUBPLATFORM),OSX)
# libraries for OS X 10.9 desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
else
# libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# libraries for Raspberry Pi compiling
# NOTE: OpenAL Soft library should be installed (libopenal1 package)
LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
LIBS = ../src/libraylib.bc
endif
# define additional parameters and flags for windows
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
WINFLAGS = ../src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
endif
# define all object files required
EXAMPLES = \
core_basic_window \
core_input_keys \
core_input_mouse \
core_mouse_wheel \
core_random_values \
core_color_select \
core_3d_mode \
shapes_logo_raylib \
shapes_basic_shapes \
shapes_colors_palette \
shapes_logo_raylib_anim \
textures_logo_raylib \
textures_image_loading \
textures_rectangle \
textures_compressed_dds \
textures_mipmaps \
textures_srcrec_dstrec \
text_sprite_fonts \
text_rbmf_fonts \
text_format_text \
text_font_select \
models_geometric_shapes \
models_planes \
models_billboard \
models_obj_loading \
models_heightmap \
models_cubicmap \
audio_sound_loading \
audio_music_stream \
#core_input_gamepad \
# typing 'make' will invoke the first target entry in the file,
# in this case, the 'default' target entry is raylib
default: examples
# compile all examples
examples: $(EXAMPLES)
# compile [core] example - basic window
core_basic_window: core_basic_window.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - keyboard input
core_input_keys: core_input_keys.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - mouse input
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
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
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 - generate random values
core_random_values: core_random_values.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - color selection (collision detection)
core_color_select: core_color_select.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - 3d mode
core_3d_mode: core_3d_mode.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)
# compile [shapes] example - basic shapes usage (rectangle, circle, ...)
shapes_basic_shapes: shapes_basic_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shapes] example - raylib color palette
shapes_colors_palette: shapes_colors_palette.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shapes] example - raylib logo animation
shapes_logo_raylib_anim: shapes_logo_raylib_anim.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - raylib logo texture loading
textures_logo_raylib: textures_logo_raylib.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - image loading and conversion to texture
textures_image_loading: textures_image_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture rectangle drawing
textures_rectangle: textures_rectangle.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - compressed texture loading (DDS)
textures_compressed_dds: textures_compressed_dds.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture mipmaps generation
textures_mipmaps: textures_mipmaps.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture source and destination rectangles
textures_srcrec_dstrec: textures_srcrec_dstrec.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)
# compile [text] example - raylib bitmap fonts (rBMF)
text_rbmf_fonts: text_rbmf_fonts.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - text formatting
text_format_text: text_format_text.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - font selection program
text_font_select: text_font_select.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic geometric 3d shapes
models_geometric_shapes: models_geometric_shapes.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)
# compile [models] example - billboard usage
models_billboard: models_billboard.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - OBJ model loading
models_obj_loading: models_obj_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - heightmap loading
models_heightmap: models_heightmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - cubesmap loading
models_cubicmap: models_cubicmap.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)
# compile [audio] example - music stream playing (OGG)
audio_music_stream: audio_music_stream.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# clean everything
clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(SUBPLATFORM),OSX)
rm -f *.o
else
ifeq ($(SUBPLATFORM),LINUX)
find . -type f -executable -delete
rm -f *.o
else
del *.o *.exe
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
find . -type f -executable -delete
rm -f *.o
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done
# instead of defining every module one by one, we can define a pattern
# this pattern below will automatically compile every module defined on $(OBJS)
#%.exe : %.c
# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)

View File

@@ -1,8 +1,8 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Testing DrawBillboard() and DrawBillboardRec() * raylib [models] example - Drawing billboards
* *
* This test has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.2 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -18,21 +18,18 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector3 position = { 0.0, 0.0, 0.0 }; InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib test - Billboards"); Texture2D lena = LoadTexture("resources/lena.png"); // Our texture for billboard
Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
Vector3 billPosition = { 0.0, 0.0, 0.0 }; // Position where draw billboard
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
Texture2D texture = LoadTexture("resources/raylib_logo.png");
Texture2D lena = LoadTexture("resources/lena.png");
Rectangle eyesRec = { 225, 240, 155, 50 };
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -43,35 +40,34 @@ int main()
if (IsKeyDown(KEY_UP)) camera.position.y -= 0.2; if (IsKeyDown(KEY_UP)) camera.position.y -= 0.2;
if (IsKeyDown(KEY_DOWN)) camera.position.y += 0.2; if (IsKeyDown(KEY_DOWN)) camera.position.y += 0.2;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
Begin3dMode(camera); Begin3dMode(camera);
//DrawBillboard(camera, texture, position, 2.0, WHITE); //DrawBillboard(camera, lena, billPosition, 1.0, WHITE);
DrawBillboardRec(camera, lena, eyesRec, position, 4.0, WHITE); DrawBillboardRec(camera, lena, eyesRec, billPosition, 4.0, WHITE);
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10.0, 1.0); // Draw a grid
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture
UnloadTexture(lena); // Unload texture UnloadTexture(lena); // Unload texture
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@@ -1,15 +1,15 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Testing Heightmap Loading and Drawing * raylib [models] example - Cubicmap loading and drawing
* *
* This test has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.2 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
#include "../raylib.h" #include "raylib.h"
int main() int main()
{ {
@@ -18,23 +18,22 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector3 position = { 0.5, 0.0, 0.5 }; InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 7.0, 6.0, 7.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 7.0, 7.0, 7.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib test - Heightmap loading and drawing"); Image img = LoadImage("resources/cubicmap.png"); // Load cubesmap image (RAM)
Texture2D texture = LoadTextureFromImage(img, false); // Convert image to texture (VRAM)
Image img = LoadImage("resources/cubesmap.png"); Model map = LoadCubicmap(img); // Load cubicmap model
Model map = LoadCubesmap(img); SetModelTexture(&map, texture); // Bind texture to model
Texture2D texture = CreateTexture(img, false); Vector3 mapPosition = { -1, 0.0, -1 }; // Set model position
UnloadImage(img);
UnloadImage(img); // Unload cubesmap image from RAM, already uploaded to VRAM
SetModelTexture(&map, texture);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -42,31 +41,29 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_UP)) camera.position.y += 0.2f; if (IsKeyDown(KEY_UP)) camera.position.y += 0.2f;
else if (IsKeyDown(KEY_DOWN)) camera.position.y -= 0.2f; else if (IsKeyDown(KEY_DOWN)) camera.position.y -= 0.2f;
if (IsKeyDown(KEY_RIGHT)) camera.position.z += 0.2f; if (IsKeyDown(KEY_RIGHT)) camera.position.z += 0.2f;
else if (IsKeyDown(KEY_LEFT)) camera.position.z -= 0.2f; else if (IsKeyDown(KEY_LEFT)) camera.position.z -= 0.2f;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
Begin3dMode(camera); Begin3dMode(camera);
//DrawCube(position, 1.0f, 1.0f, 1.0f, RED); DrawModel(map, mapPosition, 1.0f, MAROON);
DrawModel(map, position, 1.0f, MAROON); DrawGrid(10.0, 1.0);
DrawGrid(10.0, 1.0); // Draw a grid DrawGizmo(mapPosition);
DrawGizmo(position);
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -74,10 +71,10 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture UnloadTexture(texture); // Unload texture
UnloadModel(map); // Unload model UnloadModel(map); // Unload model
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 07b - Draw some basic 3d shapes (cube, sphere, cylinder...) * raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...)
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,14 +18,14 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// Define the camera to look into our 3d world // 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 }}; Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib example 07b - 3d shapes");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -33,35 +33,35 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
Begin3dMode(camera); Begin3dMode(camera);
DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED); DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED);
DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD); DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD);
DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON); DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON);
DrawSphere((Vector3){-1, 0, -2}, 1, GREEN); DrawSphere((Vector3){-1, 0, -2}, 1, GREEN);
DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME); DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME);
DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE); DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE);
DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE); DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN); DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN);
DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD); DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD);
DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK); DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK);
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10.0, 1.0); // Draw a grid
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -70,6 +70,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -1,8 +1,8 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Load and draw a 3d model (OBJ) * raylib [models] example - Heightmap loading and drawing
* *
* This test has been created using raylib 1.1 (www.raylib.com) * This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -18,51 +18,48 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector3 position = { 0.0, 0.0, 0.0 }; InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 10.0, 12.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib test - 3d models in OpenGL 3.3+"); Image img = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(img, false); // Convert image to texture (VRAM)
Texture2D texture = LoadTexture("resources/catwhite.png"); Model map = LoadHeightmap(img, 4); // Load heightmap model
Model cat = LoadModel("resources/cat.obj"); SetModelTexture(&map, texture); // Bind texture to model
Vector3 mapPosition = { -4, 0.0, -4 }; // Set model position
SetModelTexture(&cat, texture);
UnloadImage(img); // Unload heightmap image from RAM, already uploaded to VRAM
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_LEFT)) position.x -= 0.2; // ...
if (IsKeyDown(KEY_RIGHT)) position.x += 0.2;
if (IsKeyDown(KEY_UP)) position.z -= 0.2;
if (IsKeyDown(KEY_DOWN)) position.z += 0.2;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawModel(cat, position, 0.1f, BEIGE); // OK_GL11, OK_GL33
//DrawModelWires(cat, position, 0.1f, RED); // OK_GL11, OK_GL33
DrawGrid(10.0, 1.0); // Draw a grid ClearBackground(RAYWHITE);
DrawGizmo(position); Begin3dMode(camera);
DrawModel(map, mapPosition, 0.5f, MAROON);
DrawGrid(10.0, 1.0);
DrawGizmo(mapPosition);
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -70,10 +67,10 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture UnloadTexture(texture); // Unload texture
UnloadModel(cat); // Unload model UnloadModel(map); // Unload model
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 07c - Load and draw a 3d model (OBJ) * raylib [models] example - Load and draw a 3d model (OBJ)
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,49 +18,48 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector3 position = { 0.0, 0.0, 0.0 }; InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
InitWindow(screenWidth, screenHeight, "raylib example 07c - 3d models"); Texture2D texture = LoadTexture("resources/catsham.png"); // Load model texture
Model cat = LoadModel("resources/cat.obj"); // Load OBJ model
SetModelTexture(&cat, texture); // Bind texture to model
Vector3 catPosition = { 0.0, 0.0, 0.0 }; // Set model position
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
Texture2D texture = LoadTexture("resources/catwhite.png");
Model cat = LoadModel("resources/cat.obj");
SetModelTexture(&cat, texture); // Link texture to model
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_LEFT)) position.x -= 0.2; if (IsKeyDown(KEY_LEFT)) catPosition.x -= 0.2;
if (IsKeyDown(KEY_RIGHT)) position.x += 0.2; if (IsKeyDown(KEY_RIGHT)) catPosition.x += 0.2;
if (IsKeyDown(KEY_UP)) position.z -= 0.2; if (IsKeyDown(KEY_UP)) catPosition.z -= 0.2;
if (IsKeyDown(KEY_DOWN)) position.z += 0.2; if (IsKeyDown(KEY_DOWN)) catPosition.z += 0.2;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
Begin3dMode(camera); Begin3dMode(camera);
DrawModel(cat, position, 0.1f, WHITE); // Draw 3d model with texture DrawModel(cat, catPosition, 0.1f, WHITE); // Draw 3d model with texture
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10.0, 1.0); // Draw a grid
DrawGizmo(position); DrawGizmo(catPosition); // Draw gizmo
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -69,9 +68,9 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture UnloadTexture(texture); // Unload texture
UnloadModel(cat); // Unload model UnloadModel(cat); // Unload model
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

64
examples/models_planes.c Normal file
View File

@@ -0,0 +1,64 @@
/*******************************************************************************************
*
* raylib [models] example - Draw 3d planes
*
* This example has been created using raylib 1.2 (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)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d planes");
// 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 }};
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 4, 4 }, (Vector3){ 0, 45, 0 }, RED);
//DrawPlaneEx((Vector3){ 0, 8, 0 }, (Vector2){ 2, 1 }, (Vector3){ 0, 0, 0 }, 4, 4, SKYBLUE);
DrawGrid(10.0, 1.0);
End3dMode();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

BIN
examples/openal32.dll Normal file

Binary file not shown.

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 02b - Draw basic shapes 2d (rectangle, circle, line...) * raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,9 +18,9 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -28,13 +28,13 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY); DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
DrawLine(18, 42, screenWidth - 18, 42, BLACK); DrawLine(18, 42, screenWidth - 18, 42, BLACK);
@@ -47,16 +47,16 @@ int main()
DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD); DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
DrawTriangle((Vector2){screenWidth/4*3, 80}, DrawTriangle((Vector2){screenWidth/4*3, 80},
(Vector2){screenWidth/4*3 - 60, 150}, (Vector2){screenWidth/4*3 - 60, 150},
(Vector2){screenWidth/4*3 + 60, 150}, VIOLET); (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
DrawTriangleLines((Vector2){screenWidth/4*3, 160}, DrawTriangleLines((Vector2){screenWidth/4*3, 160},
(Vector2){screenWidth/4*3 - 20, 230}, (Vector2){screenWidth/4*3 - 20, 230},
(Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE); (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN); DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -65,6 +65,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 02c - Draw raylib custom color palette * raylib [shapes] example - Draw raylib custom color palette
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,10 +17,10 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette");
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -28,15 +28,15 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("raylib color palette", 28, 42, 20, BLACK); DrawText("raylib color palette", 28, 42, 20, BLACK);
DrawRectangle(26, 80, 100, 100, DARKGRAY); DrawRectangle(26, 80, 100, 100, DARKGRAY);
DrawRectangle(26, 188, 100, 100, GRAY); DrawRectangle(26, 188, 100, 100, GRAY);
DrawRectangle(26, 296, 100, 100, LIGHTGRAY); DrawRectangle(26, 296, 100, 100, LIGHTGRAY);
@@ -59,7 +59,7 @@ int main()
DrawRectangle(674, 188, 100, 100, BROWN); DrawRectangle(674, 188, 100, 100, BROWN);
DrawRectangle(674, 296, 100, 100, BEIGE); DrawRectangle(674, 296, 100, 100, BEIGE);
DrawText("DARKGRAY", 65, 166, 10, BLACK); DrawText("DARKGRAY", 65, 166, 10, BLACK);
DrawText("GRAY", 93, 274, 10, BLACK); DrawText("GRAY", 93, 274, 10, BLACK);
DrawText("LIGHTGRAY", 61, 382, 10, BLACK); DrawText("LIGHTGRAY", 61, 382, 10, BLACK);
@@ -81,7 +81,7 @@ int main()
DrawText("DARKBROWN", 705, 166, 10, BLACK); DrawText("DARKBROWN", 705, 166, 10, BLACK);
DrawText("BROWN", 733, 274, 10, BLACK); DrawText("BROWN", 733, 274, 10, BLACK);
DrawText("BEIGE", 737, 382, 10, BLACK); DrawText("BEIGE", 737, 382, 10, BLACK);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -90,6 +90,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 02a - Draw raylib logo * raylib [shapes] example - Draw raylib logo using basic shapes
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,10 +17,10 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -28,19 +28,19 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK); DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE); DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", 356, 273, 50, BLACK); DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK);
DrawText("this is NOT a texture!", 350, 370, 10, GRAY); DrawText("this is NOT a texture!", 350, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -49,6 +49,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 06b - raylib Logo Animation * raylib [shapes] example - raylib logo animation
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,30 +17,31 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation");
int logoPositionX = screenWidth/2 - 128; int logoPositionX = screenWidth/2 - 128;
int logoPositionY = screenHeight/2 - 128; int logoPositionY = screenHeight/2 - 128;
int framesCounter = 0; int framesCounter = 0;
int lettersCount = 0; int lettersCount = 0;
int topSideRecWidth = 16; int topSideRecWidth = 16;
int leftSideRecHeight = 16; int leftSideRecHeight = 16;
int bottomSideRecWidth = 16; int bottomSideRecWidth = 16;
int rightSideRecHeight = 16; int rightSideRecHeight = 16;
char raylib[8] = " "; // raylib text array, max 8 letters char raylib[8] = " \0"; // raylib text array, max 8 letters
int state = 0; // Tracking animation states (State Machine) int state = 0; // Tracking animation states (State Machine)
float alpha = 1.0; // Useful for fading float alpha = 1.0; // Useful for fading
InitWindow(screenWidth, screenHeight, "raylib example 06b - raylib logo animation");
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -49,9 +50,9 @@ int main()
if (state == 0) // State 0: Small box blinking if (state == 0) // State 0: Small box blinking
{ {
framesCounter++; framesCounter++;
if (framesCounter == 120) if (framesCounter == 120)
{ {
state = 1; state = 1;
framesCounter = 0; // Reset counter... will be used later... framesCounter = 0; // Reset counter... will be used later...
} }
@@ -60,26 +61,26 @@ int main()
{ {
topSideRecWidth += 4; topSideRecWidth += 4;
leftSideRecHeight += 4; leftSideRecHeight += 4;
if (topSideRecWidth == 256) state = 2; if (topSideRecWidth == 256) state = 2;
} }
else if (state == 2) // State 2: Bottom and right bars growing else if (state == 2) // State 2: Bottom and right bars growing
{ {
bottomSideRecWidth += 4; bottomSideRecWidth += 4;
rightSideRecHeight += 4; rightSideRecHeight += 4;
if (bottomSideRecWidth == 256) state = 3; if (bottomSideRecWidth == 256) state = 3;
} }
else if (state == 3) // State 3: Letters appearing (one by one) else if (state == 3) // State 3: Letters appearing (one by one)
{ {
framesCounter++; framesCounter++;
if (framesCounter/12) // Every 12 frames, one more letter! if (framesCounter/12) // Every 12 frames, one more letter!
{ {
lettersCount++; lettersCount++;
framesCounter = 0; framesCounter = 0;
} }
switch (lettersCount) switch (lettersCount)
{ {
case 1: raylib[0] = 'r'; break; case 1: raylib[0] = 'r'; break;
@@ -90,11 +91,11 @@ int main()
case 6: raylib[5] = 'b'; break; case 6: raylib[5] = 'b'; break;
default: break; default: break;
} }
if (lettersCount >= 10) // When all letters have appeared, just fade out everything if (lettersCount >= 10) // When all letters have appeared, just fade out everything
{ {
alpha -= 0.02; alpha -= 0.02;
if (alpha <= 0) if (alpha <= 0)
{ {
alpha = 0; alpha = 0;
@@ -108,27 +109,30 @@ int main()
{ {
framesCounter = 0; framesCounter = 0;
lettersCount = 0; lettersCount = 0;
topSideRecWidth = 16; topSideRecWidth = 16;
leftSideRecHeight = 16; leftSideRecHeight = 16;
bottomSideRecWidth = 16; bottomSideRecWidth = 16;
rightSideRecHeight = 16; rightSideRecHeight = 16;
for (int i = 0; i < 8; i++) raylib[i] = ' '; for (int i = 0; i < 7; i++) raylib[i] = ' ';
raylib[7] = '\0'; // Last character is end-of-line
alpha = 1.0; alpha = 1.0;
state = 0; // Return to State 0 state = 0; // Return to State 0
} }
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
if (state == 0) if (state == 0)
{ {
if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK);
@@ -142,22 +146,27 @@ int main()
{ {
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK);
} }
else if (state == 3) else if (state == 3)
{ {
DrawRectangle(logoPositionX, logoPositionY, 256, 256, Fade(BLACK, alpha)); DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
DrawText(raylib, 356, 273, 50, Fade(BLACK, alpha)); DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
} }
else if (state == 4) else if (state == 4)
{ {
DrawText("[R] REPLAY", 340, 200, 20, GRAY); DrawText("[R] REPLAY", 340, 200, 20, GRAY);
} }
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -166,6 +175,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 06c - Font selection... * raylib [text] example - Font selector
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,11 +18,11 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 150; int screenHeight = 150;
InitWindow(screenWidth, screenHeight, "raylib example 06c - font selection"); InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fonts[8]; // SpriteFont array SpriteFont fonts[8]; // SpriteFont array
fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading
fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading
@@ -31,50 +31,50 @@ int main()
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading
int currentFont = 0; // Selected font int currentFont = 0; // Selected font
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback", const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback",
"[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" }; "[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" };
const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text
Vector2 textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1); Vector2 textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1);
Vector2 mousePoint; Vector2 mousePoint;
Rectangle btnNextRec = { 673, 18, 109, 44 }; // Button rectangle (useful for collision) Rectangle btnNextRec = { 673, 18, 109, 44 }; // Button rectangle (useful for collision)
Color btnNextOutColor = DARKBLUE; // Button color (outside line) Color btnNextOutColor = DARKBLUE; // Button color (outside line)
Color btnNextInColor = SKYBLUE; // Button color (inside) Color btnNextInColor = SKYBLUE; // Button color (inside)
int framesCounter = 0; // Useful to count frames button is 'active' = clicked int framesCounter = 0; // Useful to count frames button is 'active' = clicked
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Keyboard-based font selection (easy) // Keyboard-based font selection (easy)
if (IsKeyPressed(KEY_RIGHT)) if (IsKeyPressed(KEY_RIGHT))
{ {
if (currentFont < 7) currentFont++; if (currentFont < 7) currentFont++;
} }
if (IsKeyPressed(KEY_LEFT)) if (IsKeyPressed(KEY_LEFT))
{ {
if (currentFont > 0) currentFont--; if (currentFont > 0) currentFont--;
} }
// Mouse-based font selection (NEXT button logic) // Mouse-based font selection (NEXT button logic)
mousePoint = GetMousePosition(); mousePoint = GetMousePosition();
if (CheckCollisionPointRec(mousePoint, btnNextRec)) if (CheckCollisionPointRec(mousePoint, btnNextRec))
{ {
// Mouse hover button logic // Mouse hover button logic
@@ -83,8 +83,8 @@ int main()
btnNextOutColor = DARKPURPLE; btnNextOutColor = DARKPURPLE;
btnNextInColor = PURPLE; btnNextInColor = PURPLE;
} }
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{ {
framesCounter = 20; // Frames button is 'active' framesCounter = 20; // Frames button is 'active'
btnNextOutColor = MAROON; btnNextOutColor = MAROON;
@@ -98,37 +98,37 @@ int main()
btnNextInColor = SKYBLUE; btnNextInColor = SKYBLUE;
} }
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON) && (framesCounter > 0)) framesCounter--; if (framesCounter > 0) framesCounter--;
if (framesCounter == 1) // We change font on frame 1 if (framesCounter == 1) // We change font on frame 1
{ {
currentFont++; currentFont++;
if (currentFont > 7) currentFont = 0; if (currentFont > 7) currentFont = 0;
} }
// Text measurement for better positioning on screen // Text measurement for better positioning on screen
textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1); textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawRectangle(18, 18, 644, 44, DARKGRAY); DrawRectangle(18, 18, 644, 44, DARKGRAY);
DrawRectangle(20, 20, 640, 40, LIGHTGRAY); DrawRectangle(20, 20, 640, 40, LIGHTGRAY);
DrawText(fontNames[currentFont], 30, 31, 20, BLACK); DrawText(fontNames[currentFont], 30, 31, 20, BLACK);
DrawText("< >", 610, 26, 30, BLACK); DrawText("< >", 610, 26, 30, BLACK);
DrawRectangleRec(btnNextRec, btnNextOutColor); DrawRectangleRec(btnNextRec, btnNextOutColor);
DrawRectangle(675, 20, 105, 40, btnNextInColor); DrawRectangle(675, 20, 105, 40, btnNextInColor);
DrawText("NEXT", 700, 31, 20, btnNextOutColor); DrawText("NEXT", 700, 31, 20, btnNextOutColor);
DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2,
75 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3, 75 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3,
1, colors[currentFont]); 1, colors[currentFont]);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -136,9 +136,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Testing FormatText() function * raylib [text] example - Text formatting
* *
* This test has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,16 +17,16 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
int score = 100020; int score = 100020;
int hiscore = 200450; int hiscore = 200450;
int lives = 5; int lives = 5;
InitWindow(screenWidth, screenHeight, "raylib test - FormatText()");
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -34,21 +34,21 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText(FormatText("Score: %08i", score), 80, 80, 20, RED); DrawText(FormatText("Score: %08i", score), 200, 80, 20, RED);
DrawText(FormatText("HiScore: %08i", hiscore), 80, 120, 20, GREEN); DrawText(FormatText("HiScore: %08i", hiscore), 200, 120, 20, GREEN);
DrawText(FormatText("Lives: %02i", lives), 80, 160, 40, BLUE); DrawText(FormatText("Lives: %02i", lives), 200, 160, 40, BLUE);
DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 80, 220, 20, BLACK); DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -57,6 +57,6 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,11 +1,14 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 05b - raylib bitmap font (rbmf) loading and using * raylib [text] example - raylib bitmap font (rbmf) loading and usage
*
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
* To view details and credits for those fonts, check raylib license file
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -18,19 +21,19 @@ int main()
int screenWidth = 560; int screenWidth = 560;
int screenHeight = 800; int screenHeight = 800;
InitWindow(screenWidth, screenHeight, "raylib example 05b - rBMF fonts"); InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font1 = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading SpriteFont font1 = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
SpriteFont font2 = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading SpriteFont font2 = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
SpriteFont font3 = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading SpriteFont font3 = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
SpriteFont font4 = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading SpriteFont font4 = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
SpriteFont font5 = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading SpriteFont font5 = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
SpriteFont font6 = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading SpriteFont font6 = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
SpriteFont font7 = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading SpriteFont font7 = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
SpriteFont font8 = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading SpriteFont font8 = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -38,22 +41,22 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTextEx(font1, "TESTING ALAGARD FONT", (Vector2){ 100, 100 }, GetFontBaseSize(font1)*2, 2, MAROON); DrawTextEx(font1, "TESTING ALAGARD FONT", (Vector2){ 100, 100 }, GetFontBaseSize(font1)*2, 2, MAROON);
DrawTextEx(font2, "TESTING PIXELPLAY FONT", (Vector2){ 100, 180 }, GetFontBaseSize(font2)*2, 4, ORANGE); DrawTextEx(font2, "TESTING PIXELPLAY FONT", (Vector2){ 100, 180 }, GetFontBaseSize(font2)*2, 4, ORANGE);
DrawTextEx(font3, "TESTING MECHA FONT", (Vector2){ 100, 260 }, GetFontBaseSize(font3)*2, 8, DARKGREEN); DrawTextEx(font3, "TESTING MECHA FONT", (Vector2){ 100, 260 }, GetFontBaseSize(font3)*2, 8, DARKGREEN);
DrawTextEx(font4, "TESTING SETBACK FONT", (Vector2){ 100, 350 }, GetFontBaseSize(font4)*2, 4, DARKBLUE); DrawTextEx(font4, "TESTING SETBACK FONT", (Vector2){ 100, 350 }, GetFontBaseSize(font4)*2, 4, DARKBLUE);
DrawTextEx(font5, "TESTING ROMULUS FONT", (Vector2){ 100, 430 }, GetFontBaseSize(font5)*2, 3, DARKPURPLE); DrawTextEx(font5, "TESTING ROMULUS FONT", (Vector2){ 100, 430 }, GetFontBaseSize(font5)*2, 3, DARKPURPLE);
DrawTextEx(font6, "TESTING PIXANTIQUA FONT", (Vector2){ 100, 510 }, GetFontBaseSize(font6)*2, 4, LIME); DrawTextEx(font6, "TESTING PIXANTIQUA FONT", (Vector2){ 100, 510 }, GetFontBaseSize(font6)*2, 4, LIME);
DrawTextEx(font7, "TESTING ALPHA_BETA FONT", (Vector2){ 100, 590 }, GetFontBaseSize(font7)*2, 4, GOLD); DrawTextEx(font7, "TESTING ALPHA_BETA FONT", (Vector2){ 100, 590 }, GetFontBaseSize(font7)*2, 4, GOLD);
DrawTextEx(font8, "TESTING JUPITER_CRASH FONT", (Vector2){ 100, 660 }, GetFontBaseSize(font8)*2, 1, RED); DrawTextEx(font8, "TESTING JUPITER_CRASH FONT", (Vector2){ 100, 660 }, GetFontBaseSize(font8)*2, 1, RED);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -68,9 +71,9 @@ int main()
UnloadSpriteFont(font6); // SpriteFont unloading UnloadSpriteFont(font6); // SpriteFont unloading
UnloadSpriteFont(font7); // SpriteFont unloading UnloadSpriteFont(font7); // SpriteFont unloading
UnloadSpriteFont(font8); // SpriteFont unloading UnloadSpriteFont(font8); // SpriteFont unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 05a - SpriteFont loading and drawing some text with it * raylib [text] example - SpriteFont loading and usage
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,31 +17,31 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage");
const char msg1[50] = "THIS IS A custom SPRITE FONT..."; const char msg1[50] = "THIS IS A custom SPRITE FONT...";
const char msg2[50] = "...and this is ANOTHER CUSTOM font..."; const char msg2[50] = "...and this is ANOTHER CUSTOM font...";
const char msg3[50] = "...and a THIRD one! GREAT! :D"; const char msg3[50] = "...and a THIRD one! GREAT! :D";
InitWindow(screenWidth, screenHeight, "raylib example 05a - sprite fonts");
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading
SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading
SpriteFont font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png"); // SpriteFont loading SpriteFont font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png"); // SpriteFont loading
Vector2 fontPosition1, fontPosition2, fontPosition3; Vector2 fontPosition1, fontPosition2, fontPosition3;
fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, GetFontBaseSize(font1), -3).x/2; fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, GetFontBaseSize(font1), -3).x/2;
fontPosition1.y = screenHeight/2 - GetFontBaseSize(font1)/2 - 80; fontPosition1.y = screenHeight/2 - GetFontBaseSize(font1)/2 - 80;
fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, GetFontBaseSize(font2), -2).x/2; fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, GetFontBaseSize(font2), -2).x/2;
fontPosition2.y = screenHeight/2 - GetFontBaseSize(font2)/2 - 10; fontPosition2.y = screenHeight/2 - GetFontBaseSize(font2)/2 - 10;
fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, GetFontBaseSize(font3), 2).x/2; fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, GetFontBaseSize(font3), 2).x/2;
fontPosition3.y = screenHeight/2 - GetFontBaseSize(font3)/2 + 50; fontPosition3.y = screenHeight/2 - GetFontBaseSize(font3)/2 + 50;
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -49,17 +49,17 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update variables here... // TODO: Update variables here...
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTextEx(font1, msg1, fontPosition1, GetFontBaseSize(font1), -3, WHITE); DrawTextEx(font1, msg1, fontPosition1, GetFontBaseSize(font1), -3, WHITE);
DrawTextEx(font2, msg2, fontPosition2, GetFontBaseSize(font2), -2, WHITE); DrawTextEx(font2, msg2, fontPosition2, GetFontBaseSize(font2), -2, WHITE);
DrawTextEx(font3, msg3, fontPosition3, GetFontBaseSize(font3), 2, WHITE); DrawTextEx(font3, msg3, fontPosition3, GetFontBaseSize(font3), 2, WHITE);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -69,9 +69,9 @@ int main()
UnloadSpriteFont(font1); // SpriteFont unloading UnloadSpriteFont(font1); // SpriteFont unloading
UnloadSpriteFont(font2); // SpriteFont unloading UnloadSpriteFont(font2); // SpriteFont unloading
UnloadSpriteFont(font3); // SpriteFont unloading UnloadSpriteFont(font3); // SpriteFont unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,8 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - DDS Texture loading and drawing (compressed and uncompressed) * raylib [textures] example - DDS Texture loading and drawing (compressed and uncompressed)
* *
* This test has been created using raylib 1.1 (www.raylib.com) * NOTE: This example requires raylib OpenGL 3.3+ or ES2 versions for compressed texture,
* OpenGL 1.1 does not support compressed textures, only uncompressed version.
*
* This example has been created using raylib 1.2 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -12,26 +15,21 @@
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - DDS texture loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - DDS texture loading and drawing");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
//Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading //Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading (compressed)
//Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading (uncompressed)
Image image = LoadImage("resources/raylib_logo_uncompressed.dds"); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
Texture2D texture = CreateTexture(image, false);
// NOTE: With OpenGL 3.3 mipmaps generation works great
SetTargetFPS(60);
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -39,28 +37,28 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
DrawText("this IS a texture!", 360, 370, 10, GRAY); DrawText("this may be a compressed texture!", 320, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
//UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,32 +1,35 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Testing LoadImage() and CreateTexture() * raylib [textures] example - Image loading and texture creation
* *
* This test has been created using raylib 1.0 (www.raylib.com) * 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)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - Image loading"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Image img = LoadImage("resources/raylib_logo.png"); Image img = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM)
Texture2D texture = CreateTexture(img, false); Texture2D texture = LoadTextureFromImage(img, false); // Image converted to texture, GPU memory (VRAM)
UnloadImage(img);
UnloadImage(img); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -34,17 +37,17 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
DrawText("this IS a texture!", 360, 370, 10, GRAY); DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -52,9 +55,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,29 +1,29 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 04a - Texture loading and drawing * raylib [textures] example - Texture loading and drawing
* *
* This example has been created using raylib 1.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -31,18 +31,18 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTexture(texture, screenWidth/2 - texture.width/2, DrawTexture(texture, screenWidth/2 - texture.width/2,
screenHeight/2 - texture.height/2, WHITE); screenHeight/2 - texture.height/2, WHITE);
DrawText("this IS a texture!", 360, 370, 10, GRAY); DrawText("this IS a texture!", 360, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -50,9 +50,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,66 @@
/*******************************************************************************************
*
* raylib [textures] example - Texture loading with mipmaps, mipmaps generation
*
* NOTE: On OpenGL 1.1, mipmaps are calculated 'manually', original image must be power-of-two
* On OpenGL 3.3 and ES2, mipmaps are generated automatically
*
* This example has been created using raylib 1.1 (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)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture mipmaps generation");
// NOTE: To generate mipmaps for an image, image must be loaded first and converted to texture
// with mipmaps option set to true on CreateTexture()
Image image = LoadImage("resources/raylib_logo.png"); // Load image to CPU memory (RAM)
Texture2D texture = LoadTextureFromImage(image, true); // Create texture and generate mipmaps
UnloadImage(image); // Once texture has been created, we can unload image data from RAM
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTexture(texture, screenWidth/2 - texture.width/2,
screenHeight/2 - texture.height/2 - 30, WHITE);
DrawText("this IS a texture with mipmaps! really!", 210, 360, 20, GRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,11 +1,11 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib example 04b - Texture loading and drawing a part defined by a rectangle * 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.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
* *
********************************************************************************************/ ********************************************************************************************/
@@ -17,24 +17,20 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
const char textLine2[] = "It comprises 512x512 pixels, and was originally cropped from the centerfold";
const char textLine3[] = "of November 1972 issue of Playboy magazine. The image is probably the most";
const char textLine4[] = "widely used test image for all sorts of image processing algorithms.";
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle"); InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
const char textLine2[] = "It comprises 512x512 pixels, and it is probably the most widely used";
const char textLine3[] = "test image for all sorts of image processing algorithms.";
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading
Color halfTrans = WHITE; Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
halfTrans.a = 30;
Rectangle eyesRec = { 225, 240, 155, 50 };
Vector2 position = { 369, 241 }; Vector2 position = { 369, 241 };
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -42,24 +38,23 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("LENA", 220, 100, 20, PINK); DrawText("LENA", 220, 100, 20, PINK);
DrawTexture(texture, screenWidth/2 - 256, 0, halfTrans); // Draw background image DrawTexture(texture, screenWidth/2 - 256, 0, Fade(WHITE, 0.1f)); // Draw background image
DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image
DrawText(textLine1, 220, 140, 10, DARKGRAY); DrawText(textLine1, 220, 140, 10, DARKGRAY);
DrawText(textLine2, 220, 160, 10, DARKGRAY); DrawText(textLine2, 220, 160, 10, DARKGRAY);
DrawText(textLine3, 220, 180, 10, DARKGRAY); DrawText(textLine3, 220, 180, 10, DARKGRAY);
DrawText(textLine4, 220, 200, 10, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -67,9 +62,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View File

@@ -1,8 +1,8 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib test - Texture loading and drawing with pro parameters (rotation, origin, scale...) * raylib [textures] example - Texture source and destination rectangles
* *
* This test has been created using raylib 1.1 (www.raylib.com) * This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
@@ -18,18 +18,21 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib test - texture pro"); InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
Vector2 position = { 200, 100 }; // NOTE: Source rectangle (part of the texture to use for drawing)
Rectangle sourceRec = { 128, 128, 128, 128 }; Rectangle sourceRec = { 128, 128, 128, 128 };
Rectangle destRec = { 128, 128, 128, 128 };
Vector2 origin = { 64, 64 }; // NOTE: origin is relative to destRec size // NOTE: Destination rectangle (screen rectangle where drawing part of texture)
Rectangle destRec = { screenWidth/2, screenHeight/2, 256, 256 };
// NOTE: Origin of the texture in case of rotation, it's relative to destination rectangle size
Vector2 origin = { 128, 128 };
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
@@ -37,20 +40,19 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
//DrawTextureEx(texture, position, 45, 1, MAROON); // NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
DrawTexturePro(texture, sourceRec, destRec, origin, 45, LIGHTGRAY);
DrawTexturePro(texture, sourceRec, destRec, origin, 45, GREEN);
DrawLine(destRec.x, 0, destRec.x, screenHeight, RED); DrawLine(destRec.x, 0, destRec.x, screenHeight, RED);
DrawLine(0, destRec.y, screenWidth, destRec.y, RED); DrawLine(0, destRec.y, screenWidth, destRec.y, RED);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@@ -58,9 +60,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
external/glfw3/lib/libglfw.3.0.dylib vendored Executable file

Binary file not shown.

1
external/glfw3/lib/libglfw.3.dylib vendored Symbolic link
View File

@@ -0,0 +1 @@
libglfw.3.0.dylib

1
external/glfw3/lib/libglfw.dylib vendored Symbolic link
View File

@@ -0,0 +1 @@
libglfw.3.dylib

210
games/floppy/floppy.c Normal file
View File

@@ -0,0 +1,210 @@
/*******************************************************************************************
*
* raylib game - Floppy Bird
*
* Welcome to raylib!
*
* 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 game has been created using raylib 1.1 (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)
*
********************************************************************************************/
#include "raylib.h"
#define MAX_TUBES 100
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "Floppy Bird");
InitAudioDevice(); // Initialize audio device
Sound coin = LoadSound("resources/coin.wav");
Sound jump = LoadSound("resources/jump.wav");
Texture2D background = LoadTexture("resources/background.png");
Texture2D tubes = LoadTexture("resources/tubes.png");
Texture2D floppy = LoadTexture("resources/floppy.png");
Vector2 floppyPos = { 80, screenHeight/2 - floppy.height/2 };
Vector2 tubesPos[MAX_TUBES];
int tubesSpeedX = 2;
for (int i = 0; i < MAX_TUBES; i++)
{
tubesPos[i].x = 400 + 280*i;
tubesPos[i].y = -GetRandomValue(0, 120);
}
Rectangle tubesRecs[MAX_TUBES*2];
bool tubesActive[MAX_TUBES];
for (int i = 0; i < MAX_TUBES*2; i += 2)
{
tubesRecs[i].x = tubesPos[i/2].x;
tubesRecs[i].y = tubesPos[i/2].y;
tubesRecs[i].width = tubes.width;
tubesRecs[i].height = 255;
tubesRecs[i+1].x = tubesPos[i/2].x;
tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255;
tubesRecs[i+1].width = tubes.width;
tubesRecs[i+1].height = 255;
tubesActive[i/2] = true;
}
int backScroll = 0;
int score = 0;
int hiscore = 0;
bool gameover = false;
bool superfx = false;
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
backScroll--;
if (backScroll <= -800) backScroll = 0;
for (int i = 0; i < MAX_TUBES; i++) tubesPos[i].x -= tubesSpeedX;
for (int i = 0; i < MAX_TUBES*2; i += 2)
{
tubesRecs[i].x = tubesPos[i/2].x;
tubesRecs[i+1].x = tubesPos[i/2].x;
}
if (IsKeyDown(KEY_SPACE) && !gameover) floppyPos.y -= 3;
else floppyPos.y += 1;
if (IsKeyPressed(KEY_SPACE) && !gameover) PlaySound(jump);
// Check Collisions
for (int i = 0; i < MAX_TUBES*2; i++)
{
if (CheckCollisionCircleRec((Vector2){ floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2 }, floppy.width/2, tubesRecs[i]))
{
gameover = true;
}
else if ((tubesPos[i/2].x < floppyPos.x) && tubesActive[i/2] && !gameover)
{
score += 100;
tubesActive[i/2] = false;
PlaySound(coin);
superfx = true;
if (score > hiscore) hiscore = score;
}
}
if (gameover && IsKeyPressed(KEY_ENTER))
{
for (int i = 0; i < MAX_TUBES; i++)
{
tubesPos[i].x = 400 + 280*i;
tubesPos[i].y = -GetRandomValue(0, 120);
}
for (int i = 0; i < MAX_TUBES*2; i += 2)
{
tubesRecs[i].x = tubesPos[i/2].x;
tubesRecs[i].y = tubesPos[i/2].y;
tubesRecs[i+1].x = tubesPos[i/2].x;
tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255;
tubesActive[i/2] = true;
}
floppyPos.x = 80;
floppyPos.y = screenHeight/2 - floppy.height/2;
gameover = false;
score = 0;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTexture(background, backScroll, 0, WHITE);
DrawTexture(background, screenWidth + backScroll, 0, WHITE);
if (!gameover)
{
DrawTextureEx(floppy, floppyPos, 0, 1.0, WHITE);
//DrawCircleLines(floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2, floppy.width/2, RED);
}
for (int i = 0; i < MAX_TUBES; i++)
{
if (tubesPos[i].x <= 800) DrawTextureEx(tubes, tubesPos[i], 0, 1.0, WHITE);
//DrawRectangleLines(tubesRecs[i*2].x, tubesRecs[i*2].y, tubesRecs[i*2].width, tubesRecs[i*2].height, RED);
//DrawRectangleLines(tubesRecs[i*2 + 1].x, tubesRecs[i*2 + 1].y, tubesRecs[i*2 + 1].width, tubesRecs[i*2 + 1].height, RED);
}
DrawText(FormatText("%04i", score), 20, 20, 40, PINK);
DrawText(FormatText("HI-SCORE: %04i", hiscore), 20, 70, 20, VIOLET);
if (gameover)
{
DrawText("GAME OVER", 100, 180, 100, MAROON);
DrawText("PRESS ENTER to RETRY!", 280, 280, 20, RED);
}
if (superfx)
{
DrawRectangle(0, 0, screenWidth, screenHeight, GOLD);
superfx = false;
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(background); // Texture unloading
UnloadTexture(tubes); // Texture unloading
UnloadTexture(floppy); // Texture unloading
UnloadSound(coin); // Unload sound data
UnloadSound(jump); // Unload sound data
CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

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