Merge branch 'master' of https://github.com/raysan5/raylib into dr/mini_al

This commit is contained in:
David Reid 2018-04-21 17:26:40 +10:00
commit f5ebbfb6bc
394 changed files with 64746 additions and 24522 deletions

25
.gitignore vendored
View File

@ -83,20 +83,20 @@ xcschememanagement.plist
xcuserdata/
DerivedData/
# external libraries DLLs
!src/external/glfw3/lib/win32/glfw3.dll
!src/external/openal_soft/lib/win32/OpenAL32.dll
# Visual Studio project
project/vs2015/*.db
project/vs2015/*.opendb
project/vs2015.UWP/packages
project/vs2015.UWP/*.db
!project/vs2015/raylib.sln
!project/vs2015/raylib/*.vcxproj
!project/vs2015/examples/*.vcxproj
!project/vs2015/external/glfw3/lib/win32/glfw3.dll
!project/vs2015/external/openal_soft/lib/win32/OpenAL32.dll
!project/vs2015/external/openal_soft/lib/win64/OpenAL32.dll
!project/vs2015/external/lua/lib/win32/lua53.dll
!project/vs2017/raylib.sln
!project/vs2017/raylib/*.vcxproj
!project/vs2017/examples/*.vcxproj
!project/vs2015.UWP/raylib/*.vcxproj
!project/vs2015.UWP/*.sln
!project/vs2015.UWP/raylib.App.UWP/*.vcxproj
# Web examples
docs/examples/web/*.html
@ -111,15 +111,11 @@ docs/examples/web/*/*.html
!docs/examples/web/shaders/loader.html
!docs/examples/web/models/loader.html
# Meson build system
builddir/
# CMake stuff
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
@ -133,3 +129,8 @@ build
# Ignore Android generated files and folders
templates/android_project/output
# Ignore GNU global tags
GPATH
GRTAGS
GTAGS

View File

@ -1,50 +1,62 @@
language: c
sudo: required
dist: trusty
git:
depth: 3
os:
- osx
- linux
# TODO we could use a 32 bit Docker container for running true 32-bit tests
# services: - docker
env:
global:
- VERBOSE=1
matrix:
- CFLAGS=-m64
- CFLAGS=-m32
matrix:
include:
- os: linux
env: ARCH=i386
sudo: required
- os: linux
env: ARCH=amd64
sudo: required
- os: osx
env: ARCH=universal
before_script:
- export CFLAGS="-std=gnu99 $CFLAGS"
before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-get install -y gcc-multilib
libopenal-dev
libxcursor-dev libxinerama-dev
mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev;
wget 'https://github.com/a3f/GLFW-3.2.1-Debian-binary-package/releases/download/v3.2.1/GLFW-3.2.1-Linux.deb' && sudo dpkg -i GLFW-3.2.1-Linux.deb;
libasound2-dev:$ARCH
libxcursor-dev:$ARCH libxinerama-dev:$ARCH mesa-common-dev:$ARCH
libx11-dev:$ARCH libxrandr-dev:$ARCH libxi-dev:$ARCH
libgl1-mesa-dev:$ARCH libglu1-mesa-dev:$ARCH;
export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH";
if [ "$ARCH" == "i386" ]; then export CFLAGS="-m32"; fi;
if [ "$ARCH" == "amd64" ]; then export CFLAGS="-m64"; fi;
if [ "$GLFW" == "SYSTEM" ]; then
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3_3.2.1-1_amd64.deb';
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3-dev_3.2.1-1_amd64.deb';
sudo dpkg -i libglfw3_3.2.1-1_amd64.deb libglfw3-dev_3.2.1-1_amd64.deb;
fi;
fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
export RAYLIB_PACKAGE_SUFFIX="-macOS";
if [ "$GLFW" == "SYSTEM" ]; then brew update; brew install glfw; fi;
fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; brew install glfw; fi
- "$CC --version"
script:
- mkdir build
- cd build
- cmake -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF ..
- make
# - make package
# - sudo make install
#
#deploy:
# provider: releases
# api_key:
# secure: XXX
# file_glob: true
# file: raylib-*.tar.gz
# skip_cleanup: true
# on:
# branch: master
# tags: true
- cmake -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE ..
- make VERBOSE=1
- make package
deploy:
provider: releases
api_key:
secure: LvqUIAN/3dJul+Ra2iK3tSaNG5IwsNMmGIwVMy0DK5IBCxiQPBc9pWGiE30RTBPt6Z+N4BhMEE8DtUl+vnISlMoHWNIIhF2zwC66hs/F7zY7qEITMRSmfiLcqxQysknFOnJB06CATgXcFqlEo9j+t4abrG/f3qcb92J4O2uNz336Au2myTx93Q5MxbyA7KiUuEutFnb2dWiPCY4d+sGeXEfsiD2R7aj/8MaWOkoGdZVrTkI9juMgvpImkjQBArvqdjUMeT3MsRrwgOIq5v2GFV9dOl8k1WzPeT8B2JHh00ed/o1/wuFq/cLLOxtYo2+Pv3+xatOrlexoX0WkDm7C9/L1W5U4rLexU3CQ9mMBmHPnp6k/WXZ5QXEE4uUF0+LpN3XlIXzFpdZmZiVV8VLxg2WvyncMmivYiu7/MTkyfZxyKkzwl7sZZslzHA9kOGedGaN7b7/2B77OFHoQK8lKfdFml7jJnarh+89nenNZYMab0E8qkOJOyb2bYlDTa0/2nyxGiyymYgq6YHLNrDbhqB/1LzdgzjMliQ8ri5q9Ux2vjfcqOzhfAmcwFwnY/D6yXJWYi0DWpHZdpKl3du6dYDrypW91/yDWbwiJ/YhrE7ZunzrcB6GH/QkbuzWxdCth39rQAHih8DG01co/K3Gvi4yGjvIH5tFUpyEolMnpMiA=
file_glob: true
file: raylib-*.tar.gz
skip_cleanup: true
on:
repo: raysan5/raylib
branch: master
tags: true

51
CMakeLists.txt Normal file → Executable file
View File

@ -1,8 +1,54 @@
cmake_minimum_required(VERSION 3.0)
# Config options
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
set(BUILD_GAMES ON CACHE BOOL "Build the example games.")
option(BUILD_EXAMPLES "Build the examples." ON)
option(BUILD_GAMES "Build the example games." ON)
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended for run with ASAN)" OFF)
if(CMAKE_VERSION VERSION_LESS "3.1")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
endif()
else()
set (CMAKE_C_STANDARD 99)
endif()
include(CheckCCompilerFlag)
function(add_if_flag_works flag)
CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES)
set(outcome "Failed")
if(COMPILER_HAS_THOSE_TOGGLES)
foreach(var ${ARGN})
set(${var} "${flag} ${${var}}" PARENT_SCOPE)
endforeach()
set(outcome "works")
endif()
message(STATUS "Testing if ${flag} can be used -- ${outcome}")
endfunction()
add_if_flag_works(-Werror=pointer-arith CMAKE_C_FLAGS)
add_if_flag_works(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
# src/external/jar_xm.h does shady stuff
add_if_flag_works(-fno-strict-aliasing CMAKE_C_FLAGS)
if (ENABLE_ASAN)
add_if_flag_works(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
add_if_flag_works(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
endif()
if (ENABLE_UBSAN)
add_if_flag_works(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
add_if_flag_works(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
endif()
if (ENABLE_MSAN)
add_if_flag_works(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
add_if_flag_works(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
endif()
if (ENABLE_MSAN AND ENABLE_ASAN)
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
endif()
add_subdirectory(src release)
@ -13,4 +59,3 @@ endif()
if (${BUILD_GAMES})
add_subdirectory(games)
endif()

128
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,128 @@
## Contributing to raylib
Hello contributors! Welcome to raylib!
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
Use your best judgement, and feel free to propose changes to this document in a pull-request.
### raylib philosophy
- raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself.
- raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not to include it.
- raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
- raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
- raylib's license (and its external libs respective licenses) allow using it for commercial products.
### Some interesting reads to start with
- [raylib history](HISTORY.md)
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
- [raylib license](LICENSE.md)
- [raylib roadmap](ROADMAP.md)
[raylib Wiki](https://github.com/raysan5/raylib/wiki) contains some information about the library and is open to anyone for edit.
Feel free to review it if required, just take care not to break anything.
### raylib C coding conventions
Despite being written in C, raylib does not follow the standard Hungarian notation for C,
it [follows Pascal-case/camel-case notation](https://github.com/raysan5/raylib/wiki/raylib-coding-conventions),
more common on C# language. All code formatting decisions have been carefully taken
to make it easier for students to read, write and understand code.
Source code is extensively commented for that purpose, raylib primary learning method is:
> learn by reading code and examples
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
### Opening new Issues
To open new issue for raylib (bug, enhancement, discussion...), just try to follow these rules:
- Make sure the issue has not already been reported before by searching on GitHub under Issues.
- If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a
title and clear description, as much relevant information as possible, and a code sample demonstrating the unexpected behavior.
- If applies, attach some screenshot of the issue and a .zip file with the code sample and required resources.
- On issue description, add a brackets tag about the raylib module that relates to this issue.
If don't know the module, just report the issue, I will review it.
- You can check other issues to see how is being done!
### Sending a Pull-Request
- Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
- Don't send big pull-requests (lots of changelists), they are difficult to review. It's better to send small pull-request, one at a time.
- Verify that changes don't break the build (at least on Windows platform). As many platforms where you can test it, the better, but don't worry
if you cannot test all the platforms.
### raylib bindings
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
- [raylib C/C++ version (default)](https://github.com/raysan5/raylib)
- [raylib Lua binding](https://github.com/raysan5/raylib-lua)
- [raylib Go binding](https://github.com/gen2brain/raylib-go)
- [raylib Nim binding](https://gitlab.com/define-private-public/raylib-Nim)
- [raylib Crystal binding](https://gitlab.com/Zatherz/cray)
- [raylib Perl wrapper](https://metacpan.org/pod/Graphics::Raylib)
- raylib Pascal binding with custom IDE (closed-source)
Usually, raylib bindings follow the convention: `raylib-{language}`
Let me know if you're writing a new binding for raylib, I will list it here and I usually
provide the icon/logo for that new language binding.
### Contact information
If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
You can write me a direct mail but you can also contact me on the following networks:
- [raylib forum](http://forum.raylib.com/) - A good place for discussions or to ask for help.
- [raylib gitter](https://gitter.im/raylib) - A direct communication channel for project discussions.
- [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs.
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.
Thank you very much for your time! :)
----
Here is a list of raylib contributors, these people have invested part of their time
contributing (in some way or another) to make the raylib project better. Huge thanks to all of them!
- [Zopokx](https://github.com/Zopokx) for testing the web.
- [Elendow](http://www.elendow.com) for testing and helping on web development.
- Victor Dual for implementing and testing 3D shapes functions.
- Marc Palau for implementing and testing 3D shapes functions and contribute on camera and gestures modules.
- Kevin Gato for improving texture internal formats support and helping on raygui development.
- Daniel Nicolas for improving texture internal formats support and helping on raygui development.
- Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- [Sergio Martinez](https://github.com/anidealgift) for helping on raygui development and tools development (raygui_styler).
- [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing PBR materials and lighting systems... among multiple other improvements and multiple tools and games.
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
- [procedural](https://github.com/procedural) for testing raylib on Linux, correcting some bugs and adding several mouse functions.
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
- [Marcelo Paez](https://github.com/paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h)
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading.
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and adding meson support for Linux
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS
- [Wilhem Barbier](https://github.com/nounoursheureux) for supporting default shaders on shader loading, if shader not provided
- [Ahmad Fatoum](https://github.com/a3f) for implementing continuus integration support for raylib (Travis and AppVeyor) and greatly improving build system.
- [SamNChiet](https://github.com/SamNChiet) for his work on UWP inputs implementation.
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing mini_al audio library.
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!

View File

@ -1,35 +0,0 @@
I believe that time is the most valuable resource and the following people have invested part of their time
contributing (in some way or another) to make raylib project better. Huge thanks!
- [Zopokx](https://github.com/Zopokx) for testing the web.
- [Elendow](http://www.elendow.com) for testing and helping on web development.
- Victor Dual for implementing and testing 3D shapes functions.
- Marc Palau for implementing and testing 3D shapes functions and contribute on camera and gestures modules.
- Kevin Gato for improving texture internal formats support and helping on raygui development.
- Daniel Nicolas for improving texture internal formats support and helping on raygui development.
- Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- [Sergio Martinez](https://github.com/anidealgift) for helping on raygui development and tools development (raygui_styler).
- [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing PBR materials and lighting systems... among multiple other improvements and multiple tools and games.
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
- [procedural](https://github.com/procedural) for testing raylib on Linux, correcting some bugs and adding several mouse functions.
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
- [Marcelo Paez](https://github.com/paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h)
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading.
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and adding meson support for Linux
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem
Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!

View File

@ -73,12 +73,12 @@ attached to 3d models or used as fullscreen postrocessing effects. A bunch of po
in this release, check raylib/shaders folder.
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c).
A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
[raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
[raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
primary intended for tools development. It's still in experimental state but already fully functional.
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
@ -91,18 +91,18 @@ notes on raylib 1.4
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version,
lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
Now a basic image processing can be done before converting the image to texture for usage.
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library).
Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
New [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
[raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
[gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`).
@ -110,7 +110,7 @@ Gamepad support has also been added (experimental).
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions,
and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported).
A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
A simple [easings](https://github.com/raysan5/raylib/blob/master/src/easings.h) module has also been added for values animation.
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
@ -122,7 +122,7 @@ notes on raylib 1.5
On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added.
VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/develop/examples/core_oculus_rift.c).
VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/master/examples/core_oculus_rift.c).
New materials system: now raylib supports standard material properties for 3D models, including diffuse-ambient-specular colors and diffuse-normal-specular textures. Just assign values to standard material and everything is processed internally.
@ -130,15 +130,15 @@ New lighting system: added support for up to 8 configurable lights and 3 light t
Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread.
Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/develop/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread.
Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/master/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread.
Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/develop/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/develop/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/develop/CHANGELOG) file for a more detailed list of changes.
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c) raylib modules as standalone libraries.
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/master/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/master/examples/audio_standalone.c) raylib modules as standalone libraries.
Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5.
@ -149,7 +149,7 @@ On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new v
Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/develop/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/develop/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/master/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
@ -187,17 +187,17 @@ notes on raylib 1.8
October 2017, around 5 months after latest raylib version, another release is published: raylib 1.8. Again, several modules of the library have been reviewed and some new functionality added. Main changes of this new release are:
[Procedural image generation](https://github.com/raysan5/raylib/blob/develop/examples/textures/textures_image_generation.c) function, a set of new functions have been added to generate gradients, checked, noise and cellular images from scratch. Image generation could be useful for certain textures or learning pourpouses.
[Procedural image generation](https://github.com/raysan5/raylib/blob/master/examples/textures/textures_image_generation.c) function, a set of new functions have been added to generate gradients, checked, noise and cellular images from scratch. Image generation could be useful for certain textures or learning pourpouses.
[Parametric mesh generation](https://github.com/raysan5/raylib/blob/develop/examples/models/models_mesh_generation.c) functions, create 3d meshes from scratch just defining a set of parameters, meshes like cube, sphere, cylinder, torus, knot and more can be very useful for prototyping or for lighting and texture testing.
[Parametric mesh generation](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_generation.c) functions, create 3d meshes from scratch just defining a set of parameters, meshes like cube, sphere, cylinder, torus, knot and more can be very useful for prototyping or for lighting and texture testing.
PBR Materials support, a completely redesigned shaders and material system allows advance materials definition and usage, with fully customizable shaders. Some new functions have been added to generate the environment textures required for PBR shading and a a new complete [PBR material example](https://github.com/raysan5/raylib/blob/develop/examples/models/models_material_pbr.c) is also provided for reference.
PBR Materials support, a completely redesigned shaders and material system allows advance materials definition and usage, with fully customizable shaders. Some new functions have been added to generate the environment textures required for PBR shading and a a new complete [PBR material example](https://github.com/raysan5/raylib/blob/master/examples/models/models_material_pbr.c) is also provided for reference.
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/develop/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/master/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
[rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/develop/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
[raymath](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
[raymath](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
Additionally, as always, examples and templates have been reviewed to work with new version (some new examples have been added), all external libraries have been updated to latest stable version and latest Notepad++ and MinGW have been configured to work with new raylib. For a full list of changes, just check [CHANGELOG](CHANGELOG).

View File

@ -27,7 +27,7 @@ applications, and to alter it and redistribute it freely, subject to the followi
fonts
------
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/develop/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/master/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
* Alpha Beta - Brian Kent (AEnigma)
* Setback - Brian Kent (AEnigma)
@ -41,9 +41,9 @@ The following fonts [provided with raylib](https://github.com/raysan5/raylib/tre
2d art
------
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
3d models
---------
[dwarf 3d model and textures](https://github.com/raysan5/raylib/tree/develop/examples/models/resources/model) have been created by David Moreno and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
[dwarf 3d model and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/model) have been created by David Moreno and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)

View File

@ -1,4 +1,4 @@
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/logo256x256.png" width=256>
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_256x256.png" width=256>
**raylib is a simple and easy-to-use library to learn videogames programming.**
@ -11,39 +11,46 @@ no fancy interface, no visual helpers, no auto-debugging... just coding in the m
pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
[![Build Status](https://travis-ci.org/raysan5/raylib.svg?branch=develop)](https://travis-ci.org/raysan5/raylib)
[![https://ci.appveyor.com/api/projects/status/github/raysan5/raylib?svg=true](https://ci.appveyor.com/api/projects/status/github/raysan5/raylib?svg=true)](https://ci.appveyor.com/project/raysan5/raylib)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/raylib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Chat on Discord](https://img.shields.io/discord/308323056592486420.svg?logo=discord)](https://discord.gg/VkzNHUE)
[![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE.md)
[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Follow)](https://twitter.com/raysan5)
features
--------
* Written in plain C code (C99) in PascalCase/camelCase notation
* Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2)
* Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile)
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
* Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF)
* Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC)
* Basic 3d support for Geometrics, Models, Billboards, Heightmaps and Cubicmaps
* Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF)
* Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
* Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
* Flexible Materials system, supporting classic maps and PBR maps
* Shaders support, including Model shaders and Postprocessing shaders
* Powerful math module for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
* Audio loading and playing with streaming support (WAV, OGG, FLAC, XM, MOD)
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5**
* VR stereo rendering support with configurable HMD device parameters
* Minimal external dependencies (GLFW3, OpenGL, OpenAL)
* Multiple platforms support: Windows, Linux, FreeBSD, MacOS, UWP, Android, Raspberry Pi, HTML5.
* VR stereo rendering with configurable HMD device parameters
* NO external dependencies, all required libraries included with raylib
* Complete bindings to LUA ([raylib-lua](https://github.com/raysan5/raylib-lua)) and Go ([raylib-go](https://github.com/gen2brain/raylib-go))
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option I found for
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, maintained, ...).
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
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, Raspberry Pi and HTML5.
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, the amazing [mini_al](https://github.com/dr-soft/mini_al) audio library, single-file header-only and supporting multiple platforms and multiple audio backends.
raylib uses internally multiple single-file header-only libraries to support multiple fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory.
*On Android, `native_app_glue module` (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
*On Raspberry Pi, Videocore API and EGL libraries are used for window/context management and raw inputs reading.*
building
--------
build and installation
----------------------
For detailed building instructions, check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
Binary releases for Windows, Linux and macOS are available at the [Github Releases](https://github.com/raysan5/raylib/releases) page. raylib is also available via multiple package managers on multiple OS distributions. For more info check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
To build raylib yourself, check out also the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
raylib has been developed using exclusively two tools:
@ -61,6 +68,7 @@ contact
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
If you are using raylib and you enjoy it, please, [let me know][raysan5].

View File

@ -4,7 +4,7 @@ roadmap
Current version of raylib is complete and functional but there is still a lot of room for improvement.
Here it is a wish-list with features and ideas to improve the library.
Note that [raylib source code](https://github.com/raysan5/raylib/tree/develop/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
**raylib 1.x**
- [ ] Basic GPU stats sytem (memory, draws, time...)

65
appveyor.yml Normal file
View File

@ -0,0 +1,65 @@
#os: Visual Studio 2015
clone_depth: 5
cache:
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
init:
- cmake -E remove c:\programdata\chocolatey\bin\cpack.exe
- set PATH=%PATH:C:\Program Files (x86)\Git\usr\bin;=%
- set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
- if [%BITS%]==[32] set MINGW=C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32
- if [%BITS%]==[64] set MINGW=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64
- if [%COMPILER%]==[mingw] set PATH=%MINGW%\bin;%PATH%
- set RAYLIB_PACKAGE_SUFFIX=-Win%BITS%-%COMPILER%
- set VERBOSE=1
environment:
matrix:
- compiler: mingw
bits: 32
examples: ON
- compiler: mingw
bits: 64
examples: ON
- compiler: msvc15
bits: 32
examples: OFF
- compiler: msvc15
bits: 64
examples: OFF
before_build:
- if [%compiler%]==[mingw] set CFLAGS=-m%BITS% & set LDFLAGS=-m%BITS% & set GENERATOR="MinGW Makefiles"
- if [%COMPILER%]==[msvc15] if [%BITS%]==[32] set GENERATOR="Visual Studio 14 2015"
- if [%COMPILER%]==[msvc15] if [%BITS%]==[64] set GENERATOR="Visual Studio 14 2015 Win64"
- mkdir build
- cd build
build_script:
- cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
- cmake --build . --target install
after_build:
- cmake --build . --target package
before_test:
test_script:
artifacts:
- path: 'build\*.zip'
deploy:
- provider: GitHub
auth_token:
secure: OxKnnT3tlkPl9365cOO84rDWU4UkHIYJc0D3r3Tv7rB3HaR2BBhlhCnl7g3nuOJy
artifact: /.*\.zip/
draft: false
prerelease: false
force_update: true
on:
branch: master
appveyor_repo_tag: true # deploy on tag push only

View File

@ -7,9 +7,20 @@ include("../utils.cmake")
# TODO `build` directory should maybe be something else...
# TODO place somewhere else?
include_directories("../build/release")
include_directories("../src/external")
include_directories("../src/external/glfw/include")
# Get the sources together
set(example_dirs audio core models others physac shaders text texutures)
set(example_dirs audio core models others shaders shapes text textures)
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
include(CheckSymbolExists)
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC)
set(CMAKE_REQUIRED_DEFINITIONS)
if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC)
set(example_dirs ${example_dirs} physac)
endif()
set(example_sources)
set(example_resources)
foreach(example_dir ${example_dirs})
@ -22,6 +33,14 @@ foreach(example_dir ${example_dirs})
list(APPEND example_resources ${resources})
endforeach()
include(CheckIncludeFiles)
check_include_files(OVR_CAPI_GL.h HAVE_OCULUS_CAPI)
if(NOT HAVE_OCULUS_CAPI)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/oculus_rift.c)
endif()
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
# Do each example
foreach(example_source ${example_sources})
# Create the basename for the example

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -24,81 +24,138 @@
.PHONY: all clean
# Define required raylib variables
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..
PROJECT_NAME ?= raylib_example
PROJECT_NAME ?= raylib_examples
RAYLIB_VERSION ?= 1.9.7
RAYLIB_API_VERSION ?= 1
RAYLIB_PATH ?= ..
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Define default options
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
PLATFORM ?= PLATFORM_DESKTOP
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif
# Locations of your newly installed library and associated headers. See ../src/Makefile
# On Linux, if you have installed raylib but cannot compile the examples, check that
# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations.
# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED.
# To enable compile-time linking to a special version of libraylib.so, change these variables here.
# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below.
# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime,
# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH.
# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
DESTDIR ?= /usr/local
RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Build mode for project: DEBUG or RELEASE
RAYLIB_BUILD_MODE ?= RELEASE
# Use external GLFW library instead of rglfw module
# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
# RAYLIB_PATH adjustment for different platforms.
# If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
# Required for ldconfig or other tools that do not perform path expansion.
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_PREFIX ?= ..
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
endif
endif
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki.
# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX.
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
# Define raylib release directory for compiled library
# Define raylib release directory for compiled library.
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version.
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux
# without formal installation from ../src/Makefile. It aids portability and is useful if you have
# multiple versions of raylib, have raylib installed to a non-standard location, or want to
# bundle libraylib.so with your game. Change it to your liking.
# Note: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
# To see which libraries a built example is linking to, ldd core/core_basic_window;
# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing.
EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH)
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -106,14 +163,20 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
# HTML5 emscripten compiler
CC = emcc
endif
@ -129,15 +192,14 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
@ -148,7 +210,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
CFLAGS += -g
#CC = clang
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
ifeq ($(RAYLIB_LIBTYPE),SHARED)
# Explicitly enable runtime link to libraylib.so
CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
@ -160,23 +232,54 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
# Define include paths for required headers.
# Precedence: immediately local, raysan5 provided sources
# NOTE: Several external required libraries (stb and others)
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI requried libraries
# RPI required libraries
INCLUDE_PATHS += -I/opt/vc/include
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
# Consider -L$(RAYLIB_H_INSTALL_PATH)
INCLUDE_PATHS += -I/usr/local/include
endif
ifeq ($(PLATFORM_OS),LINUX)
# Reset everything.
# Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include
INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external
endif
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
# Define library paths containing required libs.
# Precedence: immediately local, then raysan5 provided libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
# Consider -L$(RAYLIB_INSTALL_PATH)
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
ifeq ($(PLATFORM_OS),LINUX)
# Reset everything.
# Precedence: immediately local, installed version, raysan5 provided libs
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -186,50 +289,53 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
# Required for physac examples
LDLIBS += -static -lpthread
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all object files required
@ -266,6 +372,7 @@ EXAMPLES = \
textures/textures_image_processing \
textures/textures_image_drawing \
textures/textures_image_generation \
textures/textures_image_text \
text/text_sprite_fonts \
text/text_bmfont_ttf \
text/text_raylib_fonts \
@ -282,9 +389,9 @@ EXAMPLES = \
models/models_cubicmap \
models/models_mesh_picking \
models/models_mesh_generation \
models/models_yaw_pitch_roll \
models/models_material_pbr \
models/models_skybox \
models/models_yaw_pitch_roll \
shaders/shaders_model_shader \
shaders/shaders_shapes_textures \
shaders/shaders_custom_uniform \
@ -298,7 +405,7 @@ EXAMPLES = \
physac/physics_movement \
physac/physics_restitution \
physac/physics_shatter \
fix_dylib \
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
@ -327,7 +434,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
del *.o *.exe /s
endif
ifeq ($(PLATFORM_OS),LINUX)
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
endif
ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete
@ -336,10 +443,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
find . -type f -executable -delete
rm -f *.o
rm -fv *.o
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done

View File

@ -23,7 +23,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
// Define the camera to look into our 3d world (position, target, up vector)
Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 4.0f, 2.0f, 4.0f };
camera.target = (Vector3){ 0.0f, 1.8f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 60.0f;
camera.type = CAMERA_PERSPECTIVE;
// Generates some random columns
float heights[MAX_COLUMNS];

View File

@ -29,11 +29,11 @@ int main()
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
Ray ray; // Picking line ray
Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray
bool collision = false;
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -45,11 +45,11 @@ int main()
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
ray = GetMouseRay(GetMousePosition(), camera);
// Check collision between ray and box
collision = CheckCollisionRayBox(ray,
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
@ -65,7 +65,7 @@ int main()
Begin3dMode(camera);
if (collision)
if (collision)
{
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED);
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON);
@ -77,15 +77,14 @@ int main()
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY);
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY);
}
DrawRay(ray, MAROON);
DrawGrid(10, 1.0f);
End3dMode();
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
DrawFPS(10, 10);
@ -100,4 +99,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
}
}

View File

@ -21,7 +21,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world
Camera camera = {{ 10.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };

View File

@ -21,7 +21,13 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
// Define the camera to look into our 3d world
Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard

View File

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };

View File

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
// Define the camera to look into our 3d world
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)

View File

@ -21,7 +21,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
// Define our custom camera to look into our 3d world
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)

View File

@ -34,7 +34,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
// Define the camera to look into our 3d world
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
// Load model and PBR material
Model model = LoadModel("resources/pbr/trooper.obj");
@ -113,7 +113,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
mat.shader.locs[LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
mat.shader.locs[LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
mat.shader.locs[LOC_MAP_OCCUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
mat.shader.locs[LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
//mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
//mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");

View File

@ -41,7 +41,7 @@ int main()
for (int i = 0; i < NUM_MODELS; i++) models[i].material.maps[MAP_DIFFUSE].texture = texture;
// Define the camera to look into our 3d world
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
// Model drawing position
Vector3 position = { 0.0f, 0.0f, 0.0f };

View File

@ -38,7 +38,7 @@ int main()
tower.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
BoundingBox towerBBox = CalculateBoundingBox(tower.mesh);
BoundingBox towerBBox = MeshBoundingBox(tower.mesh); // Get mesh bounding box
bool hitMeshBBox = false;
bool hitTriangle = false;
@ -101,8 +101,8 @@ int main()
{
hitMeshBBox = true;
// Check ray collision against mesh
meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh);
// Check ray collision against model
meshHitInfo = GetCollisionRayModel(ray, &tower);
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
{

View File

@ -21,7 +21,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
// Define the camera to look into our 3d world
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture

View File

@ -0,0 +1,97 @@
/*******************************************************************************************
*
* raylib [models] example - Show the difference between perspective and orthographic projection
*
* This program is heavily based on the geometric objects example
*
* This example has been created using raylib 1.9.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2018 Max Danielsson & Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define FOVY_PERSPECTIVE 45.0f
#define WIDTH_ORTHOGRAPHIC 10.0f
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
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
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE))
{
if (camera.type == CAMERA_PERSPECTIVE)
{
camera.fovy = WIDTH_ORTHOGRAPHIC;
camera.type = CAMERA_ORTHOGRAPHIC;
}
else
{
camera.fovy = FOVY_PERSPECTIVE;
camera.type = CAMERA_PERSPECTIVE;
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
DrawGrid(10, 1.0f); // Draw a grid
End3dMode();
DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY);
if (camera.type == CAMERA_ORTHOGRAPHIC) DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK);
else if (camera.type == CAMERA_PERSPECTIVE) DrawText("PERSPECTIVE", 10, 40, 20, BLACK);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
// Define the camera to look into our 3d world
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
// Load skybox model
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@ -62,7 +62,7 @@ int main()
Begin3dMode(camera);
DrawModel(skybox, Vector3Zero(), 1.0f, WHITE);
DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE);
DrawGrid(10, 1.0f);

View File

@ -5,7 +5,7 @@
* This example has been created using raylib 1.8 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Example based on Berni work on Raspberry Pi:
* Example based on Berni work on Raspberry Pi:
* http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order
*
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
@ -30,25 +30,26 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)");
Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png");
Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png");
Texture2D texBackground = LoadTexture("resources/background.png");
Texture2D texPitch = LoadTexture("resources/pitch.png");
Texture2D texPitch = LoadTexture("resources/pitch.png");
Texture2D texPlane = LoadTexture("resources/plane.png");
RenderTexture2D framebuffer = LoadRenderTexture(192, 192);
// Model loading
Model model = LoadModel("resources/plane.obj"); // Load OBJ model
model.material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/plane_diffuse.png"); // Set map diffuse texture
GenTextureMipmaps(&model.material.maps[MAP_DIFFUSE].texture);
Camera camera = { 0 };
camera.position = (Vector3){ 0.0f, 60.0f, -120.0f };// Camera position perspective
camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 30.0f; // Camera field-of-view Y
camera.type = CAMERA_PERSPECTIVE; // Camera type
float pitch = 0.0f;
float roll = 0.0f;
float yaw = 0.0f;
@ -61,7 +62,7 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
// Plane roll (x-axis) controls
if (IsKeyDown(KEY_LEFT)) roll += 1.0f;
else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f;
@ -70,7 +71,7 @@ int main()
if (roll > 0.0f) roll -= 0.5f;
else if (roll < 0.0f) roll += 0.5f;
}
// Plane yaw (y-axis) controls
if (IsKeyDown(KEY_S)) yaw += 1.0f;
else if (IsKeyDown(KEY_A)) yaw -= 1.0f;
@ -79,7 +80,7 @@ int main()
if (yaw > 0.0f) yaw -= 0.5f;
else if (yaw < 0.0f) yaw += 0.5f;
}
// Plane pitch (z-axis) controls
if (IsKeyDown(KEY_DOWN)) pitch += 0.6f;
else if (IsKeyDown(KEY_UP)) pitch -= 0.6f;
@ -88,7 +89,7 @@ int main()
if (pitch > 0.3f) pitch -= 0.3f;
else if (pitch < -0.3f) pitch += 0.3f;
}
// Wraps the phase of an angle to fit between -180 and +180 degrees
int pitchOffset = pitch;
while (pitchOffset > 180) pitchOffset -= 360;
@ -96,20 +97,20 @@ int main()
pitchOffset *= 10;
Matrix transform = MatrixIdentity();
transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll));
transform = MatrixMultiply(transform, MatrixRotateX(DEG2RAD*pitch));
transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw));
model.transform = transform;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw framebuffer texture (Ahrs Display)
int centerX = framebuffer.texture.width/2;
int centerY = framebuffer.texture.height/2;
@ -119,18 +120,18 @@ int main()
BeginBlendMode(BLEND_ALPHA);
DrawTexturePro(texBackground, (Rectangle){0,0,texBackground.width, texBackground.height},
DrawTexturePro(texBackground, (Rectangle){ 0, 0, texBackground.width, texBackground.height },
(Rectangle){ centerX, centerY, texBackground.width*scaleFactor, texBackground.height*scaleFactor},
(Vector2){texBackground.width/2*scaleFactor, texBackground.height/2*scaleFactor + pitchOffset*scaleFactor}, roll, WHITE);
(Vector2){ texBackground.width/2*scaleFactor, texBackground.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE);
DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height },
(Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor },
(Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE);
DrawTexturePro(texPlane, (Rectangle){0,0,texPlane.width, texPlane.height },
(Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor },
(Vector2){texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE);
DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height },
(Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor },
(Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE);
EndBlendMode();
EndTextureMode();
@ -144,10 +145,10 @@ int main()
End3dMode();
// Draw 2D GUI stuff
DrawAngleGauge(texAngleGauge, 80, 80, roll, "roll", RED);
DrawAngleGauge(texAngleGauge, 190, 80, pitch, "pitch", GREEN);
DrawAngleGauge(texAngleGauge, 300, 80, yaw, "yaw", SKYBLUE);
DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED);
DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN);
DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE);
DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f));
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 370, 10, DARKGRAY);
@ -155,31 +156,31 @@ int main()
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 410, 10, DARKGRAY);
// Draw framebuffer texture
DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height },
DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height },
(Vector2){ screenWidth - framebuffer.texture.width - 20, 20 }, Fade(WHITE, 0.8f));
DrawRectangleLines(screenWidth - framebuffer.texture.width - 20, 20, framebuffer.texture.width, framebuffer.texture.height, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// Unload all loaded data
UnloadModel(model);
UnloadRenderTexture(framebuffer);
UnloadTexture(texAngleGauge);
UnloadTexture(texAngleGauge);
UnloadTexture(texBackground);
UnloadTexture(texPitch);
UnloadTexture(texPitch);
UnloadTexture(texPlane);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
@ -192,7 +193,7 @@ void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[
int textSize = 20;
DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color);
DrawText(FormatText("%5.1f°", angle), x - MeasureText(FormatText("%5.1f°", angle), textSize) / 2, y + 10, textSize, DARKGRAY);
DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY);
}
DrawText(FormatText("%5.1f", angle), x - MeasureText(FormatText("%5.1f", angle), textSize) / 2, y + 10, textSize, DARKGRAY);
DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -12,7 +12,7 @@
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec3 vertexNormal;
in vec3 vertexTangent;
in vec4 vertexTangent;
// Input uniform values
uniform mat4 mvp;
@ -28,7 +28,7 @@ out vec3 fragBinormal;
void main()
{
// Calculate binormal from vertex normal and tangent
vec3 vertexBinormal = cross(vertexNormal, vertexTangent);
vec3 vertexBinormal = cross(vertexNormal, vec3(vertexTangent));
// Calculate fragment normal based on normal transformations
mat3 normalMatrix = transpose(inverse(mat3(mMatrix)));
@ -39,7 +39,7 @@ void main()
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragNormal = normalize(normalMatrix*vertexNormal);
fragTangent = normalize(normalMatrix*vertexTangent);
fragTangent = normalize(normalMatrix*vec3(vertexTangent));
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
fragBinormal = normalize(normalMatrix*vertexBinormal);
fragBinormal = cross(fragNormal, fragTangent);

View File

@ -26,14 +26,11 @@
********************************************************************************************/
#include <stdio.h>
#include "audio.h"
#if defined(_WIN32)
#include <conio.h> // Windows only, no stardard library
#endif
#include "audio.h"
#if defined(__linux__)
#else
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
@ -79,13 +76,13 @@ int main()
{
// Initialization
//--------------------------------------------------------------------------------------
unsigned char key;
static unsigned char key;
InitAudioDevice();
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
PlayMusicStream(music);
@ -102,23 +99,23 @@ int main()
PlaySound(fxWav);
key = 0;
}
if (key == 'd')
{
PlaySound(fxOgg);
key = 0;
}
UpdateMusicStream(music);
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSound(fxWav); // Unload sound data
UnloadSound(fxOgg); // Unload sound data
UnloadMusicStream(music); // Unload music stream data
CloseAudioDevice();
//--------------------------------------------------------------------------------------

View File

@ -10,7 +10,6 @@
********************************************************************************************/
#include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free()
#define MAX_BUNNIES 100000 // 100K bunnies
@ -29,15 +28,16 @@ int main()
int screenHeight = 960;
InitWindow(screenWidth, screenHeight, "raylib example - Bunnymark");
Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png");
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
int bunniesCount = 0; // Bunnies counter
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@ -54,7 +54,7 @@ int main()
bunniesCount++;
}
}
// Update bunnies
for (int i = 0; i < bunniesCount; i++)
{
@ -65,14 +65,14 @@ int main()
if ((bunnies[i].position.y > GetScreenHeight()) || (bunnies[i].position.y < 0)) bunnies[i].speed.y *= -1;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
for (int i = 0; i <= bunniesCount; i++)
for (int i = 0; i < bunniesCount; i++)
{
// NOTE: When internal QUADS batch limit is reached, a draw call is launched and
// batching buffer starts being filled again; before launching the draw call,
@ -80,11 +80,10 @@ int main()
// a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps
DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, RAYWHITE);
}
DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY);
DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY);
DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED);
DrawFPS(260, 10);
EndDrawing();
@ -94,9 +93,9 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
free(bunnies);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
}

View File

@ -10,7 +10,7 @@ varying vec2 fragTexCoord;
varying vec4 fragColor;
varying vec3 fragNormal;
uniform mat4 mvpMatrix;
uniform mat4 mvp;
void main()
{
@ -19,5 +19,5 @@ void main()
fragColor = vertexColor;
fragNormal = vertexNormal;
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View File

@ -10,7 +10,7 @@ out vec2 fragTexCoord;
out vec4 fragColor;
out vec3 fragNormal;
uniform mat4 mvpMatrix;
uniform mat4 mvp;
void main()
{
@ -19,5 +19,5 @@ void main()
fragColor = vertexColor;
fragNormal = vertexNormal;
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View File

@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/
@ -32,6 +32,7 @@ int main()
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
bool needsReset = false;
// Initialize physics and default physics bodies
InitPhysics();
@ -52,10 +53,9 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
// Delay initialization of variables due to physics reset async
if (needsReset)
{
ResetPhysics();
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false;
@ -63,6 +63,13 @@ int main()
circle->enabled = false;
}
// Reset physics input
if (IsKeyPressed('R'))
{
ResetPhysics();
needsReset = true;
}
// Physics body creation inputs
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);

View File

@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/

View File

@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/

View File

@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/

View File

@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
* Copyright (c) 2017 Victor Fisac
* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/
@ -32,14 +32,15 @@ int main()
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
bool needsReset = false;
// Initialize physics and default physics bodies
InitPhysics();
SetPhysicsGravity(0, 0);
// Create random polygon physics body to shatter
PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -48,12 +49,17 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
// Delay initialization of variables due to physics reset asynchronous
if (needsReset)
{
// Create random polygon physics body to shatter
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
}
if (IsKeyPressed('R')) // Reset physics input
{
ResetPhysics();
// Create random polygon physics body to shatter
body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
needsReset = true;
}
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input

View File

@ -0,0 +1,22 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
uniform vec2 resolution = vec2(800, 450);
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord);
// NOTE: Implement here your fragment shader code
gl_FragColor = texelColor*colDiffuse;
}

View File

@ -0,0 +1,26 @@
#version 120
// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec3 vertexNormal;
attribute vec4 vertexColor;
// Input uniform values
uniform mat4 mvp;
// Output vertex attributes (to fragment shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View File

@ -0,0 +1,37 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
const vec2 size = vec2(800, 450); // render size
const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance
const float quality = 2.5; // lower = smaller glow, better quality
void main()
{
vec4 sum = vec4(0);
vec2 sizeFactor = vec2(1)/size*quality;
// Texel color fetching from texture sampler
vec4 source = texture2D(texture0, fragTexCoord);
const int range = 2; // should be = (samples - 1)/2;
for (int x = -range; x <= range; x++)
{
for (int y = -range; y <= range; y++)
{
sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor);
}
}
// Calculate final fragment color
gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse;
}

View File

@ -0,0 +1,32 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800.0;
const float renderHeight = 450.0;
vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308);
vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703);
void main()
{
// Texel color fetching from texture sampler
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x;
tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y;
tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z;
gl_FragColor = vec4(tc, 1.0);
}

View File

@ -0,0 +1,45 @@
# version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
float hatchOffsetY = 5.0;
float lumThreshold01 = 0.9;
float lumThreshold02 = 0.7;
float lumThreshold03 = 0.5;
float lumThreshold04 = 0.3;
void main()
{
vec3 tc = vec3(1.0, 1.0, 1.0);
float lum = length(texture2D(texture0, fragTexCoord).rgb);
if (lum < lumThreshold01)
{
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold02)
{
if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold03)
{
if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold04)
{
if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
gl_FragColor = vec4(tc, 1.0);
}

View File

@ -0,0 +1,55 @@
# version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800.0;
const float renderHeight = 450.0;
float stitchingSize = 6.0;
int invert = 0;
vec4 PostFX(sampler2D tex, vec2 uv)
{
vec4 c = vec4(0.0);
float size = stitchingSize;
vec2 cPos = uv * vec2(renderWidth, renderHeight);
vec2 tlPos = floor(cPos / vec2(size, size));
tlPos *= size;
int remX = int(mod(cPos.x, size));
int remY = int(mod(cPos.y, size));
if (remX == 0 && remY == 0) tlPos = cPos;
vec2 blPos = tlPos;
blPos.y += (size - 1.0);
if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
{
if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
}
else
{
if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
else c = vec4(0.0, 0.0, 0.0, 1.0);
}
return c;
}
void main()
{
vec3 tc = PostFX(texture0, fragTexCoord).rgb;
gl_FragColor = vec4(tc, 1.0);
}

View File

@ -0,0 +1,52 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
// Input uniform values
uniform sampler2D texture0;
// NOTE: Default parameters for Oculus Rift DK2 device
const vec2 LeftLensCenter = vec2(0.2863248, 0.5);
const vec2 RightLensCenter = vec2(0.7136753, 0.5);
const vec2 LeftScreenCenter = vec2(0.25, 0.5);
const vec2 RightScreenCenter = vec2(0.75, 0.5);
const vec2 Scale = vec2(0.25, 0.45);
const vec2 ScaleIn = vec2(4.0, 2.5);
const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0);
const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
void main()
{
// The following two variables need to be set per eye
vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
// Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
float rSq = theta.x*theta.x + theta.y*theta.y;
vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
//vec2 tc = LensCenter + Scale*theta1;
// Detect whether blue texture coordinates are out of range since these will scaled out the furthest
vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
vec2 tcBlue = LensCenter + Scale*thetaBlue;
if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
else
{
// Do blue texture lookup
float blue = texture2D(texture0, tcBlue).b;
// Do green lookup (no scaling)
vec2 tcGreen = LensCenter + Scale*theta1;
float green = texture2D(texture0, tcGreen).g;
// Do red scale and lookup
vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq);
vec2 tcRed = LensCenter + Scale*thetaRed;
float red = texture2D(texture0, tcRed).r;
gl_FragColor = vec4(red, green, blue, 1.0);
}
}

View File

@ -0,0 +1,35 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
void main()
{
vec4 color = texture2D(texture0, fragTexCoord);
color += texture2D(texture0, fragTexCoord + 0.001);
color += texture2D(texture0, fragTexCoord + 0.003);
color += texture2D(texture0, fragTexCoord + 0.005);
color += texture2D(texture0, fragTexCoord + 0.007);
color += texture2D(texture0, fragTexCoord + 0.009);
color += texture2D(texture0, fragTexCoord + 0.011);
color += texture2D(texture0, fragTexCoord - 0.001);
color += texture2D(texture0, fragTexCoord - 0.003);
color += texture2D(texture0, fragTexCoord - 0.005);
color += texture2D(texture0, fragTexCoord - 0.007);
color += texture2D(texture0, fragTexCoord - 0.009);
color += texture2D(texture0, fragTexCoord - 0.011);
color.rgb = vec3((color.r + color.g + color.b)/3.0);
color = color/9.5;
gl_FragColor = color;
}

View File

@ -0,0 +1,41 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
const float PI = 3.1415926535;
void main()
{
float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (PI / 180.0);
float maxFactor = sin(apertureHalf);
vec2 uv = vec2(0.0);
vec2 xy = 2.0 * fragTexCoord.xy - 1.0;
float d = length(xy);
if (d < (2.0 - maxFactor))
{
d = length(xy * maxFactor);
float z = sqrt(1.0 - d * d);
float r = atan(d, z) / PI;
float phi = atan(xy.y, xy.x);
uv.x = r * cos(phi) + 0.5;
uv.y = r * sin(phi) + 0.5;
}
else
{
uv = fragTexCoord.xy;
}
gl_FragColor = texture2D(texture0, uv);
}

View File

@ -0,0 +1,23 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor;
// Convert texel color to grayscale using NTSC conversion weights
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
// Calculate final fragment color
gl_FragColor = vec4(gray, gray, gray, texelColor.a);
}

View File

@ -0,0 +1,30 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values must be passed from code
const float renderWidth = 800.0;
const float renderHeight = 450.0;
float pixelWidth = 5.0;
float pixelHeight = 5.0;
void main()
{
float dx = pixelWidth*(1.0/renderWidth);
float dy = pixelHeight*(1.0/renderHeight);
vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy));
vec3 tc = texture2D(texture0, coord).rgb;
gl_FragColor = vec4(tc, 1.0);
}

View File

@ -0,0 +1,27 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
float gamma = 0.6;
float numColors = 8.0;
void main()
{
vec3 color = texture2D(texture0, fragTexCoord.xy).rgb;
color = pow(color, vec3(gamma, gamma, gamma));
color = color*numColors;
color = floor(color);
color = color/numColors;
color = pow(color, vec3(1.0/gamma));
gl_FragColor = vec4(color, 1.0);
}

View File

@ -0,0 +1,29 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
void main()
{
vec3 color = texture2D(texture0, fragTexCoord).rgb;
vec3 colors[3];
colors[0] = vec3(0.0, 0.0, 1.0);
colors[1] = vec3(1.0, 1.0, 0.0);
colors[2] = vec3(1.0, 0.0, 0.0);
float lum = (color.r + color.g + color.b)/3.0;
vec3 tc = vec3(0.0, 0.0, 0.0);
if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5);
else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5);
gl_FragColor = vec4(tc, 1.0);
}

View File

@ -0,0 +1,42 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
float offset = 0.0;
float frequency = 450.0/3.0;
uniform float time;
void main()
{
/*
// Scanlines method 1
float tval = 0; //time
vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval));
vec4 color = texture2D(texture0, fragTexCoord);
color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0);
color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y);
color *= vec4(0.8, 1.0, 0.7, 1);
color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0);
color *= 0.97 + 0.03*sin(110.0*tval);
fragColor = color;
*/
// Scanlines method 2
float globalPos = (fragTexCoord.y + offset) * frequency;
float wavePos = cos((fract(globalPos) - 0.5)*3.14);
vec4 color = texture2D(texture0, fragTexCoord);
gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos);
}

View File

@ -0,0 +1,38 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
vec2 resolution = vec2(800.0, 450.0);
void main()
{
float x = 1.0/resolution.x;
float y = 1.0/resolution.y;
vec4 horizEdge = vec4(0.0);
horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0;
horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0;
horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
vec4 vertEdge = vec4(0.0);
vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0;
vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0;
vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb));
gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a);
}

View File

@ -0,0 +1,44 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
// NOTE: Render size values should be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
float radius = 250.0;
float angle = 0.8;
uniform vec2 center;
void main()
{
vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize;
tc -= center;
float dist = length(tc);
if (dist < radius)
{
float percent = (radius - dist)/radius;
float theta = percent*percent*angle*8.0;
float s = sin(theta);
float c = cos(theta);
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
}
tc += center;
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
gl_FragColor = vec4(color.rgb, 1.0);;
}

View File

@ -30,7 +30,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
// Define the camera to look into our 3d world
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)

View File

@ -30,7 +30,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
// Define the camera to look into our 3d world
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = { 0 };
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE;
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture

View File

@ -20,10 +20,8 @@
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#define DEFAULT_VERTEX_SHADER "resources/shaders/glsl330/base.vs"
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#define DEFAULT_VERTEX_SHADER "resources/shaders/glsl100/base.vs"
#endif
#define MAX_POSTPRO_SHADERS 12
@ -72,7 +70,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
@ -85,18 +83,19 @@ int main()
// NOTE 2: We load the correct shader depending on GLSL version
Shader shaders[MAX_POSTPRO_SHADERS];
shaders[FX_GRAYSCALE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
shaders[FX_POSTERIZATION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION));
shaders[FX_DREAM_VISION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION));
shaders[FX_PIXELIZER] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION));
shaders[FX_CROSS_HATCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION));
shaders[FX_CROSS_STITCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION));
shaders[FX_PREDATOR_VIEW] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION));
shaders[FX_SCANLINES] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION));
shaders[FX_FISHEYE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION));
shaders[FX_SOBEL] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION));
shaders[FX_BLOOM] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION));
shaders[FX_BLUR] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION));
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
shaders[FX_POSTERIZATION] = LoadShader(0, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION));
shaders[FX_DREAM_VISION] = LoadShader(0, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION));
shaders[FX_PIXELIZER] = LoadShader(0, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION));
shaders[FX_CROSS_HATCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION));
shaders[FX_CROSS_STITCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION));
shaders[FX_PREDATOR_VIEW] = LoadShader(0, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION));
shaders[FX_SCANLINES] = LoadShader(0, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION));
shaders[FX_FISHEYE] = LoadShader(0, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION));
shaders[FX_SOBEL] = LoadShader(0, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION));
shaders[FX_BLOOM] = LoadShader(0, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION));
shaders[FX_BLUR] = LoadShader(0, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION));
int currentShader = FX_GRAYSCALE;
@ -177,4 +176,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
}
}

View File

@ -52,7 +52,7 @@ int main()
letterCount++;
}
if (key == KEY_BACKSPACE)
if (IsKeyPressed(KEY_BACKSPACE))
{
letterCount--;
name[letterCount] = '\0';

View File

@ -32,7 +32,7 @@ int main()
GenTextureMipmaps(&font.texture);
float fontSize = font.baseSize;
Vector2 fontPosition = { 40, screenHeight/2 + 50 };
Vector2 fontPosition = { 40, screenHeight/2 - 50 };
Vector2 textSize;
SetTextureFilter(font.texture, FILTER_POINT);

Binary file not shown.

View File

@ -24,10 +24,10 @@ int main()
Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, RED, BLUE);
Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.f, WHITE, BLACK);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK);
Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE);
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 8.f);
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
Texture2D textures[NUM_TEXTURES];

View File

@ -0,0 +1,83 @@
/*******************************************************************************************
*
* raylib [texture] example - Image text drawing using TTF generated spritefont
*
* This example has been created using raylib 1.8 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing");
// TTF SpriteFont loading with custom generation parameters
SpriteFont font = LoadSpriteFontEx("resources/KAISG.ttf", 64, 0, 0);
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// Draw over image using custom font
ImageDrawTextEx(&parrots, (Vector2){ 20, 20 }, font, "[Parrots font drawing]", font.baseSize, 0, WHITE);
Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM)
UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
Vector2 position = { screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 20 };
bool showFont = false;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_SPACE)) showFont = true;
else showFont = false;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
if (!showFont)
{
// Draw texture with text already drawn inside
DrawTextureV(texture, position, WHITE);
// Draw text directly using sprite font
DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20,
position.y + 20 + 280 }, font.baseSize, 0, WHITE);
}
else DrawTexture(font.texture, screenWidth/2 - font.texture.width/2, 50, BLACK);
DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
UnloadSpriteFont(font); // Unload custom spritefont
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..
PROJECT_NAME ?= sample_game
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@ -125,19 +145,23 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -177,57 +214,53 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains raylib icon for windows .exe
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif
# define all object files required
# Define all source files required
SAMPLES = \
arkanoid \
asteroids \
@ -246,17 +279,11 @@ all: $(SAMPLES)
%: %.c
ifeq ($(PLATFORM),PLATFORM_ANDROID)
mingw32-make -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
else
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
endif
# fix dylib install path name for each executable (MAC)
fix_dylib:
ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file
endif
# Clean everything
clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -279,3 +306,4 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done

View File

@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -83,19 +79,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: arkanoid");
#endif
InitGame();
@ -122,9 +110,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -338,4 +325,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -15,10 +15,6 @@
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -101,19 +97,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: asteroids");
#endif
InitGame();
@ -140,9 +128,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -578,4 +565,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -15,10 +15,6 @@
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -84,19 +80,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: asteroids survival");
#endif
InitGame();
@ -123,9 +111,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -388,4 +375,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -1,8 +1,8 @@
#**************************************************************************************************
#
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -23,223 +23,268 @@
.PHONY: all clean
# define raylib platform to compile for
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
# Define required raylib variables
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= drturtle
# define NO to use OpenAL Soft as static library (shared by default)
SHARED_OPENAL ?= NO
ifeq ($(PLATFORM),PLATFORM_WEB)
SHARED_OPENAL = NO
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# define raylib directory for include and library
RAYLIB_PATH ?= C:\raylib\raylib
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS:=$(shell uname)
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
# define compiler: gcc for C program, define as g++ for C++
ifeq ($(PLATFORM),PLATFORM_WEB)
# define emscripten compiler
CC = emcc
else
ifeq ($(PLATFORM_OS),OSX)
# define llvm compiler for mac
CC = clang
else
# define default gcc compiler
CC = gcc
endif
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
# define compiler flags:
# -O2 defines optimization level
# -Og enable debugging
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),OSX)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# HTML5 emscripten compiler
CC = emcc
endif
# Define default make program: Mingw32-make
MAKE = mingw32-make
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
MAKE = make
endif
endif
# Define compiler flags:
# -O1 defines optimization level
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
CFLAGS = -O2 -s -Wall -std=c99
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
endif
ifeq ($(PLATFORM_OS),OSX)
CFLAGS = -O2 -s -Wall -std=c99
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=33554432 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# --preload-file file.res # embbed file.res resource into .data file
# -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# define raylib release directory for compiled library
# Define include paths for required headers
# NOTE: Several external required libraries (stb and others)
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI requried libraries
INCLUDE_PATHS += -I/opt/vc/include
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi
endif
# define any directories containing required header files
INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# external libraries headers
# GLFW3
INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include
# OpenAL Soft
INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include
endif
ifeq ($(PLATFORM_OS),LINUX)
# you may optionally create this directory and install raylib
# and related headers there. Edit ../src/Makefile appropriately.
INCLUDES += -I/usr/local/include/raylib
endif
ifeq ($(PLATFORM_OS),OSX)
# additional directories for MacOS
endif
LDFLAGS += -L/opt/vc/lib
endif
# define library paths containing required libs
LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_RPI)
LFLAGS += -L/opt/vc/lib
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),WINDOWS)
# external libraries to link with
# GLFW3
LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH)
# OpenAL Soft
LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH)
endif
endif
# define any libraries to link into executable
# Define any libraries required on linking
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# libraries for Debian GNU/Linux desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# on XWindow requires also below libraries
LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else
ifeq ($(PLATFORM_OS),OSX)
# libraries for OSX 10.9 desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-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 -lopengl32 -lgdi32
# if static OpenAL Soft required, define the corresponding libs
ifeq ($(SHARED_OPENAL),NO)
LIBS += -lopenal32 -lwinmm
CFLAGS += -Wl,-allow-multiple-definition
else
LIBS += -lopenal32dll
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
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
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# NOTE: Set the correct path to libraylib.bc
LIBS = $(RAYLIB_RELEASE)/libraylib.bc
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif
# define all screen object files required
SCREENS = \
# Define all source files required
SCREENS = drturtle_final_web \
# typing 'make' will invoke the default target entry
default: drturtle
all: $(SCREENS)
# compile program
drturtle: drturtle_final_web.c $(SCREENS)
$(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL)
%: %.c
ifeq ($(PLATFORM),PLATFORM_ANDROID)
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
else
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
endif
# clean everything
# Clean everything
clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
del *.o *.exe /s
endif
ifeq ($(PLATFORM_OS),LINUX)
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
endif
ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete
rm -f *.o
else
ifeq ($(PLATFORM_OS),LINUX)
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
else
del *.o *.exe /s
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
@ -251,7 +296,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
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

@ -13,10 +13,6 @@
#include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -72,19 +68,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: floppy");
#endif
InitGame();
@ -111,9 +99,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
// Module Functions Definitions (local)
@ -250,4 +237,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -13,10 +13,6 @@
#include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -81,19 +77,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: gold fever");
#endif
InitGame();
@ -120,9 +108,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -291,4 +278,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -120,19 +116,11 @@ static bool UpdateBall(int playerTurn);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: gorilas");
#endif
InitGame();
@ -159,9 +147,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -576,4 +563,4 @@ static bool UpdateBall(int playerTurn)
}
return false;
}
}

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= just_do
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@ -125,19 +145,23 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
endif
# Define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains raylib icon for windows .exe
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all source files required

View File

@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16
@ -101,7 +96,7 @@ LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v
# Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
LDLIBS = -lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
# Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
@ -154,15 +149,9 @@ copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif
ifeq ($(OPENAL_LIBTYPE),STATIC)
copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
endif
# Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
@ -182,9 +171,6 @@ generate_loader_script:
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
ifeq ($(OPENAL_LIBTYPE),SHARED)
@echo System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif

View File

@ -16,10 +16,6 @@
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines currentScreen
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -53,19 +49,11 @@ void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "GGJ15 - JUST DO");
#endif
// Load global data here (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@ -104,9 +92,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//----------------------------------------------------------------------------------
@ -370,4 +357,4 @@ void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
}
}

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= koala_seasons
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@ -125,19 +145,23 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
endif
# Define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains raylib icon for windows .exe
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all source files required

View File

@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16
@ -101,7 +96,7 @@ LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v
# Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
LDLIBS = -lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
# Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
@ -154,15 +149,9 @@ copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif
ifeq ($(OPENAL_LIBTYPE),STATIC)
copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
endif
# Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
@ -182,9 +171,6 @@ generate_loader_script:
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
ifeq ($(OPENAL_LIBTYPE),SHARED)
@echo System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif

View File

@ -15,10 +15,6 @@
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines currentScreen
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -47,12 +43,7 @@ void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
int main(void) {
// Initialization
//---------------------------------------------------------
const int screenWidth = 1280;
@ -62,11 +53,8 @@ int main(void)
//ShowLogo();
//SetConfigFlags(FLAG_FULLSCREEN_MODE);
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
// Note that windowTitle is ignored on Android
InitWindow(screenWidth, screenHeight, windowTitle);
#endif
// Load global data here (assets that must be available in all screens, i.e. fonts)
font = LoadSpriteFont("resources/graphics/mainfont.png");
@ -145,9 +133,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
void TransitionToScreen(int screen)
@ -282,4 +269,4 @@ void UpdateDrawFrame(void)
EndDrawing();
//----------------------------------------------------------------------------------
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 899 KiB

After

Width:  |  Height:  |  Size: 994 KiB

View File

@ -6,7 +6,7 @@ attribute vec2 vertexTexCoord;
attribute vec4 vertexColor;
// Input uniform values
uniform mat4 mvpMatrix;
uniform mat4 mvp;
// Output vertex attributes (to fragment shader)
varying vec2 fragTexCoord;
@ -21,5 +21,5 @@ void main()
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View File

@ -858,8 +858,8 @@ void DrawTitleScreen(void)
DrawTexturePro(atlas02, gameplay_background, (Rectangle){0, 0, gameplay_background.width*2, gameplay_background.height*2}, (Vector2){0, 0}, 0, color02);
// Draw parallax
//DrawParallaxBack();
//DrawParallaxMiddle();
DrawParallaxBack();
DrawParallaxMiddle();
for (int i = 0; i < MAX_particle; i++)
{
@ -984,8 +984,6 @@ void DrawTitleScreen(void)
if (musicActive)DrawTexturePro(atlas01, title_speaker_on, (Rectangle){speakerButton.x, speakerButton.y, title_speaker_on.width, title_speaker_on.height}, (Vector2){0,0}, 0, WHITE);
else DrawTexturePro(atlas01, title_speaker_off, (Rectangle){speakerButton.x, speakerButton.y, title_speaker_off.width, title_speaker_off.height}, (Vector2){0,0}, 0, WHITE);
*/
DrawParallaxFront();
}
// Title Screen Unload logic
@ -1003,10 +1001,7 @@ int FinishTitleScreen(void)
static void DrawParallaxFront(void)
{
Rectangle ground01 = gameplay_back_ground01;
DrawTexturePro(atlas02, gameplay_back_tree01_layer01, (Rectangle){0, 0, gameplay_back_tree01_layer01.width*2, gameplay_back_tree01_layer01.height*2}, (Vector2){0,0}, 0, WHITE);
/*
//DrawTexturePro(atlas02, gameplay_back_tree01_layer03, (Rectangle){0, 21, gameplay_back_tree01_layer03.width*2, gameplay_back_tree01_layer03.height*2}, (Vector2){0,0}, 0, color02);
DrawTexturePro(atlas02, gameplay_back_tree01_layer01, (Rectangle){(int)parallaxFrontOffset, 60, gameplay_back_tree01_layer01.width*2, gameplay_back_tree01_layer01.height*2}, (Vector2){0,0}, 0, color02);
DrawTexturePro(atlas02, gameplay_back_tree02_layer01, (Rectangle){(int)parallaxFrontOffset + 140, 60, gameplay_back_tree02_layer01.width*2, gameplay_back_tree02_layer01.height*2}, (Vector2){0,0}, 0, color02);
@ -1018,7 +1013,6 @@ static void DrawParallaxFront(void)
DrawTexturePro(atlas02, gameplay_back_tree08_layer01, (Rectangle){(int)parallaxFrontOffset + 140*7, 60, gameplay_back_tree08_layer01.width*2, gameplay_back_tree08_layer01.height*2}, (Vector2){0,0}, 0, color02);
DrawTexturePro(atlas02, gameplay_back_ground01, (Rectangle){0, 559, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01);
DrawTexturePro(atlas02, (Rectangle){ground01.x, ground01.y + ground01.height, ground01.width, -ground01.height}, (Rectangle){0, -33, ground01.width*2, ground01.height*2}, (Vector2){0,0}, 0, color01);
*/
}
static void DrawParallaxMiddle(void)

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= light_my_ritual
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@ -125,19 +145,23 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
endif
# Define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains raylib icon for windows .exe
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all source files required

View File

@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16
@ -101,7 +96,7 @@ LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v
# Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
LDLIBS = -lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
# Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
@ -154,15 +149,9 @@ copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif
ifeq ($(OPENAL_LIBTYPE),STATIC)
copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
endif
# Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
@ -182,9 +171,6 @@ generate_loader_script:
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
ifeq ($(OPENAL_LIBTYPE),SHARED)
@echo System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif

View File

@ -19,10 +19,6 @@
#include <stdlib.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -55,19 +51,11 @@ void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "GGJ16 - LIGHT MY RITUAL!");
#endif
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@ -129,9 +117,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
void TransitionToScreen(int screen)

View File

@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -119,19 +115,11 @@ static void UpdateIncomingFire();
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: missile commander");
#endif
InitGame();
@ -158,9 +146,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//--------------------------------------------------------------------------------------
@ -544,4 +531,4 @@ static void UpdateIncomingFire()
missileIndex++;
if (missileIndex == MAX_MISSILES) missileIndex = 0;
}
}
}

View File

@ -15,10 +15,6 @@
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -110,19 +106,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: pang");
#endif
InitGame();
@ -149,9 +137,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -637,4 +624,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -2,7 +2,7 @@
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= skully_escape
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# NOTE: Libraries should be provided in the selected form
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS
LIBPATH=win32
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
LIBPATH=linux
else
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
LIBPATH=osx
endif
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
RPI_CROSS_COMPILE ?= NO
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21
CLANG_VERSION=e1.37.21_64bit
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/osx
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/rpi
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES)
# RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
@ -125,19 +145,23 @@ endif
# Define compiler flags:
# -O1 defines optimization level
# -Og enable debugging
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s TOTAL_MEMORY=16777216 --preload-file resources
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LDLIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# Define required flags and libs for OpenAL Soft STATIC/SHARED usage
# NOTE: ALLIBS flag only required for raylib Win32 SHARED library building
ifeq ($(OPENAL_LIBTYPE),STATIC)
LDLIBS += -lopenal32 -lwinmm
CFLAGS += -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition
else
LDLIBS += -lopenal32dll
endif
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc
endif
# Define additional parameters and flags for windows
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains raylib icon for windows .exe
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
# Define output extension to generate a .html file using provided shell
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all source files required

View File

@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll)
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16
@ -101,7 +96,7 @@ LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v
# Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
LDLIBS = -lraylib -lnative_app_glue -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
LDLIBS = -lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
# Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
@ -154,15 +149,9 @@ copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif
ifeq ($(OPENAL_LIBTYPE),STATIC)
copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a
endif
# Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
@ -182,9 +171,6 @@ generate_loader_script:
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
ifeq ($(OPENAL_LIBTYPE),SHARED)
@echo System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif

View File

@ -14,10 +14,6 @@
#include "player.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -52,19 +48,11 @@ void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "SKULLY ESCAPE [KING GAMEJAM]");
#endif
// Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice();
@ -112,9 +100,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
void TransitionToScreen(int screen)

View File

@ -13,10 +13,6 @@
#include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -73,19 +69,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: snake");
#endif
InitGame();
@ -112,9 +100,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -298,4 +285,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -13,10 +13,6 @@
#include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -90,19 +86,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: space invaders");
#endif
InitGame();
@ -129,9 +117,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//------------------------------------------------------------------------------------
@ -410,4 +397,4 @@ void UpdateDrawFrame(void)
{
UpdateGame();
DrawGame();
}
}

View File

@ -18,10 +18,6 @@
#include <time.h>
#include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@ -109,19 +105,11 @@ static void DeleteCompleteLines();
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: tetris");
#endif
InitGame();
@ -148,9 +136,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
//--------------------------------------------------------------------------------------
@ -841,4 +828,4 @@ static void DeleteCompleteLines()
}
}
}
}
}

319
games/transmission/Makefile Normal file
View File

@ -0,0 +1,319 @@
#**************************************************************************************************
#
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
#
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
#
# 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.
#
#**************************************************************************************************
.PHONY: all clean
# Define required raylib variables
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= transmission
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
endif
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
# Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS 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)
PLATFORM_OS=WINDOWS
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX
endif
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
endif
ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif
# Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),OSX)
# OSX default compiler
CC = clang
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# Define RPI cross-compiler
#CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# HTML5 emscripten compiler
CC = emcc
endif
# Define default make program: Mingw32-make
MAKE = mingw32-make
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
MAKE = make
endif
endif
# Define compiler flags:
# -O1 defines optimization level
# -g enable debugging
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
# Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
# --preload-file resources # specify a resources folder for data compilation
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources -s TOTAL_MEMORY=67108864
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
EXT = .html
endif
# Define include paths for required headers
# NOTE: Several external required libraries (stb and others)
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI requried libraries
INCLUDE_PATHS += -I/opt/vc/include
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
endif
# Define library paths containing required libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include
LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib
endif
# Define any libraries required on linking
# if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On X11 requires also below libraries
LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
endif
ifeq ($(PLATFORM_OS),FREEBSD)
# Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# NOTE: It could require additional packages installed: libglfw3-dev
LDLIBS += -lglfw
endif
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif
# Define all source files required
PROJECT_SOURCE_FILES ?= transmission.c \
screens/screen_logo.c \
screens/screen_title.c \
screens/screen_mission.c \
screens/screen_gameplay.c \
screens/screen_ending.c
# Define all object files from source files
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
# For Android platform we call a custom Makefile.Android
ifeq ($(PLATFORM),PLATFORM_ANDROID)
MAKEFILE_PARAMS = -f Makefile.Android
export PROJECT_NAME
export PROJECT_SOURCE_FILES
else
MAKEFILE_PARAMS = $(PROJECT_NAME)
endif
# Default target entry
# NOTE: We call this Makefile target or Makefile.Android target
all:
$(MAKE) $(MAKEFILE_PARAMS)
# Project target defined by PROJECT_NAME
$(PROJECT_NAME): $(OBJS)
$(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile source files
# NOTE: This pattern will compile every module defined on $(OBJS)
%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
# Clean everything
clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
del *.o *.exe /s
endif
ifeq ($(PLATFORM_OS),LINUX)
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
endif
ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete
rm -f *.o
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

View File

@ -0,0 +1,275 @@
#**************************************************************************************************
#
# raylib makefile for Android project (APK building)
#
# Copyright (c) 2017 Ramon Santamaria (@raysan5)
#
# This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software.
#
# 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 required raylib variables
PLATFORM ?= PLATFORM_ANDROID
RAYLIB_PATH ?= ..\..
# Required path variables
# NOTE: JAVA_HOME must be set to JDK
ANDROID_HOME = C:/android-sdk
ANDROID_NDK = C:/android-ndk
ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.2
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_144
# Android project configuration variables
PROJECT_NAME ?= raylib_game
PROJECT_LIBRARY_NAME ?= main
PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
PROJECT_RESOURCES_PATH ?= resources
PROJECT_SOURCE_FILES ?= raylib_game.c
# Some source files are placed in directories, when compiling to some
# output directory other than source, that directory must pre-exist.
# Here we get a list of required folders that need to be created on
# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES)))
# Android app configuration variables
APP_LABEL_NAME ?= rGame
APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a
# Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif
# Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16
CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
# Compiler flags for arquitecture
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
# Compilation functions attributes options
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
# Compiler options for the linker
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
# Preprocessor macro definitions
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16
# Paths containing required header files
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src/external/android/native_app_glue
# Linker options
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
# Force linking of library module to define symbol
LDFLAGS += -u ANativeActivity_onCreate
# Library paths containing required libs
LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/armeabi-v7a
# Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname
LDLIBS = -lraylib -lnative_app_glue -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm -ldl
# Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
# Android APK building process... some steps required...
# NOTE: typing 'make' will invoke the default target entry called 'all',
all: create_temp_project_dirs \
copy_project_required_libs \
copy_project_resources \
generate_loader_script \
generate_android_manifest \
generate_apk_keystore \
config_project_package \
compile_native_app_glue \
compile_project_code \
compile_project_class \
compile_project_class_dex \
create_project_apk_package \
sign_project_apk_package \
zipalign_project_apk_package
# Create required temp directories for APK building
create_temp_project_dirs:
if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME)
if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib
if not exist $(PROJECT_BUILD_PATH)\lib\armeabi-v7a mkdir $(PROJECT_BUILD_PATH)\lib\armeabi-v7a
if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin
if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res
if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi
if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi
if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi
if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values
if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH)
if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens
$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
define create_dir
if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
endef
# Copy required shared libs for integration into APK
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif
# Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
# TODO: Review xcopy usage, it can not be found in some systems!
copy_project_resources:
copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y
copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y
copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F
# Generate NativeLoader.java to load required shared libraries
# NOTE: Probably not the bet way to generate this file... but it works.
generate_loader_script:
@echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif
@echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
# Generate AndroidManifest.xml with all the required options
# NOTE: Probably not the bet way to generate this file... but it works.
generate_android_manifest:
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<manifest xmlns:android="http://schemas.android.com/apk/res/android" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<uses-sdk android:minSdkVersion="16" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<uses-feature android:glEsVersion="0x00020000" android:required="true" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<application android:allowBackup="false" android:label="@string/app_name" android:icon="@drawable/icon" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<activity android:name="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<meta-data android:name="android.app.lib_name" android:value="$(PROJECT_LIBRARY_NAME)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<action android:name="android.intent.action.MAIN" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^<category android:name="android.intent.category.LAUNCHER" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^</intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
@echo ^</manifest^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
# Generate storekey for APK signing: $(PROJECT_NAME).keystore
# NOTE: Configure here your Distinguished Names (-dname) if required!
generate_apk_keystore:
if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
config_project_package:
$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-16/android.jar
# Compile native_app_glue code as static library: obj/libnative_app_glue.a
compile_native_app_glue:
$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
compile_project_code: $(OBJS)
$(CC) -o $(PROJECT_BUILD_PATH)/lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
# Compile all .c files required into object (.o) files
# NOTE: Those files will be linked into a shared library
$(PROJECT_BUILD_PATH)/obj/%.o:%.c
$(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
# Compile project .java code into .class (Java bytecode)
compile_project_class:
$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-16/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
# Compile .class files into Dalvik executable bytecode (.dex)
# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
compile_project_class_dex:
$(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj
# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk
# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so
# NOTE: Use -A resources to define additional directory in which to find raw asset files
create_project_apk_package:
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-16/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk
sign_project_apk_package:
$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
# Create zip-aligned APK package: $(PROJECT_NAME).apk
zipalign_project_apk_package:
$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
# Install $(PROJECT_NAME).apk to default emulator/device
# NOTE: Use -e (emulator) or -d (device) parameters if required
install:
$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
# Monitorize output log coming from device, only raylib tag
logcat:
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
deploy:
$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W
# Clean everything
clean:
del $(PROJECT_BUILD_PATH)\* /f /s /q
rmdir $(PROJECT_BUILD_PATH) /s /q
@echo Cleaning done

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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