140 Commits

Author SHA1 Message Date
Ray San
cc3b8645df Updated release version 2018-04-10 10:37:48 +02:00
Ray
8e44f7b3c7 Reviewed config.h formatting
Added raylib version to config
2018-04-09 23:01:20 +02:00
Ray
54e24d905a Init frame timming measure variables 2018-04-09 22:28:41 +02:00
Ray
cd616258c6 Merge pull request #522 from a3f/master
Refactor all #define SUPPORT_* into a config.h
2018-04-08 22:46:44 +02:00
Ray
9e7dedf5af Merge pull request #521 from TheLumaio/master
Added GetCollisionRayModel
2018-04-08 22:28:19 +02:00
Ahmad Fatoum
1dbce35247 CMake: Generate config.h from CMakeOptions.txt
I would have liked config.h to be selected by include dir configuration,
but this way is less intrusive.
2018-04-07 23:39:53 +02:00
Ahmad Fatoum
1841afad11 Refactor all #define SUPPORT_* into a config.h
That way, a user needs only to touch a single file to configure what
features raylib is built with.
Include guards are left out intentionally, because config.h should only
be included in source files, not headers.

Later on, config.h can also define the raylib version (#461).
2018-04-07 23:37:48 +02:00
Ahmad Fatoum
d88523f03a Split CMake options into separate CMakeOptions.txt 2018-04-07 22:41:43 +02:00
Milan Nikolic
3caa044bf2 Add GNUInstallDirs and USE_AUDIO/USE_WAYLAND options to CMake (#518) 2018-04-07 16:32:14 +02:00
lumaio teon
7bd0f8b28c Fix mesh picking example 2018-04-07 04:00:06 -04:00
lumaio teon
d2cc5b88df Removed useless GetCollisionRayMesh and libraylib.a 2018-04-07 03:49:56 -04:00
lumaio teon
d003c23ecf Added GetCollisionRayModel 2018-04-06 12:04:09 -04:00
Ray
b8bd1d2ea6 Remove unnecesary NPOT check
Now PLATFORM checks only used on core and utils modules
2018-04-05 19:22:45 +02:00
Ray
005f2ffb75 Simplified some code 2018-04-05 19:18:44 +02:00
Ray
931b672c92 Added: ImageDrawRectangle()
Renamed SaveImageAs() to ExportImage() for consistency on what actually happens with data.
2018-04-04 12:02:20 +02:00
Ray
6edf15b9f9 Added funtion: ExportMesh() 2018-04-04 12:00:54 +02:00
Ray
322cebcbaf Updated to latest raylib changes
Removed OpenAL and GLFW3 dependencies on building.
Reviewed platforms and flags
2018-04-03 22:44:45 +02:00
Ray
9393d1d76f Merge branch 'master' of https://github.com/raysan5/raylib 2018-04-03 12:43:42 +02:00
Ray San
fe1c04d1b8 Removed old code 2018-04-03 12:42:28 +02:00
Ray
533780aadf Review ImageDraw() alpha blending
Not sure if math is ok... just left a commented piece of code that uses pre-multiplied alpha.
2018-04-03 12:42:22 +02:00
Ray
0c0ff2802e Review games Makefile 2018-04-02 18:46:22 +02:00
Ray
3e0de31424 Merge pull request #504 from Martinfx/master
Fix potential bugs from static analysis
2018-04-02 18:10:38 +02:00
Ray
befd363966 Update README.md 2018-04-02 15:38:33 +02:00
raysan5
375adf86a6 Review math usage to reduce temp variables 2018-04-02 15:16:45 +02:00
raysan5
6985953e3d Update release to latest raylib version
Note that only some lib versions have been updated
2018-04-02 14:50:16 +02:00
raysan5
e18e8c6276 Review UWP configuration 2018-04-02 14:49:27 +02:00
raysan5
bbdf9f4880 Review InitWindow() to avoid void pointer
Reviewed for PLATFORM_ANDROID and PLATFORM_UWP
2018-04-02 14:49:01 +02:00
maficccc@gmail.com
201007e426 Fix sscanf() without field limits can crash with huge input data 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
db98dba10f Fix Allocator sizeof operand mismatch 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
03ca9508bf Fix Dead initialization 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
44eedf235d Redundant assignment of 'angle' to itself 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
551cf50685 Fix Uninitialized argument value 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
6a3eca3f92 Fix value stored to 'body' is never read 2018-04-02 13:30:20 +02:00
maficccc@gmail.com
ca9e652f8b Remove dead assignment 2018-04-02 13:30:19 +02:00
Martinfx
28a9a181cb Fix use after free 2018-04-02 13:30:19 +02:00
maficccc@gmail.com
9459186125 Fix call argument is an uninitialized value 2018-04-02 13:30:19 +02:00
maficccc@gmail.com
df74607479 Fix warning: illegal character encoding in string literal 2018-04-02 13:30:19 +02:00
maficccc@gmail.com
e659336c11 Fix value stored to 'num_channels' is never read 2018-04-02 13:30:19 +02:00
Ray
e72b96ada1 Merge pull request #508 from a3f/master
Allow use of main instead of android_main
2018-04-02 10:48:02 +02:00
raysan5
bd2c81d481 Review links 2018-04-01 23:33:37 +02:00
Ray
564baa22d6 Merge pull request #513 from autious/master
Add orthographic 3d rendering mode
2018-04-01 00:27:20 +02:00
Jacques Heunis
b4e2f5b45c Initialize the timer after the graphics device on desktop and web platforms. (#516)
This is already the order that is used for Android. It doesn't appear to
make a difference on desktop but on web using the timer before it's been
initialized (by glfwInit, inside InitGraphicsDevice) causes the a long
(and variable but often several seconds) sleep between the first and
second frame.

Fixes: 468309d ("Early-exit InitWindow if InitGraphicsDevice fails")
2018-03-31 12:22:44 +02:00
Max Danielsson
42e64e931b Simplify camera data switch in orthographic 3d example 2018-03-27 21:16:25 +02:00
Max Danielsson
6c049fdd76 Move deduplicate aspect variable in begin render.
Changes motivated by commentary in pull request 513
2018-03-27 19:59:54 +02:00
Max Danielsson
e38d28543a Remove state bool in camera projection type example.
Changes made based on commentary in pull request 513
2018-03-27 19:58:42 +02:00
Max Danielsson
d91179f8ab Add orthographic projection example 2018-03-25 18:49:15 +02:00
Max Danielsson
5ecee69088 Add 3d orthographic projection mode 2018-03-25 18:33:19 +02:00
Ray
22c8ea76aa Merge pull request #510 from mackron/patch-2
Fix an infinite loop in ALSA backend of mini_al.
2018-03-20 09:53:08 +01:00
David Reid
a8e2c7de9c Fix an infinite loop in ALSA backend of mini_al. 2018-03-20 18:39:21 +10:00
Ray
deffad1701 Review tabs issue when compiling...
...PLATFORM_ANDROID on Windows, using MinGW-w64 (x86) provided Make (GCC
7.2)
2018-03-19 23:49:14 +01:00
Ray
aab6c11ce1 Merge pull request #509 from mackron/patch-1
Fix a buffer overflow in the OSS/BSD backend of mini_al.
2018-03-18 13:15:32 +01:00
David Reid
4a69c2d75e Fix a buffer overflow in the OSS/BSD backend. 2018-03-18 14:37:41 +10:00
Ahmad Fatoum
2c219fb814 Allow use of main instead of android_main
Inspired by #504.
Instead of requiring the user to do PLATFORM_ANDROID #ifdefery,
have the android_main entry point exported by raylib and call
the user-defined main. This way many games could (in theory)
run unmodified on Android and elsewhere.

This is untested!
2018-03-16 21:37:22 +01:00
Ray
61e0e4b4f3 Complete review of raymath for API consistency 2018-03-16 13:47:01 +01:00
Ray San
9318dc98ce Support case-insensitive extension check 2018-03-16 13:09:49 +01:00
Ray
487bc613fd Updated raylib dev version 2018-03-15 12:37:52 +01:00
Ray
9d8f15c19d Reviewed raymath changes 2018-03-15 12:37:23 +01:00
Ray
6c6d6776c0 Merge pull request #482 from a3f/master
raymath.h: Use C99 inline semantics
2018-03-15 12:27:40 +01:00
Ray
4cae2b8829 Merge pull request #505 from Martinfx/max-add-memory-sanitizer
Add memory sanitizer for better debug
2018-03-14 16:11:29 +01:00
maficccc@gmail.com
4c0925067a Add message warning for msan 2018-03-14 15:23:14 +01:00
maficccc@gmail.com
82491fcf6c Add memory sanitizer for better debug 2018-03-14 00:13:23 +01:00
raysan5
b9573e583f Merge branch 'master' of https://github.com/raysan5/raylib 2018-03-11 11:02:03 +01:00
raysan5
d6c1159fce Corrected typo 2018-03-11 11:01:58 +01:00
Ray
8bc2813b0c Merge pull request #500 from victorfisac/fork/master
[fork/master] Fixed some memory leaks and add null checks for consistency
2018-03-11 10:51:15 +01:00
raysan5
a0127d8300 Corrected typo 2018-03-11 10:49:51 +01:00
raysan5
fd5e457bb4 Correct issue with triangleCount 2018-03-11 10:41:49 +01:00
victorfisac
5b4197afeb Updated copyright years 2018-03-10 21:14:11 +01:00
victorfisac
d6fee9da29 Fixed compilation code comment in header 2018-03-10 19:30:25 +01:00
victorfisac
3201bad65a Fixed memory leaks in physics step operations 2018-03-10 19:25:17 +01:00
victorfisac
8f1d6f3850 Merge branch 'master' of github.com:raysan5/raylib into fork/master 2018-03-10 19:10:37 +01:00
Ray San
df50eada53 Added new functions
- SetWindowSize() to scale Windows in runtime
- SetMouseScale() to scale mouse input, useful when rendering game to a
RenderTexture2D that will be scaled to Window size (used on rFXGen tool)
2018-03-09 11:43:53 +01:00
Ray
276847eca9 Correct issue with tangents 2018-03-04 23:24:30 +01:00
maficccc@gmail.com
8cb324b2da Fix result of operation is garbage or undefined 2018-03-04 16:26:49 +01:00
raysan5
85850a955a Removed additional code
GLFW has been updated to latest version, probably this code is not
required any more due to already been integrated into library... but it
needs to be tested...
2018-03-03 16:01:24 +01:00
raysan5
3b4a64f2d6 Updated GLFW library to latest version 2018-03-03 15:58:44 +01:00
Ray
fd2adbe62d Renamed CalculateBoundingBox() to MeshBoundingBox()
Renamed function for consistency with a possible Mesh manipulation functions (maybe added in a future). Naming follows Image*() manipulation functions.
2018-02-26 12:10:45 +01:00
Ray
a7207dc6d4 Removed tangents generation
It has no sense to be inside LoadOBJ(), mesh processing moved to own functions: MeshTangents() and MeshBinormals(). Not exposed to user yet.
2018-02-26 12:02:05 +01:00
Ahmad Fatoum
3f48ffb1b6 Fix two memory leaks in jar_xm.h
Found by LeakSanitizer in #494.
2018-02-26 00:14:19 +01:00
RDR8
18f61948ce Update Makefile
$ make clean
Makefile:296: *** missing separator.  Stop.
2018-02-25 22:27:32 +01:00
Ahmad Fatoum
80bf636f81 Don't exceed signed int range when shifting left
Fixes UB in #489, found by UBSan.
2018-02-25 03:17:57 +01:00
Ahmad Fatoum
76aca9b0d1 Fix possible buffer overflow in LoadBMFont
Width specifier doesn't include NUL terminator.
Fixes #487 found by AddressSanitizer.
2018-02-25 03:03:37 +01:00
Ray
c5f7863689 Merge pull request #492 from a3f/raylib-master
jar_xm: Workaround for unaligned pointer accesses
2018-02-25 00:04:50 +01:00
Ahmad Fatoum
1430d01906 jar_xm: Workaround for unaligned pointer accesses
jar_xm.h does some shady pointer casts leading to unaligned accesses
and breaking strict aliasing. x86 has special circuitry for doing
unaligned accesses, but on other architectures, it may trap and require
kernel fix-up or crash outright. With this patch, one obstacle in
porting raylib to the GameBoy Advance has been removed. Go for it ;-)

To avoid having to rewrite that `mempool' code, insert padding before
structs and instruct the compiler (GCC, most importantly), to be gentle
when optimizing.

This fixes #490 (Unless we got ourselves 256-bit pointers, if so,
hello future!)
2018-02-24 23:59:56 +01:00
Ray
6026ed61a5 Merge pull request #480 from RDR8/master-patch-makefiles
Update Makefiles. Automate example usage of staged libraylib.so.
2018-02-24 23:57:46 +01:00
Ahmad Fatoum
f52d2de582 raymath.h: Use C99 inline semantics
RAYMATH_EXTERN_INLINE was renamed to RAYMATH_HEADER_ONLY, which user code
may define if they want to use it as header-only library. If multiple
files in the same project define RAYMATH_HEADER_ONLY, they might each
have duplicate out-of-line definitions of the same functions.

By default, raymath.h exposes inline definitions, which instructs the
compiler _not_ to generate out-of-line definitons, if out-of-line
definitions are required, those of the file defined with
RAYLIB_IMPLEMENTATION are used instead. There may be only one such file.

In C++ mode, the compiler will select only one out-of-line definition
automatically, so no need to define a RAYLIB_IMPLEMENTATION.

Unfortunately, we have to remove raymath function declaration from
raylib.h as those declarations would lead to duplicate out-of-line
definitions which would yield linker errors. This problem didn't
exist with GNU89 or C++, because there multiple defintions are ok,
but in C99 they aren't.
2018-02-24 23:39:23 +01:00
Ahmad Fatoum
ed6962edd3 Make MatrixToFloat and Vector3ToFloat reentrant
Besides making it thread-safe, it suppresses a GCC warning
when making them static inline in an upcoming patch.
2018-02-24 23:39:17 +01:00
RDR8
2b5fc12036 Update Makefiles. Enable example usage of staged libraylib.so. 2018-02-24 14:24:55 -06:00
Ahmad Fatoum
a5881fb9cc Revert "raymath.h: Use C99 inline semantics"
This reverts commit 6ffc8cb799.
and commit e4d7bbec1e.
which I pushed by mistake...
2018-02-24 15:40:08 +01:00
Ahmad Fatoum
c9043b5a87 CMake: Add options to use -fsanitize={address,undefined}
To make bugs like #485, #486, #487 and #488 easier to find in future.
2018-02-24 15:37:38 +01:00
Ahmad Fatoum
6ffc8cb799 raymath.h: Use C99 inline semantics
RAYMATH_EXTERN_INLINE was renamed to RAYMATH_HEADER_ONLY, which user code
may define if they want to use it as header-only library. If multiple
files in the same project define RAYMATH_HEADER_ONLY, they might each
have duplicate out-of-line definitions of the same functions.

By default, raymath.h exposes inline definitions, which instructs the
compiler _not_ to generate out-of-line definitons, if out-of-line
definitions are required, those of the file defined with
RAYLIB_IMPLEMENTATION are used instead. There may be only one such file.

In C++ mode, the compiler will select only one out-of-line definition
automatically, so no need to define a RAYLIB_IMPLEMENTATION.

Unfortunately, we have to remove raymath function declaration from
raylib.h as those declarations would lead to duplicate out-of-line
definitions which would yield linker errors. This problem didn't
exist with GNU89 or C++, because there multiple defintions are ok,
but in C99 they aren't.
2018-02-24 15:37:37 +01:00
Ahmad Fatoum
e4d7bbec1e Make MatrixToFloat and Vector3ToFloat reentrant
Besides making it thread-safe, it suppresses a GCC warning
when making them static inline in an upcoming patch.
2018-02-24 15:37:37 +01:00
Ray
077bef4286 Support 4 components mesh.tangent data
Added struct Vector4 for convenience
2018-02-24 12:31:32 +01:00
Ray
6d64327a87 Reviewed unloading model data
When UnloadModel() --> UnloadMaterial(), avoid unloading default shader (if used) and avoid unlaoding default texture (if used), that data is managed by raylib internally. The question is... should UnloadModel() also UnloadMaterial()?
2018-02-22 12:39:17 +01:00
Ray
cd5e2e0f17 Corrected cursor issue for Wayland 2018-02-22 00:01:13 +01:00
Ray
326fe09777 Reviewed compilation for OpenGL 1.1 2018-02-21 23:47:48 +01:00
Ray
97bf2706c4 Removed flag -fgnu89-inline 2018-02-21 23:28:34 +01:00
Ray
788049df09 Update README.md 2018-02-20 11:04:02 +01:00
Ray
81546308cd Update README.md 2018-02-20 10:48:34 +01:00
Ray
11612fce27 Reviewed timming system for macOS
Apparently, before macOS Sierra version, clock_gettime was not available, using MATCH timming system instead
2018-02-20 10:30:51 +01:00
Ahmad Fatoum
1652943f98 Docs: Replace references to raylib develop branch
Found by grepping for '(blob|tree)/develop'.  See #443 for more information.
2018-02-19 13:58:25 +01:00
Ahmad Fatoum
d892243d18 CI: Build artifacts for master, not develop tags
See #443 for more information.
2018-02-19 13:56:55 +01:00
Ray
f6231aa8b6 Merge pull request #474 from raysan5/develop
Integrate develop branch (LAST INTEGRATION)
2018-02-19 12:08:35 +01:00
Ray
7e32a627e8 Corrected path backslash 2018-02-19 00:03:24 +01:00
raysan5
0958904eac Added comments to review function ImageTextEx() 2018-02-18 19:29:13 +01:00
raysan5
4492a70a4b Support UTF8 basic characters on ImageTextEx()
Supported UTF8 range equivalent to [128..255] (80h..FFh)
Exposed and renamed text function GetGlyphIndex()
Renamed spriteFont parameter name to simply font
Small security check on transmission mission ending screen
2018-02-18 18:07:57 +01:00
raysan5
50fc4f7164 Reviewed transmission mission game
Support string replacing to generate newspaper headline
ISSUE: UTF8 characters not supported when drawing to Image
2018-02-17 21:23:45 +01:00
Ray
769cf23e53 Merge pull request #470 from jubalh/develop
Add Builder project files
2018-02-16 12:12:59 +01:00
Michael Vetter
883ed20e7c Add note about glfw3 and openAL 2018-02-16 11:53:04 +01:00
Michael Vetter
e0a3a51b75 Builder project: Add note about examples 2018-02-16 11:25:12 +01:00
Michael Vetter
6ebc3fd29a Add core_basic_window project example for Builder 2018-02-16 11:23:02 +01:00
Michael Vetter
988f5b7832 Add Builder project template 2018-02-16 11:20:21 +01:00
Ahmad Fatoum
051040af2d CMake: Remove _RAYLIB suffix from -D{SHARED,STATIC}_RAYLIB
They were named so for compatibility with make, but make doesn't use
the anymore. I always forget whether it's SHARED_RAYLIB or
RAYLIB_SHARED...

For now, RAYLIB_SHARED and STATIC_RAYLIB may still be used,
but print a deprecation warning.
2018-02-16 05:58:18 +01:00
Ray
ffde83d85f Merge pull request #467 from raysan5/develop
Integrate develop branch
2018-02-14 22:44:09 +01:00
Ray
36750ffb9a BREAKING CHANGE: Renamed function for consistency
Rename: GetHexValue() renamed to ColorToInt()
Added: ColorToHSV()
2018-02-12 11:55:22 +01:00
Ray
7530a60abc Update README.md 2018-02-12 11:53:47 +01:00
Ray
dd8f0765b8 Merge pull request #465 from raysan5/develop
Integrate develop branch into master
2018-02-12 11:27:26 +01:00
Ray
8af5f9dfe0 Avoid rendering SPACE character! 2018-02-12 11:25:00 +01:00
Ray
51124bfb74 Merge pull request #464 from RDR8/develop-make-install-linux
Linux make install improvements
2018-02-12 11:23:31 +01:00
RDR8
97f8b85429 Update Makefile 2018-02-12 09:19:24 +00:00
RDR8
f742f1289d Update Makefile 2018-02-12 05:17:02 +00:00
RDR8
0be4d802ee Update Makefile 2018-02-12 01:25:08 +00:00
RDR8
5616314069 Update Makefile 2018-02-12 00:15:58 +00:00
RDR8
4c4b564392 Update Makefiles for Linux installation. See prior commit.
These changes are intended to provide context and control over the Linux make install process. make install RAYLIB_LIBTYPE=SHARED now works as expected. libraylib.so is properly installed with attendant runtime links. The examples will be running against the newly installed libraylib.so unless otherwise specified with RAYLIB_RUNTIME_PATH. See raylib/src/Makefile and raylib/examples/Makefile for usage of RAYLIB_INSTALL_PATH, RAYLIB_H_INSTALL_PATH, and RAYLIB_RUNTIME_PATH variables. RAYLIB_RUNTIME_PATH in particular is interesting for portability since sudo isn't needed.
The default configuration and workflow is essentially unchanged and unaffected.
2018-02-11 23:42:22 +00:00
RDR8
e86b4d4e03 Update Makefiles for Linux installation. 2018-02-11 22:58:15 +00:00
Ahmad Fatoum
1be72a2e72 pkg-config: Empty Requires.private on shared-only build
If user doesn't build the static library,
`pkg-config --static --libs raylib` should be equivalent to
`pkg-config --libs raylib`.
2018-02-11 20:10:50 +01:00
Ahmad Fatoum
09b022305f mini_al: Support {Net,Open}BSD OSS
Fixes this build failure:
http://www.cpantesters.org/cpan/report/a069fade-0e1f-11e8-a1cf-bb670eaac09d
2018-02-11 12:20:17 +01:00
Ray
d90a33b850 Some reviews for Android compilation 2018-02-11 01:48:53 +01:00
Ray
231a69417a Corrected masteVolume setting 2018-02-11 01:28:30 +01:00
Ray
7bf6becc94 Reviewed mini_al implementation
- Some functions renamed
- Comments reviewed
- Functions reorganized
2018-02-11 01:12:16 +01:00
Ray
6d922b3e1f Renamed iconography 2018-02-10 23:29:40 +01:00
Ahmad Fatoum
468309d06c Early-exit InitWindow if InitGraphicsDevice fails
Otherwise we may run into LoadDefaultFont and crash in rlLoadTexture
Also moves InitTimer() before InitGraphicsDevice(), to allow it to be
tested even if InitWindow ultimately fails.
2018-02-09 22:54:35 +01:00
Ray
f72b315cb6 Updated external libraries 2018-02-09 00:01:00 +01:00
Ray
2ace360230 Merge pull request #462 from a3f/develop
InitWindow: return false if no monitor found
2018-02-08 12:24:51 +01:00
Ahmad Fatoum
a976e76ae6 InitWindow: return false if no monitor found
Otherwise we run into an assertion failure inside GLFW's glfwGetVideoMode.
Example:
http://www.cpantesters.org/cpan/report/b4ba5894-0bdb-11e8-841e-2c60b04e1d2d

This is related to #456.
2018-02-08 12:06:21 +01:00
Ray
4d5d1e0434 Added function LoadShaderCode()
Allows loading of shader from text code string directly
2018-02-05 01:03:13 +01:00
victorfisac
dd50348b4d Merge branch 'master' of https://github.com/raysan5/raylib 2017-09-02 08:25:38 +02:00
victorfisac
353912b215 Merge branch 'master' of https://github.com/raysan5/raylib 2017-08-27 12:48:51 +02:00
victorfisac
eb7b5e59bb Merge branch 'master' of https://github.com/raysan5/raylib 2017-07-15 16:05:00 +02:00
victorfisac
f9277f2163 Merge remote-tracking branch 'refs/remotes/raysan5/master' 2017-03-06 09:47:08 +01:00
victorfisac
ce56fcb1ed Merge remote-tracking branch 'refs/remotes/raysan5/master' 2016-02-26 14:32:30 +01:00
161 changed files with 11952 additions and 4416 deletions

View File

@@ -45,7 +45,7 @@ before_install:
script: script:
- mkdir build - mkdir build
- cd build - cd build
- cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE .. - cmake -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE ..
- make VERBOSE=1 - make VERBOSE=1
- make package - make package
@@ -58,5 +58,5 @@ deploy:
skip_cleanup: true skip_cleanup: true
on: on:
repo: raysan5/raylib repo: raysan5/raylib
branch: develop branch: master
tags: true tags: true

View File

@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
# Config options # Config options
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.") option(BUILD_EXAMPLES "Build the examples." ON)
set(BUILD_GAMES ON CACHE BOOL "Build the example games.") 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_VERSION VERSION_LESS "3.1")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU") if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
@@ -11,17 +14,41 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
else() else()
set (CMAKE_C_STANDARD 99) set (CMAKE_C_STANDARD 99)
endif() endif()
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
foreach(option -Werror=pointer-arith;-Werror=implicit-function-declaration) function(add_if_flag_works flag)
CHECK_C_COMPILER_FLAG("${option}" COMPILER_HAS_THOSE_TOGGLES) CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES)
set(outcome "Failed") set(outcome "Failed")
if(COMPILER_HAS_THOSE_TOGGLES) if(COMPILER_HAS_THOSE_TOGGLES)
set(CMAKE_C_FLAGS "${option} ${CMAKE_C_FLAGS}") foreach(var ${ARGN})
set(${var} "${flag} ${${var}}" PARENT_SCOPE)
endforeach()
set(outcome "works") set(outcome "works")
endif() endif()
message(STATUS "Testing if ${option} can be used -- ${outcome}") message(STATUS "Testing if ${flag} can be used -- ${outcome}")
endforeach() 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) add_subdirectory(src release)
@@ -32,4 +59,3 @@ endif()
if (${BUILD_GAMES}) if (${BUILD_GAMES})
add_subdirectory(games) add_subdirectory(games)
endif() endif()

View File

@@ -34,18 +34,6 @@ Source code is extensively commented for that purpose, raylib primary learning m
> learn by reading code and examples > learn by reading code and examples
### Using raylib develop branch
raylib [master branch](https://github.com/raysan5/raylib) contains the latest raylib release but all
the future work is always done on [develop branch](https://github.com/raysan5/raylib/tree/develop),
it's far ahead of master and I try to keep it always stable with latest library changes.
Please, if issuing a bug or sending a pull-request, verify that you're using develop branch.
Note that while using develop branch predefined Notepad++ building scripts could not work, in that case,
use provided [Makefile](https://github.com/raysan5/raylib/blob/develop/src/Makefile) or [CMake](https://github.com/raysan5/raylib/blob/develop/src/CMakeLists.txt) building systems.
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki). For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
### Opening new Issues ### Opening new Issues
@@ -62,8 +50,6 @@ To open new issue for raylib (bug, enhancement, discussion...), just try to foll
### Sending a Pull-Request ### Sending a Pull-Request
To send a pull-request, first of all, make sure you're sending it to [develop branch](https://github.com/raysan5/raylib/tree/develop). Here are some other rules:
- Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. - 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. - 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 - 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

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. 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. 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). 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/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). 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. 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. 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, 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. 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. 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). 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. 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. 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. 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`). 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, 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). 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 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. 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. 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. 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. 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. 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. 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. 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! [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: 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). 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 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) * Alpha Beta - Brian Kent (AEnigma)
* Setback - 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 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 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.** **raylib is a simple and easy-to-use library to learn videogames programming.**
@@ -13,6 +13,7 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
[![Build Status](https://travis-ci.org/raysan5/raylib.svg?branch=develop)](https://travis-ci.org/raysan5/raylib) [![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) [![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) [![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) [![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) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Follow)](https://twitter.com/raysan5)
@@ -34,11 +35,11 @@ features
* NO external dependencies, all required libraries included with raylib * 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)) * 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 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.
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, maintained, ...).
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, 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.
to accomodate to Android, Raspberry Pi and HTML5.
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 Android, `native_app_glue module` (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
@@ -47,11 +48,9 @@ to accomodate to Android, Raspberry Pi and HTML5.
build and installation build and installation
---------------------- ----------------------
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 following package managers: 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).
* Homebrew: `brew install raylib` To build raylib yourself, check out also the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
To build raylib yourself, check out the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
raylib has been developed using exclusively two tools: raylib has been developed using exclusively two tools:

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. 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. 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** **raylib 1.x**
- [ ] Basic GPU stats sytem (memory, draws, time...) - [ ] Basic GPU stats sytem (memory, draws, time...)

View File

@@ -39,7 +39,7 @@ before_build:
- cd build - cd build
build_script: build_script:
- cmake -G %GENERATOR% -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% .. - cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
- cmake --build . --target install - cmake --build . --target install
after_build: after_build:
@@ -61,5 +61,5 @@ deploy:
prerelease: false prerelease: false
force_update: true force_update: true
on: on:
branch: develop branch: master
appveyor_repo_tag: true # deploy on tag push only appveyor_repo_tag: true # deploy on tag push only

View File

@@ -24,29 +24,46 @@
.PHONY: all clean .PHONY: all clean
# Define required raylib variables # Define required raylib variables
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() PROJECT_NAME ?= raylib_examples
PLATFORM ?= PLATFORM_DESKTOP RAYLIB_VERSION ?= 1.9.7
RAYLIB_PATH ?= .. RAYLIB_API_VERSION ?= 1
PROJECT_NAME ?= raylib_example RAYLIB_PATH ?= ..
# Default path for raylib on Raspberry Pi, if installed in different path, update it! # Define default options
ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib # One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
endif PLATFORM ?= PLATFORM_DESKTOP
# 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) # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_LIBTYPE ?= STATIC
# Build mode for project: DEBUG or RELEASE
RAYLIB_BUILD_MODE ?= RELEASE
# Use external GLFW library instead of rglfw module # Use external GLFW library instead of rglfw module
USE_EXTERNAL_GLFW ?= FALSE # 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 # Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system # by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE USE_WAYLAND_DISPLAY ?= FALSE
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile) # NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
@@ -73,6 +90,22 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
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) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
@@ -84,9 +117,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs # Define raylib release directory for compiled library.
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version.
# Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
@@ -108,6 +140,20 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
endif 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 # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++ # NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
@@ -130,6 +176,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) 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 # HTML5 emscripten compiler
CC = emcc CC = emcc
endif endif
@@ -150,10 +197,9 @@ endif
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
@@ -164,7 +210,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
CFLAGS += -g
#CC = clang
endif
ifeq ($(RAYLIB_LIBTYPE),STATIC)
CFLAGS += -no-pie -D_DEFAULT_SOURCE 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
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
@@ -185,26 +241,44 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html EXT = .html
endif 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) # 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 INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
# Define additional directories containing required header files # Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI requried libraries # RPI required libraries
INCLUDE_PATHS += -I/opt/vc/include INCLUDE_PATHS += -I/opt/vc/include
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
endif 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 # Define library paths containing required libs.
# Precedence: immediately local, then raysan5 provided libs
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),FREEBSD) ifeq ($(PLATFORM_OS),FREEBSD)
INCLUDE_PATHS += -I/usr/local/include # Consider -L$(RAYLIB_INSTALL_PATH)
LDFLAGS += -L. -Lsrc -L/usr/local/lib LDFLAGS += -L. -Lsrc -L/usr/local/lib
endif 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 endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
@@ -217,7 +291,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation # Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32 LDLIBS = -lraylib -lopengl32 -lgdi32
# Required for physac examples # Required for physac examples
LDLIBS += -static -lpthread LDLIBS += -static -lpthread
endif endif
@@ -225,16 +298,18 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
# On X11 requires also below libraries # On X11 requires also below libraries
LDLIBS += -lX11 LDLIBS += -lX11
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# On Wayland windowing system, additional libraries requires # On Wayland windowing system, additional libraries requires
ifeq ($(USE_WAYLAND_DISPLAY),TRUE) ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif endif
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# Libraries for OSX 10.9 desktop compiling # Libraries for OSX 10.9 desktop compiling
@@ -245,7 +320,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# Libraries for FreeBSD desktop compiling # Libraries for FreeBSD desktop compiling
# NOTE: Required packages: mesa-libs # NOTE: Required packages: mesa-libs
LDLIBS = -lraylib -lGL -lpthread -lm LDLIBS = -lraylib -lGL -lpthread -lm
# On XWindow requires also below libraries # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
@@ -360,7 +434,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
del *.o *.exe /s del *.o *.exe /s
endif endif
ifeq ($(PLATFORM_OS),LINUX) 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 endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete find . -type f -perm +ugo+x -delete
@@ -369,10 +443,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
find . -type f -executable -delete find . -type f -executable -delete
rm -f *.o rm -fv *.o
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js del *.o *.html *.js
endif endif
@echo Cleaning done @echo Cleaning done

View File

@@ -30,7 +30,7 @@ int main()
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.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; bool collision = false;
@@ -79,7 +79,6 @@ int main()
} }
DrawRay(ray, MAROON); DrawRay(ray, MAROON);
DrawGrid(10, 1.0f); DrawGrid(10, 1.0f);
End3dMode(); End3dMode();

View File

@@ -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_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.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_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_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
//mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler"); //mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap"); mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");

View File

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

View File

@@ -0,0 +1,112 @@
/*******************************************************************************************
*
* 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.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#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
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
//
// Input
//----------------------------------------------------------------------------------
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();
DrawFPS(10, 10);
DrawText("Press Spacebar to switch camera type", 10, 40, 24, BLACK);
if(camera.type == CAMERA_ORTHOGRAPHIC)
{
DrawText("Orthographic", 10, 65, 24, BLACK);
}
else if(camera.type == CAMERA_PERSPECTIVE)
{
DrawText("Perspective", 10, 65, 24, BLACK);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@@ -62,7 +62,7 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawModel(skybox, Vector3Zero(), 1.0f, WHITE); DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE);
DrawGrid(10, 1.0f); DrawGrid(10, 1.0f);

View File

@@ -193,6 +193,6 @@ void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[
DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color); DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color);
DrawText(FormatText("%5.1f<EFBFBD>", angle), x - MeasureText(FormatText("%5.1f<EFBFBD>", angle), textSize) / 2, y + 10, 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); DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY);
} }

View File

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

View File

@@ -76,7 +76,7 @@ int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
unsigned char key; static unsigned char key;
InitAudioDevice(); InitAudioDevice();

View File

@@ -10,7 +10,6 @@
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free() #include <stdlib.h> // Required for: malloc(), free()
#define MAX_BUNNIES 100000 // 100K bunnies #define MAX_BUNNIES 100000 // 100K bunnies
@@ -33,6 +32,7 @@ int main()
Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png"); Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png");
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
int bunniesCount = 0; // Bunnies counter int bunniesCount = 0; // Bunnies counter
SetTargetFPS(60); SetTargetFPS(60);
@@ -72,7 +72,7 @@ int main()
ClearBackground(RAYWHITE); 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 // 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, // batching buffer starts being filled again; before launching the draw call,
@@ -84,7 +84,6 @@ int main()
DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY); DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY);
DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY); DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY);
DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED); DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED);
DrawFPS(260, 10); DrawFPS(260, 10);
EndDrawing(); EndDrawing();

View File

@@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * 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 * -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 // Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10; int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15; int logoY = 15;
bool needsReset = false;
// Initialize physics and default physics bodies // Initialize physics and default physics bodies
InitPhysics(); InitPhysics();
@@ -52,10 +53,9 @@ int main()
{ {
// Update // 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 = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false; floor->enabled = false;
@@ -63,6 +63,13 @@ int main()
circle->enabled = false; circle->enabled = false;
} }
// Reset physics input
if (IsKeyPressed('R'))
{
ResetPhysics();
needsReset = true;
}
// Physics body creation inputs // Physics body creation inputs
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10); 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); 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 * 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 * -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 * 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 * -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 * 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 * -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 * 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 * -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,13 +32,14 @@ int main()
// Physac logo drawing position // Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10; int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15; int logoY = 15;
bool needsReset = false;
// Initialize physics and default physics bodies // Initialize physics and default physics bodies
InitPhysics(); InitPhysics();
SetPhysicsGravity(0, 0); SetPhysicsGravity(0, 0);
// Create random polygon physics body to shatter // 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); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@@ -48,12 +49,17 @@ int main()
{ {
// Update // 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 if (IsKeyPressed('R')) // Reset physics input
{ {
ResetPhysics(); ResetPhysics();
needsReset = true;
// Create random polygon physics body to shatter
body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
} }
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= .. RAYLIB_PATH ?= ..
PROJECT_NAME ?= sample_game PROJECT_NAME ?= sample_game
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,57 +214,53 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE)/libraylib.bc LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif endif
# Define additional parameters and flags for windows # Define all source files required
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
SAMPLES = \ SAMPLES = \
arkanoid \ arkanoid \
asteroids \ asteroids \
@@ -246,17 +279,11 @@ all: $(SAMPLES)
%: %.c %: %.c
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
mingw32-make -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
else else
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
endif 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 everything
clean: clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -279,3 +306,4 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js del *.o *.html *.js
endif endif
@echo Cleaning done @echo Cleaning done

View File

@@ -18,10 +18,6 @@
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -83,19 +79,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: arkanoid");
#endif
InitGame(); InitGame();
@@ -122,9 +110,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

@@ -15,10 +15,6 @@
#include <math.h> #include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -101,19 +97,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: asteroids");
#endif
InitGame(); InitGame();
@@ -140,9 +128,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

@@ -15,10 +15,6 @@
#include <math.h> #include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -84,19 +80,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: asteroids survival");
#endif
InitGame(); InitGame();
@@ -123,9 +111,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -23,223 +23,268 @@
.PHONY: all clean .PHONY: all clean
# define raylib platform to compile for # Define required raylib variables
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= drturtle
# define NO to use OpenAL Soft as static library (shared by default) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
SHARED_OPENAL ?= NO ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_PATH ?= /home/pi/raylib
ifeq ($(PLATFORM),PLATFORM_WEB)
SHARED_OPENAL = NO
endif endif
# define raylib directory for include and library # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_PATH ?= C:\raylib\raylib 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) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS:=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
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) ifeq ($(PLATFORM),PLATFORM_WEB)
# define emscripten compiler # Emscripten required variables
CC = emcc EMSDK_PATH = C:/emsdk
else EMSCRIPTEN_VERSION = 1.37.28
ifeq ($(PLATFORM_OS),OSX) CLANG_VERSION=e1.37.28_64bit
# define llvm compiler for mac PYTHON_VERSION=2.7.5.3_64bit
CC = clang NODE_VERSION=4.1.1_64bit
else 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)
# define default gcc compiler EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
CC = gcc
endif
endif endif
# define compiler flags: RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# -O2 defines optimization level
# -Og enable debugging # 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 # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) 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 endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif
ifeq ($(PLATFORM_OS),OSX)
CFLAGS = -O2 -s -Wall -std=c99
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_WEB) 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
# -O2 # if used, also set --memory-init-file 0 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support
# --preload-file file.res # embbed file.res resource into .data file # -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
endif # --preload-file resources # specify a resources folder for data compilation
ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
endif # Define a custom shell .html and output extension
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes 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
# define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),FREEBSD)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 INCLUDE_PATHS += -I/usr/local/include
endif LDFLAGS += -L. -Lsrc -L/usr/local/lib
ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux
endif
ifeq ($(PLATFORM_OS),OSX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx
endif endif
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) ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads LDFLAGS += -L/opt/vc/lib
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
endif endif
# define library paths containing required libs # Define any libraries required on linking
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
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# requires the following packages: # NOTE: Required packages: libegl1-mesa-dev
# libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
# on XWindow requires also below libraries # On X11 requires also below libraries
LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11
else # NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
ifeq ($(PLATFORM_OS),OSX) #LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
# libraries for OSX 10.9 desktop compiling
# requires the following packages: # On Wayland windowing system, additional libraries requires
# libglfw3-dev libopenal-dev libegl1-mesa-dev ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
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
endif endif
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
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: OpenAL Soft library should be installed (libopenal1 package) # NOTE: Required packages: libasound2-dev (ALSA)
LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# NOTE: Set the correct path to libraylib.bc # Libraries for web (HTML5) compiling
LIBS = $(RAYLIB_RELEASE)/libraylib.bc LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
endif endif
# define additional parameters and flags for windows # Define all source files required
ifeq ($(PLATFORM_OS),WINDOWS) SCREENS = drturtle_final_web \
# 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 = \
# typing 'make' will invoke the default target entry # typing 'make' will invoke the default target entry
default: drturtle all: $(SCREENS)
# compile program %: %.c
drturtle: drturtle_final_web.c $(SCREENS) ifeq ($(PLATFORM),PLATFORM_ANDROID)
$(CC) -o $@$(EXT) $^ $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(WEB_SHELL) $(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: clean:
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),OSX)
find . -type f -perm +ugo+x -delete find . -type f -perm +ugo+x -delete
rm -f *.o 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
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
@@ -251,7 +296,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
endif endif
@echo Cleaning done @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" #include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -72,19 +68,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) int main(void)
#endif
{ {
// Initialization // Initialization
//--------------------------------------------------------- //---------------------------------------------------------
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, "sample game: floppy"); InitWindow(screenWidth, screenHeight, "sample game: floppy");
#endif
InitGame(); InitGame();
@@ -111,9 +99,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Definitions (local) // Module Functions Definitions (local)

View File

@@ -13,10 +13,6 @@
#include "raylib.h" #include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -81,19 +77,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: gold fever");
#endif
InitGame(); InitGame();
@@ -120,9 +108,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

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

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= just_do PROJECT_NAME ?= just_do
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # 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
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif endif
# Define all source files required # Define all source files required

View File

@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # 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 # Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname # 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 # Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

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

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= koala_seasons PROJECT_NAME ?= koala_seasons
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -s USE_PTHREADS=1 # multithreading support
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling -s ALLOW_MEMORY_GROWTH=1 --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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # 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
LDLIBS += $(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
endif endif
# Define all source files required # Define all source files required
@@ -253,7 +286,7 @@ all:
# Project target defined by PROJECT_NAME # Project target defined by PROJECT_NAME
$(PROJECT_NAME): $(OBJS) $(PROJECT_NAME): $(OBJS)
$(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(WEB_SHELL) $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile source files # Compile source files
# NOTE: This pattern will compile every module defined on $(OBJS) # NOTE: This pattern will compile every module defined on $(OBJS)

View File

@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # 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 # Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname # 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 # Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

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

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= light_my_ritual PROJECT_NAME ?= light_my_ritual
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # 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
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif endif
# Define all source files required # Define all source files required

View File

@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # 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 # Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname # 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 # Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

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

View File

@@ -18,10 +18,6 @@
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -119,19 +115,11 @@ static void UpdateIncomingFire();
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: missile commander");
#endif
InitGame(); InitGame();
@@ -158,9 +146,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@@ -15,10 +15,6 @@
#include <math.h> #include <math.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -110,19 +106,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: pang");
#endif
InitGame(); InitGame();
@@ -149,9 +137,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= skully_escape PROJECT_NAME ?= skully_escape
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # 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
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif endif
# Define all source files required # Define all source files required

View File

@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # 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 # Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname # 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 # Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

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

View File

@@ -13,10 +13,6 @@
#include "raylib.h" #include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -73,19 +69,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: snake");
#endif
InitGame(); InitGame();
@@ -112,9 +100,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

@@ -13,10 +13,6 @@
#include "raylib.h" #include "raylib.h"
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -90,19 +86,11 @@ static void UpdateDrawFrame(void); // Update and Draw (one frame)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) 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"); InitWindow(screenWidth, screenHeight, "sample game: space invaders");
#endif
InitGame(); InitGame();
@@ -129,9 +117,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------

View File

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

View File

@@ -26,7 +26,7 @@
# Define required raylib variables # Define required raylib variables
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH = C:\GitHub\raylib RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= transmission PROJECT_NAME ?= transmission
# Default path for raylib on Raspberry Pi, if installed in different path, update it! # Default path for raylib on Raspberry Pi, if installed in different path, update it!
@@ -150,10 +150,9 @@ endif
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
@@ -161,8 +160,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# resources file contains windows exe icon # resources file contains windows exe icon
# -Wl,--subsystem,windows hides the console window # -Wl,--subsystem,windows hides the console window
CFLAGS += -Wl,--subsystem,windows CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
WINRES = $(RAYLIB_PATH)/src/resources
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
@@ -218,9 +216,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation # Libraries for Windows desktop compilation
LDLIBS = -lraylib -lopengl32 -lgdi32 LDLIBS = -lraylib -lopengl32 -lgdi32
# Required for physac examples
#LDLIBS += -static -lpthread
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
@@ -292,7 +287,7 @@ all:
# Project target defined by PROJECT_NAME # Project target defined by PROJECT_NAME
$(PROJECT_NAME): $(OBJS) $(PROJECT_NAME): $(OBJS)
$(CC) -o $(PROJECT_NAME)$(EXT) $(WINRES) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) $(CC) -o $(PROJECT_NAME)$(EXT) $(OBJS) $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
# Compile source files # Compile source files
# NOTE: This pattern will compile every module defined on $(OBJS) # NOTE: This pattern will compile every module defined on $(OBJS)

View File

@@ -23,7 +23,7 @@
# Define required raylib variables # Define required raylib variables
PLATFORM ?= PLATFORM_ANDROID PLATFORM ?= PLATFORM_ANDROID
RAYLIB_PATH = C:\GitHub\raylib RAYLIB_PATH ?= ..\..
# Required path variables # Required path variables
# NOTE: JAVA_HOME must be set to JDK # NOTE: JAVA_HOME must be set to JDK
@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # NOTE: GCC is being deprectated in Android NDK r16
@@ -154,15 +149,9 @@ copy_project_required_libs:
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

@@ -1,4 +1,4 @@
# Total missions # Total missions
# NOTE: Missions follow the order of this file # NOTE: Missions follow the order of this file
t 4 t 4
# ----------------------------------------------------------------- # -----------------------------------------------------------------
@@ -10,7 +10,7 @@ k oviparo
# #
# Message to be coded # Message to be coded
# NOTE: Sensible words must be noted using @ # NOTE: Sensible words must be noted using @
m El @presidente es visto en un @hotel acompañado de su @amante . m El @presidente es visto en un @hotel acompañado de su @amante.
# #
# Solution to mission # Solution to mission
# NOTE: Provide the correct solution nums, according to above words # NOTE: Provide the correct solution nums, according to above words
@@ -26,7 +26,7 @@ k roedor
# #
# Message to be coded # Message to be coded
# NOTE: Sensible words must be noted using @ # NOTE: Sensible words must be noted using @
m Un @ovni ha sido detectado en el @cielo del @pais . Preparaos para el ataque de un @alien . m Un @ovni ha sido detectado en el @cielo del @pais . Preparaos para el ataque de un @alien.
# #
# NOTE: Provide the correct solution nums, according to above words # NOTE: Provide the correct solution nums, according to above words
# WARNING: Always provide 8 values, use -1 for not used ones # WARNING: Always provide 8 values, use -1 for not used ones

View File

@@ -29,7 +29,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#define MAX_TITLE_CHAR 128 #define MAX_TITLE_CHAR 256
#define MAX_SUBTITLE_CHAR 256 #define MAX_SUBTITLE_CHAR 256
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@@ -66,7 +66,12 @@ static int state = 0;
static Mission *missions = NULL; static Mission *missions = NULL;
static bool showResults = false; static char headline[MAX_TITLE_CHAR] = "\0";
SpriteFont fontNews;
// String (const char *) replacement function
static char *StringReplace(char *orig, char *rep, char *with);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Ending Screen Functions Definition // Ending Screen Functions Definition
@@ -84,60 +89,43 @@ void InitEndingScreen(void)
texBackground = LoadTexture("resources/textures/ending_background.png"); texBackground = LoadTexture("resources/textures/ending_background.png");
texVignette = LoadTexture("resources/textures/message_vignette.png"); texVignette = LoadTexture("resources/textures/message_vignette.png");
fxNews = LoadSound("resources/audio/fx_batman.ogg"); fxNews = LoadSound("resources/audio/fx_batman.ogg");
// TODO: Check game results!
missions = LoadMissions("resources/missions.txt"); missions = LoadMissions("resources/missions.txt");
int wordsCount = missions[currentMission].wordsCount; int wordsCount = missions[currentMission].wordsCount;
TraceLog(LOG_WARNING, "Words count %i", wordsCount);
char title[MAX_TITLE_CHAR] = "\0"; strcpy(headline, missions[currentMission].msg); // Base headline
//char subtitle[MAX_SUBTITLE_CHAR] = "\0"; int len = strlen(headline);
char *ptrTitle = title; // Remove @ from headline
int len = 0; // TODO: Also remove additional spaces
for (int i = 0; i < len; i++)
{
if (headline[i] == '@') headline[i] = ' ';
}
for (int i = 0; i < wordsCount; i++) for (int i = 0; i < wordsCount; i++)
{ {
if (messageWords[i].id == missions[currentMission].sols[i]) if (messageWords[i].id != missions[currentMission].sols[i])
{ {
len = strlen(messageWords[i].text); // WARNING: It fails if the last sentence word has a '.' after space
strncpy(ptrTitle, messageWords[i].text, len); char *title = StringReplace(headline, messageWords[i].text, codingWords[messageWords[i].id]);
ptrTitle += len;
// title[len] = ' '; strcpy(headline, title); // Base headline updated
// len++;
// ptrTitle++;
}
else
{
TraceLog(LOG_WARNING, "Coding word: %s", codingWords[messageWords[i].id]);
len = strlen(codingWords[messageWords[i].id]);
TraceLog(LOG_WARNING, "Lenght: %i", len);
strncpy(ptrTitle, codingWords[messageWords[i].id], len);
ptrTitle += len;
// title[len] = ' '; if (title != NULL) free(title);
// len++;
// ptrTitle++;
} }
} }
ptrTitle = '\0'; TraceLog(LOG_WARNING, "Titular: %s", headline);
//TraceLog(LOG_WARNING, "Titular: %s", title);
// Generate newspaper with title and subtitle // Generate newspaper with title and subtitle
Image imNewspaper = LoadImage("resources/textures/ending_newspaper.png"); Image imNewspaper = LoadImage("resources/textures/ending_newspaper.png");
SpriteFont fontNews = LoadSpriteFontEx("resources/fonts/Lora-Bold.ttf", 82, 250, 0); fontNews = LoadSpriteFontEx("resources/fonts/Lora-Bold.ttf", 32, 250, 0);
ImageDrawTextEx(&imNewspaper, (Vector2){ 50, 220 }, fontNews, "FRACASO EN LA GGJ18!", fontNews.baseSize, 0, DARKGRAY); ImageDrawTextEx(&imNewspaper, (Vector2){ 50, 220 }, fontNews, headline, fontNews.baseSize, 0, DARKGRAY);
// TODO: Draw subtitle message
//ImageDrawTextEx(&imNewspaper, (Vector2){ 50, 210 }, fontNews, "SUBE LA ESCALERA!", fontNews.baseSize, 0, DARKGRAY);
texNewspaper = LoadTextureFromImage(imNewspaper); texNewspaper = LoadTextureFromImage(imNewspaper);
UnloadSpriteFont(fontNews); //UnloadSpriteFont(fontNews);
UnloadImage(imNewspaper); UnloadImage(imNewspaper);
} }
@@ -167,8 +155,6 @@ void UpdateEndingScreen(void)
if (currentMission >= totalMissions) finishScreen = 2; if (currentMission >= totalMissions) finishScreen = 2;
else finishScreen = 1; else finishScreen = 1;
} }
if (IsKeyPressed(KEY_SPACE)) showResults = !showResults;
} }
// Ending Screen Draw logic // Ending Screen Draw logic
@@ -182,13 +168,12 @@ void DrawEndingScreen(void)
DrawTextureEx(texVignette, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE); DrawTextureEx(texVignette, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE);
if (showResults) // Draw debug information
DrawTextEx(fontNews, headline, (Vector2){ 10, 10 }, fontNews.baseSize, 0, RAYWHITE);
for (int i = 0; i < missions[currentMission].wordsCount; i++)
{ {
for (int i = 0; i < missions[currentMission].wordsCount; i++) DrawText(codingWords[messageWords[i].id], 10, 60 + 30*i, 20, (messageWords[i].id == missions[currentMission].sols[i]) ? GREEN : RED);
{
if (messageWords[i].id == missions[currentMission].sols[i]) DrawText(messageWords[i].text, 10, 10 + 30*i, 20, GREEN);
else DrawText(codingWords[messageWords[i].id], 10, 10 + 30*i, 20, RED);
}
} }
if (state == 1) DrawButton("continuar"); if (state == 1) DrawButton("continuar");
@@ -210,3 +195,54 @@ int FinishEndingScreen(void)
{ {
return finishScreen; return finishScreen;
} }
// String (const char *) replacement function
// NOTE: Internally allocated memory must be freed by the user (if return != NULL)
// https://stackoverflow.com/questions/779875/what-is-the-function-to-replace-string-in-c
static char *StringReplace(char *orig, char *rep, char *with)
{
char *result; // the return string
char *ins; // the next insert point
char *tmp; // varies
int len_rep; // length of rep (the string to remove)
int len_with; // length of with (the string to replace rep with)
int len_front; // distance between rep and end of last rep
int count; // number of replacements
// Sanity checks and initialization
if (!orig || !rep) return NULL;
len_rep = strlen(rep);
if (len_rep == 0) return NULL; // Empty rep causes infinite loop during count
if (!with) with = ""; // Replace with nothing if not provided
len_with = strlen(with);
// Count the number of replacements needed
ins = orig;
for (count = 0; tmp = strstr(ins, rep); ++count)
{
ins = tmp + len_rep;
}
tmp = result = malloc(strlen(orig) + (len_with - len_rep)*count + 1);
if (!result) return NULL; // Memory could not be allocated
// First time through the loop, all the variable are set correctly from here on,
// tmp points to the end of the result string
// ins points to the next occurrence of rep in orig
// orig points to the remainder of orig after "end of rep"
while (count--)
{
ins = strstr(orig, rep);
len_front = ins - orig;
tmp = strncpy(tmp, orig, len_front) + len_front;
tmp = strcpy(tmp, with) + len_with;
orig += len_front + len_rep; // move to next "end of rep"
}
strcpy(tmp, orig);
return result;
}

View File

@@ -71,7 +71,7 @@ void InitTitleScreen(void)
texBackground = LoadTexture("resources/textures/title_background.png"); texBackground = LoadTexture("resources/textures/title_background.png");
fxTyping = LoadSound("resources/audio/fx_typing.ogg"); fxTyping = LoadSound("resources/audio/fx_typing.ogg");
fontTitle = LoadSpriteFontEx("resources/fonts/fontTitle.ttf", 96, 0, 0); fontTitle = LoadSpriteFontEx("resources/fonts/mom_typewritter.ttf", 96, 0, 0);
titleSize = 44; titleSize = 44;
transmissionPosition = (Vector2){519, 221}; transmissionPosition = (Vector2){519, 221};

View File

@@ -17,10 +17,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -55,20 +51,15 @@ static void UpdateDrawFrame(void); // Update and Draw one frame
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Main entry point // Main entry point
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void) int main(void)
#endif
{ {
// Initialization // Initialization
//--------------------------------------------------------- //---------------------------------------------------------
#if defined(PLATFORM_ANDROID) #ifndef PLATFORM_ANDROID
InitWindow(screenWidth, screenHeight, app);
#else
SetConfigFlags(FLAG_SHOW_LOGO); // | FLAG_FULLSCREEN_MODE); SetConfigFlags(FLAG_SHOW_LOGO); // | FLAG_FULLSCREEN_MODE);
InitWindow(screenWidth, screenHeight, "raylib game - transmission mission");
#endif #endif
// Note windowTitle is unused on Android
InitWindow(screenWidth, screenHeight, "raylib game - transmission mission");
// Global data loading (assets that must be available in all screens, i.e. fonts) // Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice(); InitAudioDevice();
@@ -138,9 +129,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@@ -2,7 +2,7 @@
# #
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # 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 # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@@ -29,72 +29,87 @@ PLATFORM ?= PLATFORM_DESKTOP
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
PROJECT_NAME ?= wave_collector PROJECT_NAME ?= wave_collector
# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) # Default path for raylib on Raspberry Pi, if installed in different path, update it!
# NOTE: Libraries should be provided in the selected form ifeq ($(PLATFORM),PLATFORM_RPI)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_PATH ?= /home/pi/raylib
OPENAL_LIBTYPE ?= STATIC
# On PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
OPENAL_LIBTYPE = SHARED
endif 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 # Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(OS),Windows_NT)
PLATFORM_OS=WINDOWS PLATFORM_OS=WINDOWS
LIBPATH=win32
else else
UNAMEOS=$(shell uname) UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux) ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX PLATFORM_OS=LINUX
LIBPATH=linux endif
else ifeq ($(UNAMEOS),FreeBSD)
PLATFORM_OS=FREEBSD
endif
ifeq ($(UNAMEOS),Darwin) ifeq ($(UNAMEOS),Darwin)
PLATFORM_OS=OSX PLATFORM_OS=OSX
LIBPATH=osx
endif
endif endif
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler UNAMEOS=$(shell uname)
RPI_CROSS_COMPILE ?= NO ifeq ($(UNAMEOS),Linux)
PLATFORM_OS=LINUX
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.21 EMSCRIPTEN_VERSION = 1.37.28
CLANG_VERSION=e1.37.21_64bit CLANG_VERSION=e1.37.28_64bit
PYTHON_VERSION=2.7.5.3_64bit PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_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) 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) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/win32/mingw32 RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/linux RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux
endif endif
ifeq ($(PLATFORM_OS),OSX) 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
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
RAYLIB_RELEASE = $(RAYLIB_PATH)/release/libs/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI) 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 endif
# Define default C compiler: gcc # Define default C compiler: gcc
# NOTE: define g++ compiler if using C++
CC = gcc CC = gcc
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -102,11 +117,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# OSX default compiler # OSX default compiler
CC = clang CC = clang
endif endif
ifeq ($(PLATFORM_OS),FREEBSD)
# FreeBSD default compiler
CC = clang
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(RPI_CROSS_COMPILE),YES) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
# RPI cross-compiler # Define RPI cross-compiler
CC = armv6j-hardfloat-linux-gnueabi-gcc #CC = armv6j-hardfloat-linux-gnueabi-gcc
CC = $(RPI_TOOLCHAIN)/bin/arm-linux-gnueabihf-gcc
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
@@ -125,19 +145,23 @@ endif
# Define compiler flags: # Define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging # -g enable debugging
# -s strip unnecessary data from build # -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -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) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
ifeq ($(PLATFORM),PLATFORM_DESKTOP) 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) ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -no-pie -D_DEFAULT_SOURCE CFLAGS += -no-pie -D_DEFAULT_SOURCE
endif endif
@@ -151,7 +175,13 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -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 endif
# Define include paths for required headers # Define include paths for required headers
@@ -167,7 +197,14 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
# Define library paths containing required libs # 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) ifeq ($(PLATFORM),PLATFORM_RPI)
LDFLAGS += -L/opt/vc/lib LDFLAGS += -L/opt/vc/lib
@@ -177,54 +214,50 @@ endif
# if you want to link libraries (libname.so or libname.a), use the -lname # if you want to link libraries (libname.so or libname.a), use the -lname
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compiling # Libraries for Windows desktop compilation
# NOTE: GLFW3 and OpenAL Soft libraries should be installed LDLIBS = -lraylib -lopengl32 -lgdi32
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
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling # Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl 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 # On XWindow requires also below libraries
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Libraries for OSX 10.9 desktop compiling # NOTE: It could require additional packages installed: libglfw3-dev
# NOTE: Required packages: libglfw3-dev libopenal-dev libegl1-mesa-dev LDLIBS += -lglfw
LDLIBS = -lraylib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# Libraries for Raspberry Pi compiling # Libraries for Raspberry Pi compiling
# NOTE: Required packages: libopenal1 # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Libraries for web (HTML5) compiling # 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
WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
endif endif
# Define all source files required # Define all source files required

View File

@@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib
APP_PRODUCT_NAME ?= rgame APP_PRODUCT_NAME ?= rgame
APP_VERSION_CODE ?= 1 APP_VERSION_CODE ?= 1
APP_VERSION_NAME ?= 1.0 APP_VERSION_NAME ?= 1.0
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
APP_SCREEN_ORIENTATION ?= landscape APP_SCREEN_ORIENTATION ?= landscape
APP_KEYSTORE_PASS ?= raylib 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 RAYLIB_LIBTYPE ?= STATIC
OPENAL_LIBTYPE ?= STATIC
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a 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 # Shared libs must be added to APK if required
# NOTE: Generated NativeLoader.java automatically load those libraries # NOTE: Generated NativeLoader.java automatically load those libraries
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so
endif endif
ifeq ($(OPENAL_LIBTYPE),SHARED)
PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so
endif
# Compiler and archiver # Compiler and archiver
# NOTE: GCC is being deprectated in Android NDK r16 # 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 # Define any libraries to link into executable
# if you want to link libraries (libname.so or libname.a), use the -lname # 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 # Generate target objects list from PROJECT_SOURCE_FILES
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so
endif 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) ifeq ($(RAYLIB_LIBTYPE),STATIC)
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a
endif 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 # Copy project required resources: strings.xml, icon.png, assets
# NOTE: Required strings.xml is generated and game resources are copied to assets folder # 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. >> $(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 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 @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) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
endif endif

View File

@@ -22,10 +22,6 @@
#include <stdio.h> // Required for: printf() #include <stdio.h> // Required for: printf()
#include <string.h> // Required for: strcpy() #include <string.h> // Required for: strcpy()
#if defined(PLATFORM_ANDROID)
#include "android_native_app_glue.h"
#endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#endif #endif
@@ -60,11 +56,7 @@ static void UpdateDrawFrame(void); // Update and Draw one frame
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Main entry point // Main entry point
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(int argc, char *argv[]) int main(int argc, char *argv[])
#endif
{ {
// Initialization // Initialization
//--------------------------------------------------------- //---------------------------------------------------------
@@ -89,12 +81,11 @@ int main(int argc, char *argv[])
} }
#endif #endif
#if defined(PLATFORM_ANDROID) #ifndef PLATFORM_ANDROID
InitWindow(screenWidth, screenHeight, app);
#else
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "GGJ17 - WAVE COLLECTOR");
#endif #endif
// Note windowTitle is unused on Android
InitWindow(screenWidth, screenHeight, "GGJ17 - WAVE COLLECTOR");
// Global data loading (assets that must be available in all screens, i.e. fonts) // Global data loading (assets that must be available in all screens, i.e. fonts)
InitAudioDevice(); InitAudioDevice();
@@ -143,9 +134,8 @@ int main(int argc, char *argv[])
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0; return 0;
#endif
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

View File

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 383 B

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 552 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 922 B

After

Width:  |  Height:  |  Size: 922 B

BIN
logo/raylib_512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
logo/raylib_96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

26
project/Builder/README.md Normal file
View File

@@ -0,0 +1,26 @@
# Builder project template
This is a project template to be used with [GNOME Builder](https://raw.githubusercontent.com/jubalh/raymario/master/meson.build).
We use the [meson](https://raw.githubusercontent.com/jubalh/raymario/master/meson.build) build system here.
We can compile our project via the command line:
```
meson build
cd build
ninja
ninja install
```
Or can simply click on the `meson.build` file to open it with Builder.
Alternatively you can open Builder first and click on the `open` button and the left top.
We added comments to the file to give you an idea which values you should edit.
For a full overview of options please check the [meson manual](http://mesonbuild.com/Manual.html).
In the provided file we assume that the build file is located at the root folder of your project, and that all your sources are in a `src` subfolder.
Check out the `examples` directory for a simple example on how to use this template.
You can also look at [raymario](https://github.com/jubalh/raymario) for a slightly more complex example which also installs resource files.
# Notice
The files provided link against glfw3 and openAL because the latest stable version of raylib is version 1.8, which still needs this. For later versions these two dependencies are not necessary anymore.

View File

@@ -0,0 +1 @@
Open `meson.build` with Builder or run `meson build; cd build; ninja; ./core_basic_window` on the commandline to launch the example.

View File

@@ -0,0 +1,27 @@
# This file should be in the main folder of your project
# Replace 'projectname' with the name of your project
# Replace '1.0' with its version
project('core_basic_window', 'c', version: '1.0',
meson_version: '>= 0.39.1')
# We want a C Compiler to be present
cc = meson.get_compiler('c')
# Find dependencies
glfw_dep = dependency('glfw3')
gl_dep = dependency('gl')
openal_dep = dependency('openal')
m_dep = cc.find_library('m', required : false)
raylib_dep = cc.find_library('raylib', required : false)
# List your source files here
source_c = [
'../../../examples/core/core_basic_window.c',
]
# Build executable
core_basic_window = executable('core_basic_window',
source_c,
dependencies : [ raylib_dep, glfw_dep, gl_dep, openal_dep, m_dep ],
install : true)

View File

@@ -0,0 +1,28 @@
# This file should be in the main folder of your project
# Replace 'projectname' with the name of your project
# Replace '1.0' with its version
project('projectname', 'c', version: '1.0',
meson_version: '>= 0.39.1')
# We want a C Compiler to be present
cc = meson.get_compiler('c')
# Find dependencies
# glfw3 and openal are not needed for raylib > 1.8.0
glfw_dep = dependency('glfw3')
gl_dep = dependency('gl')
openal_dep = dependency('openal')
m_dep = cc.find_library('m', required : false)
raylib_dep = cc.find_library('raylib', required : false)
# List your source files here
source_c = [
'src/main.c',
]
# Build executable
projectname = executable('projectname',
source_c,
dependencies : [ raylib_dep, glfw_dep, gl_dep, openal_dep, m_dep ],
install : true)

View File

@@ -18,16 +18,21 @@ using namespace Platform;
using namespace raylibUWP; using namespace raylibUWP;
/* /*
To-do list TODO list:
- Cache reference to our CoreWindow? - Cache reference to our CoreWindow?
- Implement gestures - Implement gestures support
*/ */
// Declare uwpWindow as exter to be used by raylib internals
// NOTE: It should be properly assigned before calling InitWindow()
extern "C" { EGLNativeWindowType uwpWindow; };
/* INPUT CODE */ /* INPUT CODE */
// Stand-ins for "core.c" variables // Stand-ins for "core.c" variables
#define MAX_GAMEPADS 4 // Max number of gamepads supported #define MAX_GAMEPADS 4 // Max number of gamepads supported
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) #define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) #define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready
static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state
static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
@@ -36,7 +41,6 @@ static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Curre
static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state
static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state
//...
static char previousMouseState[3] = { 0 }; // Registers previous mouse button state static char previousMouseState[3] = { 0 }; // Registers previous mouse button state
static char currentMouseState[3] = { 0 }; // Registers current mouse button state static char currentMouseState[3] = { 0 }; // Registers current mouse button state
static int previousMouseWheelY = 0; // Registers previous mouse wheel variation static int previousMouseWheelY = 0; // Registers previous mouse wheel variation
@@ -46,7 +50,7 @@ static bool cursorOnScreen = false; // Tracks if cursor is inside client
static bool cursorHidden = false; // Track if cursor is hidden static bool cursorHidden = false; // Track if cursor is hidden
static Vector2 mousePosition; static Vector2 mousePosition;
static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c" static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c"
static bool toggleCursorLock; static bool toggleCursorLock;
CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type
@@ -122,7 +126,7 @@ void ProcessKeyEvent(Windows::System::VirtualKey key, int action)
} }
} }
/* CALLBACKS */ // Callbacks
void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args) void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args)
{ {
if (args->CurrentPoint->Properties->IsLeftButtonPressed) if (args->CurrentPoint->Properties->IsLeftButtonPressed)
@@ -206,6 +210,7 @@ void UWPSetMousePosition(Vector2 position)
window->PointerPosition = mousePosScreen; window->PointerPosition = mousePosScreen;
mousePosition = position; mousePosition = position;
} }
// Enables cursor (unlock cursor) // Enables cursor (unlock cursor)
void UWPEnableCursor() void UWPEnableCursor()
{ {
@@ -321,8 +326,7 @@ bool UWPIsKeyPressed(int key)
{ {
bool pressed = false; bool pressed = false;
if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true;
pressed = true;
else pressed = false; else pressed = false;
return pressed; return pressed;
@@ -422,7 +426,10 @@ void App::SetWindow(CoreWindow^ window)
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged); currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);
// The CoreWindow has been created, so EGL can be initialized. // The CoreWindow has been created, so EGL can be initialized.
InitWindow(800, 450, (EGLNativeWindowType)window);
uwpWindow = (EGLNativeWindowType)window;
InitWindow(800, 450, NULL);
} }
// Initializes scene resources // Initializes scene resources
@@ -446,7 +453,6 @@ void App::Run()
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5; posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5;
posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5; posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5;
DrawRectangle(posX, posY, 400, 100, RED); DrawRectangle(posX, posY, 400, 100, RED);
@@ -455,38 +461,32 @@ void App::Run()
DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE); DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE);
if(UWPIsKeyDown(KEY_S)) if (UWPIsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
{
DrawCircle(100, 100, 100, BLUE);
}
if(UWPIsKeyPressed(KEY_A)) if (UWPIsKeyPressed(KEY_A))
{ {
posX -= 50; posX -= 50;
UWPEnableCursor(); UWPEnableCursor();
} }
if (UWPIsKeyPressed(KEY_D)) if (UWPIsKeyPressed(KEY_D))
{ {
posX += 50; posX += 50;
UWPDisableCursor(); UWPDisableCursor();
} }
if(currentKeyState[KEY_LEFT_ALT]) if (currentKeyState[KEY_LEFT_ALT]) DrawRectangle(250, 250, 20, 20, BLACK);
DrawRectangle(250, 250, 20, 20, BLACK); if (currentKeyState[KEY_BACKSPACE]) DrawRectangle(280, 250, 20, 20, BLACK);
if (currentKeyState[KEY_BACKSPACE]) if (currentMouseState[MOUSE_LEFT_BUTTON]) DrawRectangle(280, 250, 20, 20, BLACK);
DrawRectangle(280, 250, 20, 20, BLACK);
if (currentMouseState[MOUSE_LEFT_BUTTON])
DrawRectangle(280, 250, 20, 20, BLACK);
static int pos = 0; static int pos = 0;
pos -= currentMouseWheelY; pos -= currentMouseWheelY;
DrawRectangle(280, pos + 50, 20, 20, BLACK);
DrawRectangle(280, pos + 50, 20, 20, BLACK);
DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE); DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
EndDrawing(); EndDrawing();
UWP_PollInput(); UWP_PollInput();
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);

View File

@@ -4,7 +4,7 @@
<mp:PhoneIdentity PhoneProductId="56d2ca94-c361-4e9f-9a33-bacd751552fa" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <mp:PhoneIdentity PhoneProductId="56d2ca94-c361-4e9f-9a33-bacd751552fa" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties> <Properties>
<DisplayName>raylibUWP</DisplayName> <DisplayName>raylibUWP</DisplayName>
<PublisherDisplayName>Alumno</PublisherDisplayName> <PublisherDisplayName>raysan5</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo> <Logo>Assets\StoreLogo.png</Logo>
</Properties> </Properties>
<Dependencies> <Dependencies>

View File

@@ -34,7 +34,7 @@
<AppContainerApplication>true</AppContainerApplication> <AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType> <ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.10586.0</WindowsTargetPlatformMinVersion> <WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision> <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<ProjectName>raylib.App.UWP</ProjectName> <ProjectName>raylib.App.UWP</ProjectName>
</PropertyGroup> </PropertyGroup>

View File

@@ -28,7 +28,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">

View File

@@ -8,6 +8,6 @@ Description: Simple and easy-to-use library to learn videogames programming
URL: http://github.com/raysan5/raylib URL: http://github.com/raysan5/raylib
Version: @PROJECT_VERSION@ Version: @PROJECT_VERSION@
Libs: -L${libdir} -lraylib Libs: -L${libdir} -lraylib
Libs.private:@PKG_CONFIG_LIBS_PRIVATE@ Libs.private: @PKG_CONFIG_LIBS_PRIVATE@
Requires.private: Requires.private:
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@@ -1,6 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib v1.9-dev * raylib v1.9.6-dev
* *
* A simple and easy-to-use library to learn videogames programming (www.raylib.com) * A simple and easy-to-use library to learn videogames programming (www.raylib.com)
* *
@@ -103,11 +103,23 @@
#define KEY_SPACE 32 #define KEY_SPACE 32
#define KEY_ESCAPE 256 #define KEY_ESCAPE 256
#define KEY_ENTER 257 #define KEY_ENTER 257
#define KEY_TAB 258
#define KEY_BACKSPACE 259 #define KEY_BACKSPACE 259
#define KEY_INSERT 260
#define KEY_DELETE 261
#define KEY_RIGHT 262 #define KEY_RIGHT 262
#define KEY_LEFT 263 #define KEY_LEFT 263
#define KEY_DOWN 264 #define KEY_DOWN 264
#define KEY_UP 265 #define KEY_UP 265
#define KEY_PAGE_UP 266
#define KEY_PAGE_DOWN 267
#define KEY_HOME 268
#define KEY_END 269
#define KEY_CAPS_LOCK 280
#define KEY_SCROLL_LOCK 281
#define KEY_NUM_LOCK 282
#define KEY_PRINT_SCREEN 283
#define KEY_PAUSE 284
#define KEY_F1 290 #define KEY_F1 290
#define KEY_F2 291 #define KEY_F2 291
#define KEY_F3 292 #define KEY_F3 292
@@ -310,6 +322,14 @@ typedef struct Vector3 {
float z; float z;
} Vector3; } Vector3;
// Vector4 type
typedef struct Vector4 {
float x;
float y;
float z;
float w;
} Vector4;
// Matrix type (OpenGL style 4x4 - right handed, column major) // Matrix type (OpenGL style 4x4 - right handed, column major)
typedef struct Matrix { typedef struct Matrix {
float m0, m4, m8, m12; float m0, m4, m8, m12;
@@ -378,12 +398,19 @@ typedef struct SpriteFont {
CharInfo *chars; // Characters info data CharInfo *chars; // Characters info data
} SpriteFont; } SpriteFont;
// Camera projection modes
typedef enum {
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
} CameraType;
// Camera type, defines a camera position/orientation in 3d space // Camera type, defines a camera position/orientation in 3d space
typedef struct Camera { typedef struct Camera {
Vector3 position; // Camera position Vector3 position; // Camera position
Vector3 target; // Camera target it looks-at Vector3 target; // Camera target it looks-at
Vector3 up; // Camera up vector (rotation over its axis) Vector3 up; // Camera up vector (rotation over its axis)
float fovy; // Camera field-of-view apperture in Y (degrees) float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
CameraType type; // Camera type, controlling projection type, either CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC.
} Camera; } Camera;
// Camera2D type, defines a 2d camera // Camera2D type, defines a 2d camera
@@ -410,7 +437,7 @@ typedef struct Mesh {
float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
float *tangents; // Vertex tangents (XYZ - 3 components per vertex) (shader-location = 4) float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
unsigned short *indices;// Vertex indices (in case vertex data comes indexed) unsigned short *indices;// Vertex indices (in case vertex data comes indexed)
@@ -541,7 +568,7 @@ typedef enum {
LOC_MAP_METALNESS, // LOC_MAP_SPECULAR LOC_MAP_METALNESS, // LOC_MAP_SPECULAR
LOC_MAP_NORMAL, LOC_MAP_NORMAL,
LOC_MAP_ROUGHNESS, LOC_MAP_ROUGHNESS,
LOC_MAP_OCCUSION, LOC_MAP_OCCLUSION,
LOC_MAP_EMISSION, LOC_MAP_EMISSION,
LOC_MAP_HEIGHT, LOC_MAP_HEIGHT,
LOC_MAP_CUBEMAP, LOC_MAP_CUBEMAP,
@@ -672,8 +699,9 @@ extern "C" { // Prevents name mangling of functions
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Window-related functions // Window-related functions
RLAPI void InitWindow(int width, int height, void *data); // Initialize window and OpenGL context RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
RLAPI void CloseWindow(void); // Close window and unload OpenGL context RLAPI void CloseWindow(void); // Close window and unload OpenGL context
RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
@@ -682,6 +710,7 @@ RLAPI void SetWindowTitle(const char *title); // Set title f
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height RLAPI int GetScreenHeight(void); // Get current screen height
@@ -704,7 +733,7 @@ RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes
RLAPI void EndTextureMode(void); // Ends drawing to render texture RLAPI void EndTextureMode(void); // Ends drawing to render texture
// Screen-space-related functions // Screen-space-related functions
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
@@ -715,17 +744,11 @@ RLAPI float GetFrameTime(void); // Returns tim
RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow() RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow()
// Color-related functions // Color-related functions
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color RLAPI float *ColorToFloat(Color color); // Returns normalized float array for a Color
RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color
RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
// Math useful functions (available from raymath.h)
RLAPI float *Vector3ToFloat(Vector3 vec); // Returns Vector3 as float array
RLAPI float *MatrixToFloat(Matrix mat); // Returns Matrix as float array
RLAPI Vector3 Vector3Zero(void); // Vector with components value 0.0f
RLAPI Vector3 Vector3One(void); // Vector with components value 1.0f
RLAPI Matrix MatrixIdentity(void); // Returns identity matrix
// Misc. functions // Misc. functions
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags) RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
@@ -783,6 +806,7 @@ RLAPI int GetMouseX(void); // Returns mouse p
RLAPI int GetMouseY(void); // Returns mouse position Y RLAPI int GetMouseY(void); // Returns mouse position Y
RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY RLAPI Vector2 GetMousePosition(void); // Returns mouse position XY
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
RLAPI void SetMouseScale(float scale); // Set mouse scaling
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
// Input-related functions: touch // Input-related functions: touch
@@ -839,6 +863,7 @@ RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Col
RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle
RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors
RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
RLAPI void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color); // Draw rectangle outline with extended parameters
RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
@@ -886,6 +911,7 @@ RLAPI void ImageAlphaPremultiply(Image *image);
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering) RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering)
RLAPI void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm) RLAPI void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm)
RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
RLAPI Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing, Color tint); // Create an image from text (custom sprite font) RLAPI Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing, Color tint); // Create an image from text (custom sprite font)
@@ -908,7 +934,7 @@ RLAPI Image GenImageGradientH(int width, int height, Color left, Color right);
RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient RLAPI Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked RLAPI Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise RLAPI Image GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
RLAPI Image GenImagePerlinNoise(int width, int height, float scale); // Generate image: perlin noise RLAPI Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float scale); // Generate image: perlin noise
RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells RLAPI Image GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells
// Texture2D configuration functions // Texture2D configuration functions
@@ -932,19 +958,20 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM) RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM) RLAPI void UnloadSpriteFont(SpriteFont font); // Unload SpriteFont from GPU memory (VRAM)
// Text drawing functions // Text drawing functions
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters RLAPI void DrawTextEx(SpriteFont font, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
float fontSize, int spacing, Color tint); float fontSize, int spacing, Color tint);
// Text misc. functions // Text misc. functions
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont RLAPI Vector2 MeasureTextEx(SpriteFont font, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
RLAPI int GetGlyphIndex(SpriteFont font, int character); // Returns index position for a unicode character on sprite font
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Basic 3d Shapes Drawing Functions (Module: models) // Basic 3d Shapes Drawing Functions (Module: models)
@@ -981,6 +1008,11 @@ RLAPI void UnloadModel(Model model);
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM) RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
// Mesh manipulation functions
RLAPI BoundingBox MeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits
RLAPI void MeshTangents(Mesh *mesh); // Compute mesh tangents
RLAPI void MeshBinormals(Mesh *mesh); // Compute mesh binormals
// Mesh generation functions // Mesh generation functions
RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)
RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh
@@ -1010,7 +1042,6 @@ RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRe
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
// Collision detection functions // Collision detection functions
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
@@ -1029,7 +1060,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
// Shader loading/unloading functions // Shader loading/unloading functions
RLAPI char *LoadText(const char *fileName); // Load chars array from text file RLAPI char *LoadText(const char *fileName); // Load chars array from text file
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations RLAPI Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations
RLAPI Shader LoadShaderCode(char *vsCode, char *fsCode); // Load shader from code strings and bind default locations
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
RLAPI Shader GetShaderDefault(void); // Get default shader RLAPI Shader GetShaderDefault(void); // Get default shader

Binary file not shown.

View File

@@ -1,42 +1,35 @@
# Setup the project and settings # Setup the project and settings
project(raylib) project(raylib)
include("../utils.cmake") include(GNUInstallDirs)
set(PROJECT_VERSION 1.9.4) set(PROJECT_VERSION 1.9.7)
set(API_VERSION 1) set(API_VERSION 1)
set(RAYLIB raylib) # Name of the generated library set(RAYLIB raylib) # Name of the generated library
### Config options ### include("CMakeOptions.txt")
# Shared library is always PIC. Static library should be PIC too if linked into a shared library configure_file(config.h.in ${CMAKE_BINARY_DIR}/cmake/config.h)
set(WITH_PIC OFF CACHE BOOL "Compile static library as position-independent code" OFF) include_directories(${CMAKE_BINARY_DIR})
# Build a static and/or shared raylib?
set(SHARED_RAYLIB OFF CACHE BOOL "Build raylib as a dynamic library")
set(STATIC_RAYLIB ON CACHE BOOL "Build raylib as a static library")
set(MACOS_FATLIB ON CACHE BOOL "Build fat library for both i386 and x86_64 on macOS")
if(NOT (STATIC_RAYLIB OR SHARED_RAYLIB)) include("../utils.cmake")
message(FATAL_ERROR "Nothing to do if both -DSHARED_RAYLIB=OFF and -DSTATIC_RAYLIB=OFF...")
endif()
# Platform
set(PLATFORM "Desktop" CACHE STRING "Platform to build for.")
set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi")
# OpenGL version
set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
# Get the sources together # Get the sources together
file(GLOB raylib_sources *.c) file(GLOB raylib_sources *.c)
if(glfw3_FOUND) if(glfw3_FOUND)
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c) list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c)
else() else()
include_directories(external/glfw/include) include_directories(external/glfw/include)
endif() endif()
file(GLOB stb_vorbis external/stb_vorbis.c) if(USE_AUDIO)
file(GLOB mini_al external/mini_al.c ${stb_vorbis}) file(GLOB stb_vorbis external/stb_vorbis.c)
set(sources ${raylib_sources} ${mini_al}) file(GLOB mini_al external/mini_al.c ${stb_vorbis})
set(sources ${raylib_sources} ${mini_al})
else()
set(INCLUDE_AUDIO_MODULE 0)
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio.c)
set(sources ${raylib_sources})
endif()
### Config options ### ### Config options ###
# Translate the config options to what raylib wants # Translate the config options to what raylib wants
@@ -85,7 +78,7 @@ endif()
if(MACOS_FATLIB) if(MACOS_FATLIB)
if (CMAKE_OSX_ARCHITECTURES) if (CMAKE_OSX_ARCHITECTURES)
message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides BUILD_MACOS_FATLIB=ON") message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides -DMACOS_FATLIB=ON")
else() else()
SET(CMAKE_OSX_ARCHITECTURES "x86_64;i386") SET(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
endif() endif()
@@ -94,7 +87,7 @@ endif()
# Which platform? # Which platform?
if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
if(${SHARED_RAYLIB}) if(${SHARED})
add_library(${RAYLIB}_shared SHARED ${sources}) add_library(${RAYLIB}_shared SHARED ${sources})
target_compile_definitions(${RAYLIB}_shared target_compile_definitions(${RAYLIB}_shared
@@ -103,7 +96,7 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
) )
set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH ON) set(CMAKE_MACOSX_RPATH ON)
@@ -123,13 +116,13 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB}) set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB})
install( install(
TARGETS ${RAYLIB}_shared TARGETS ${RAYLIB}_shared
LIBRARY DESTINATION lib LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION include PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
) )
endif() endif()
endif(${SHARED_RAYLIB}) endif(${SHARED})
if(${STATIC_RAYLIB}) if(${STATIC})
add_library(${RAYLIB} STATIC ${sources}) add_library(${RAYLIB} STATIC ${sources})
target_compile_definitions(${RAYLIB} target_compile_definitions(${RAYLIB}
@@ -137,18 +130,20 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
PUBLIC ${GRAPHICS} PUBLIC ${GRAPHICS}
) )
set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE})
if (WITH_PIC) if (WITH_PIC)
set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
endif() endif()
set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h") set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
install(TARGETS ${RAYLIB} install(TARGETS ${RAYLIB}
ARCHIVE DESTINATION lib ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION include PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
) )
endif(${STATIC_RAYLIB}) endif(${STATIC})
configure_file(../raylib.pc.in raylib.pc @ONLY) configure_file(../raylib.pc.in raylib.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig) install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
# Copy the header files to the build directory # Copy the header files to the build directory
file(COPY "raylib.h" DESTINATION ".") file(COPY "raylib.h" DESTINATION ".")

89
src/CMakeOptions.txt Normal file
View File

@@ -0,0 +1,89 @@
### Config options ###
include(CMakeDependentOption)
# Shared library is always PIC. Static library should be PIC too if linked into a shared library
option(WITH_PIC "Compile static library as position-independent code" OFF)
option(SHARED "Build raylib as a dynamic library" OFF)
option(STATIC "Build raylib as a static library" ON)
option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" ON)
option(USE_AUDIO "Build raylib with audio module" ON)
cmake_dependent_option(USE_OPENAL_BACKEND "Link raylib with openAL instead of mini-al" OFF "USE_AUDIO" OFF)
set(USE_EXTERNAL_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one")
set_property(CACHE USE_EXTERNAL_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE)
if(UNIX AND NOT APPLE)
option(USE_WAYLAND "Use Wayland for window creation" OFF)
endif()
set(PLATFORM "Desktop" CACHE STRING "Platform to build for.")
set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi")
set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
# core.c
option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" ON)
option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON)
option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON)
option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON)
option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON)
option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON)
# rlgl.c
option(SUPPORT_VR_SIMULATOR "Support VR simulation functionality (stereo rendering)" ON)
option(SUPPORT_DISTORTION_SHADER "Include stereo rendering distortion shader (shader_distortion.h)" ON)
# models.c
option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON)
option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON)
option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON)
# textures.c
option(SUPPORT_IMAGE_GENERATION "Support proedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON)
option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON)
option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON)
option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON)
option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON)
option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON)
option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" OFF)
option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" OFF)
option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" OFF)
option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" OFF)
option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" OFF)
option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" OFF)
option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" OFF)
# audio.c
option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON)
option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON)
option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON)
option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON)
option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" OFF)
# shapes.c
option(USE_DEFAULT_FONT_TEXTURE "Draw rectangle shapes using font texture white character instead of default white texture. Allows drawing rectangles and text with a single draw call, very useful for GUI systems!" ON)
# utils.c
option(SUPPORT_SAVE_PNG "Support saving image data in PNG file format" ON)
option(SUPPORT_SAVE_BMP "Support saving image data in BMP file format" OFF)
option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON)
option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON)
option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF format" ON)
option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON)
if(NOT (STATIC OR SHARED))
message(FATAL_ERROR "Nothing to do if both -DSHARED=OFF and -DSTATIC=OFF...")
endif()
if(DEFINED SHARED_RAYLIB)
set(SHARED ${SHARED_RAYLIB})
message(DEPRECATION "-DSHARED_RAYLIB is deprecated. Please use -DSHARED instead.")
endif()
if(DEFINED STATIC_RAYLIB)
set(STATIC ${STATIC_RAYLIB})
message(DEPRECATION "-DSTATIC_RAYLIB is deprecated. Please use -DSTATIC instead.")
endif()
# vim: ft=cmake

View File

@@ -42,38 +42,52 @@
.PHONY: all clean install uninstall .PHONY: all clean install uninstall
# Define required raylib variables # Define required raylib variables
PLATFORM ?= PLATFORM_DESKTOP RAYLIB_VERSION = 1.9.7
RAYLIB_PATH = ..
RAYLIB_VERSION = 1.9.4
RAYLIB_API_VERSION = 1 RAYLIB_API_VERSION = 1
# See below for alternatives.
RAYLIB_PATH = ..
# Define default options
# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
PLATFORM ?= PLATFORM_DESKTOP
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
RAYLIB_LIBTYPE ?= STATIC RAYLIB_LIBTYPE ?= STATIC
# Build mode for library: DEBUG or RELEASE # Build mode for library: DEBUG or RELEASE
RAYLIB_BUILD_MODE ?= RELEASE RAYLIB_BUILD_MODE ?= RELEASE
# Included raylib audio module on compilation # Included raylib audio module on compilation
# NOTE: Some programs like tools could not require audio support # NOTE: Some programs like tools could not require audio support
INCLUDE_AUDIO_MODULE ?= TRUE INCLUDE_AUDIO_MODULE ?= TRUE
# Use OpenAL Soft backend for audio # Use OpenAL Soft backend for audio
USE_OPENAL_BACKEND ?= FALSE USE_OPENAL_BACKEND ?= FALSE
# 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
# OpenAL Soft audio backend forced on HTML5 and OSX (see below) # OpenAL Soft audio backend forced on HTML5 and OSX (see below)
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
USE_OPENAL_BACKEND = TRUE USE_OPENAL_BACKEND = TRUE
endif endif
# Use external GLFW library instead of rglfw module
# TODO: Review usage of examples on Linux.
USE_EXTERNAL_GLFW ?= FALSE
# Use Wayland display server protocol on Linux desktop
# by default it uses X11 windowing system
USE_WAYLAND_DISPLAY ?= FALSE
# See below for more GRAPHICS options.
# See below for RAYLIB_RELEASE_PATH.
# See install target for *_INSTALL_PATH locations.
# Use cross-compiler for PLATFORM_RPI # Use cross-compiler for PLATFORM_RPI
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
USE_RPI_CROSS_COMPILER ?= FALSE USE_RPI_CROSS_COMPILER ?= FALSE
ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) ifeq ($(USE_RPI_CROSS_COMPILER),TRUE)
RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry RPI_TOOLCHAIN ?= C:/SysGCC/Raspberry
RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot RPI_TOOLCHAIN_SYSROOT ?= $(RPI_TOOLCHAIN)/arm-linux-gnueabihf/sysroot
@@ -111,6 +125,23 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
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!
# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX.
# WARNING: The following is copied from examples/Makefile and is here only for reference.
# Consequences of enabling this are UNKNOWN. Please test and report.
#ifeq ($(PLATFORM),PLATFORM_RPI)
# RAYLIB_PATH ?= /home/pi/raylib
#endif
# Force OpenAL Soft audio backend for OSX platform # Force OpenAL Soft audio backend for OSX platform
# NOTE 1: mini_al library does not support CoreAudio yet # NOTE 1: mini_al library does not support CoreAudio yet
# NOTE 2: Required OpenAL libraries should be available on OSX # NOTE 2: Required OpenAL libraries should be available on OSX
@@ -138,7 +169,9 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
ANDROID_ARCH ?= ARM ANDROID_ARCH ?= ARM
endif endif
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs # RAYLIB_RELEASE_PATH points to provided binaries or your immediate build of raylib.
# It is further modified below by PLATFORM below.
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
# Define output directory for compiled library # Define output directory for compiled library
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
@@ -177,17 +210,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# On RPI OpenGL ES 2.0 must be used # On RPI OpenGL ES 2.0 must be used
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
# By default use OpenGL ES 2.0 on Android # By default use OpenGL ES 2.0 on Android
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
@@ -258,19 +288,25 @@ endif
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU 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) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
# -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers
# -Werror=implicit-function-declaration catch function calls without prior declaration # -fno-strict-aliasing jar_xm.h does shady stuff (breaks strict aliasing)
CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -Werror=implicit-function-declaration CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing
ifeq ($(RAYLIB_BUILD_MODE), DEBUG) ifeq ($(RAYLIB_BUILD_MODE), DEBUG)
CFLAGS += -g CFLAGS += -g
#CC = clang
endif endif
# Additional flags for compiler (if desired) # Additional flags for compiler (if desired)
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes # -Wextra enables some extra warning flags that are not enabled by -Wall
# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration
# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types
# -Werror=implicit-function-declaration catch function calls without prior declaration
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CFLAGS += -Werror=implicit-function-declaration
endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
@@ -285,7 +321,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
# Compilation functions attributes options # Compilation functions attributes options
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
# Compiler options for the linker # Compiler options for the linker
CFLAGS += -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes # -Werror=format-security
CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes
# Preprocessor macro definitions # Preprocessor macro definitions
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16 CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16
endif endif
@@ -293,7 +330,7 @@ endif
# Define required compilation flags for raylib SHARED lib # Define required compilation flags for raylib SHARED lib
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
# make sure code is compiled as position independent # make sure code is compiled as position independent
# BE CAREFUL: It seems that for gcc -fpic si not the same as -fPIC # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC
# MinGW32 just doesn't need -fPIC, it shows warnings # MinGW32 just doesn't need -fPIC, it shows warnings
CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
endif endif
@@ -322,13 +359,15 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
LDFLAGS += -L. -Lsrc -L/usr/local/lib -L$(RAYLIB_RELEASE_PATH) LDFLAGS += -L. -Lsrc -L/usr/local/lib -L$(RAYLIB_RELEASE_PATH)
endif endif
ifeq ($(USE_EXTERNAL_GLFW),TRUE) ifeq ($(USE_EXTERNAL_GLFW),TRUE)
# Check the version name. If GLFW3 was built manually, it may have produced
# a static library known as libglfw3.a. In that case, the name should be -lglfw3
LDFLAGS += -lglfw LDFLAGS += -lglfw
endif endif
endif endif
# Define additional directories containing required header files # Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI requried libraries # RPI required libraries
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vmcs_host/linux
INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads INCLUDE_PATHS += -I$(RPI_TOOLCHAIN_SYSROOT)/opt/vc/include/interface/vcos/pthreads
@@ -411,12 +450,12 @@ else
@echo "raylib dynamic library (raylib.dll) and import library (libraylibdll.a) generated!" @echo "raylib dynamic library (raylib.dll) and import library (libraylibdll.a) generated!"
endif endif
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Compile raylib to shared library version for GNU/Linux. # Compile raylib shared library version $(RAYLIB_VERSION).
# WARNING: you should type "make clean" before doing this target # WARNING: you should type "make clean" before doing this target
$(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).so $(OBJS) -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -lGL -lm -lpthread -ldl -lrt $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(OBJS) -shared -Wl,-soname,libraylib.so.$(RAYLIB_API_VERSION) -lGL -lc -lm -lpthread -ldl -lrt
@echo "raylib shared library generated (libraylib.$(RAYLIB_VERSION).so)!" @echo "raylib shared library generated (libraylib.so.$(RAYLIB_VERSION)) in $(RAYLIB_RELEASE_PATH)!"
cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.$(RAYLIB_API_VERSION).so cd $(RAYLIB_RELEASE_PATH) && ln -fsv libraylib.so.$(RAYLIB_VERSION) libraylib.so.$(RAYLIB_API_VERSION)
cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.so cd $(RAYLIB_RELEASE_PATH) && ln -fsv libraylib.so.$(RAYLIB_API_VERSION) libraylib.so
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
$(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).dylib $(OBJS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).dylib $(OBJS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa
@@ -426,7 +465,7 @@ else
cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).dylib libraylib.dylib cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).dylib libraylib.dylib
endif endif
ifeq ($(PLATFORM_OS),FREEBSD) ifeq ($(PLATFORM_OS),FREEBSD)
# WARNING: you should type "gmake clean" before doing this target # WARNING: you should type "gmake clean" before doing this target
$(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).so $(OBJS) -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -lGL -lpthread $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).so $(OBJS) -Wl,-soname,libraylib.$(RAYLIB_API_VERSION).so -lGL -lpthread
@echo "raylib shared library generated (libraylib.$(RAYLIB_VERSION).so)!" @echo "raylib shared library generated (libraylib.$(RAYLIB_VERSION).so)!"
cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.$(RAYLIB_API_VERSION).so cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.$(RAYLIB_API_VERSION).so
@@ -439,10 +478,10 @@ else
cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.so cd $(RAYLIB_RELEASE_PATH) && ln -fs libraylib.$(RAYLIB_VERSION).so libraylib.so
endif endif
else else
# Compile raylib static library # Compile raylib static library version $(RAYLIB_VERSION)
@echo raylib library release path is $(RAYLIB_RELEASE_PATH) # WARNING: You should type "make clean" before doing this target.
$(AR) rcs $(RAYLIB_RELEASE_PATH)/libraylib.a $(OBJS) $(AR) rcs $(RAYLIB_RELEASE_PATH)/libraylib.a $(OBJS)
@echo "raylib static library generated (libraylib.a)!" @echo "raylib static library generated (libraylib.a) in $(RAYLIB_RELEASE_PATH)!"
endif endif
endif endif
@@ -492,50 +531,85 @@ stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h
utils.o : utils.c utils.h utils.o : utils.c utils.h
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
# Install generated and needed files to required directories # Install generated and needed files to desired directories.
# TODO: add other platforms. # On GNU/Linux and BSDs, there are some standard directories that contain extra
# libraries and header files. These directories (often /usr/local/lib and
# /usr/local/include) are for libraries that are installed manually
# (without a package manager). We'll use /usr/local/lib/raysan5 and /usr/local/include/raysan5
# for our -L and -I specification to simplify management of the raylib source package.
# Customize these locations if you like but don't forget to pass them to make
# for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
# Hint: add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
# See below and ../examples/Makefile for more information.
# TODO: Add other platforms. Remove sudo requirement, i.e. add USER mode.
# 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
install : install :
ifeq ($(ROOT),root) ifeq ($(ROOT),root)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# On GNU/Linux there are some standard directories that contain # Attention! You are root, writing files to $(RAYLIB_INSTALL_PATH)
# libraries and header files. These directory (/usr/local/lib and # and $(RAYLIB_H_INSTALL_PATH). Consult this Makefile for more information.
# /usr/local/include/) are for libraries that are installed # Prepare the environment as needed.
# manually (without a package manager). mkdir --parents --verbose $(RAYLIB_INSTALL_PATH)
mkdir --parents --verbose $(RAYLIB_H_INSTALL_PATH)
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
cp --update $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).so /usr/local/lib/libraylib.$(RAYLIB_VERSION).so # Installing raylib to $(RAYLIB_INSTALL_PATH).
cp --update $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_API_VERSION).so /usr/local/lib/libraylib.$(RAYLIB_API_VERSION).so cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.so.$(RAYLIB_VERSION) $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
cp --update $(RAYLIB_RELEASE_PATH)/libraylib.so /usr/local/lib/libraylib.so cd $(RAYLIB_INSTALL_PATH); ln -fsv libraylib.so.$(RAYLIB_VERSION) libraylib.so.$(RAYLIB_API_VERSION)
cd $(RAYLIB_INSTALL_PATH); ln -fsv libraylib.so.$(RAYLIB_API_VERSION) libraylib.so
# Uncomment to update the runtime linker cache with RAYLIB_INSTALL_PATH.
# Not necessary if later embedding RPATH in your executable. See examples/Makefile.
ldconfig $(RAYLIB_INSTALL_PATH)
else else
cp --update raylib.h /usr/local/include/raylib.h # Installing raylib to $(RAYLIB_INSTALL_PATH).
cp --update $(RAYLIB_RELEASE_PATH)/libraylib.a /usr/local/lib/libraylib.a cp --update --verbose $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_INSTALL_PATH)/libraylib.a
endif endif
@echo "raylib dev files installed/updated!" # Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
cp --update rlgl.c $(RAYLIB_H_INSTALL_PATH)/rlgl.c
cp --update physac.h $(RAYLIB_H_INSTALL_PATH)/physac.h
@echo "raylib development files installed/updated!"
else else
@echo "This function works only on GNU/Linux systems" @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
endif endif
else else
@echo "Error: no root permissions" @echo "Error: Root permissions needed for installation. Try sudo make install"
endif endif
# Remove raylib dev files installed on the system # Remove raylib dev files installed on the system
# TODO: see 'install' target. # TODO: see 'install' target.
uninstall : uninstall :
ifeq ($(ROOT),root) ifeq ($(ROOT),root)
# WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
# and $(RAYLIB_H_INSTALL_PATH). Please confirm each item.
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
rm --force /usr/local/include/raylib.h
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
rm --force /usr/local/lib/libraylib.so rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so
rm --force /usr/local/lib/libraylib.$(RAYLIB_API_VERSION).so rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_API_VERSION)
rm --force /usr/local/lib/libraylib.$(RAYLIB_VERSION).so rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.so.$(RAYLIB_VERSION)
# Uncomment to clean up the runtime linker cache. See install target.
ldconfig
else else
rm --force /usr/local/lib/libraylib.a rm --force --interactive --verbose $(RAYLIB_INSTALL_PATH)/libraylib.a
endif endif
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.c
rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/physac.h
@echo "raylib development files removed!" @echo "raylib development files removed!"
else else
@echo "This function works only on GNU/Linux systems" @echo "This function currently works on GNU/Linux systems. Add yours today (^;"
endif endif
else else
@echo "Error: no root permissions" @echo "Error: Root permissions needed for uninstallation. Try sudo make uninstall"
endif endif
# Clean everything # Clean everything
@@ -543,7 +617,7 @@ clean:
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
del *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so external/stb_vorbis.o del *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so external/stb_vorbis.o
else else
rm -f *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_API_VERSION).so $(RAYLIB_RELEASE_PATH)/libraylib.$(RAYLIB_VERSION).so external/stb_vorbis.o rm -fv *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so* external/stb_vorbis.o
endif endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
rm -rf $(ANDROID_TOOLCHAIN) rm -rf $(ANDROID_TOOLCHAIN)

View File

@@ -72,13 +72,7 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features) #include "config.h"
//-------------------------------------------------
#define SUPPORT_FILEFORMAT_WAV
#define SUPPORT_FILEFORMAT_OGG
#define SUPPORT_FILEFORMAT_XM
#define SUPPORT_FILEFORMAT_MOD
//-------------------------------------------------
#if !defined(USE_OPENAL_BACKEND) #if !defined(USE_OPENAL_BACKEND)
#define USE_MINI_AL 1 // Set to 1 to use mini_al; 0 to use OpenAL. #define USE_MINI_AL 1 // Set to 1 to use mini_al; 0 to use OpenAL.
@@ -225,9 +219,10 @@ void TraceLog(int msgType, const char *text, ...); // Show trace lo
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition - Audio Device initialization and Closing // mini_al AudioBuffer Functionality
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if USE_MINI_AL #if USE_MINI_AL
#define DEVICE_FORMAT mal_format_f32 #define DEVICE_FORMAT mal_format_f32
#define DEVICE_CHANNELS 2 #define DEVICE_CHANNELS 2
#define DEVICE_SAMPLE_RATE 44100 #define DEVICE_SAMPLE_RATE 44100
@@ -235,15 +230,16 @@ void TraceLog(int msgType, const char *text, ...); // Show trace lo
typedef enum { AUDIO_BUFFER_USAGE_STATIC = 0, AUDIO_BUFFER_USAGE_STREAM } AudioBufferUsage; typedef enum { AUDIO_BUFFER_USAGE_STATIC = 0, AUDIO_BUFFER_USAGE_STREAM } AudioBufferUsage;
// Audio buffer structure // Audio buffer structure
// NOTE: Slightly different logic is used when feeding data to the playback device depending on whether or not data is streamed
typedef struct AudioBuffer AudioBuffer; typedef struct AudioBuffer AudioBuffer;
struct AudioBuffer { struct AudioBuffer {
mal_dsp dsp; // For format conversion. mal_dsp dsp; // Required for format conversion
float volume; float volume;
float pitch; float pitch;
bool playing; bool playing;
bool paused; bool paused;
bool looping; // Always true for AudioStreams. bool looping; // Always true for AudioStreams
AudioBufferUsage usage; // Slightly different logic is used when feeding data to the playback device depending on whether or not data is streamed. int usage; // AudioBufferUsage type
bool isSubBufferProcessed[2]; bool isSubBufferProcessed[2];
unsigned int frameCursorPos; unsigned int frameCursorPos;
unsigned int bufferSizeInFrames; unsigned int bufferSizeInFrames;
@@ -252,76 +248,48 @@ struct AudioBuffer {
unsigned char buffer[1]; unsigned char buffer[1];
}; };
void StopAudioBuffer(AudioBuffer *audioBuffer); // mini_al global variables
static mal_context context; static mal_context context;
static mal_device device; static mal_device device;
static mal_bool32 isAudioInitialized = MAL_FALSE;
static float masterVolume = 1;
static mal_mutex audioLock; static mal_mutex audioLock;
static AudioBuffer *firstAudioBuffer = NULL; // Audio buffers are tracked in a linked list. static bool isAudioInitialized = MAL_FALSE;
static float masterVolume = 1.0f;
// Audio buffers are tracked in a linked list
static AudioBuffer *firstAudioBuffer = NULL;
static AudioBuffer *lastAudioBuffer = NULL; static AudioBuffer *lastAudioBuffer = NULL;
static void TrackAudioBuffer(AudioBuffer* audioBuffer) // mini_al functions declaration
{ static void OnLog(mal_context *pContext, mal_device *pDevice, const char *message);
mal_mutex_lock(&audioLock); static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameCount, void *pFramesOut);
static mal_uint32 OnAudioBufferDSPRead(mal_dsp *pDSP, mal_uint32 frameCount, void *pFramesOut, void *pUserData);
static void MixAudioFrames(float *framesOut, const float *framesIn, mal_uint32 frameCount, float localVolume);
{ // AudioBuffer management functions declaration
if (firstAudioBuffer == NULL) firstAudioBuffer = audioBuffer; // NOTE: Those functions are not exposed by raylib... for the moment
else AudioBuffer *CreateAudioBuffer(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_uint32 bufferSizeInFrames, AudioBufferUsage usage);
{ void DeleteAudioBuffer(AudioBuffer *audioBuffer);
lastAudioBuffer->next = audioBuffer; bool IsAudioBufferPlaying(AudioBuffer *audioBuffer);
audioBuffer->prev = lastAudioBuffer; void PlayAudioBuffer(AudioBuffer *audioBuffer);
} void StopAudioBuffer(AudioBuffer *audioBuffer);
void PauseAudioBuffer(AudioBuffer *audioBuffer);
void ResumeAudioBuffer(AudioBuffer *audioBuffer);
void SetAudioBufferVolume(AudioBuffer *audioBuffer, float volume);
void SetAudioBufferPitch(AudioBuffer *audioBuffer, float pitch);
void TrackAudioBuffer(AudioBuffer *audioBuffer);
void UntrackAudioBuffer(AudioBuffer *audioBuffer);
lastAudioBuffer = audioBuffer;
}
mal_mutex_unlock(&audioLock); // Log callback function
} static void OnLog(mal_context *pContext, mal_device *pDevice, const char *message)
static void UntrackAudioBuffer(AudioBuffer* audioBuffer)
{
mal_mutex_lock(&audioLock);
{
if (audioBuffer->prev == NULL) firstAudioBuffer = audioBuffer->next;
else audioBuffer->prev->next = audioBuffer->next;
if (audioBuffer->next == NULL) lastAudioBuffer = audioBuffer->prev;
else audioBuffer->next->prev = audioBuffer->prev;
audioBuffer->prev = NULL;
audioBuffer->next = NULL;
}
mal_mutex_unlock(&audioLock);
}
static void OnLog_MAL(mal_context *pContext, mal_device *pDevice, const char *message)
{ {
(void)pContext; (void)pContext;
(void)pDevice; (void)pDevice;
TraceLog(LOG_ERROR, message); // All log messages from mini_al are errors.
} TraceLog(LOG_ERROR, message); // All log messages from mini_al are errors
// This is the main mixing function. Mixing is pretty simple in this project - it's just an accumulation.
//
// framesOut is both an input and an output. It will be initially filled with zeros outside of this function.
static void MixFrames(float* framesOut, const float* framesIn, mal_uint32 frameCount, float localVolume)
{
for (mal_uint32 iFrame = 0; iFrame < frameCount; ++iFrame)
{
for (mal_uint32 iChannel = 0; iChannel < device.channels; ++iChannel)
{
float *frameOut = framesOut + (iFrame*device.channels);
const float *frameIn = framesIn + (iFrame*device.channels);
frameOut[iChannel] += frameIn[iChannel]*masterVolume*localVolume;
}
}
} }
// Sending audio data to device callback function
static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameCount, void *pFramesOut) static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameCount, void *pFramesOut)
{ {
// This is where all of the mixing takes place. // This is where all of the mixing takes place.
@@ -334,7 +302,7 @@ static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameC
// want to consider how you might want to avoid this. // want to consider how you might want to avoid this.
mal_mutex_lock(&audioLock); mal_mutex_lock(&audioLock);
{ {
for (AudioBuffer* audioBuffer = firstAudioBuffer; audioBuffer != NULL; audioBuffer = audioBuffer->next) for (AudioBuffer *audioBuffer = firstAudioBuffer; audioBuffer != NULL; audioBuffer = audioBuffer->next)
{ {
// Ignore stopped or paused sounds. // Ignore stopped or paused sounds.
if (!audioBuffer->playing || audioBuffer->paused) continue; if (!audioBuffer->playing || audioBuffer->paused) continue;
@@ -364,14 +332,14 @@ static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameC
// If we're not looping, we need to make sure we flush the internal buffers of the DSP pipeline to ensure we get the // If we're not looping, we need to make sure we flush the internal buffers of the DSP pipeline to ensure we get the
// last few samples. // last few samples.
mal_bool32 flushDSP = !audioBuffer->looping; bool flushDSP = !audioBuffer->looping;
mal_uint32 framesJustRead = mal_dsp_read_frames_ex(&audioBuffer->dsp, framesToReadRightNow, tempBuffer, flushDSP); mal_uint32 framesJustRead = mal_dsp_read_frames_ex(&audioBuffer->dsp, framesToReadRightNow, tempBuffer, flushDSP);
if (framesJustRead > 0) if (framesJustRead > 0)
{ {
float *framesOut = (float *)pFramesOut + (framesRead*device.channels); float *framesOut = (float *)pFramesOut + (framesRead*device.channels);
float *framesIn = tempBuffer; float *framesIn = tempBuffer;
MixFrames(framesOut, framesIn, framesJustRead, audioBuffer->volume); MixAudioFrames(framesOut, framesIn, framesJustRead, audioBuffer->volume);
framesToRead -= framesJustRead; framesToRead -= framesJustRead;
framesRead += framesJustRead; framesRead += framesJustRead;
@@ -387,15 +355,16 @@ static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameC
} }
else else
{ {
// Should never get here, but just for safety, move the cursor position back to the start and continue the loop. // Should never get here, but just for safety,
// move the cursor position back to the start and continue the loop.
audioBuffer->frameCursorPos = 0; audioBuffer->frameCursorPos = 0;
continue; continue;
} }
} }
} }
// If for some reason we weren't able to read every frame we'll need to break from the loop. Not doing this could // If for some reason we weren't able to read every frame we'll need to break from the loop.
// theoretically put us into an infinite loop. // Not doing this could theoretically put us into an infinite loop.
if (framesToRead > 0) break; if (framesToRead > 0) break;
} }
} }
@@ -405,14 +374,122 @@ static mal_uint32 OnSendAudioDataToDevice(mal_device *pDevice, mal_uint32 frameC
return frameCount; // We always output the same number of frames that were originally requested. return frameCount; // We always output the same number of frames that were originally requested.
} }
// DSP read from audio buffer callback function
static mal_uint32 OnAudioBufferDSPRead(mal_dsp *pDSP, mal_uint32 frameCount, void *pFramesOut, void *pUserData)
{
AudioBuffer *audioBuffer = (AudioBuffer *)pUserData;
mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames;
if (currentSubBufferIndex > 1)
{
TraceLog(LOG_DEBUG, "Frame cursor position moved too far forward in audio stream");
return 0;
}
// Another thread can update the processed state of buffers so we just take a copy here to try and avoid potential synchronization problems.
bool isSubBufferProcessed[2];
isSubBufferProcessed[0] = audioBuffer->isSubBufferProcessed[0];
isSubBufferProcessed[1] = audioBuffer->isSubBufferProcessed[1];
mal_uint32 frameSizeInBytes = mal_get_sample_size_in_bytes(audioBuffer->dsp.config.formatIn)*audioBuffer->dsp.config.channelsIn;
// Fill out every frame until we find a buffer that's marked as processed. Then fill the remainder with 0.
mal_uint32 framesRead = 0;
for (;;)
{
// We break from this loop differently depending on the buffer's usage. For static buffers, we simply fill as much data as we can. For
// streaming buffers we only fill the halves of the buffer that are processed. Unprocessed halves must keep their audio data in-tact.
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{
if (framesRead >= frameCount) break;
}
else
{
if (isSubBufferProcessed[currentSubBufferIndex]) break;
}
mal_uint32 totalFramesRemaining = (frameCount - framesRead);
if (totalFramesRemaining == 0) break;
mal_uint32 framesRemainingInOutputBuffer;
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{
framesRemainingInOutputBuffer = audioBuffer->bufferSizeInFrames - audioBuffer->frameCursorPos;
}
else
{
mal_uint32 firstFrameIndexOfThisSubBuffer = subBufferSizeInFrames * currentSubBufferIndex;
framesRemainingInOutputBuffer = subBufferSizeInFrames - (audioBuffer->frameCursorPos - firstFrameIndexOfThisSubBuffer);
}
mal_uint32 framesToRead = totalFramesRemaining;
if (framesToRead > framesRemainingInOutputBuffer) framesToRead = framesRemainingInOutputBuffer;
memcpy((unsigned char *)pFramesOut + (framesRead*frameSizeInBytes), audioBuffer->buffer + (audioBuffer->frameCursorPos*frameSizeInBytes), framesToRead*frameSizeInBytes);
audioBuffer->frameCursorPos = (audioBuffer->frameCursorPos + framesToRead) % audioBuffer->bufferSizeInFrames;
framesRead += framesToRead;
// If we've read to the end of the buffer, mark it as processed.
if (framesToRead == framesRemainingInOutputBuffer)
{
audioBuffer->isSubBufferProcessed[currentSubBufferIndex] = true;
isSubBufferProcessed[currentSubBufferIndex] = true;
currentSubBufferIndex = (currentSubBufferIndex + 1)%2;
// We need to break from this loop if we're not looping.
if (!audioBuffer->looping)
{
StopAudioBuffer(audioBuffer);
break;
}
}
}
// Zero-fill excess.
mal_uint32 totalFramesRemaining = (frameCount - framesRead);
if (totalFramesRemaining > 0)
{
memset((unsigned char*)pFramesOut + (framesRead*frameSizeInBytes), 0, totalFramesRemaining*frameSizeInBytes);
// For static buffers we can fill the remaining frames with silence for safety, but we don't want
// to report those frames as "read". The reason for this is that the caller uses the return value
// to know whether or not a non-looping sound has finished playback.
if (audioBuffer->usage != AUDIO_BUFFER_USAGE_STATIC) framesRead += totalFramesRemaining;
}
return framesRead;
}
// This is the main mixing function. Mixing is pretty simple in this project - it's just an accumulation.
// NOTE: framesOut is both an input and an output. It will be initially filled with zeros outside of this function.
static void MixAudioFrames(float *framesOut, const float *framesIn, mal_uint32 frameCount, float localVolume)
{
for (mal_uint32 iFrame = 0; iFrame < frameCount; ++iFrame)
{
for (mal_uint32 iChannel = 0; iChannel < device.channels; ++iChannel)
{
float *frameOut = framesOut + (iFrame*device.channels);
const float *frameIn = framesIn + (iFrame*device.channels);
frameOut[iChannel] += frameIn[iChannel]*masterVolume*localVolume;
}
}
}
#endif #endif
//----------------------------------------------------------------------------------
// Module Functions Definition - Audio Device initialization and Closing
//----------------------------------------------------------------------------------
// Initialize audio device // Initialize audio device
void InitAudioDevice(void) void InitAudioDevice(void)
{ {
#if USE_MINI_AL #if USE_MINI_AL
// Context. // Context.
mal_context_config contextConfig = mal_context_config_init(OnLog_MAL); mal_context_config contextConfig = mal_context_config_init(OnLog);
mal_result result = mal_context_init(NULL, 0, &contextConfig, &context); mal_result result = mal_context_init(NULL, 0, &contextConfig, &context);
if (result != MAL_SUCCESS) if (result != MAL_SUCCESS)
{ {
@@ -550,106 +627,17 @@ void SetMasterVolume(float volume)
else if (volume > 1.0f) volume = 1.0f; else if (volume > 1.0f) volume = 1.0f;
#if USE_MINI_AL #if USE_MINI_AL
masterVolume = 1; masterVolume = volume;
#else #else
alListenerf(AL_GAIN, volume); alListenerf(AL_GAIN, volume);
#endif #endif
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Audio Buffer // Module Functions Definition - Audio Buffer management
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if USE_MINI_AL #if USE_MINI_AL
static mal_uint32 AudioBuffer_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCount, void* pFramesOut, void* pUserData) // Create a new audio buffer. Initially filled with silence
{
AudioBuffer *audioBuffer = (AudioBuffer *)pUserData;
mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames;
if (currentSubBufferIndex > 1)
{
TraceLog(LOG_DEBUG, "Frame cursor position moved too far forward in audio stream");
return 0;
}
// Another thread can update the processed state of buffers so we just take a copy here to try and avoid potential synchronization problems.
bool isSubBufferProcessed[2];
isSubBufferProcessed[0] = audioBuffer->isSubBufferProcessed[0];
isSubBufferProcessed[1] = audioBuffer->isSubBufferProcessed[1];
mal_uint32 frameSizeInBytes = mal_get_sample_size_in_bytes(audioBuffer->dsp.config.formatIn)*audioBuffer->dsp.config.channelsIn;
// Fill out every frame until we find a buffer that's marked as processed. Then fill the remainder with 0.
mal_uint32 framesRead = 0;
for (;;)
{
// We break from this loop differently depending on the buffer's usage. For static buffers, we simply fill as much data as we can. For
// streaming buffers we only fill the halves of the buffer that are processed. Unprocessed halves must keep their audio data in-tact.
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{
if (framesRead >= frameCount) break;
}
else
{
if (isSubBufferProcessed[currentSubBufferIndex]) break;
}
mal_uint32 totalFramesRemaining = (frameCount - framesRead);
if (totalFramesRemaining == 0) break;
mal_uint32 framesRemainingInOutputBuffer;
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{
framesRemainingInOutputBuffer = audioBuffer->bufferSizeInFrames - audioBuffer->frameCursorPos;
}
else
{
mal_uint32 firstFrameIndexOfThisSubBuffer = subBufferSizeInFrames * currentSubBufferIndex;
framesRemainingInOutputBuffer = subBufferSizeInFrames - (audioBuffer->frameCursorPos - firstFrameIndexOfThisSubBuffer);
}
mal_uint32 framesToRead = totalFramesRemaining;
if (framesToRead > framesRemainingInOutputBuffer) framesToRead = framesRemainingInOutputBuffer;
memcpy((unsigned char *)pFramesOut + (framesRead*frameSizeInBytes), audioBuffer->buffer + (audioBuffer->frameCursorPos*frameSizeInBytes), framesToRead*frameSizeInBytes);
audioBuffer->frameCursorPos = (audioBuffer->frameCursorPos + framesToRead) % audioBuffer->bufferSizeInFrames;
framesRead += framesToRead;
// If we've read to the end of the buffer, mark it as processed.
if (framesToRead == framesRemainingInOutputBuffer)
{
audioBuffer->isSubBufferProcessed[currentSubBufferIndex] = true;
isSubBufferProcessed[currentSubBufferIndex] = true;
currentSubBufferIndex = (currentSubBufferIndex + 1) % 2;
// We need to break from this loop if we're not looping.
if (!audioBuffer->looping)
{
StopAudioBuffer(audioBuffer);
break;
}
}
}
// Zero-fill excess.
mal_uint32 totalFramesRemaining = (frameCount - framesRead);
if (totalFramesRemaining > 0)
{
memset((unsigned char*)pFramesOut + (framesRead*frameSizeInBytes), 0, totalFramesRemaining*frameSizeInBytes);
// For static buffers we can fill the remaining frames with silence for safety, but we don't want
// to report those frames as "read". The reason for this is that the caller uses the return value
// to know whether or not a non-looping sound has finished playback.
if (audioBuffer->usage != AUDIO_BUFFER_USAGE_STATIC) framesRead += totalFramesRemaining;
}
return framesRead;
}
// Create a new audio buffer. Initially filled with silence.
AudioBuffer *CreateAudioBuffer(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_uint32 bufferSizeInFrames, AudioBufferUsage usage) AudioBuffer *CreateAudioBuffer(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, mal_uint32 bufferSizeInFrames, AudioBufferUsage usage)
{ {
AudioBuffer *audioBuffer = (AudioBuffer *)calloc(sizeof(*audioBuffer) + (bufferSizeInFrames*channels*mal_get_sample_size_in_bytes(format)), 1); AudioBuffer *audioBuffer = (AudioBuffer *)calloc(sizeof(*audioBuffer) + (bufferSizeInFrames*channels*mal_get_sample_size_in_bytes(format)), 1);
@@ -668,7 +656,7 @@ AudioBuffer *CreateAudioBuffer(mal_format format, mal_uint32 channels, mal_uint3
dspConfig.channelsOut = DEVICE_CHANNELS; dspConfig.channelsOut = DEVICE_CHANNELS;
dspConfig.sampleRateIn = sampleRate; dspConfig.sampleRateIn = sampleRate;
dspConfig.sampleRateOut = DEVICE_SAMPLE_RATE; dspConfig.sampleRateOut = DEVICE_SAMPLE_RATE;
mal_result resultMAL = mal_dsp_init(&dspConfig, AudioBuffer_OnDSPRead, audioBuffer, &audioBuffer->dsp); mal_result resultMAL = mal_dsp_init(&dspConfig, OnAudioBufferDSPRead, audioBuffer, &audioBuffer->dsp);
if (resultMAL != MAL_SUCCESS) if (resultMAL != MAL_SUCCESS)
{ {
TraceLog(LOG_ERROR, "LoadSoundFromWave() : Failed to create data conversion pipeline"); TraceLog(LOG_ERROR, "LoadSoundFromWave() : Failed to create data conversion pipeline");
@@ -694,7 +682,7 @@ AudioBuffer *CreateAudioBuffer(mal_format format, mal_uint32 channels, mal_uint3
return audioBuffer; return audioBuffer;
} }
// Delete an audio buffer. // Delete an audio buffer
void DeleteAudioBuffer(AudioBuffer *audioBuffer) void DeleteAudioBuffer(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -707,7 +695,7 @@ void DeleteAudioBuffer(AudioBuffer *audioBuffer)
free(audioBuffer); free(audioBuffer);
} }
// Check if an audio buffer is playing. // Check if an audio buffer is playing
bool IsAudioBufferPlaying(AudioBuffer *audioBuffer) bool IsAudioBufferPlaying(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -719,10 +707,9 @@ bool IsAudioBufferPlaying(AudioBuffer *audioBuffer)
return audioBuffer->playing && !audioBuffer->paused; return audioBuffer->playing && !audioBuffer->paused;
} }
// Play an audio buffer. // Play an audio buffer
// // NOTE: Buffer is restarted to the start.
// This will restart the buffer from the start. Use PauseAudioBuffer() and ResumeAudioBuffer() if the playback position // Use PauseAudioBuffer() and ResumeAudioBuffer() if the playback position should be maintained.
// should be maintained.
void PlayAudioBuffer(AudioBuffer *audioBuffer) void PlayAudioBuffer(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -736,7 +723,7 @@ void PlayAudioBuffer(AudioBuffer *audioBuffer)
audioBuffer->frameCursorPos = 0; audioBuffer->frameCursorPos = 0;
} }
// Stop an audio buffer. // Stop an audio buffer
void StopAudioBuffer(AudioBuffer *audioBuffer) void StopAudioBuffer(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -755,7 +742,7 @@ void StopAudioBuffer(AudioBuffer *audioBuffer)
audioBuffer->isSubBufferProcessed[1] = true; audioBuffer->isSubBufferProcessed[1] = true;
} }
// Pause an audio buffer. // Pause an audio buffer
void PauseAudioBuffer(AudioBuffer *audioBuffer) void PauseAudioBuffer(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -767,7 +754,7 @@ void PauseAudioBuffer(AudioBuffer *audioBuffer)
audioBuffer->paused = true; audioBuffer->paused = true;
} }
// Resume an audio buffer. // Resume an audio buffer
void ResumeAudioBuffer(AudioBuffer *audioBuffer) void ResumeAudioBuffer(AudioBuffer *audioBuffer)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -779,7 +766,7 @@ void ResumeAudioBuffer(AudioBuffer *audioBuffer)
audioBuffer->paused = false; audioBuffer->paused = false;
} }
// Set volume for an audio buffer. // Set volume for an audio buffer
void SetAudioBufferVolume(AudioBuffer *audioBuffer, float volume) void SetAudioBufferVolume(AudioBuffer *audioBuffer, float volume)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -791,7 +778,7 @@ void SetAudioBufferVolume(AudioBuffer *audioBuffer, float volume)
audioBuffer->volume = volume; audioBuffer->volume = volume;
} }
// Set pitch for an audio buffer. // Set pitch for an audio buffer
void SetAudioBufferPitch(AudioBuffer *audioBuffer, float pitch) void SetAudioBufferPitch(AudioBuffer *audioBuffer, float pitch)
{ {
if (audioBuffer == NULL) if (audioBuffer == NULL)
@@ -807,6 +794,44 @@ void SetAudioBufferPitch(AudioBuffer *audioBuffer, float pitch)
mal_uint32 newOutputSampleRate = (mal_uint32)((((float)audioBuffer->dsp.config.sampleRateOut / (float)audioBuffer->dsp.config.sampleRateIn) / pitch) * audioBuffer->dsp.config.sampleRateIn); mal_uint32 newOutputSampleRate = (mal_uint32)((((float)audioBuffer->dsp.config.sampleRateOut / (float)audioBuffer->dsp.config.sampleRateIn) / pitch) * audioBuffer->dsp.config.sampleRateIn);
mal_dsp_set_output_sample_rate(&audioBuffer->dsp, newOutputSampleRate); mal_dsp_set_output_sample_rate(&audioBuffer->dsp, newOutputSampleRate);
} }
// Track audio buffer to linked list next position
void TrackAudioBuffer(AudioBuffer *audioBuffer)
{
mal_mutex_lock(&audioLock);
{
if (firstAudioBuffer == NULL) firstAudioBuffer = audioBuffer;
else
{
lastAudioBuffer->next = audioBuffer;
audioBuffer->prev = lastAudioBuffer;
}
lastAudioBuffer = audioBuffer;
}
mal_mutex_unlock(&audioLock);
}
// Untrack audio buffer from linked list
void UntrackAudioBuffer(AudioBuffer *audioBuffer)
{
mal_mutex_lock(&audioLock);
{
if (audioBuffer->prev == NULL) firstAudioBuffer = audioBuffer->next;
else audioBuffer->prev->next = audioBuffer->next;
if (audioBuffer->next == NULL) lastAudioBuffer = audioBuffer->prev;
else audioBuffer->next->prev = audioBuffer->prev;
audioBuffer->prev = NULL;
audioBuffer->next = NULL;
}
mal_mutex_unlock(&audioLock);
}
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@@ -883,13 +908,13 @@ Sound LoadSoundFromWave(Wave wave)
mal_uint32 frameCountIn = wave.sampleCount; // Is wave->sampleCount actually the frame count? That terminology needs to change, if so. mal_uint32 frameCountIn = wave.sampleCount; // Is wave->sampleCount actually the frame count? That terminology needs to change, if so.
mal_uint32 frameCount = mal_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn); mal_uint32 frameCount = mal_convert_frames(NULL, DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, NULL, formatIn, wave.channels, wave.sampleRate, frameCountIn);
if (frameCount == 0) TraceLog(LOG_ERROR, "LoadSoundFromWave() : Failed to get frame count for format conversion"); if (frameCount == 0) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Failed to get frame count for format conversion");
AudioBuffer* audioBuffer = CreateAudioBuffer(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, frameCount, AUDIO_BUFFER_USAGE_STATIC); AudioBuffer* audioBuffer = CreateAudioBuffer(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, frameCount, AUDIO_BUFFER_USAGE_STATIC);
if (audioBuffer == NULL) TraceLog(LOG_ERROR, "LoadSoundFromWave() : Failed to create audio buffer"); if (audioBuffer == NULL) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Failed to create audio buffer");
frameCount = mal_convert_frames(audioBuffer->buffer, audioBuffer->dsp.config.formatIn, audioBuffer->dsp.config.channelsIn, audioBuffer->dsp.config.sampleRateIn, wave.data, formatIn, wave.channels, wave.sampleRate, frameCountIn); frameCount = mal_convert_frames(audioBuffer->buffer, audioBuffer->dsp.config.formatIn, audioBuffer->dsp.config.channelsIn, audioBuffer->dsp.config.sampleRateIn, wave.data, formatIn, wave.channels, wave.sampleRate, frameCountIn);
if (frameCount == 0) TraceLog(LOG_ERROR, "LoadSoundFromWave() : Format conversion failed"); if (frameCount == 0) TraceLog(LOG_WARNING, "LoadSoundFromWave() : Format conversion failed");
sound.audioBuffer = audioBuffer; sound.audioBuffer = audioBuffer;
#else #else
@@ -1522,7 +1547,7 @@ void UpdateMusicStream(Music music)
case MUSIC_AUDIO_OGG: case MUSIC_AUDIO_OGG:
{ {
// NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!) // NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!)
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels); stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels);
} break; } break;
#if defined(SUPPORT_FILEFORMAT_FLAC) #if defined(SUPPORT_FILEFORMAT_FLAC)
@@ -1853,7 +1878,7 @@ void CloseAudioStream(AudioStream stream)
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount) void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount)
{ {
#if USE_MINI_AL #if USE_MINI_AL
AudioBuffer* audioBuffer = (AudioBuffer*)stream.audioBuffer; AudioBuffer *audioBuffer = (AudioBuffer *)stream.audioBuffer;
if (audioBuffer == NULL) if (audioBuffer == NULL)
{ {
TraceLog(LOG_ERROR, "UpdateAudioStream() : No audio buffer"); TraceLog(LOG_ERROR, "UpdateAudioStream() : No audio buffer");

129
src/config.h Normal file
View File

@@ -0,0 +1,129 @@
/**********************************************************************************************
*
* raylib configuration flags
*
* This file defines all the configuration flags for the different raylib modules
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2018 Ahmad Fatoum & 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 RAYLIB_VERSION "1.9.7-dev"
// Edit to control what features Makefile'd raylib is compiled with
#if defined(RAYLIB_CMAKE)
// Edit CMakeOptions.txt for CMake instead
#include "cmake/config.h"
#else
//------------------------------------------------------------------------------------
// Module: core - Configuration Flags
//------------------------------------------------------------------------------------
// Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
#define SUPPORT_CAMERA_SYSTEM 1
// Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag
#define SUPPORT_GESTURES_SYSTEM 1
// Mouse gestures are directly mapped like touches and processed by gestures system
#define SUPPORT_MOUSE_GESTURES 1
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
#define SUPPORT_BUSY_WAIT_LOOP 1
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
#define SUPPORT_GIF_RECORDING 1
//------------------------------------------------------------------------------------
// Module: rlgl - Configuration Flags
//------------------------------------------------------------------------------------
// Support VR simulation functionality (stereo rendering)
#define SUPPORT_VR_SIMULATOR 1
// Include stereo rendering distortion shader (shader_distortion.h)
#define SUPPORT_DISTORTION_SHADER 1
//------------------------------------------------------------------------------------
// Module: textures - Configuration Flags
//------------------------------------------------------------------------------------
// Selecte desired fileformats to be supported for image data loading
#define SUPPORT_FILEFORMAT_PNG 1
//#define SUPPORT_FILEFORMAT_BMP 1
//#define SUPPORT_FILEFORMAT_TGA 1
//#define SUPPORT_FILEFORMAT_JPG 1
//#define SUPPORT_FILEFORMAT_GIF 1
//#define SUPPORT_FILEFORMAT_PSD 1
#define SUPPORT_FILEFORMAT_DDS 1
#define SUPPORT_FILEFORMAT_HDR 1
#define SUPPORT_FILEFORMAT_KTX 1
#define SUPPORT_FILEFORMAT_ASTC 1
//#define SUPPORT_FILEFORMAT_PKM 1
//#define SUPPORT_FILEFORMAT_PVR 1
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
// If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()
#define SUPPORT_IMAGE_MANIPULATION 1
// Support proedural image generation functionality (gradient, spot, perlin-noise, cellular)
#define SUPPORT_IMAGE_GENERATION 1
//------------------------------------------------------------------------------------
// Module: text - Configuration Flags
//------------------------------------------------------------------------------------
// Default font is loaded on window initialization to be available for the user to render simple text
// NOTE: If enabled, uses external module functions to load default raylib font
#define SUPPORT_DEFAULT_FONT 1
// Selected desired font fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_FNT 1
#define SUPPORT_FILEFORMAT_TTF 1
//------------------------------------------------------------------------------------
// Module: models - Configuration Flags
//------------------------------------------------------------------------------------
// Selected desired model fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_OBJ 1
#define SUPPORT_FILEFORMAT_MTL 1
// Support procedural mesh generation functions, uses external par_shapes.h library
// NOTE: Some generated meshes DO NOT include generated texture coordinates
#define SUPPORT_MESH_GENERATION 1
//------------------------------------------------------------------------------------
// Module: audio - Configuration Flags
//------------------------------------------------------------------------------------
// Desired audio fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_WAV 1
#define SUPPORT_FILEFORMAT_OGG 1
#define SUPPORT_FILEFORMAT_XM 1
#define SUPPORT_FILEFORMAT_MOD 1
//#define SUPPORT_FILEFORMAT_FLAC 1
//------------------------------------------------------------------------------------
// Module: utils - Configuration Flags
//------------------------------------------------------------------------------------
// Show TraceLog() output messages
// NOTE: By default LOG_DEBUG traces not shown
#define SUPPORT_TRACELOG 1
// Support saving image data fileformats
// NOTE: Requires stb_image_write library
#define SUPPORT_SAVE_PNG 1
//#define SUPPORT_SAVE_BMP 1
#endif //defined(RAYLIB_CMAKE)

74
src/config.h.in Normal file
View File

@@ -0,0 +1,74 @@
/* config.h.in */
// text.c
/* Default font is loaded on window initialization to be available for the user to render simple text. NOTE: If enabled, uses external module functions to load default raylib font (module: text) */
#cmakedefine SUPPORT_DEFAULT_FONT 1
/* Selected desired fileformats to be supported for loading. */
#cmakedefine SUPPORT_FILEFORMAT_FNT 1
#cmakedefine SUPPORT_FILEFORMAT_TTF 1
// textures.c
/* Selecte desired fileformats to be supported for image data loading. */
#cmakedefine SUPPORT_FILEFORMAT_PNG 1
#cmakedefine SUPPORT_FILEFORMAT_DDS 1
#cmakedefine SUPPORT_FILEFORMAT_HDR 1
#cmakedefine SUPPORT_FILEFORMAT_KTX 1
#cmakedefine SUPPORT_FILEFORMAT_ASTC 1
#cmakedefine SUPPORT_FILEFORMAT_BMP 1
#cmakedefine SUPPORT_FILEFORMAT_TGA 1
#cmakedefine SUPPORT_FILEFORMAT_JPG 1
#cmakedefine SUPPORT_FILEFORMAT_GIF 1
#cmakedefine SUPPORT_FILEFORMAT_PSD 1
#cmakedefine SUPPORT_FILEFORMAT_PKM 1
#cmakedefine SUPPORT_FILEFORMAT_PVR 1
/* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT() */
#cmakedefine SUPPORT_IMAGE_MANIPULATION 1
/* Support proedural image generation functionality (gradient, spot, perlin-noise, cellular) */
#cmakedefine SUPPORT_IMAGE_GENERATION 1
// rlgl.c
/* Support VR simulation functionality (stereo rendering) */
#cmakedefine SUPPORT_VR_SIMULATOR 1
/* Include stereo rendering distortion shader (shader_distortion.h) */
#cmakedefine SUPPORT_DISTORTION_SHADER 1
// core.c
/* Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital */
#cmakedefine SUPPORT_CAMERA_SYSTEM 1
/* Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag */
#cmakedefine SUPPORT_GESTURES_SYSTEM 1
/* Mouse gestures are directly mapped like touches and processed by gestures system. */
#cmakedefine SUPPORT_MOUSE_GESTURES 1
/* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used */
#cmakedefine SUPPORT_BUSY_WAIT_LOOP 1
/* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() */
#cmakedefine SUPPORT_GIF_RECORDING 1
// audio.c
/* Desired fileformats to be supported for loading. */
#cmakedefine SUPPORT_FILEFORMAT_WAV 1
#cmakedefine SUPPORT_FILEFORMAT_OGG 1
#cmakedefine SUPPORT_FILEFORMAT_XM 1
#cmakedefine SUPPORT_FILEFORMAT_MOD 1
#cmakedefine SUPPORT_FILEFORMAT_FLAC 1
// models.c
/* Selected desired fileformats to be supported for loading. */
#cmakedefine SUPPORT_FILEFORMAT_OBJ 1
#cmakedefine SUPPORT_FILEFORMAT_MTL 1
/* Support procedural mesh generation functions, uses external par_shapes.h library
* NOTE: Some generated meshes DO NOT include generated texture coordinates
*/
#cmakedefine SUPPORT_MESH_GENERATION 1
// utils.c
/* Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown */
#cmakedefine SUPPORT_TRACELOG 1
/* Support saving image data as PNG fileformat. NOTE: Requires stb_image_write library */
#cmakedefine SUPPORT_SAVE_PNG 1
/* Support saving image data as PMP fileformat. NOTE: Requires stb_image_write library */
#cmakedefine SUPPORT_SAVE_BMP 1

View File

@@ -48,7 +48,7 @@
* Mouse gestures are directly mapped like touches and processed by gestures system. * Mouse gestures are directly mapped like touches and processed by gestures system.
* *
* #define SUPPORT_BUSY_WAIT_LOOP * #define SUPPORT_BUSY_WAIT_LOOP
* Use busy wait loop for timming sync, if not defined, a high-resolution timer is setup and used * Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
* *
* #define SUPPORT_GIF_RECORDING * #define SUPPORT_GIF_RECORDING
* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() * Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
@@ -81,15 +81,7 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features) #include "config.h"
//-------------------------------------------------
#define SUPPORT_DEFAULT_FONT
#define SUPPORT_MOUSE_GESTURES
#define SUPPORT_CAMERA_SYSTEM
#define SUPPORT_GESTURES_SYSTEM
#define SUPPORT_BUSY_WAIT_LOOP
#define SUPPORT_GIF_RECORDING
//-------------------------------------------------
#include "raylib.h" #include "raylib.h"
@@ -98,13 +90,12 @@
#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
#endif #endif
#define RAYMATH_IMPLEMENTATION // Define external out-of-line implementation of raymath here
#include "raymath.h" // Required for: Vector3 and Matrix functions
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
#include "utils.h" // Required for: fopen() Android mapping #include "utils.h" // Required for: fopen() Android mapping
#define RAYMATH_IMPLEMENTATION // Use raymath as a header-only library (includes implementation)
#define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint)
#include "raymath.h" // Required for: Vector3 and Matrix functions
#if defined(SUPPORT_GESTURES_SYSTEM) #if defined(SUPPORT_GESTURES_SYSTEM)
#define GESTURES_IMPLEMENTATION #define GESTURES_IMPLEMENTATION
#include "gestures.h" // Gestures detection functionality #include "gestures.h" // Gestures detection functionality
@@ -127,6 +118,7 @@
#include <math.h> // Required for: tan() [Used in Begin3dMode() to set perspective] #include <math.h> // Required for: tan() [Used in Begin3dMode() to set perspective]
#include <string.h> // Required for: strrchr(), strcmp() #include <string.h> // Required for: strrchr(), strcmp()
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes //#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#include <ctype.h> // Required for: tolower() [Used in IsFileExtension()]
#if defined(_WIN32) #if defined(_WIN32)
#include <direct.h> // Required for: _getch(), _chdir() #include <direct.h> // Required for: _getch(), _chdir()
@@ -238,9 +230,10 @@ static GLFWwindow *window; // Native window (graphic device
static bool windowReady = false; // Check if window has been initialized successfully static bool windowReady = false; // Check if window has been initialized successfully
static bool windowMinimized = false; // Check if window has been minimized static bool windowMinimized = false; // Check if window has been minimized
static const char *windowTitle = NULL; // Window text title...
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
static struct android_app *app; // Android activity static struct android_app *androidApp; // Android activity
static struct android_poll_source *source; // Android events polling source static struct android_poll_source *source; // Android events polling source
static int ident, events; // Android ALooper_pollAll() variables static int ident, events; // Android ALooper_pollAll() variables
static const char *internalDataPath; // Android internal data path to write data (/data/data/<package>/files) static const char *internalDataPath; // Android internal data path to write data (/data/data/<package>/files)
@@ -283,10 +276,10 @@ static bool windowShouldClose = false; // Flag to set window for closing
#endif #endif
#if defined(PLATFORM_UWP) #if defined(PLATFORM_UWP)
static EGLNativeWindowType uwpWindow; extern EGLNativeWindowType uwpWindow; // Native EGL window handler for UWP (external, defined in UWP App)
#endif #endif
// Display size-related data // Screen related variables
static unsigned int displayWidth, displayHeight; // Display width and height (monitor, device-screen, LCD, ...) static unsigned int displayWidth, displayHeight; // Display width and height (monitor, device-screen, LCD, ...)
static int screenWidth, screenHeight; // Screen width and height (used render area) static int screenWidth, screenHeight; // Screen width and height (used render area)
static int renderWidth, renderHeight; // Framebuffer width and height (render area, including black bars if required) static int renderWidth, renderHeight; // Framebuffer width and height (render area, including black bars if required)
@@ -295,10 +288,10 @@ static int renderOffsetY = 0; // Offset Y from render area (must b
static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP) static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP)
static Matrix downscaleView; // Matrix to downscale view (in case screen size bigger than display size) static Matrix downscaleView; // Matrix to downscale view (in case screen size bigger than display size)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
static const char *windowTitle = NULL; // Window text title...
static bool cursorHidden = false; // Track if cursor is hidden static bool cursorHidden = false; // Track if cursor is hidden
static bool cursorOnScreen = false; // Tracks if cursor is inside client area static bool cursorOnScreen = false; // Tracks if cursor is inside client area
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
static int screenshotCounter = 0; // Screenshots counter static int screenshotCounter = 0; // Screenshots counter
// Register mouse states // Register mouse states
@@ -326,6 +319,7 @@ static int lastGamepadButtonPressed = -1; // Register last gamepad button pres
static int gamepadAxisCount = 0; // Register number of available gamepad axis static int gamepadAxisCount = 0; // Register number of available gamepad axis
static Vector2 mousePosition; // Mouse position on screen static Vector2 mousePosition; // Mouse position on screen
static float mouseScale = 1.0f; // Mouse default scale
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click
@@ -338,8 +332,10 @@ static char **dropFilesPath; // Store dropped files paths as stri
static int dropFilesCount = 0; // Count stored strings static int dropFilesCount = 0; // Count stored strings
#endif #endif
static double currentTime, previousTime; // Used to track timmings static double currentTime = 0.0; // Current time measure
static double updateTime, drawTime; // Time measures for update and draw static double previousTime = 0.0; // Previous time measure
static double updateTime = 0.0; // Time measure for frame update
static double drawTime = 0.0; // Time measure for frame draw
static double frameTime = 0.0; // Time measure for one frame static double frameTime = 0.0; // Time measure for one frame
static double targetTime = 0.0; // Desired time for one frame, if 0 not applied static double targetTime = 0.0; // Desired time for one frame, if 0 not applied
@@ -415,7 +411,7 @@ static void *GamepadThread(void *arg); // Mouse reading thread
#endif #endif
#if defined(PLATFORM_UWP) #if defined(PLATFORM_UWP)
// Define functions required to manage inputs // TODO: Define functions required to manage inputs
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
@@ -426,24 +422,93 @@ static void *GamepadThread(void *arg); // Mouse reading thread
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition - Window and OpenGL Context Functions // Module Functions Definition - Window and OpenGL Context Functions
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
#if defined(PLATFORM_ANDROID)
// To allow easier porting to android, we allow the user to define a
// main function which we call from android_main, defined by ourselves
extern int main(int argc, char *argv[]);
void android_main(struct android_app *app)
{
char arg0[] = "raylib"; // NOTE: argv[] are mutable
androidApp = app;
// TODO: Should we maybe report != 0 return codes somewhere?
(void)main(1, (char*[]) { arg0, NULL });
}
// TODO: Add this to header (if apps really need it)
struct android_app *GetAndroidApp(void)
{
return androidApp;
}
#endif
// Initialize window and OpenGL context // Initialize window and OpenGL context
// NOTE: data parameter could be used to pass any kind of required data to the initialization // NOTE: data parameter could be used to pass any kind of required data to the initialization
void InitWindow(int width, int height, void *data) void InitWindow(int width, int height, const char *title)
{ {
TraceLog(LOG_INFO, "Initializing raylib (v1.9.4-dev)"); TraceLog(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
#if defined(PLATFORM_DESKTOP) windowTitle = title;
windowTitle = (char *)data; #if defined(PLATFORM_ANDROID)
#endif screenWidth = width;
screenHeight = height;
#if defined(PLATFORM_UWP) // Input data is android app pointer
uwpWindow = (EGLNativeWindowType)data; internalDataPath = androidApp->activity->internalDataPath;
#endif
// Set desired windows flags before initializing anything
ANativeActivity_setWindowFlags(androidApp->activity, AWINDOW_FLAG_FULLSCREEN, 0); //AWINDOW_FLAG_SCALED, AWINDOW_FLAG_DITHER
//ANativeActivity_setWindowFlags(androidApp->activity, AWINDOW_FLAG_FORCE_NOT_FULLSCREEN, AWINDOW_FLAG_FULLSCREEN);
int orientation = AConfiguration_getOrientation(androidApp->config);
if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(LOG_INFO, "PORTRAIT window orientation");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(LOG_INFO, "LANDSCAPE window orientation");
// TODO: Automatic orientation doesn't seem to work
if (width <= height)
{
AConfiguration_setOrientation(androidApp->config, ACONFIGURATION_ORIENTATION_PORT);
TraceLog(LOG_WARNING, "Window set to portraid mode");
}
else
{
AConfiguration_setOrientation(androidApp->config, ACONFIGURATION_ORIENTATION_LAND);
TraceLog(LOG_WARNING, "Window set to landscape mode");
}
//AConfiguration_getDensity(androidApp->config);
//AConfiguration_getKeyboard(androidApp->config);
//AConfiguration_getScreenSize(androidApp->config);
//AConfiguration_getScreenLong(androidApp->config);
androidApp->onAppCmd = AndroidCommandCallback;
androidApp->onInputEvent = AndroidInputCallback;
InitAssetManager(androidApp->activity->assetManager);
TraceLog(LOG_INFO, "Android app initialized successfully");
// Wait for window to be initialized (display and context)
while (!windowReady)
{
// Process events loop
while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
{
// Process this event
if (source != NULL) source->process(androidApp, source);
// NOTE: Never close window, native activity is controlled by the system!
//if (androidApp->destroyRequested != 0) windowShouldClose = true;
}
}
#else
// Init graphics device (display device and OpenGL context) // Init graphics device (display device and OpenGL context)
// NOTE: returns true if window and graphic device has been initialized successfully // NOTE: returns true if window and graphic device has been initialized successfully
windowReady = InitGraphicsDevice(width, height); windowReady = InitGraphicsDevice(width, height);
if (!windowReady) return;
// Init hi-res timer // Init hi-res timer
InitTimer(); InitTimer();
@@ -493,71 +558,8 @@ void InitWindow(int width, int height, void *data)
SetTargetFPS(60); SetTargetFPS(60);
LogoAnimation(); LogoAnimation();
} }
#endif // defined(PLATFORM_ANDROID)
} }
#endif
#if defined(PLATFORM_ANDROID)
// Initialize window and OpenGL context (and Android activity)
// NOTE: data parameter could be used to pass any kind of required data to the initialization
void InitWindow(int width, int height, void *data)
{
TraceLog(LOG_INFO, "Initializing raylib (v1.9.4-dev)");
screenWidth = width;
screenHeight = height;
// Input data is android app pointer
app = (struct android_app *)data;
internalDataPath = app->activity->internalDataPath;
// Set desired windows flags before initializing anything
ANativeActivity_setWindowFlags(app->activity, AWINDOW_FLAG_FULLSCREEN, 0); //AWINDOW_FLAG_SCALED, AWINDOW_FLAG_DITHER
//ANativeActivity_setWindowFlags(app->activity, AWINDOW_FLAG_FORCE_NOT_FULLSCREEN, AWINDOW_FLAG_FULLSCREEN);
int orientation = AConfiguration_getOrientation(app->config);
if (orientation == ACONFIGURATION_ORIENTATION_PORT) TraceLog(LOG_INFO, "PORTRAIT window orientation");
else if (orientation == ACONFIGURATION_ORIENTATION_LAND) TraceLog(LOG_INFO, "LANDSCAPE window orientation");
// TODO: Automatic orientation doesn't seem to work
if (width <= height)
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_PORT);
TraceLog(LOG_WARNING, "Window set to portraid mode");
}
else
{
AConfiguration_setOrientation(app->config, ACONFIGURATION_ORIENTATION_LAND);
TraceLog(LOG_WARNING, "Window set to landscape mode");
}
//AConfiguration_getDensity(app->config);
//AConfiguration_getKeyboard(app->config);
//AConfiguration_getScreenSize(app->config);
//AConfiguration_getScreenLong(app->config);
app->onAppCmd = AndroidCommandCallback;
app->onInputEvent = AndroidInputCallback;
InitAssetManager(app->activity->assetManager);
TraceLog(LOG_INFO, "Android app initialized successfully");
// Wait for window to be initialized (display and context)
while (!windowReady)
{
// Process events loop
while ((ident = ALooper_pollAll(0, NULL, &events,(void**)&source)) >= 0)
{
// Process this event
if (source != NULL) source->process(app, source);
// NOTE: Never close window, native activity is controlled by the system!
//if (app->destroyRequested != 0) windowShouldClose = true;
}
}
}
#endif
// Close window and unload OpenGL context // Close window and unload OpenGL context
void CloseWindow(void) void CloseWindow(void)
@@ -735,6 +737,15 @@ void SetWindowMinSize(int width, int height)
#endif #endif
} }
// Set window dimensions
void SetWindowSize(int width, int height)
{
#if defined(PLATFORM_DESKTOP)
glfwSetWindowSize(window, width, height);
#endif
}
// Get current screen width // Get current screen width
int GetScreenWidth(void) int GetScreenWidth(void)
{ {
@@ -751,11 +762,7 @@ int GetScreenHeight(void)
void ShowCursor() void ShowCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#if defined(__linux__) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window));
#else
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#endif
#endif #endif
cursorHidden = false; cursorHidden = false;
} }
@@ -764,18 +771,7 @@ void ShowCursor()
void HideCursor() void HideCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#if defined(__linux__) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
XColor col;
const char nil[] = {0};
Pixmap pix = XCreateBitmapFromData(glfwGetX11Display(), glfwGetX11Window(window), nil, 1, 1);
Cursor cur = XCreatePixmapCursor(glfwGetX11Display(), pix, pix, &col, &col, 0, 0);
XDefineCursor(glfwGetX11Display(), glfwGetX11Window(window), cur);
XFreeCursor(glfwGetX11Display(), cur);
#else
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
#endif
#endif #endif
cursorHidden = true; cursorHidden = true;
} }
@@ -923,13 +919,26 @@ void Begin3dMode(Camera camera)
rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection
rlLoadIdentity(); // Reset current matrix (PROJECTION) rlLoadIdentity(); // Reset current matrix (PROJECTION)
// Setup perspective projection
float aspect = (float)screenWidth/(float)screenHeight; float aspect = (float)screenWidth/(float)screenHeight;
double top = 0.01*tan(camera.fovy*0.5*DEG2RAD);
double right = top*aspect; if(camera.type == CAMERA_PERSPECTIVE)
{
// Setup perspective projection
double top = 0.01*tan(camera.fovy*0.5*DEG2RAD);
double right = top*aspect;
rlFrustum(-right, right, -top, top, 0.01, 1000.0);
}
else if(camera.type == CAMERA_ORTHOGRAPHIC)
{
// Setup orthographic projection
double top = camera.fovy/2.0;
double right = top*aspect;
rlOrtho(-right,right,-top,top, 0.01, 1000.0);
}
// NOTE: zNear and zFar values are important when computing depth buffer values // NOTE: zNear and zFar values are important when computing depth buffer values
rlFrustum(-right, right, -top, top, 0.01, 1000.0);
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
rlLoadIdentity(); // Reset current matrix (MODELVIEW) rlLoadIdentity(); // Reset current matrix (MODELVIEW)
@@ -1017,22 +1026,47 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
TraceLog(LOG_DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z); TraceLog(LOG_DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
// Calculate projection matrix from perspective
Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
// Calculate view matrix from camera look at // Calculate view matrix from camera look at
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
Matrix matProj;
if(camera.type == CAMERA_PERSPECTIVE)
{
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
}
else if(camera.type == CAMERA_ORTHOGRAPHIC)
{
float aspect = (float)screenWidth/(float)screenHeight;
double top = camera.fovy/2.0;
double right = top*aspect;
// Calculate projection matrix from orthographic
matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0);
}
// Unproject far/near points // Unproject far/near points
Vector3 nearPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView); Vector3 nearPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView);
Vector3 farPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView); Vector3 farPoint = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
// Unproject the mouse cursor in the near plane.
// We need this as the source position because orthographic projects, compared to perspect doesn't have a
// convergence point, meaning that the "eye" of the camera is more like a plane than a point.
Vector3 cameraPlanePointerPos = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
// Calculate normalized direction vector // Calculate normalized direction vector
Vector3 direction = Vector3Subtract(farPoint, nearPoint); Vector3 direction = Vector3Normalize(Vector3Subtract(farPoint, nearPoint));
Vector3Normalize(&direction);
if(camera.type == CAMERA_PERSPECTIVE)
{
ray.position = camera.position;
}
else if(camera.type == CAMERA_ORTHOGRAPHIC)
{
ray.position = cameraPlanePointerPos;
}
// Apply calculated vectors to ray // Apply calculated vectors to ray
ray.position = camera.position;
ray.direction = direction; ray.direction = direction;
return ray; return ray;
@@ -1042,7 +1076,21 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
Vector2 GetWorldToScreen(Vector3 position, Camera camera) Vector2 GetWorldToScreen(Vector3 position, Camera camera)
{ {
// Calculate projection matrix (from perspective instead of frustum // Calculate projection matrix (from perspective instead of frustum
Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0); Matrix matProj;
if(camera.type == CAMERA_PERSPECTIVE)
{
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
}
else if(camera.type == CAMERA_ORTHOGRAPHIC)
{
float aspect = (float)screenWidth/(float)screenHeight;
double top = camera.fovy/2.0;
double right = top*aspect;
// Calculate projection matrix from orthographic
matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0);
}
// Calculate view matrix from camera look at (and transpose it) // Calculate view matrix from camera look at (and transpose it)
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
@@ -1051,10 +1099,10 @@ Vector2 GetWorldToScreen(Vector3 position, Camera camera)
Quaternion worldPos = { position.x, position.y, position.z, 1.0f }; Quaternion worldPos = { position.x, position.y, position.z, 1.0f };
// Transform world position to view // Transform world position to view
QuaternionTransform(&worldPos, matView); worldPos = QuaternionTransform(worldPos, matView);
// Transform result to projection (clip space position) // Transform result to projection (clip space position)
QuaternionTransform(&worldPos, matProj); worldPos = QuaternionTransform(worldPos, matProj);
// Calculate normalized device coordinates (inverted y) // Calculate normalized device coordinates (inverted y)
Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w }; Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w };
@@ -1111,7 +1159,7 @@ double GetTime(void)
#endif #endif
} }
// Converts Color to float array and normalizes // Returns normalized float array for a Color
float *ColorToFloat(Color color) float *ColorToFloat(Color color)
{ {
static float buffer[4]; static float buffer[4];
@@ -1124,6 +1172,64 @@ float *ColorToFloat(Color color)
return buffer; return buffer;
} }
// Returns hexadecimal value for a Color
int ColorToInt(Color color)
{
return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
}
// Returns HSV values for a Color
// NOTE: Hue is returned as degrees [0..360]
Vector3 ColorToHSV(Color color)
{
Vector3 rgb = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
Vector3 hsv = { 0.0f, 0.0f, 0.0f };
float min, max, delta;
min = rgb.x < rgb.y ? rgb.x : rgb.y;
min = min < rgb.z ? min : rgb.z;
max = rgb.x > rgb.y ? rgb.x : rgb.y;
max = max > rgb.z ? max : rgb.z;
hsv.z = max; // Value
delta = max - min;
if (delta < 0.00001f)
{
hsv.y = 0.0f;
hsv.x = 0.0f; // Undefined, maybe NAN?
return hsv;
}
if (max > 0.0f)
{
// NOTE: If max is 0, this divide would cause a crash
hsv.y = (delta/max); // Saturation
}
else
{
// NOTE: If max is 0, then r = g = b = 0, s = 0, h is undefined
hsv.y = 0.0f;
hsv.x = NAN; // Undefined
return hsv;
}
// NOTE: Comparing float values could not work properly
if (rgb.x >= max) hsv.x = (rgb.y - rgb.z)/delta; // Between yellow & magenta
else
{
if (rgb.y >= max) hsv.x = 2.0f + (rgb.z - rgb.x)/delta; // Between cyan & yellow
else hsv.x = 4.0f + (rgb.x - rgb.y)/delta; // Between magenta & cyan
}
hsv.x *= 60.0f; // Convert to degrees
if (hsv.x < 0.0f) hsv.x += 360.0f;
return hsv;
}
// Returns a Color struct from hexadecimal value // Returns a Color struct from hexadecimal value
Color GetColor(int hexValue) Color GetColor(int hexValue)
{ {
@@ -1137,11 +1243,7 @@ Color GetColor(int hexValue)
return color; return color;
} }
// Returns hexadecimal value for a Color
int GetHexValue(Color color)
{
return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a);
}
// Returns a random value between min and max (both included) // Returns a random value between min and max (both included)
int GetRandomValue(int min, int max) int GetRandomValue(int min, int max)
@@ -1202,7 +1304,24 @@ bool IsFileExtension(const char *fileName, const char *ext)
if ((fileExt = strrchr(fileName, '.')) != NULL) if ((fileExt = strrchr(fileName, '.')) != NULL)
{ {
#if defined(_WIN32)
result = true;
int extLen = strlen(ext);
if (strlen(fileExt) == extLen)
{
for (int i = 0; i < extLen; i++)
{
if (tolower(fileExt[i]) != tolower(ext[i]))
{
result = false;
break;
}
}
}
#else
if (strcmp(fileExt, ext) == 0) result = true; if (strcmp(fileExt, ext) == 0) result = true;
#endif
} }
return result; return result;
@@ -1213,7 +1332,7 @@ const char *GetExtension(const char *fileName)
{ {
const char *dot = strrchr(fileName, '.'); const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return ""; if (!dot || dot == fileName) return NULL;
return (dot + 1); return (dot + 1);
} }
@@ -1608,7 +1727,7 @@ int GetMouseX(void)
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
return (int)touchPosition[0].x; return (int)touchPosition[0].x;
#else #else
return (int)mousePosition.x; return (int)(mousePosition.x*mouseScale);
#endif #endif
} }
@@ -1618,7 +1737,7 @@ int GetMouseY(void)
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
return (int)touchPosition[0].x; return (int)touchPosition[0].x;
#else #else
return (int)mousePosition.y; return (int)(mousePosition.y*mouseScale);
#endif #endif
} }
@@ -1628,7 +1747,7 @@ Vector2 GetMousePosition(void)
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
return GetTouchPosition(0); return GetTouchPosition(0);
#else #else
return mousePosition; return (Vector2){ mousePosition.x*mouseScale, mousePosition.y*mouseScale };
#endif #endif
} }
@@ -1642,6 +1761,15 @@ void SetMousePosition(Vector2 position)
#endif #endif
} }
// Set mouse scaling
// NOTE: Useful when rendering to different size targets
void SetMouseScale(float scale)
{
#if !defined(PLATFORM_ANDROID)
mouseScale = scale;
#endif
}
// Returns mouse wheel movement Y // Returns mouse wheel movement Y
int GetMouseWheelMove(void) int GetMouseWheelMove(void)
{ {
@@ -1733,7 +1861,13 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: Getting video modes is not implemented in emscripten GLFW3 version // NOTE: Getting video modes is not implemented in emscripten GLFW3 version
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
// Find monitor resolution // Find monitor resolution
const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor()); GLFWmonitor *monitor = glfwGetPrimaryMonitor();
if (!monitor)
{
TraceLog(LOG_WARNING, "Failed to get monitor");
return false;
}
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
displayWidth = mode->width; displayWidth = mode->width;
displayHeight = mode->height; displayHeight = mode->height;
@@ -2061,7 +2195,7 @@ static bool InitGraphicsDevice(int width, int height)
} }
} }
//SetupFramebufferSize(displayWidth, displayHeight); //SetupFramebufferSize(displayWidth, displayHeight);
EGLint numConfigs = 0; EGLint numConfigs = 0;
if ((eglChooseConfig(display, framebufferAttribs, &config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) if ((eglChooseConfig(display, framebufferAttribs, &config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0))
@@ -2115,9 +2249,9 @@ static bool InitGraphicsDevice(int width, int height)
return false; return false;
} }
// Get EGL display window size // Get EGL display window size
eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth); eglQuerySurface(display, surface, EGL_WIDTH, &screenWidth);
eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight); eglQuerySurface(display, surface, EGL_HEIGHT, &screenHeight);
#else // PLATFORM_ANDROID, PLATFORM_RPI #else // PLATFORM_ANDROID, PLATFORM_RPI
EGLint numConfigs; EGLint numConfigs;
@@ -2158,8 +2292,8 @@ static bool InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
EGLint displayFormat; EGLint displayFormat;
displayWidth = ANativeWindow_getWidth(app->window); displayWidth = ANativeWindow_getWidth(androidApp->window);
displayHeight = ANativeWindow_getHeight(app->window); displayHeight = ANativeWindow_getHeight(androidApp->window);
// EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is guaranteed to be accepted by ANativeWindow_setBuffersGeometry() // EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is guaranteed to be accepted by ANativeWindow_setBuffersGeometry()
// As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID // As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID
@@ -2169,10 +2303,10 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: This function use and modify global module variables: screenWidth/screenHeight and renderWidth/renderHeight and downscaleView // NOTE: This function use and modify global module variables: screenWidth/screenHeight and renderWidth/renderHeight and downscaleView
SetupFramebufferSize(displayWidth, displayHeight); SetupFramebufferSize(displayWidth, displayHeight);
ANativeWindow_setBuffersGeometry(app->window, renderWidth, renderHeight, displayFormat); ANativeWindow_setBuffersGeometry(androidApp->window, renderWidth, renderHeight, displayFormat);
//ANativeWindow_setBuffersGeometry(app->window, 0, 0, displayFormat); // Force use of native display size //ANativeWindow_setBuffersGeometry(androidApp->window, 0, 0, displayFormat); // Force use of native display size
surface = eglCreateWindowSurface(display, config, app->window, NULL); surface = eglCreateWindowSurface(display, config, androidApp->window, NULL);
#endif // defined(PLATFORM_ANDROID) #endif // defined(PLATFORM_ANDROID)
#if defined(PLATFORM_RPI) #if defined(PLATFORM_RPI)
@@ -2236,8 +2370,8 @@ static bool InitGraphicsDevice(int width, int height)
} }
#endif // defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) #endif // defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
renderWidth = screenWidth; renderWidth = screenWidth;
renderHeight = screenHeight; renderHeight = screenHeight;
// Initialize OpenGL context (states and resources) // Initialize OpenGL context (states and resources)
// NOTE: screenWidth and screenHeight not used, just stored as globals // NOTE: screenWidth and screenHeight not used, just stored as globals
@@ -2578,14 +2712,14 @@ static void PollInputEvents(void)
while ((ident = ALooper_pollAll(appEnabled ? 0 : -1, NULL, &events,(void**)&source)) >= 0) while ((ident = ALooper_pollAll(appEnabled ? 0 : -1, NULL, &events,(void**)&source)) >= 0)
{ {
// Process this event // Process this event
if (source != NULL) source->process(app, source); if (source != NULL) source->process(androidApp, source);
// NOTE: Never close window, native activity is controlled by the system! // NOTE: Never close window, native activity is controlled by the system!
if (app->destroyRequested != 0) if (androidApp->destroyRequested != 0)
{ {
//TraceLog(LOG_INFO, "Closing Window..."); //TraceLog(LOG_INFO, "Closing Window...");
//windowShouldClose = true; //windowShouldClose = true;
//ANativeActivity_finish(app->activity); //ANativeActivity_finish(androidApp->activity);
} }
} }
#endif #endif
@@ -2922,14 +3056,14 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
case APP_CMD_DESTROY: case APP_CMD_DESTROY:
{ {
// TODO: Finish activity? // TODO: Finish activity?
//ANativeActivity_finish(app->activity); //ANativeActivity_finish(androidApp->activity);
TraceLog(LOG_INFO, "APP_CMD_DESTROY"); TraceLog(LOG_INFO, "APP_CMD_DESTROY");
} break; } break;
case APP_CMD_CONFIG_CHANGED: case APP_CMD_CONFIG_CHANGED:
{ {
//AConfiguration_fromAssetManager(app->config, app->activity->assetManager); //AConfiguration_fromAssetManager(androidApp->config, androidApp->activity->assetManager);
//print_cur_config(app); //print_cur_config(androidApp);
// Check screen orientation here! // Check screen orientation here!

View File

@@ -106,9 +106,9 @@ located in the `deps/` directory.
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
- [Vulkan headers](https://www.khronos.org/registry/vulkan/) for Vulkan tests - [Vulkan headers](https://www.khronos.org/registry/vulkan/) for Vulkan tests
The Vulkan example additionally requires the Vulkan SDK to be installed, or it The Vulkan example additionally requires the LunarG Vulkan SDK to be installed,
will not be included in the build. On macOS you need to provide the path to the or it will not be included in the build. On macOS you need to provide the path
MoltenVK SDK manually as it has no standard installation location. to the SDK manually as it has no standard installation location.
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
find that tool. find that tool.
@@ -136,8 +136,9 @@ information on what to include when reporting a bug.
gamepad mapping (#900) gamepad mapping (#900)
- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate` - Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate`
for retrieving gamepad input state (#900) for retrieving gamepad input state (#900)
- Added `glfwGetWindowContentScale` and `glfwGetMonitorContentScale` for - Added `glfwGetWindowContentScale`, `glfwGetMonitorContentScale` and
DPI-aware rendering (#235,#439,#677,#845,#898) `glfwSetWindowContentScaleCallback` for DPI-aware rendering
(#235,#439,#677,#845,#898)
- Added `glfwRequestWindowAttention` function for requesting attention from the - Added `glfwRequestWindowAttention` function for requesting attention from the
user (#732,#988) user (#732,#988)
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent - Added `glfwGetKeyScancode` function that allows retrieving platform dependent
@@ -147,30 +148,38 @@ information on what to include when reporting a bug.
- Added `glfwSetWindowAttrib` function for changing window attributes (#537) - Added `glfwSetWindowAttrib` function for changing window attributes (#537)
- Added `glfwGetJoystickHats` function for querying joystick hats - Added `glfwGetJoystickHats` function for querying joystick hats
(#889,#906,#934) (#889,#906,#934)
- Added `glfwInitHint` and `glfwInitHintString` for setting initialization hints - Added `glfwInitHint` for setting initialization hints
- Added `glfwWindowHintString` for setting string type window hints (#893,#1139)
- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole - Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole
window transparency (#1089) window transparency (#1089)
- Added `glfwSetMonitorUserPointer` and `glfwGetMonitorUserPointer` for
per-monitor user pointers
- Added `glfwSetJoystickUserPointer` and `glfwGetJoystickUserPointer` for
per-joystick user pointers
- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString` - Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString`
functions for accessing X11 primary selection (#894,#1056) functions for accessing X11 primary selection (#894,#1056)
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850) - Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
- Added definition of `GLAPIENTRY` to public header - Added definition of `GLAPIENTRY` to public header
- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling - Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling
per-pixel framebuffer transparency (#197,#663,#715,#723,#1078) per-pixel framebuffer transparency (#197,#663,#715,#723,#1078)
- Added `GLFW_HOVERED` window attribute for polling cursor hover state (#1166)
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering - Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
(#749,#842) (#749,#842)
- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889) - Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889)
- Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946) - Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946)
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint - Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195) - Added macOS specific `GLFW_COCOA_FRAME_NAME` window hint (#195)
- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935) - Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935)
- Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint - Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
- Added macOS specific `GLFW_COCOA_MENUBAR` init hint - Added macOS specific `GLFW_COCOA_MENUBAR` init hint
- Added X11 specific `GLFW_X11_WM_CLASS_NAME` and `GLFW_X11_WM_CLASS_CLASS` init - Added X11 specific `GLFW_X11_CLASS_NAME` and `GLFW_X11_INSTANCE_NAME` window
hints (#893) hints (#893,#1139)
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header - Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with - Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281) [OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
- Added `GenerateMappings.cmake` script for updating gamepad mappings - Added `GenerateMappings.cmake` script for updating gamepad mappings
- Made `glfwCreateWindowSurface` emit an error when the window has a context
(#1194,#1205)
- Deprecated window parameter of clipboard string functions - Deprecated window parameter of clipboard string functions
- Deprecated charmods callback - Deprecated charmods callback
- Removed `GLFW_USE_RETINA` compile-time option - Removed `GLFW_USE_RETINA` compile-time option
@@ -207,6 +216,9 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: Returned key names did not match other platforms (#943) - [Win32] Bugfix: Returned key names did not match other platforms (#943)
- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899) - [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899)
- [Win32] Bugfix: Window was resized twice when entering full screen (#1085) - [Win32] Bugfix: Window was resized twice when entering full screen (#1085)
- [Win32] Bugfix: The HID device notification was not unregistered (#1170)
- [Win32] Bugfix: `glfwCreateWindow` activated window even with `GLFW_FOCUSED`
hint set to false (#1179,#1180)
- [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125) - [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125)
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading - [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X - [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
@@ -221,6 +233,8 @@ information on what to include when reporting a bug.
- [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT` - [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT`
- [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8 - [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8
- [X11] Bugfix: NVidia EGL would segfault if unloaded before closing the display - [X11] Bugfix: NVidia EGL would segfault if unloaded before closing the display
- [Linux] Added workaround for missing `SYN_DROPPED` in pre-2.6.39 kernel
headers (#1196)
- [Linux] Moved to evdev for joystick input (#906,#1005) - [Linux] Moved to evdev for joystick input (#906,#1005)
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932) - [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
- [Linux] Bugfix: The joystick device path could be truncated (#1025) - [Linux] Bugfix: The joystick device path could be truncated (#1025)
@@ -250,6 +264,7 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: Window title was lost when full screen or undecorated (#1082) - [Cocoa] Bugfix: Window title was lost when full screen or undecorated (#1082)
- [Cocoa] Bugfix: Window was resized twice when entering full screen (#1085) - [Cocoa] Bugfix: Window was resized twice when entering full screen (#1085)
- [Cocoa] Bugfix: Duplicate size events were not filtered (#1085) - [Cocoa] Bugfix: Duplicate size events were not filtered (#1085)
- [Cocoa] Bugfix: Event polling did not initialize AppKit if necessary (#1218)
- [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts - [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts
- [WGL] Added support for `WGL_ARB_create_context_no_error` - [WGL] Added support for `WGL_ARB_create_context_no_error`
- [GLX] Added support for `GLX_ARB_create_context_no_error` - [GLX] Added support for `GLX_ARB_create_context_no_error`
@@ -325,6 +340,8 @@ skills.
- Mário Freitas - Mário Freitas
- GeO4d - GeO4d
- Marcus Geelnard - Marcus Geelnard
- Stephen Gowen
- Kovid Goyal
- Eloi Marín Gratacós - Eloi Marín Gratacós
- Stefan Gustavson - Stefan Gustavson
- Jonathan Hale - Jonathan Hale
@@ -390,6 +407,7 @@ skills.
- Keith Pitt - Keith Pitt
- Stanislav Podgorskiy - Stanislav Podgorskiy
- Alexandre Pretyman - Alexandre Pretyman
- przemekmirek
- Philip Rideout - Philip Rideout
- Eddie Ringle - Eddie Ringle
- Jorge Rodriguez - Jorge Rodriguez
@@ -429,6 +447,7 @@ skills.
- Ricardo Vieira - Ricardo Vieira
- Nicholas Vitovitch - Nicholas Vitovitch
- Simon Voordouw - Simon Voordouw
- Corentin Wallez
- Torsten Walluhn - Torsten Walluhn
- Patrick Walton - Patrick Walton
- Xo Wang - Xo Wang

282
src/external/glfw/deps/KHR/khrplatform.h vendored Normal file
View File

@@ -0,0 +1,282 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by sending them to the public Khronos Bugzilla
* (http://khronos.org/bugzilla) by filing a bug against product
* "Khronos (general)" component "Registry".
*
* A predefined template which fills in some of the bug fields can be
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
* must create a Bugzilla login first.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

View File

@@ -0,0 +1,120 @@
//
// File: vk_platform.h
//
/*
** Copyright (c) 2014-2015 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#ifndef VK_PLATFORM_H_
#define VK_PLATFORM_H_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
/*
***************************************************************************************************
* Platform-specific directives and type declarations
***************************************************************************************************
*/
/* Platform-specific calling convention macros.
*
* Platforms should define these so that Vulkan clients call Vulkan commands
* with the same calling conventions that the Vulkan implementation expects.
*
* VKAPI_ATTR - Placed before the return type in function declarations.
* Useful for C++11 and GCC/Clang-style function attribute syntax.
* VKAPI_CALL - Placed after the return type in function declarations.
* Useful for MSVC-style calling convention syntax.
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
*
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
*/
#if defined(_WIN32)
// On Windows, Vulkan commands use the stdcall convention
#define VKAPI_ATTR
#define VKAPI_CALL __stdcall
#define VKAPI_PTR VKAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
// is true even if the rest of the application passes floats on the stack,
// as it does by default when compiling for the armeabi-v7a NDK ABI.
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
#define VKAPI_CALL
#define VKAPI_PTR VKAPI_ATTR
#else
// On other platforms, use the default calling convention
#define VKAPI_ATTR
#define VKAPI_CALL
#define VKAPI_PTR
#endif
#include <stddef.h>
#if !defined(VK_NO_STDINT_H)
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#endif // !defined(VK_NO_STDINT_H)
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
// Platform-specific headers required by platform window system extensions.
// These are enabled prior to #including "vulkan.h". The same enable then
// controls inclusion of the extension interfaces in vulkan.h.
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include <android/native_window.h>
#endif
#ifdef VK_USE_PLATFORM_MIR_KHR
#include <mir_toolkit/client_types.h>
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <wayland-client.h>
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <windows.h>
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
#include <X11/Xlib.h>
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
#include <xcb/xcb.h>
#endif
#endif

4763
src/external/glfw/deps/vulkan/vulkan.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -814,6 +814,11 @@ extern "C" {
* [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib). * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
*/ */
#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A #define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
/*! @brief Mouse cursor hover window attribute.
*
* Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
*/
#define GLFW_HOVERED 0x0002000B
/*! @brief Framebuffer bit depth hint. /*! @brief Framebuffer bit depth hint.
* *
@@ -964,8 +969,11 @@ extern "C" {
#define GLFW_CONTEXT_CREATION_API 0x0002200B #define GLFW_CONTEXT_CREATION_API 0x0002200B
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002 #define GLFW_COCOA_FRAME_NAME 0x00023002
#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003 #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
#define GLFW_X11_CLASS_NAME 0x00024001
#define GLFW_X11_INSTANCE_NAME 0x00024002
/*! @} */ /*! @} */
#define GLFW_NO_API 0 #define GLFW_NO_API 0
@@ -1046,9 +1054,6 @@ extern "C" {
#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001 #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002
#define GLFW_X11_WM_CLASS_NAME 0x00052001
#define GLFW_X11_WM_CLASS_CLASS 0x00052002
/*! @} */ /*! @} */
#define GLFW_DONT_CARE -1 #define GLFW_DONT_CARE -1
@@ -1067,7 +1072,7 @@ extern "C" {
* @sa @ref glfwGetProcAddress * @sa @ref glfwGetProcAddress
* *
* @since Added in version 3.0. * @since Added in version 3.0.
*
* @ingroup context * @ingroup context
*/ */
typedef void (*GLFWglproc)(void); typedef void (*GLFWglproc)(void);
@@ -1278,6 +1283,24 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
*/ */
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int); typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
/*! @brief The function signature for window content scale callbacks.
*
* This is the function signature for window content scale callback
* functions.
*
* @param[in] window The window whose content scale changed.
* @param[in] xscale The new x-axis content scale of the window.
* @param[in] yscale The new y-axis content scale of the window.
*
* @sa @ref window_scale
* @sa @ref glfwSetWindowContentScaleCallback
*
* @since Added in version 3.3.
*
* @ingroup window
*/
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
/*! @brief The function signature for mouse button callbacks. /*! @brief The function signature for mouse button callbacks.
* *
* This is the function signature for mouse button callback functions. * This is the function signature for mouse button callback functions.
@@ -1435,7 +1458,8 @@ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
* This is the function signature for monitor configuration callback functions. * This is the function signature for monitor configuration callback functions.
* *
* @param[in] monitor The monitor that was connected or disconnected. * @param[in] monitor The monitor that was connected or disconnected.
* @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
* values reserved for future use.
* *
* @sa @ref monitor_event * @sa @ref monitor_event
* @sa @ref glfwSetMonitorCallback * @sa @ref glfwSetMonitorCallback
@@ -1452,7 +1476,8 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
* functions. * functions.
* *
* @param[in] jid The joystick that was connected or disconnected. * @param[in] jid The joystick that was connected or disconnected.
* @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
* values reserved for future use.
* *
* @sa @ref joystick_event * @sa @ref joystick_event
* @sa @ref glfwSetJoystickCallback * @sa @ref glfwSetJoystickCallback
@@ -1644,8 +1669,7 @@ GLFWAPI void glfwTerminate(void);
/*! @brief Sets the specified init hint to the desired value. /*! @brief Sets the specified init hint to the desired value.
* *
* This function sets hints for the next initialization of GLFW. Only integer * This function sets hints for the next initialization of GLFW.
* type hints can be set with this function.
* *
* The values you set hints to are never reset by GLFW, but they only take * The values you set hints to are never reset by GLFW, but they only take
* effect during initialization. Once GLFW has been initialized, any values * effect during initialization. Once GLFW has been initialized, any values
@@ -1668,7 +1692,6 @@ GLFWAPI void glfwTerminate(void);
* *
* @sa init_hints * @sa init_hints
* @sa glfwInit * @sa glfwInit
* @sa glfwInitHintString
* *
* @since Added in version 3.3. * @since Added in version 3.3.
* *
@@ -1676,40 +1699,6 @@ GLFWAPI void glfwTerminate(void);
*/ */
GLFWAPI void glfwInitHint(int hint, int value); GLFWAPI void glfwInitHint(int hint, int value);
/*! @brief Sets the specified init hint to the desired value.
*
* This function sets hints for the next initialization of GLFW. Only string
* type hints can be set with this function.
*
* The values you set hints to are never reset by GLFW, but they only take
* effect during initialization. Once GLFW has been initialized, any values
* you set will be ignored until the library is terminated and initialized
* again.
*
* Some hints are platform specific. These may be set on any platform but they
* will only affect their specific platform. Other platforms will ignore them.
* Setting these hints requires no platform specific headers or functions.
*
* @param[in] hint The [init hint](@ref init_hints) to set.
* @param[in] value The new value of the init hint.
*
* @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
* GLFW_INVALID_VALUE.
*
* @remarks This function may be called before @ref glfwInit.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa init_hints
* @sa glfwInit
* @sa glfwInitHint
*
* @since Added in version 3.3.
*
* @ingroup init
*/
GLFWAPI void glfwInitHintString(int hint, const char* value);
/*! @brief Retrieves the version of the GLFW library. /*! @brief Retrieves the version of the GLFW library.
* *
* This function retrieves the major, minor and revision numbers of the GLFW * This function retrieves the major, minor and revision numbers of the GLFW
@@ -2006,6 +1995,56 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, flo
*/ */
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
/*! @brief Sets the user pointer of the specified monitor.
*
* This function sets the user-defined pointer of the specified monitor. The
* current value is retained until the monitor is disconnected. The initial
* value is `NULL`.
*
* This function may be called from the monitor callback, even for a monitor
* that is being disconnected.
*
* @param[in] monitor The monitor whose pointer to set.
* @param[in] pointer The new value.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @sa @ref monitor_userptr
* @sa @ref glfwGetMonitorUserPointer
*
* @since Added in version 3.3.
*
* @ingroup monitor
*/
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
/*! @brief Returns the user pointer of the specified monitor.
*
* This function returns the current value of the user-defined pointer of the
* specified monitor. The initial value is `NULL`.
*
* This function may be called from the monitor callback, even for a monitor
* that is being disconnected.
*
* @param[in] monitor The monitor whose pointer to return.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @sa @ref monitor_userptr
* @sa @ref glfwSetMonitorUserPointer
*
* @since Added in version 3.3.
*
* @ingroup monitor
*/
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
/*! @brief Sets the monitor configuration callback. /*! @brief Sets the monitor configuration callback.
* *
* This function sets the monitor configuration callback, or removes the * This function sets the monitor configuration callback, or removes the
@@ -2205,6 +2244,7 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
* *
* @sa @ref window_hints * @sa @ref window_hints
* @sa @ref glfwWindowHint * @sa @ref glfwWindowHint
* @sa @ref glfwWindowHintString
* *
* @since Added in version 3.0. * @since Added in version 3.0.
* *
@@ -2215,14 +2255,20 @@ GLFWAPI void glfwDefaultWindowHints(void);
/*! @brief Sets the specified window hint to the desired value. /*! @brief Sets the specified window hint to the desired value.
* *
* This function sets hints for the next call to @ref glfwCreateWindow. The * This function sets hints for the next call to @ref glfwCreateWindow. The
* hints, once set, retain their values until changed by a call to @ref * hints, once set, retain their values until changed by a call to this
* glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is * function or @ref glfwDefaultWindowHints, or until the library is terminated.
* terminated. *
* Only integer value hints can be set with this function. String value hints
* are set with @ref glfwWindowHintString.
* *
* This function does not check whether the specified hint values are valid. * This function does not check whether the specified hint values are valid.
* If you set hints to invalid values this will instead be reported by the next * If you set hints to invalid values this will instead be reported by the next
* call to @ref glfwCreateWindow. * call to @ref glfwCreateWindow.
* *
* Some hints are platform specific. These may be set on any platform but they
* will only affect their specific platform. Other platforms will ignore them.
* Setting these hints requires no platform specific headers or functions.
*
* @param[in] hint The [window hint](@ref window_hints) to set. * @param[in] hint The [window hint](@ref window_hints) to set.
* @param[in] value The new value of the window hint. * @param[in] value The new value of the window hint.
* *
@@ -2232,6 +2278,7 @@ GLFWAPI void glfwDefaultWindowHints(void);
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_hints * @sa @ref window_hints
* @sa @ref glfwWindowHintString
* @sa @ref glfwDefaultWindowHints * @sa @ref glfwDefaultWindowHints
* *
* @since Added in version 3.0. Replaces `glfwOpenWindowHint`. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
@@ -2240,6 +2287,44 @@ GLFWAPI void glfwDefaultWindowHints(void);
*/ */
GLFWAPI void glfwWindowHint(int hint, int value); GLFWAPI void glfwWindowHint(int hint, int value);
/*! @brief Sets the specified window hint to the desired value.
*
* This function sets hints for the next call to @ref glfwCreateWindow. The
* hints, once set, retain their values until changed by a call to this
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
*
* Only string type hints can be set with this function. Integer value hints
* are set with @ref glfwWindowHint.
*
* This function does not check whether the specified hint values are valid.
* If you set hints to invalid values this will instead be reported by the next
* call to @ref glfwCreateWindow.
*
* Some hints are platform specific. These may be set on any platform but they
* will only affect their specific platform. Other platforms will ignore them.
* Setting these hints requires no platform specific headers or functions.
*
* @param[in] hint The [window hint](@ref window_hints) to set.
* @param[in] value The new value of the window hint.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_INVALID_ENUM.
*
* @pointer_lifetime The specified string is copied before this function
* returns.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_hints
* @sa @ref glfwWindowHint
* @sa @ref glfwDefaultWindowHints
*
* @since Added in version 3.3.
*
* @ingroup window
*/
GLFWAPI void glfwWindowHintString(int hint, const char* value);
/*! @brief Creates a window and its associated context. /*! @brief Creates a window and its associated context.
* *
* This function creates a window and its associated OpenGL or OpenGL ES * This function creates a window and its associated OpenGL or OpenGL ES
@@ -2350,9 +2435,8 @@ GLFWAPI void glfwWindowHint(int hint, int value);
* `CMake/MacOSXBundleInfo.plist.in` in the source tree. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
* *
* @remark @macos When activating frame autosaving with * @remark @macos When activating frame autosaving with
* [GLFW_COCOA_FRAME_AUTOSAVE](@ref GLFW_COCOA_FRAME_AUTOSAVE_hint), the * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
* specified window size may be overriden by a previously saved size and * window size and position may be overriden by previously saved values.
* position.
* *
* @remark @x11 Some window managers will not respect the placement of * @remark @x11 Some window managers will not respect the placement of
* initially hidden windows. * initially hidden windows.
@@ -2362,23 +2446,22 @@ GLFWAPI void glfwWindowHint(int hint, int value);
* query the final size, position or other attributes directly after window * query the final size, position or other attributes directly after window
* creation. * creation.
* *
* @remark @x11 The name and class of the `WM_CLASS` window property will by * @remark @x11 The class part of the `WM_CLASS` window property will by
* default be set to the window title passed to this function. Set the @ref * default be set to the window title passed to this function. The instance
* GLFW_X11_WM_CLASS_NAME and @ref GLFW_X11_WM_CLASS_CLASS init hints before * part will use the contents of the `RESOURCE_NAME` environment variable, if
* initialization to override this. * present and not empty, or fall back to the window title. Set the @ref
* GLFW_X11_CLASS_NAME and @ref GLFW_X11_INSTANCE_NAME window hints to override
* this.
* *
* @remark @wayland The window frame is currently unimplemented, as if * @remark @wayland The window frame is currently very simple, only allowing
* [GLFW_DECORATED](@ref GLFW_DECORATED_hint) was always set to `GLFW_FALSE`. * window resize or move. A compositor can still emit close, maximize or
* A compositor can still emit close, resize or maximize events, using for * fullscreen events, using for example a keybind mechanism. Additionally,
* example a keybind mechanism. * the wp_viewporter protocol is required for this feature, otherwise the
* window will not be decorated.
* *
* @remark @wayland A full screen window will not attempt to change the mode, * @remark @wayland A full screen window will not attempt to change the mode,
* no matter what the requested size or refresh rate. * no matter what the requested size or refresh rate.
* *
* @remark @wayland The wl_shell protocol does not support window
* icons, the window will inherit the one defined in the application's
* desktop file, so this function emits @ref GLFW_PLATFORM_ERROR.
*
* @remark @wayland Screensaver inhibition requires the idle-inhibit protocol * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
* to be implemented in the user's compositor. * to be implemented in the user's compositor.
* *
@@ -2522,9 +2605,9 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
* in the Mac Developer Library. * in the Mac Developer Library.
* *
* @remark @wayland The wl_shell protocol does not support icons, the window * @remark @wayland There is no existing protocol to change an icon, the
* will inherit the one defined in the application's desktop file, so this * window will thus inherit the one defined in the application's desktop file.
* function emits @ref GLFW_PLATFORM_ERROR. * This function always emits @ref GLFW_PLATFORM_ERROR.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -2816,10 +2899,6 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height)
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland The window frame is currently unimplemented, as if
* [GLFW_DECORATED](@ref GLFW_DECORATED_hint) was always set to `GLFW_FALSE`,
* so the returned values will always be zero.
*
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_size * @sa @ref window_size
@@ -2852,6 +2931,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref window_scale * @sa @ref window_scale
* @sa @ref glfwSetWindowContentScaleCallback
* @sa @ref glfwGetMonitorContentScale * @sa @ref glfwGetMonitorContentScale
* *
* @since Added in version 3.3. * @since Added in version 3.3.
@@ -2931,7 +3011,8 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland There is no concept of iconification in wl_shell, this * @remark @wayland There is no concept of iconification in wl_shell, this
* function will always emit @ref GLFW_PLATFORM_ERROR. * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated
* protocol.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3456,7 +3537,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
* *
* @remark @wayland The wl_shell protocol has no concept of iconification, * @remark @wayland The wl_shell protocol has no concept of iconification,
* this callback will never be called. * this callback will never be called when using this deprecated protocol.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3514,6 +3595,30 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window,
*/ */
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
/*! @brief Sets the window content scale callback for the specified window.
*
* This function sets the window content scale callback of the specified window,
* which is called when the content scale of the specified window changes.
*
* @param[in] window The window whose callback to set.
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
* callback.
* @return The previously set callback, or `NULL` if no callback was set or the
* library had not been [initialized](@ref intro_init).
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_scale
* @sa @ref glfwGetWindowContentScale
*
* @since Added in version 3.3.
*
* @ingroup window
*/
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun);
/*! @brief Processes all pending events. /*! @brief Processes all pending events.
* *
* This function processes only those events that are already in the event * This function processes only those events that are already in the event
@@ -4583,6 +4688,56 @@ GLFWAPI const char* glfwGetJoystickName(int jid);
*/ */
GLFWAPI const char* glfwGetJoystickGUID(int jid); GLFWAPI const char* glfwGetJoystickGUID(int jid);
/*! @brief Sets the user pointer of the specified joystick.
*
* This function sets the user-defined pointer of the specified joystick. The
* current value is retained until the joystick is disconnected. The initial
* value is `NULL`.
*
* This function may be called from the joystick callback, even for a joystick
* that is being disconnected.
*
* @param[in] joystick The joystick whose pointer to set.
* @param[in] pointer The new value.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @sa @ref joystick_userptr
* @sa @ref glfwGetJoystickUserPointer
*
* @since Added in version 3.3.
*
* @ingroup input
*/
GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
/*! @brief Returns the user pointer of the specified joystick.
*
* This function returns the current value of the user-defined pointer of the
* specified joystick. The initial value is `NULL`.
*
* This function may be called from the joystick callback, even for a joystick
* that is being disconnected.
*
* @param[in] joystick The joystick whose pointer to return.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @sa @ref joystick_userptr
* @sa @ref glfwSetJoystickUserPointer
*
* @since Added in version 3.3.
*
* @ingroup input
*/
GLFWAPI void* glfwGetJoystickUserPointer(int jid);
/*! @brief Returns whether the specified joystick has a gamepad mapping. /*! @brief Returns whether the specified joystick has a gamepad mapping.
* *
* This function returns whether the specified joystick is both present and has * This function returns whether the specified joystick is both present and has
@@ -5285,6 +5440,11 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* glfwGetRequiredInstanceExtensions to check what instance extensions are * glfwGetRequiredInstanceExtensions to check what instance extensions are
* required. * required.
* *
* The window surface cannot be shared with another API so the window must
* have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
* set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
* and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
*
* The window surface must be destroyed before the specified Vulkan instance. * The window surface must be destroyed before the specified Vulkan instance.
* It is the responsibility of the caller to destroy the window surface. GLFW * It is the responsibility of the caller to destroy the window surface. GLFW
* does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
@@ -5300,7 +5460,7 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
* *
* @remark If an error occurs before the creation call is made, GLFW returns * @remark If an error occurs before the creation call is made, GLFW returns
* the Vulkan error code most appropriate for the error. Appropriate use of * the Vulkan error code most appropriate for the error. Appropriate use of

View File

@@ -39,6 +39,14 @@ elseif (_GLFW_WAYLAND)
linux_joystick.c posix_time.c posix_thread.c xkb_unicode.c linux_joystick.c posix_time.c posix_thread.c xkb_unicode.c
egl_context.c osmesa_context.c) egl_context.c osmesa_context.c)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
BASENAME xdg-shell)
ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
BASENAME viewporter)
ecm_add_wayland_client_protocol(glfw_SOURCES ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
@@ -49,7 +57,7 @@ elseif (_GLFW_WAYLAND)
BASENAME pointer-constraints-unstable-v1) BASENAME pointer-constraints-unstable-v1)
ecm_add_wayland_client_protocol(glfw_SOURCES ecm_add_wayland_client_protocol(glfw_SOURCES
PROTOCOL PROTOCOL
${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
BASENAME idle-inhibit-unstable-v1) BASENAME idle-inhibit-unstable-v1)
elseif (_GLFW_MIR) elseif (_GLFW_MIR)
set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h
@@ -90,9 +98,7 @@ set_target_properties(glfw PROPERTIES
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
FOLDER "GLFW3") FOLDER "GLFW3")
target_compile_definitions(glfw PRIVATE target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
_GLFW_USE_CONFIG_H
$<$<BOOL:${UNIX}>:_XOPEN_SOURCE=600>)
target_include_directories(glfw PUBLIC target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>") "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>")

View File

@@ -264,7 +264,7 @@ void _glfwPollMonitorsNS(void)
const CGSize size = CGDisplayScreenSize(displays[i]); const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]); char* name = getDisplayName(displays[i]);
if (!name) if (!name)
name = strdup("Unknown"); name = _glfw_strdup("Unknown");
monitor = _glfwAllocMonitor(name, size.width, size.height); monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i]; monitor->ns.displayID = displays[i];
@@ -287,7 +287,7 @@ void _glfwPollMonitorsNS(void)
// Change the current video mode // Change the current video mode
// //
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{ {
CFArrayRef modes; CFArrayRef modes;
CFIndex count, i; CFIndex count, i;
@@ -299,7 +299,7 @@ GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
best = _glfwChooseVideoMode(monitor, desired); best = _glfwChooseVideoMode(monitor, desired);
_glfwPlatformGetVideoMode(monitor, &current); _glfwPlatformGetVideoMode(monitor, &current);
if (_glfwCompareVideoModes(&current, best) == 0) if (_glfwCompareVideoModes(&current, best) == 0)
return GLFW_TRUE; return;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
@@ -332,15 +332,6 @@ GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
CFRelease(modes); CFRelease(modes);
CVDisplayLinkRelease(link); CVDisplayLinkRelease(link);
if (!native)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Monitor mode list changed");
return GLFW_FALSE;
}
return GLFW_TRUE;
} }
// Restore the previously saved (original) video mode // Restore the previously saved (original) video mode
@@ -364,6 +355,10 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
{
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{ {
const CGRect bounds = CGDisplayBounds(monitor->ns.displayID); const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);

View File

@@ -88,9 +88,10 @@ typedef struct _GLFWwindowNS
GLFWbool maximized; GLFWbool maximized;
// Cached window and framebuffer sizes used to filter out duplicate events // Cached window properties to filter out duplicate events
int width, height; int width, height;
int fbWidth, fbHeight; int fbWidth, fbHeight;
float xscale, yscale;
// The total sum of the distances the cursor has been warped // The total sum of the distances the cursor has been warped
// since the last cursor motion event was processed // since the last cursor motion event was processed
@@ -163,6 +164,6 @@ typedef struct _GLFWtimerNS
void _glfwInitTimerNS(void); void _glfwInitTimerNS(void);
void _glfwPollMonitorsNS(void); void _glfwPollMonitorsNS(void);
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);

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