Merge branch 'master' of https://github.com/raysan5/raylib
This commit is contained in:
commit
3a3bb46c8c
92 changed files with 9170 additions and 6161 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -113,6 +113,10 @@ docs/examples/web/*/*.html
|
||||||
!docs/examples/web/shaders/loader.html
|
!docs/examples/web/shaders/loader.html
|
||||||
!docs/examples/web/models/loader.html
|
!docs/examples/web/models/loader.html
|
||||||
|
|
||||||
|
# Jetbrains project
|
||||||
|
.idea/
|
||||||
|
cmake-build-debug/
|
||||||
|
|
||||||
# CMake stuff
|
# CMake stuff
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
### raylib bindings
|
## raylib bindings
|
||||||
|
|
||||||
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
|
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
|
||||||
|
|
||||||
|
|
@ -46,6 +46,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
| ringraylib | Ring | https://github.com/ringpackages/ringraylib |
|
| ringraylib | Ring | https://github.com/ringpackages/ringraylib |
|
||||||
| cl-raylib | Common Lisp | https://github.com/longlene/cl-raylib |
|
| cl-raylib | Common Lisp | https://github.com/longlene/cl-raylib |
|
||||||
| raylib-scm | Chicken Scheme | https://github.com/yashrk/raylib-scm |
|
| raylib-scm | Chicken Scheme | https://github.com/yashrk/raylib-scm |
|
||||||
|
| raylib-chibi | Chibi-Scheme | https://github.com/VincentToups/raylib-chibi |
|
||||||
| Euraylib | Euphoria | https://github.com/gAndy50/Euraylib |
|
| Euraylib | Euphoria | https://github.com/gAndy50/Euraylib |
|
||||||
| raylib-wren | Wren | https://github.com/TSnake41/raylib-wren |
|
| raylib-wren | Wren | https://github.com/TSnake41/raylib-wren |
|
||||||
| raylib-odin | Odin | https://github.com/kevinw/raylib-odin |
|
| raylib-odin | Odin | https://github.com/kevinw/raylib-odin |
|
||||||
|
|
|
||||||
148
CHANGELOG
148
CHANGELOG
|
|
@ -1,7 +1,153 @@
|
||||||
changelog
|
changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Current Release: raylib 2.5.0 (31 May 2019)
|
Current Release: raylib 3.0.0 (Feb.2020) -WIP-
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Release: raylib 3.0 (Feb 2020)
|
||||||
|
-----------------------------------------------
|
||||||
|
KEY CHANGES:
|
||||||
|
- Global context states used on all modules.
|
||||||
|
- Custom memory allocators for all modules and dependencies.
|
||||||
|
- Structures reviewed to reduce size and always used as pass-by-value.
|
||||||
|
- raudio module reviewed to accomodate new Music struct and new miniaudio.
|
||||||
|
- text module reviewed to improve fonts generation and text management functions.
|
||||||
|
- examples addition, multiple new examples and categorized examples table.
|
||||||
|
- GitHub Actions CI implemented for Windows, Linux and macOS.
|
||||||
|
|
||||||
|
Detailed changes:
|
||||||
|
[build] ADDED: VS2017.ANGLE project, by @msmshazan
|
||||||
|
[build] ADDED: VS2017 project support for x64 platform configuration
|
||||||
|
[build] ADDED: Makefile for Android building on macOS, by @Yunoinsky
|
||||||
|
[build] ADDED: Makefile for Android building on Linux, by @pamarcos
|
||||||
|
[build] REMOVED: VS2015 project
|
||||||
|
[build] REVIEWED: VSCode project
|
||||||
|
[build] REVIEWED: Makefile build system
|
||||||
|
[build] REVIEWED: Android building, by @NimbusFox
|
||||||
|
[build] REVIEWED: Compilation with CLion IDE, by @Rover656
|
||||||
|
[build] REVIEWED: Generation of web examples, by @pamarcos
|
||||||
|
[build] REVIEWED: Makefiles path to 'shell.html', by @niorad
|
||||||
|
[build] REVIEWED: VS2017 64bit compilation issues, by @spec-chum
|
||||||
|
[build] REVIEWED: Multiple fixes on projkects building, by @ChrisDill, @JuDelCo, @electronstudio
|
||||||
|
[core] ADDED: Support touch/mouse indistinctly
|
||||||
|
[core] ADDED: FLAG_WINDOW_ALWAYS_RUN to avoid pause on minimize
|
||||||
|
[core] ADDED: Config flag SUPPORT_HALFBUSY_WAIT_LOOP
|
||||||
|
[core] ADDED: RPI mouse cursor point support on native mode
|
||||||
|
[core] ADDED: BeginScissorMode() - Define screen area for following drawing
|
||||||
|
[core] ADDED: EndScissorMode() - End scissor mode
|
||||||
|
[core] ADDED: GetWorldToScreen2D()- Get screen space position for a 2d camera world space position, by @arvyy
|
||||||
|
[core] ADDED: GetScreenToWorld2D() - Get world space position for a 2d camera screen space position, by @arvyy
|
||||||
|
[core] ADDED: GetWorldToScreenEx() - Get size position for a 3d world space position
|
||||||
|
[core] ADDED: DirectoryExists() - Check if a directory path exists
|
||||||
|
[core] ADDED: GetPrevDirectoryPath() - Get previous directory path for a given path
|
||||||
|
[core] ADDED: CompressData() - Compress data (DEFLATE algorythm)
|
||||||
|
[core] ADDED: DecompressData() - Decompress data (DEFLATE algorythm)
|
||||||
|
[core] ADDED: GetWindowPosition() - Get window position XY on monitor
|
||||||
|
[core] REMOVED: Show raylib logo at initialization
|
||||||
|
[core] REVIEWED: GetFileName(), security checks
|
||||||
|
[core] REVIEWED: IsMouseButtonReleased(), when press/release events come too fast, by @oswjk
|
||||||
|
[core] REVIEWED: SetWindowMonitor(), by @DropsOfSerenity
|
||||||
|
[core] REVIEWED: IsFileExtension() to be case-insensitive
|
||||||
|
[core] REVIEWED: IsFileExtension() when checking no-extension files
|
||||||
|
[core] REVIEWED: Default font scale filter for HighDPI mode
|
||||||
|
[core] REVIEWED: Touch input scaling for PLATFORM_WEB
|
||||||
|
[core] REVIEWED: RPI input system, by @DarkElvenAngel
|
||||||
|
[core] REVIEWED: RPI input threads issues
|
||||||
|
[core] REVIEWED: OpenGL extensions loading and freeing
|
||||||
|
[core] REVIEWED: GetDirectoryPath()
|
||||||
|
[core] REVIEWED: Camera2D behavior, by @arvyy
|
||||||
|
[core] REVIEWED: OpenGL ES 2.0 extensions check
|
||||||
|
[rlgl] ADDED: Flags to allow frustrum culling near/far distance configuration at compile time
|
||||||
|
[rlgl] ADDED: Flags to sllow MAX_BATCH_BUFFERING config at compile time
|
||||||
|
[rlgl] ADDED: GetMatrixProjection(), by @chriscamacho
|
||||||
|
[rlgl] ADDED: rlUpdateMeshAt() - Update vertex or index data on GPU, at index, by @brankoku
|
||||||
|
[rlgl] REVIEWED: Vertex padding not zeroed for quads, by @kawa-yoiko
|
||||||
|
[rlgl] REVIEWED: Read texture data as RGBA from FBO on GLES 2.0
|
||||||
|
[rlgl] REVIEWED: LoadShaderCode() for const correctness, by @heretique
|
||||||
|
[rlgl] REVIEWED: rlLoadTexture()
|
||||||
|
[rlgl] REVIEWED: rlReadTexturePixels()
|
||||||
|
[rlgl] REVIEWED: rlUpdateMesh() to supports updating indices, by @brankoku
|
||||||
|
[rlgl] REVIEWED: GenTextureCubemap(), renamed parameters for consistency
|
||||||
|
[rlgl] REVIEWED: HDR pixels loading
|
||||||
|
[raymath] ADDED: MatrixRotateXYZ(), by @chriscamacho
|
||||||
|
[raymath] RENAMED: Vector3Multiply() to Vector3Scale()
|
||||||
|
[camera] REVIEWED: Free camera pitch, by @chriscamacho
|
||||||
|
[camera] REVIEWED: Camera not working properly at z-align, by @Ushio
|
||||||
|
[shapes] ADDED: DrawTriangleStrip() - Draw a triangle strip defined by points
|
||||||
|
[shapes] ADDED: DrawEllipse() - Draw ellipse
|
||||||
|
[shapes] ADDED: DrawEllipseLines() - Draw ellipse outline
|
||||||
|
[shapes] ADDED: DrawPolyLines() - Draw a polygon outline of n sides
|
||||||
|
[shapes] REVIEWED: DrawPoly() shape rendering, by @AlexHCC
|
||||||
|
[textures] ADDED: LoadAnimatedGIF() - Load animated GIF file
|
||||||
|
[textures] ADDED: GetImageAlphaBorder() - Get image alpha border rectangle
|
||||||
|
[textures] ADDED: ImageFromImage() - Create an image from another image piece
|
||||||
|
[textures] REVIEWED: ImageDraw(), now it supports color tint parameter
|
||||||
|
[textures] REVIEWED: ImageResizeCanvas()
|
||||||
|
[textures] REVIEWED: ImageCrop() with security checks
|
||||||
|
[textures] REVIEWED: ImageAlphaMask()
|
||||||
|
[textures] REVIEWED: ImageDrawRectangleLines()
|
||||||
|
[textures] REVIEWED: GetImageData()
|
||||||
|
[text] ADDED: TextCopy() - Copy one string to another, returns bytes copied
|
||||||
|
[text] ADDED: GetCodepoints() - Get all codepoints in a string
|
||||||
|
[text] ADDED: CodepointToUtf8() - Encode codepoint into utf8 text
|
||||||
|
[text] ADDED: DrawTextCodepoint() - Draw one character (codepoint)
|
||||||
|
[text] RENAMED: LoadDefaultFont() -> LoadFontDefault()
|
||||||
|
[text] RENAMED: TextCountCodepoints() -> GetCodepointsCount()
|
||||||
|
[text] REVIEWED: TextFormat(), to support caching, by @brankoku
|
||||||
|
[text] REVIEWED: LoadFontData(), generate empty image for space character
|
||||||
|
[text] REVIEWED: TextSplit()
|
||||||
|
[text] REVIEWED: TextToInteger()
|
||||||
|
[text] REVIEWED: GetNextCodepoint(), renamed parameters for clarity
|
||||||
|
[text] REVIEWED: GenImageFontAtlas(), improved atlas size computing
|
||||||
|
[text] REDESIGNED: struct Font, character rectangles have been moved out from CharInfo to Font
|
||||||
|
[text] REDESIGNED: struct CharInfo, now includes directly an Image of the glyph
|
||||||
|
[text] REDESIGNED: GenImageFontAtlas(), additional recs parameter added
|
||||||
|
[text] REDESIGNED: ImageTextEx(), to avoid font retrieval from GPU
|
||||||
|
[models] ADDED: Support rlPushMatrix() and rlPopMatrix() on mesh drawing
|
||||||
|
[models] ADDED: DrawPoint3D() - Draw a point in 3D space, actually a small line, by @ProfJski
|
||||||
|
[models] ADDED: Multi texture support for materials in GLTF format, by @Gamerfiend, @chriscamacho
|
||||||
|
[models] REVIEWED: LoadGLTF(), fixed memory leak, by @jubalh
|
||||||
|
[models] REVIEWED: LoadIQM(), support multiple animations loading, by @culacant
|
||||||
|
[models] REVIEWED: GetCollisionRayModel(), to avoid pointers
|
||||||
|
[models] REVIEWED: CheckCollisionRay*(), parameters renamed
|
||||||
|
[models] REVIEWED: UnloadMesh(), to avoid pointers
|
||||||
|
[models] REVIEWED: LoadModel(), memory initialization
|
||||||
|
[models] REVIEWED: UpdateModelAnimation(), added security checks
|
||||||
|
[models] REVIEWED: Multiple fixes on models loading, by @jubalh
|
||||||
|
[models] REVIEWED: Normals updated when using animated meshes, by @@las3rlars
|
||||||
|
[models] REVIEWED: Compilation when the SUPPORT_MESH_GENERATION not set, by @@Elkantor
|
||||||
|
[raudio] ADDED: Multi-channel audio playing, by @chriscamacho
|
||||||
|
[raudio] REMOVED: LoadWaveEx()
|
||||||
|
[raudio] RENAMED: IsAudioBufferProcessed() to IsAudioStreamProcessed()
|
||||||
|
[raudio] REVIEWED: Ensure .xm playback starts in the right place, by @illegalinstruction
|
||||||
|
[raudio] REVIEWED: Fix short non-looping sounds, by @jbosh
|
||||||
|
[raudio] REVIEWED: Modules playing time to full length
|
||||||
|
[raudio] REDESIGNED: Replaced Music pointer by struct
|
||||||
|
[raudio] REDESIGNED: Removed sampleLeft from Music struct
|
||||||
|
[examples] ADDED: core_scissor_test, by @ChrisDill
|
||||||
|
[examples] ADDED: core_2d_camera_platformer, by @arvyy
|
||||||
|
[examples] ADDED: textures_mouse_painting, by @ChrisDill
|
||||||
|
[examples] ADDED: models_waving_cubes, by @codecat
|
||||||
|
[examples] ADDED: models_solar_system, by @aldrinmartoq
|
||||||
|
[examples] ADDED: shaders_fog, by @chriscamacho
|
||||||
|
[examples] ADDED: shaders_texture_waves, by @Anata
|
||||||
|
[examples] ADDED: shaders_basic_lighting, by @chriscamacho
|
||||||
|
[examples] ADDED: shaders_simple_mask, by @chriscamacho
|
||||||
|
[examples] ADDED: audio_multichannel_sound, by @chriscamacho
|
||||||
|
[examples] RENAMED: text_sprite_font > text_font_spritefont
|
||||||
|
[examples] RENAMED: text_ttf_loading > text_font_filters
|
||||||
|
[examples] RENAMED: text_bmfont_ttf > text_font_loading
|
||||||
|
[examples] REMOVED: models_obj_viewer
|
||||||
|
[examples] REMOVED: models_solar_system
|
||||||
|
[examples] REVIEWED: models_obj_loading > models_loading
|
||||||
|
[examples] REVIEWED: models_materials_pbr, shader issues
|
||||||
|
[examples] REVIEWED: core_window_letterbox, detailed explanation, by @jotac0
|
||||||
|
[games] ADDED: GGJ2020 game - RE-PAIR
|
||||||
|
[*] Misc fixes and tweaks, by @yaram, @oraoto, @zatherz, @piecedigital, @Shylie
|
||||||
|
[*] Update ALL supported projects (Notepad++, VS2017)
|
||||||
|
[*] Update ALL external libraries to latest versions (29.Jan.2020)
|
||||||
|
[*] Update ALL examples and games
|
||||||
|
[*] Update BINDINGS list
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Release: raylib 2.5 (May 2019)
|
Release: raylib 2.5 (May 2019)
|
||||||
|
|
|
||||||
19
ROADMAP.md
19
ROADMAP.md
|
|
@ -3,14 +3,19 @@ roadmap
|
||||||
|
|
||||||
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are quite high-level and could be long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are quite high-level and could be long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
||||||
|
|
||||||
[raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve.
|
[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!
|
||||||
Also, check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
|
||||||
|
|
||||||
**raylib 2.x**
|
**raylib 3.x**
|
||||||
- [ ] rnet: raylib network module
|
- [ ] Network module (UDP): `rnet` ([info](https://github.com/raysan5/raylib/issues/753))
|
||||||
- [ ] rres: raylib resource packer
|
- [ ] Custom raylib resource packer: `rres` ([info](https://github.com/raysan5/rres))
|
||||||
- [ ] rlvk: raylib Vulkan API support (GRAPHICS_API_VULKAN)
|
- [ ] Trace log messages redesign ([info](https://github.com/raysan5/raylib/issues/1065))
|
||||||
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
- [ ] Basic CPU/GPU stats system (memory, draws, time...)
|
||||||
|
- [ ] Continuous Deployment using GitHub Actions
|
||||||
|
|
||||||
|
**raylib 3.0**
|
||||||
|
- [x] Optimize data structures for pass-by-value
|
||||||
|
- [x] Custom memory allocators support: `rmem`
|
||||||
|
- [x] Continuous Integration using GitHub Actions
|
||||||
|
|
||||||
**raylib 2.5**
|
**raylib 2.5**
|
||||||
- [x] Support Animated models
|
- [x] Support Animated models
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,8 @@ endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# Emscripten required variables
|
# Emscripten required variables
|
||||||
EMSDK_PATH ?= C:/emsdk
|
EMSDK_PATH ?= C:/emsdk
|
||||||
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
|
||||||
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
|
||||||
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
|
|
@ -196,7 +196,7 @@ ifeq ($(BUILD_MODE),DEBUG)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
CFLAGS += -Os
|
CFLAGS += -O3
|
||||||
else
|
else
|
||||||
CFLAGS += -s -O1
|
CFLAGS += -s -O1
|
||||||
endif
|
endif
|
||||||
|
|
@ -205,11 +205,6 @@ endif
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -238,7 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -s USE_GLFW=3 -s FORCE_FILESYSTEM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 --preload-file $(dir $<)resources@resources
|
CFLAGS += -s USE_GLFW=3 -s FORCE_FILESYSTEM=1 -s ASYNCIFY --preload-file $(dir $<)resources@resources
|
||||||
|
|
||||||
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
|
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
|
||||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||||
|
|
@ -277,6 +272,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -500,7 +503,8 @@ 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|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
|
find . -type f -executable -delete
|
||||||
|
rm -fv *.o
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
find . -type f -perm +ugo+x -delete
|
find . -type f -perm +ugo+x -delete
|
||||||
|
|
|
||||||
|
|
@ -2,78 +2,71 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - Client/Server ping-pong
|
* raylib [network] example - Client/Server ping-pong
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "rnet.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#define RNET_IMPLEMENTATION
|
||||||
#include <stdio.h>
|
#include "rnet.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
float elapsed = 0.0f;
|
float elapsed = 0.0f;
|
||||||
float delay = 1.0f;
|
float delay = 1.0f;
|
||||||
bool ping = false;
|
bool ping = false;
|
||||||
bool pong = false;
|
bool pong = false;
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
bool client_connected = false;
|
bool clientConnected = false;
|
||||||
const char *pingmsg = "Ping!";
|
const char *pingmsg = "Ping!";
|
||||||
const char *pongmsg = "Pong!";
|
const char *pongmsg = "Pong!";
|
||||||
int msglen = 0;
|
int msglen = 0;
|
||||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true};
|
SocketConfig serverConfig = { .host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true };
|
||||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true};
|
SocketConfig clientConfig = { .host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true };
|
||||||
SocketConfig connection_cfg = {.nonblocking = true};
|
SocketConfig connectionConfig = { .nonblocking = true };
|
||||||
SocketResult *server_res = NULL;
|
SocketResult *serverResult = NULL;
|
||||||
SocketResult *client_res = NULL;
|
SocketResult *clientResult = NULL;
|
||||||
SocketSet * socket_set = NULL;
|
SocketSet *socketSet = NULL;
|
||||||
Socket *connection = NULL;
|
Socket *connection = NULL;
|
||||||
char recvBuffer[512];
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Attempt to connect to the network (Either TCP, or UDP)
|
// Attempt to connect to the network (Either TCP, or UDP)
|
||||||
void NetworkConnect()
|
static void NetworkConnect(void)
|
||||||
{
|
{
|
||||||
// If the server is configured as UDP, ignore connection requests
|
// If the server is configured as UDP, ignore connection requests
|
||||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
if ((serverConfig.type == SOCKET_UDP) && (clientConfig.type == SOCKET_UDP))
|
||||||
|
{
|
||||||
ping = true;
|
ping = true;
|
||||||
connected = true;
|
connected = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// If the client is connected, run the server code to check for a connection
|
// If the client is connected, run the server code to check for a connection
|
||||||
if (client_connected) {
|
if (clientConnected)
|
||||||
int active = CheckSockets(socket_set, 0);
|
{
|
||||||
if (active != 0) {
|
int active = CheckSockets(socketSet, 0);
|
||||||
TraceLog(LOG_DEBUG,
|
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
if (active > 0)
|
||||||
if (active > 0) {
|
{
|
||||||
if ((connection = SocketAccept(server_res->socket, &connection_cfg)) != NULL) {
|
if ((connection = SocketAccept(serverResult->socket, &connectionConfig)) != NULL)
|
||||||
AddSocket(socket_set, connection);
|
{
|
||||||
ping = true;
|
AddSocket(socketSet, connection);
|
||||||
connected = true;
|
connected = true;
|
||||||
|
ping = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Check if we're connected every _delay_ seconds
|
// Check if we're connected every _delay_ seconds
|
||||||
elapsed += GetFrameTime();
|
elapsed += GetFrameTime();
|
||||||
if (elapsed > delay) {
|
if (elapsed > delay)
|
||||||
if (IsSocketConnected(client_res->socket)) {
|
{
|
||||||
client_connected = true;
|
if (IsSocketConnected(clientResult->socket)) clientConnected = true;
|
||||||
}
|
|
||||||
elapsed = 0.0f;
|
elapsed = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,144 +75,138 @@ void NetworkConnect()
|
||||||
|
|
||||||
// Once connected to the network, check the sockets for pending information
|
// Once connected to the network, check the sockets for pending information
|
||||||
// and when information is ready, send either a Ping or a Pong.
|
// and when information is ready, send either a Ping or a Pong.
|
||||||
void NetworkUpdate()
|
static void UpdateNetwork(void)
|
||||||
{
|
{
|
||||||
// CheckSockets
|
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||||
//
|
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
int active = CheckSockets(socketSet, 0);
|
||||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
int active = CheckSockets(socket_set, 0);
|
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSocketReady
|
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||||
//
|
|
||||||
// If the socket is ready, attempt to receive data from the socket
|
|
||||||
int bytesRecv = 0;
|
int bytesRecv = 0;
|
||||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
if ((serverConfig.type == SOCKET_UDP) && (clientConfig.type == SOCKET_UDP))
|
||||||
if (IsSocketReady(client_res->socket)) {
|
{
|
||||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, msglen);
|
||||||
}
|
if (IsSocketReady(serverResult->socket)) bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, msglen);
|
||||||
if (IsSocketReady(server_res->socket)) {
|
|
||||||
bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (IsSocketReady(connection)) {
|
|
||||||
bytesRecv = SocketReceive(connection, recvBuffer, msglen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (IsSocketReady(connection)) bytesRecv = SocketReceive(connection, receiveBuffer, msglen);
|
||||||
|
|
||||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||||
if (bytesRecv > 0) {
|
if (bytesRecv > 0)
|
||||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
{
|
||||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||||
|
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||||
elapsed += GetFrameTime();
|
elapsed += GetFrameTime();
|
||||||
if (elapsed > delay) {
|
if (elapsed > delay)
|
||||||
if (ping) {
|
{
|
||||||
|
if (ping)
|
||||||
|
{
|
||||||
ping = false;
|
ping = false;
|
||||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
if (serverConfig.type == SOCKET_UDP && clientConfig.type == SOCKET_UDP) SocketSend(clientResult->socket, pingmsg, msglen);
|
||||||
SocketSend(client_res->socket, pingmsg, msglen);
|
else SocketSend(clientResult->socket, pingmsg, msglen);
|
||||||
} else {
|
|
||||||
SocketSend(client_res->socket, pingmsg, msglen);
|
|
||||||
}
|
}
|
||||||
} else if (pong) {
|
else if (pong)
|
||||||
|
{
|
||||||
pong = false;
|
pong = false;
|
||||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
if (serverConfig.type == SOCKET_UDP && clientConfig.type == SOCKET_UDP) SocketSend(clientResult->socket, pongmsg, msglen);
|
||||||
SocketSend(client_res->socket, pongmsg, msglen);
|
else SocketSend(clientResult->socket, pongmsg, msglen);
|
||||||
} else {
|
|
||||||
SocketSend(client_res->socket, pongmsg, msglen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed = 0.0f;
|
elapsed = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Setup
|
// Initialization
|
||||||
int screenWidth = 800;
|
//--------------------------------------------------------------------------------------
|
||||||
int screenHeight = 450;
|
const int screenWidth = 800;
|
||||||
InitWindow(
|
const int screenHeight = 450;
|
||||||
screenWidth, screenHeight, "raylib [network] example - ping pong");
|
|
||||||
SetTargetFPS(60);
|
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
|
||||||
|
|
||||||
// Networking
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - ping pong");
|
||||||
InitNetwork();
|
|
||||||
|
|
||||||
// Create the server
|
InitNetworkDevice(); // Init network communications
|
||||||
//
|
|
||||||
// Performs
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
// getaddrinfo
|
serverResult = LoadSocketResult();
|
||||||
// socket
|
if (!SocketCreate(&serverConfig, serverResult))
|
||||||
// setsockopt
|
{
|
||||||
// bind
|
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
// listen
|
}
|
||||||
server_res = AllocSocketResult();
|
else
|
||||||
if (!SocketCreate(&server_cfg, server_res)) {
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
if (!SocketBind(&serverConfig, serverResult))
|
||||||
server_res->status, server_res->socket->status);
|
{
|
||||||
} else {
|
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
if (!SocketBind(&server_cfg, server_res)) {
|
}
|
||||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
else
|
||||||
server_res->status, server_res->socket->status);
|
{
|
||||||
} else {
|
if (!(serverConfig.type == SOCKET_UDP))
|
||||||
if (!(server_cfg.type == SOCKET_UDP)) {
|
{
|
||||||
if (!SocketListen(&server_cfg, server_res)) {
|
if (!SocketListen(&serverConfig, serverResult))
|
||||||
TraceLog(LOG_WARNING,
|
{
|
||||||
"Failed to start listen server: status %d, errno %d",
|
TraceLog(LOG_WARNING, "Failed to start listen server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the client
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
//
|
clientResult = LoadSocketResult();
|
||||||
// Performs
|
if (!SocketCreate(&clientConfig, clientResult))
|
||||||
// getaddrinfo
|
{
|
||||||
// socket
|
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
// setsockopt
|
}
|
||||||
// connect (TCP only)
|
else
|
||||||
client_res = AllocSocketResult();
|
{
|
||||||
if (!SocketCreate(&client_cfg, client_res)) {
|
if (!(clientConfig.type == SOCKET_UDP))
|
||||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
{
|
||||||
client_res->status, client_res->socket->status);
|
if (!SocketConnect(&clientConfig, clientResult))
|
||||||
} else {
|
{
|
||||||
if (!(client_cfg.type == SOCKET_UDP)) {
|
TraceLog(LOG_WARNING, "Failed to connect to server: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
if (!SocketConnect(&client_cfg, client_res)) {
|
|
||||||
TraceLog(LOG_WARNING,
|
|
||||||
"Failed to connect to server: status %d, errno %d",
|
|
||||||
client_res->status, client_res->socket->status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create & Add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socket_set = AllocSocketSet(3);
|
socketSet = LoadSocketSet(3);
|
||||||
msglen = strlen(pingmsg) + 1;
|
|
||||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
AddSocket(socketSet, serverResult->socket);
|
||||||
AddSocket(socket_set, server_res->socket);
|
AddSocket(socketSet, clientResult->socket);
|
||||||
AddSocket(socket_set, client_res->socket);
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (connected) UpdateNetwork();
|
||||||
|
//else NetworkConnect();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
if (connected) {
|
|
||||||
NetworkUpdate();
|
// TODO: Draw relevant connection info
|
||||||
} else {
|
|
||||||
NetworkConnect();
|
|
||||||
}
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// De-Initialization
|
||||||
CloseWindow();
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,79 +2,77 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - Resolve Host
|
* raylib [network] example - Resolve Host
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
int main(void)
|
||||||
uint16_t port = 0;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
// Setup
|
// Initialization
|
||||||
int screenWidth = 800;
|
//--------------------------------------------------------------------------------------
|
||||||
int screenHeight = 450;
|
const int screenWidth = 800;
|
||||||
InitWindow(
|
const int screenHeight = 450;
|
||||||
screenWidth, screenHeight, "raylib [network] example - ping pong");
|
|
||||||
SetTargetFPS(60);
|
|
||||||
|
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - resolve host");
|
||||||
|
|
||||||
// Networking
|
InitNetworkDevice(); // Init network communications
|
||||||
InitNetwork();
|
|
||||||
|
|
||||||
AddressInformation* addr = AllocAddressList(1);
|
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
||||||
int count = ResolveHost(
|
unsigned short port = 0;
|
||||||
NULL,
|
|
||||||
"5210",
|
AddressInformation *address = LoadAddressList(1);
|
||||||
ADDRESS_TYPE_IPV4,
|
|
||||||
0 // Uncomment any of these flags
|
// Address info flags
|
||||||
// ADDRESS_INFO_NUMERICHOST // or try them in conjunction to
|
// ADDRESS_INFO_NUMERICHOST // or try them in conjunction to
|
||||||
// ADDRESS_INFO_NUMERICSERV // specify custom behaviour from
|
// ADDRESS_INFO_NUMERICSERV // specify custom behaviour from
|
||||||
// ADDRESS_INFO_DNS_ONLY // the function getaddrinfo()
|
// ADDRESS_INFO_DNS_ONLY // the function getaddrinfo()
|
||||||
// ADDRESS_INFO_ALL //
|
// ADDRESS_INFO_ALL //
|
||||||
// ADDRESS_INFO_FQDN // e.g. ADDRESS_INFO_CANONNAME | ADDRESS_INFO_NUMERICSERV
|
// ADDRESS_INFO_FQDN // e.g. ADDRESS_INFO_CANONNAME | ADDRESS_INFO_NUMERICSERV
|
||||||
,
|
int count = ResolveHost(NULL, "5210", ADDRESS_TYPE_IPV4, 0, address);
|
||||||
addr
|
|
||||||
);
|
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
GetAddressHostAndPort(addr[0], buffer, &port);
|
GetAddressHostAndPort(address[0], buffer, &port);
|
||||||
TraceLog(LOG_INFO, "Resolved to ip %s::%d\n", buffer, port);
|
TraceLog(LOG_INFO, "Resolved to ip %s::%d", buffer, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// TODO: Update your variables here
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
// Clear
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// End draw
|
// TODO: Draw relevant connection info
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// De-Initialization
|
||||||
CloseWindow();
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,150 +2,141 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - TCP Client
|
* raylib [network] example - TCP Client
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
#include <assert.h>
|
int main(void)
|
||||||
#include <stdio.h>
|
{
|
||||||
#include <string.h>
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - tcp client");
|
||||||
|
|
||||||
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
float elapsed = 0.0f;
|
|
||||||
float delay = 1.0f;
|
|
||||||
bool ping = false;
|
|
||||||
bool pong = false;
|
|
||||||
bool connected = false;
|
|
||||||
const char *pingmsg = "Ping!";
|
const char *pingmsg = "Ping!";
|
||||||
const char *pongmsg = "Pong!";
|
const char *pongmsg = "Pong!";
|
||||||
int msglen = 0;
|
|
||||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true};
|
|
||||||
SocketResult *client_res = NULL;
|
|
||||||
SocketSet * socket_set = NULL;
|
|
||||||
char recvBuffer[512];
|
|
||||||
|
|
||||||
// Attempt to connect to the network (Either TCP, or UDP)
|
bool ping = false;
|
||||||
void NetworkConnect()
|
bool pong = false;
|
||||||
|
float elapsed = 0.0f;
|
||||||
|
float delay = 1.0f;
|
||||||
|
bool connected = false;
|
||||||
|
|
||||||
|
SocketConfig clientConfig = {
|
||||||
|
.host = "127.0.0.1",
|
||||||
|
.port = "4950",
|
||||||
|
.type = SOCKET_TCP,
|
||||||
|
.nonblocking = true
|
||||||
|
};
|
||||||
|
|
||||||
|
SocketSet *socketSet = NULL;
|
||||||
|
SocketResult *clientResult = NULL;
|
||||||
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
|
clientResult = LoadSocketResult();
|
||||||
|
if (!SocketCreate(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Check if we're connected every _delay_ seconds
|
if (!(clientConfig.type == SOCKET_UDP))
|
||||||
elapsed += GetFrameTime();
|
{
|
||||||
if (elapsed > delay) {
|
if (!SocketConnect(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to connect to server: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
if (IsSocketConnected(client_res->socket)) { connected = true; }
|
|
||||||
elapsed = 0.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create and add sockets to the socket set
|
||||||
|
socketSet = LoadSocketSet(1);
|
||||||
|
AddSocket(socketSet, clientResult->socket);
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (connected)
|
||||||
|
{
|
||||||
// Once connected to the network, check the sockets for pending information
|
// Once connected to the network, check the sockets for pending information
|
||||||
// and when information is ready, send either a Ping or a Pong.
|
// and when information is ready, send either a Ping or a Pong.
|
||||||
void NetworkUpdate()
|
|
||||||
{
|
|
||||||
// CheckSockets
|
|
||||||
//
|
|
||||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
|
||||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
|
||||||
int active = CheckSockets(socket_set, 0);
|
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSocketReady
|
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||||
//
|
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||||
// If the socket is ready, attempt to receive data from the socket
|
int active = CheckSockets(socketSet, 0);
|
||||||
|
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
|
|
||||||
|
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||||
int bytesRecv = 0;
|
int bytesRecv = 0;
|
||||||
if (IsSocketReady(client_res->socket)) {
|
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||||
if (bytesRecv > 0) {
|
if (bytesRecv > 0)
|
||||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
{
|
||||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||||
|
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||||
elapsed += GetFrameTime();
|
elapsed += GetFrameTime();
|
||||||
if (elapsed > delay) {
|
if (elapsed > delay)
|
||||||
if (ping) {
|
{
|
||||||
|
if (ping)
|
||||||
|
{
|
||||||
ping = false;
|
ping = false;
|
||||||
SocketSend(client_res->socket, pingmsg, msglen);
|
SocketSend(clientResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||||
} else if (pong) {
|
|
||||||
pong = false;
|
|
||||||
SocketSend(client_res->socket, pongmsg, msglen);
|
|
||||||
}
|
}
|
||||||
|
else if (pong)
|
||||||
|
{
|
||||||
|
pong = false;
|
||||||
|
SocketSend(clientResult->socket, pongmsg, strlen(pingmsg) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
elapsed = 0.0f;
|
elapsed = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
// Setup
|
// Check if we're connected every delay seconds
|
||||||
int screenWidth = 800;
|
elapsed += GetFrameTime();
|
||||||
int screenHeight = 450;
|
if (elapsed > delay)
|
||||||
InitWindow(
|
{
|
||||||
screenWidth, screenHeight, "raylib [network] example - tcp client");
|
if (IsSocketConnected(clientResult->socket)) { connected = true; }
|
||||||
SetTargetFPS(60);
|
elapsed = 0.0f;
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
|
||||||
|
|
||||||
// Networking
|
|
||||||
InitNetwork();
|
|
||||||
|
|
||||||
// Create the client
|
|
||||||
//
|
|
||||||
// Performs
|
|
||||||
// getaddrinfo
|
|
||||||
// socket
|
|
||||||
// setsockopt
|
|
||||||
// connect (TCP only)
|
|
||||||
client_res = AllocSocketResult();
|
|
||||||
if (!SocketCreate(&client_cfg, client_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
|
||||||
client_res->status, client_res->socket->status);
|
|
||||||
} else {
|
|
||||||
if (!(client_cfg.type == SOCKET_UDP)) {
|
|
||||||
if (!SocketConnect(&client_cfg, client_res)) {
|
|
||||||
TraceLog(LOG_WARNING,
|
|
||||||
"Failed to connect to server: status %d, errno %d",
|
|
||||||
client_res->status, client_res->socket->status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Create & Add sockets to the socket set
|
// Draw
|
||||||
socket_set = AllocSocketSet(1);
|
//----------------------------------------------------------------------------------
|
||||||
msglen = strlen(pingmsg) + 1;
|
|
||||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
|
||||||
AddSocket(socket_set, client_res->socket);
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) {
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
if (connected) {
|
|
||||||
NetworkUpdate();
|
// TODO: Draw relevant connection info
|
||||||
} else {
|
|
||||||
NetworkConnect();
|
|
||||||
}
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// De-Initialization
|
||||||
CloseWindow();
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,164 +2,161 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - TCP Server
|
* raylib [network] example - TCP Server
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
#include <assert.h>
|
int main(void)
|
||||||
#include <stdio.h>
|
{
|
||||||
#include <string.h>
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - tcp server");
|
||||||
|
|
||||||
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
float elapsed = 0.0f;
|
|
||||||
float delay = 1.0f;
|
|
||||||
bool ping = false;
|
|
||||||
bool pong = false;
|
|
||||||
bool connected = false;
|
|
||||||
const char *pingmsg = "Ping!";
|
const char *pingmsg = "Ping!";
|
||||||
const char *pongmsg = "Pong!";
|
const char *pongmsg = "Pong!";
|
||||||
int msglen = 0;
|
|
||||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true};
|
bool ping = false;
|
||||||
SocketConfig connection_cfg = {.nonblocking = true};
|
bool pong = false;
|
||||||
SocketResult *server_res = NULL;
|
float elapsed = 0.0f;
|
||||||
SocketSet * socket_set = NULL;
|
float delay = 1.0f;
|
||||||
|
bool connected = false;
|
||||||
|
|
||||||
|
SocketConfig serverConfig = {
|
||||||
|
.host = "127.0.0.1",
|
||||||
|
.port = "4950",
|
||||||
|
.type = SOCKET_TCP,
|
||||||
|
.server = true,
|
||||||
|
.nonblocking = true
|
||||||
|
};
|
||||||
|
|
||||||
|
SocketConfig connectionConfig = { .nonblocking = true };
|
||||||
|
|
||||||
Socket *connection = NULL;
|
Socket *connection = NULL;
|
||||||
char recvBuffer[512];
|
SocketSet *socketSet = NULL;
|
||||||
|
SocketResult *serverResult = NULL;
|
||||||
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Attempt to connect to the network (Either TCP, or UDP)
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
void NetworkConnect()
|
serverResult = LoadSocketResult();
|
||||||
|
if (!SocketCreate(&serverConfig, serverResult))
|
||||||
{
|
{
|
||||||
int active = CheckSockets(socket_set, 0);
|
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
}
|
||||||
if (active > 0) {
|
else
|
||||||
if ((connection = SocketAccept(server_res->socket, &connection_cfg)) != NULL) {
|
{
|
||||||
AddSocket(socket_set, connection);
|
if (!SocketBind(&serverConfig, serverResult))
|
||||||
ping = true;
|
{
|
||||||
connected = true;
|
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(serverConfig.type == SOCKET_UDP))
|
||||||
|
{
|
||||||
|
if (!SocketListen(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to start listen server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create and add sockets to the socket set
|
||||||
|
socketSet = LoadSocketSet(2);
|
||||||
|
AddSocket(socketSet, serverResult->socket);
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (connected)
|
||||||
|
{
|
||||||
// Once connected to the network, check the sockets for pending information
|
// Once connected to the network, check the sockets for pending information
|
||||||
// and when information is ready, send either a Ping or a Pong.
|
// and when information is ready, send either a Ping or a Pong.
|
||||||
void NetworkUpdate()
|
|
||||||
{
|
|
||||||
// CheckSockets
|
|
||||||
//
|
|
||||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
|
||||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
|
||||||
int active = CheckSockets(socket_set, 0);
|
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSocketReady
|
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||||
//
|
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||||
// If the socket is ready, attempt to receive data from the socket
|
int active = CheckSockets(socketSet, 0);
|
||||||
|
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
|
|
||||||
|
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||||
int bytesRecv = 0;
|
int bytesRecv = 0;
|
||||||
if (IsSocketReady(connection)) {
|
if (IsSocketReady(connection)) bytesRecv = SocketReceive(connection, receiveBuffer, strlen(pingmsg) + 1);
|
||||||
bytesRecv = SocketReceive(connection, recvBuffer, msglen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||||
if (bytesRecv > 0) {
|
if (bytesRecv > 0)
|
||||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
{
|
||||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||||
|
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||||
elapsed += GetFrameTime();
|
elapsed += GetFrameTime();
|
||||||
if (elapsed > delay) {
|
if (elapsed > delay)
|
||||||
if (ping) {
|
{
|
||||||
|
if (ping)
|
||||||
|
{
|
||||||
ping = false;
|
ping = false;
|
||||||
SocketSend(connection, pingmsg, msglen);
|
SocketSend(connection, pingmsg, strlen(pingmsg) + 1);
|
||||||
} else if (pong) {
|
|
||||||
pong = false;
|
|
||||||
SocketSend(connection, pongmsg, msglen);
|
|
||||||
}
|
}
|
||||||
|
else if (pong)
|
||||||
|
{
|
||||||
|
pong = false;
|
||||||
|
SocketSend(connection, pongmsg, strlen(pingmsg) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
elapsed = 0.0f;
|
elapsed = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
// Setup
|
// Attempt to connect to the network (Either TCP, or UDP)
|
||||||
int screenWidth = 800;
|
int active = CheckSockets(socketSet, 0);
|
||||||
int screenHeight = 450;
|
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
InitWindow(
|
|
||||||
screenWidth, screenHeight, "raylib [network] example - tcp server");
|
|
||||||
SetTargetFPS(60);
|
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
|
||||||
|
|
||||||
// Networking
|
if (active > 0)
|
||||||
InitNetwork();
|
{
|
||||||
|
if ((connection = SocketAccept(serverResult->socket, &connectionConfig)) != NULL)
|
||||||
// Create the server
|
{
|
||||||
//
|
AddSocket(socketSet, connection);
|
||||||
// Performs
|
connected = true;
|
||||||
// getaddrinfo
|
ping = true;
|
||||||
// socket
|
|
||||||
// setsockopt
|
|
||||||
// bind
|
|
||||||
// listen
|
|
||||||
server_res = AllocSocketResult();
|
|
||||||
if (!SocketCreate(&server_cfg, server_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
} else {
|
|
||||||
if (!SocketBind(&server_cfg, server_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
} else {
|
|
||||||
if (!(server_cfg.type == SOCKET_UDP)) {
|
|
||||||
if (!SocketListen(&server_cfg, server_res)) {
|
|
||||||
TraceLog(LOG_WARNING,
|
|
||||||
"Failed to start listen server: status %d, errno %d",
|
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Create & Add sockets to the socket set
|
// Draw
|
||||||
socket_set = AllocSocketSet(2);
|
//----------------------------------------------------------------------------------
|
||||||
msglen = strlen(pingmsg) + 1;
|
|
||||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
|
||||||
AddSocket(socket_set, server_res->socket);
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) {
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
if (connected) {
|
|
||||||
NetworkUpdate();
|
// TODO: Draw relevant connection info
|
||||||
} else {
|
|
||||||
NetworkConnect();
|
|
||||||
}
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// De-Initialization
|
||||||
CloseWindow();
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,47 +2,38 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - Network Test
|
* raylib [network] example - Network Test
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void test_network_initialise()
|
void test_network_initialise()
|
||||||
{
|
{
|
||||||
assert(InitNetwork() == true);
|
assert(InitNetworkDevice() == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_socket_result()
|
void test_socket_result()
|
||||||
{
|
{
|
||||||
SocketResult *result = AllocSocketResult();
|
SocketResult *result = LoadSocketResult();
|
||||||
assert(result != NULL);
|
assert(result != NULL);
|
||||||
FreeSocketResult(&result);
|
UnloadSocketResult(&result);
|
||||||
assert(result == NULL);
|
assert(result == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_socket()
|
void test_socket()
|
||||||
{
|
{
|
||||||
Socket *socket = AllocSocket();
|
Socket *socket = LoadSocket();
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
FreeSocket(&socket);
|
UnloadSocket(&socket);
|
||||||
assert(socket == NULL);
|
assert(socket == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +84,7 @@ void test_resolve_host()
|
||||||
{
|
{
|
||||||
const char *address = "localhost";
|
const char *address = "localhost";
|
||||||
const char *port = "80";
|
const char *port = "80";
|
||||||
AddressInformation *addr = AllocAddressList(3);
|
AddressInformation *addr = LoadAddressList(3);
|
||||||
int count = ResolveHost(address, port, ADDRESS_TYPE_ANY, 0, addr);
|
int count = ResolveHost(address, port, ADDRESS_TYPE_ANY, 0, addr);
|
||||||
|
|
||||||
assert(GetAddressFamily(addr[0]) == ADDRESS_TYPE_IPV6);
|
assert(GetAddressFamily(addr[0]) == ADDRESS_TYPE_IPV6);
|
||||||
|
|
@ -114,35 +105,60 @@ void test_address_list()
|
||||||
void test_socket_create()
|
void test_socket_create()
|
||||||
{
|
{
|
||||||
SocketConfig server_cfg = { .host = "127.0.0.1", .port = "8080", .server = true, .nonblocking = true };
|
SocketConfig server_cfg = { .host = "127.0.0.1", .port = "8080", .server = true, .nonblocking = true };
|
||||||
Socket * socket = AllocSocket();
|
Socket *socket = LoadSocket();
|
||||||
SocketResult *server_res = AllocSocketResult();
|
SocketResult *server_res = LoadSocketResult();
|
||||||
SocketSet * socket_set = AllocSocketSet(1);
|
SocketSet *socket_set = LoadSocketSet(1);
|
||||||
|
|
||||||
assert(SocketCreate(&server_cfg, server_res));
|
assert(SocketCreate(&server_cfg, server_res));
|
||||||
assert(AddSocket(socket_set, server_res->socket));
|
assert(AddSocket(socket_set, server_res->socket));
|
||||||
assert(SocketListen(&server_cfg, server_res));
|
assert(SocketListen(&server_cfg, server_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
int screenWidth = 800;
|
// Initialization
|
||||||
int screenHeight = 450;
|
//--------------------------------------------------------------------------------------
|
||||||
InitWindow(
|
const int screenWidth = 800;
|
||||||
screenWidth, screenHeight, "raylib [network] example - network test");
|
const int screenHeight = 450;
|
||||||
SetTargetFPS(60);
|
|
||||||
|
|
||||||
// Run the tests
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - network test");
|
||||||
test_network_initialise();
|
|
||||||
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
|
// Run some tests
|
||||||
test_resolve_host();
|
test_resolve_host();
|
||||||
//test_socket_create();
|
//test_socket_create();
|
||||||
|
//test_resolve_ip();
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// TODO: Update your variables here
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
|
||||||
|
// TODO: Draw relevant connection info
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
CloseWindow();
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,127 +2,123 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - UDP Client
|
* raylib [network] example - UDP Client
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
#include <assert.h>
|
int main(void)
|
||||||
#include <stdio.h>
|
{
|
||||||
#include <string.h>
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - udp client");
|
||||||
|
|
||||||
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
float elapsed = 0.0f;
|
|
||||||
float delay = 1.0f;
|
|
||||||
bool ping = false;
|
|
||||||
bool pong = false;
|
|
||||||
const char *pingmsg = "Ping!";
|
const char *pingmsg = "Ping!";
|
||||||
const char *pongmsg = "Pong!";
|
const char *pongmsg = "Pong!";
|
||||||
int msglen = 0;
|
|
||||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_UDP, .nonblocking = true};
|
|
||||||
SocketResult *client_res = NULL;
|
|
||||||
SocketSet * socket_set = NULL;
|
|
||||||
char recvBuffer[512];
|
|
||||||
|
|
||||||
// Once connected to the network, check the sockets for pending information
|
bool ping = true;
|
||||||
// and when information is ready, send either a Ping or a Pong.
|
bool pong = false;
|
||||||
void NetworkUpdate()
|
float elapsed = 0.0f;
|
||||||
|
float delay = 1.0f;
|
||||||
|
|
||||||
|
SocketConfig clientConfig = {
|
||||||
|
.host = "127.0.0.1",
|
||||||
|
.port = "4950",
|
||||||
|
.type = SOCKET_UDP,
|
||||||
|
.nonblocking = true
|
||||||
|
};
|
||||||
|
|
||||||
|
SocketResult *clientResult = NULL;
|
||||||
|
SocketSet *socketSet = NULL;
|
||||||
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
|
clientResult = LoadSocketResult();
|
||||||
|
if (!SocketCreate(&clientConfig, clientResult))
|
||||||
{
|
{
|
||||||
// CheckSockets
|
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
//
|
|
||||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
|
||||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
|
||||||
int active = CheckSockets(socket_set, 0);
|
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSocketReady
|
// Create and add sockets to the socket set
|
||||||
//
|
socketSet = LoadSocketSet(1);
|
||||||
// If the socket is ready, attempt to receive data from the socket
|
AddSocket(socketSet, clientResult->socket);
|
||||||
int bytesRecv = 0;
|
|
||||||
if (IsSocketReady(client_res->socket)) {
|
|
||||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
if (bytesRecv > 0) {
|
//--------------------------------------------------------------------------------------
|
||||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
|
||||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
|
||||||
elapsed += GetFrameTime();
|
|
||||||
if (elapsed > delay) {
|
|
||||||
if (ping) {
|
|
||||||
ping = false;
|
|
||||||
SocketSend(client_res->socket, pingmsg, msglen);
|
|
||||||
} else if (pong) {
|
|
||||||
pong = false;
|
|
||||||
SocketSend(client_res->socket, pongmsg, msglen);
|
|
||||||
}
|
|
||||||
elapsed = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Setup
|
|
||||||
int screenWidth = 800;
|
|
||||||
int screenHeight = 450;
|
|
||||||
InitWindow(
|
|
||||||
screenWidth, screenHeight, "raylib [network] example - udp client");
|
|
||||||
SetTargetFPS(60);
|
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
|
||||||
|
|
||||||
// Networking
|
|
||||||
InitNetwork();
|
|
||||||
|
|
||||||
// Create the client
|
|
||||||
//
|
|
||||||
// Performs
|
|
||||||
// getaddrinfo
|
|
||||||
// socket
|
|
||||||
// setsockopt
|
|
||||||
// connect (TCP only)
|
|
||||||
client_res = AllocSocketResult();
|
|
||||||
if (!SocketCreate(&client_cfg, client_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
|
||||||
client_res->status, client_res->socket->status);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create & Add sockets to the socket set
|
|
||||||
socket_set = AllocSocketSet(1);
|
|
||||||
msglen = strlen(pingmsg) + 1;
|
|
||||||
ping = true;
|
|
||||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
|
||||||
AddSocket(socket_set, client_res->socket);
|
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
BeginDrawing();
|
{
|
||||||
ClearBackground(RAYWHITE);
|
// Update
|
||||||
NetworkUpdate();
|
//----------------------------------------------------------------------------------
|
||||||
EndDrawing();
|
// Once connected to the network, check the sockets for pending information
|
||||||
|
// and when information is ready, send either a Ping or a Pong.
|
||||||
|
|
||||||
|
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||||
|
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||||
|
int active = CheckSockets(socketSet, 0);
|
||||||
|
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
|
|
||||||
|
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||||
|
int bytesRecv = 0;
|
||||||
|
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||||
|
|
||||||
|
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||||
|
if (bytesRecv > 0)
|
||||||
|
{
|
||||||
|
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||||
|
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice-versa
|
||||||
CloseWindow();
|
elapsed += GetFrameTime();
|
||||||
|
if (elapsed > delay)
|
||||||
|
{
|
||||||
|
if (ping)
|
||||||
|
{
|
||||||
|
ping = false;
|
||||||
|
SocketSend(clientResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||||
|
}
|
||||||
|
else if (pong)
|
||||||
|
{
|
||||||
|
pong = false;
|
||||||
|
SocketSend(clientResult->socket, pongmsg, strlen(pongmsg) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
elapsed = 0.0f;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// TODO: Draw relevant connection info
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,133 +2,127 @@
|
||||||
*
|
*
|
||||||
* raylib [network] example - UDP Server
|
* raylib [network] example - UDP Server
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h
|
|
||||||
*for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RNET_IMPLEMENTATION
|
||||||
#include "rnet.h"
|
#include "rnet.h"
|
||||||
|
|
||||||
#include <assert.h>
|
int main(void)
|
||||||
#include <stdio.h>
|
{
|
||||||
#include <string.h>
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [network] example - udp server");
|
||||||
|
|
||||||
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
float elapsed = 0.0f;
|
|
||||||
float delay = 1.0f;
|
|
||||||
bool ping = false;
|
|
||||||
bool pong = false;
|
|
||||||
const char *pingmsg = "Ping!";
|
const char *pingmsg = "Ping!";
|
||||||
const char *pongmsg = "Pong!";
|
const char *pongmsg = "Pong!";
|
||||||
int msglen = 0;
|
|
||||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .server = true, .type = SOCKET_UDP, .nonblocking = true};
|
|
||||||
SocketResult *server_res = NULL;
|
|
||||||
SocketSet * socket_set = NULL;
|
|
||||||
char recvBuffer[512];
|
|
||||||
|
|
||||||
// Once connected to the network, check the sockets for pending information
|
bool ping = false;
|
||||||
// and when information is ready, send either a Ping or a Pong.
|
bool pong = false;
|
||||||
void NetworkUpdate()
|
float elapsed = 0.0f;
|
||||||
{
|
float delay = 1.0f;
|
||||||
// CheckSockets
|
|
||||||
//
|
|
||||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
|
||||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
|
||||||
int active = CheckSockets(socket_set, 0);
|
|
||||||
if (active != 0) {
|
|
||||||
TraceLog(LOG_DEBUG,
|
|
||||||
"There are currently %d socket(s) with data to be processed.", active);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSocketReady
|
SocketConfig serverConfig = {
|
||||||
//
|
.host = "127.0.0.1",
|
||||||
// If the socket is ready, attempt to receive data from the socket
|
.port = "4950",
|
||||||
// int bytesRecv = 0;
|
.server = true,
|
||||||
// if (IsSocketReady(server_res->socket)) {
|
.type = SOCKET_UDP,
|
||||||
// bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
.nonblocking = true
|
||||||
// }
|
};
|
||||||
int bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
|
||||||
|
|
||||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
SocketResult *serverResult = NULL;
|
||||||
if (bytesRecv > 0) {
|
SocketSet *socketSet = NULL;
|
||||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
char receiveBuffer[512] = { 0 };
|
||||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
elapsed += GetFrameTime();
|
serverResult = LoadSocketResult();
|
||||||
if (elapsed > delay) {
|
|
||||||
if (ping) {
|
|
||||||
ping = false;
|
|
||||||
SocketSend(server_res->socket, pingmsg, msglen);
|
|
||||||
} else if (pong) {
|
|
||||||
pong = false;
|
|
||||||
SocketSend(server_res->socket, pongmsg, msglen);
|
|
||||||
}
|
|
||||||
elapsed = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
if (!SocketCreate(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
{
|
else if (!SocketBind(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
// Setup
|
|
||||||
int screenWidth = 800;
|
|
||||||
int screenHeight = 450;
|
|
||||||
InitWindow(
|
|
||||||
screenWidth, screenHeight, "raylib [network] example - udp server");
|
|
||||||
SetTargetFPS(60);
|
|
||||||
SetTraceLogLevel(LOG_DEBUG);
|
|
||||||
|
|
||||||
// Networking
|
// Create and add sockets to the socket set
|
||||||
InitNetwork();
|
socketSet = LoadSocketSet(1);
|
||||||
|
AddSocket(socketSet, serverResult->socket);
|
||||||
|
|
||||||
// Create the server
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//
|
//--------------------------------------------------------------------------------------
|
||||||
// Performs
|
|
||||||
// getaddrinfo
|
|
||||||
// socket
|
|
||||||
// setsockopt
|
|
||||||
// bind
|
|
||||||
// listen
|
|
||||||
server_res = AllocSocketResult();
|
|
||||||
if (!SocketCreate(&server_cfg, server_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
} else {
|
|
||||||
if (!SocketBind(&server_cfg, server_res)) {
|
|
||||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
|
||||||
server_res->status, server_res->socket->status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create & Add sockets to the socket set
|
|
||||||
socket_set = AllocSocketSet(1);
|
|
||||||
msglen = strlen(pingmsg) + 1;
|
|
||||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
|
||||||
AddSocket(socket_set, server_res->socket);
|
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
BeginDrawing();
|
{
|
||||||
ClearBackground(RAYWHITE);
|
// Update
|
||||||
NetworkUpdate();
|
//----------------------------------------------------------------------------------
|
||||||
EndDrawing();
|
// Once connected to the network, check the sockets for pending information
|
||||||
|
// and when information is ready, send either a Ping or a Pong.
|
||||||
|
|
||||||
|
// CheckSockets, if any of the sockets in the set are pending (received data, or requests)
|
||||||
|
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||||
|
int active = CheckSockets(socketSet, 0);
|
||||||
|
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||||
|
|
||||||
|
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||||
|
// int bytesRecv = 0;
|
||||||
|
// if (IsSocketReady(serverResult->socket)) {
|
||||||
|
// bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, msglen);
|
||||||
|
// }
|
||||||
|
int bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||||
|
|
||||||
|
// If we received data, is that data a "Ping!" or a "Pong!"?
|
||||||
|
if (bytesRecv > 0)
|
||||||
|
{
|
||||||
|
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||||
|
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice-versa
|
||||||
CloseWindow();
|
elapsed += GetFrameTime();
|
||||||
|
|
||||||
|
if (elapsed > delay)
|
||||||
|
{
|
||||||
|
if (ping)
|
||||||
|
{
|
||||||
|
ping = false;
|
||||||
|
SocketSend(serverResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||||
|
}
|
||||||
|
else if (pong)
|
||||||
|
{
|
||||||
|
pong = false;
|
||||||
|
SocketSend(serverResult->socket, pongmsg, strlen(pongmsg) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
elapsed = 0.0f;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// TODO: Draw relevant connection info
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseNetworkDevice(); // Close network communication
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= raylib_examples
|
PROJECT_NAME ?= raylib_examples
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= ..
|
RAYLIB_PATH ?= ..
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -115,13 +115,12 @@ endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# Emscripten required variables
|
# Emscripten required variables
|
||||||
EMSDK_PATH ?= D:/emsdk
|
EMSDK_PATH ?= C:/emsdk
|
||||||
EMSCRIPTEN_VERSION ?= 1.38.31
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,10 +187,19 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Additional flags for compiler (if desired)
|
# Additional flags for compiler (if desired)
|
||||||
|
|
@ -200,7 +208,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
# resource file contains windows executable icon and properties
|
# resource file contains windows executable icon and properties
|
||||||
# -Wl,--subsystem,windows hides the console window
|
# -Wl,--subsystem,windows hides the console window
|
||||||
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
|
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
CFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
|
|
@ -230,10 +241,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3
|
CFLAGS += -s USE_GLFW=3
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -372,7 +380,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= roomba
|
PROJECT_NAME ?= roomba
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= C:\GitHub\raylib
|
RAYLIB_PATH ?= C:\GitHub\raylib
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -116,12 +116,11 @@ 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.38.31
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,20 +187,24 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -230,10 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources
|
CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -267,6 +267,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -290,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
# NOTE: WinMM library required to set high-res timer resolution
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
# Required for physac examples
|
# Required for physac examples
|
||||||
#LDLIBS += -static -lpthread
|
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
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -380,7 +388,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GameScreen currentScreen = 0;
|
||||||
|
Font font = { 0 };
|
||||||
|
Font font2 = { 0 };
|
||||||
|
Music music = { 0 };
|
||||||
|
Sound fxCoin = { 0 };
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition (local to this module)
|
// Global Variables Definition (local to this module)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScree
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition
|
// Global Variables Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
GameScreen currentScreen;
|
extern GameScreen currentScreen;
|
||||||
Font font;
|
extern Font font;
|
||||||
Font font2;
|
extern Font font2;
|
||||||
Music music;
|
extern Music music;
|
||||||
Sound fxCoin;
|
extern Sound fxCoin;
|
||||||
|
|
||||||
int score;
|
int score;
|
||||||
int result; // 0-Loose, 1-Win
|
int result; // 0-Loose, 1-Win
|
||||||
|
|
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= drturtle
|
PROJECT_NAME ?= drturtle
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= C:\GitHub\raylib
|
RAYLIB_PATH ?= C:\GitHub\raylib
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -116,12 +116,11 @@ 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.38.32
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,20 +187,24 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -230,10 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -267,6 +267,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -290,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
# NOTE: WinMM library required to set high-res timer resolution
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
# Required for physac examples
|
# Required for physac examples
|
||||||
#LDLIBS += -static -lpthread
|
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
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -359,7 +367,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= just_do
|
PROJECT_NAME ?= just_do
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= C:\GitHub\raylib
|
RAYLIB_PATH ?= C:\GitHub\raylib
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -116,12 +116,11 @@ 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.38.31
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,20 +187,24 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -230,10 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources
|
CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -267,6 +267,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -290,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
# NOTE: WinMM library required to set high-res timer resolution
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
# Required for physac examples
|
# Required for physac examples
|
||||||
#LDLIBS += -static -lpthread
|
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
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -387,7 +395,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= koala_seasons
|
PROJECT_NAME ?= koala_seasons
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= C:\GitHub\raylib
|
RAYLIB_PATH ?= C:\GitHub\raylib
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -116,12 +116,11 @@ 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.38.32
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,20 +187,24 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -230,10 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -267,6 +267,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -290,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
# NOTE: WinMM library required to set high-res timer resolution
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
# Required for physac examples
|
# Required for physac examples
|
||||||
#LDLIBS += -static -lpthread
|
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
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -380,7 +388,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
|
|
@ -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-2019 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2020 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.
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= light_my_ritual
|
PROJECT_NAME ?= light_my_ritual
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 3.0.0
|
||||||
RAYLIB_API_VERSION ?= 2
|
RAYLIB_API_VERSION ?= 3
|
||||||
RAYLIB_PATH ?= C:\GitHub\raylib
|
RAYLIB_PATH ?= C:\GitHub\raylib
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -116,12 +116,11 @@ 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.38.32
|
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten
|
||||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||||
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);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
|
|
@ -188,20 +187,24 @@ endif
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -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
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
ifeq ($(BUILD_MODE),DEBUG)
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS += -Os
|
||||||
|
else
|
||||||
|
CFLAGS += -s -O1
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# 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)
|
|
||||||
# resource file contains windows executable icon and properties
|
|
||||||
# -Wl,--subsystem,windows hides the console window
|
|
||||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
|
|
@ -230,10 +233,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
# --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)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources
|
||||||
ifeq ($(BUILD_MODE), DEBUG)
|
|
||||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
|
|
@ -267,6 +267,14 @@ endif
|
||||||
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),WINDOWS)
|
||||||
|
# resource file contains windows executable icon and properties
|
||||||
|
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
ifeq ($(BUILD_MODE), RELEASE)
|
||||||
|
LDFLAGS += -Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||||
|
|
@ -290,7 +298,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# NOTE: WinMM library required to set high-res timer resolution
|
# NOTE: WinMM library required to set high-res timer resolution
|
||||||
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
# Required for physac examples
|
# Required for physac examples
|
||||||
#LDLIBS += -static -lpthread
|
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
|
||||||
|
|
@ -314,7 +322,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# Libraries for OSX 10.9 desktop compiling
|
# Libraries for OSX 10.9 desktop compiling
|
||||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
ifeq ($(PLATFORM_OS),BSD)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
|
|
@ -379,7 +387,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 -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-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
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue