@ -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 | |||
# | |||
c">#deploy: | |||
c"># provider: releases | |||
c"># api_key: | |||
c"># secure: XXX | |||
c"># file_glob: true | |||
c"># file: raylib-*.tar.gz | |||
c"># skip_cleanup: true | |||
c"># on: | |||
c"># branch: master | |||
c"># tags: true | |||
- cmake -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE .. | |||
- make VERBOSE=1 | |||
w"> - make package | |||
deploy: | |||
w"> provider: releases | |||
w"> api_key: | |||
w"> 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= | |||
w"> file_glob: true | |||
w"> file: raylib-*.tar.gz | |||
w"> skip_cleanup: true | |||
w"> on: | |||
w"> repo: raysan5/raylib | |||
w"> branch: master | |||
w"> tags: true |
@ -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! |
@ -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! |
@ -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 |
@ -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; | |||
} |
@ -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; | |||
} |
@ -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); | |||
} |
@ -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; | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} | |||
} |
@ -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; | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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); | |||
} |
@ -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);; | |||
} |
@ -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; | |||
} |
@ -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 | |||
@ -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 |