From d739895e4a8602034d7a65a3be0c90163dabb817 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 8 Jan 2015 21:10:06 +0100 Subject: [PATCH 1/3] Reorganized external folders by platform Improved makefiles! --- examples/makefile | 45 +++++++++++++----- external/glew/lib/{ => win32}/libglew32.a | Bin external/glew/lib/{ => win32}/libglew32dll.a | Bin external/glfw3/lib/libglfw.3.dylib | 1 - external/glfw3/lib/libglfw.dylib | 1 - .../glfw3/lib/{ => osx}/libglfw.3.0.dylib | Bin external/glfw3/lib/osx/libglfw.3.dylib | 1 + external/glfw3/lib/osx/libglfw.dylib | 1 + external/glfw3/lib/{ => win32}/libglfw3.a | Bin external/glfw3/lib/{ => win32}/libglfw3dll.a | Bin .../openal_soft/lib/{ => win32}/libopenal32.a | Bin src/makefile | 21 +++++--- 12 files changed, 50 insertions(+), 20 deletions(-) rename external/glew/lib/{ => win32}/libglew32.a (100%) rename external/glew/lib/{ => win32}/libglew32dll.a (100%) delete mode 120000 external/glfw3/lib/libglfw.3.dylib delete mode 120000 external/glfw3/lib/libglfw.dylib rename external/glfw3/lib/{ => osx}/libglfw.3.0.dylib (100%) mode change 100755 => 100644 create mode 100644 external/glfw3/lib/osx/libglfw.3.dylib create mode 100644 external/glfw3/lib/osx/libglfw.dylib rename external/glfw3/lib/{ => win32}/libglfw3.a (100%) rename external/glfw3/lib/{ => win32}/libglfw3dll.a (100%) rename external/openal_soft/lib/{ => win32}/libopenal32.a (100%) diff --git a/examples/makefile b/examples/makefile index 9763b233..500ba715 100644 --- a/examples/makefile +++ b/examples/makefile @@ -26,18 +26,21 @@ # WARNING: To compile examples to HTML5, they must be redesigned to use emscripten.h and emscripten_set_main_loop() PLATFORM ?= PLATFORM_DESKTOP -# determine SUBPLATFORM in case PLATFORM_DESKTOP selected +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) - SUBPLATFORM=WINDOWS + PLATFORM_OS=WINDOWS + LIBPATH=win32 else UNAMEOS:=$(shell uname) ifeq ($(UNAMEOS),Linux) - SUBPLATFORM=LINUX + PLATFORM_OS=LINUX + LIBPATH=linux else ifeq ($(UNAMEOS),Darwin) - SUBPLATFORM=OSX + PLATFORM_OS=OSX + LIBPATH=osx endif endif endif @@ -47,10 +50,15 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # define emscripten compiler CC = emcc +else +ifeq ($(PLATFORM_OS),OSX) + # define llvm compiler for mac + CC = clang else # define default gcc compiler CC = gcc endif +endif # define compiler flags: # -O2 defines optimization level @@ -74,25 +82,39 @@ ifeq ($(PLATFORM),PLATFORM_RPI) INCLUDES = -I. -I../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads else INCLUDES = -I. -I../src +# external libraries headers +# GLFW3 + INCLUDES += -I../external/glfw3/include +# GLEW + INCLUDES += -I../external/glew/include +# OpenAL Soft + INCLUDES += -I../external/openal_soft/include endif # define library paths containing required libs ifeq ($(PLATFORM),PLATFORM_RPI) LFLAGS = -L. -L../src -L/opt/vc/lib else - LFLAGS = -L. -L../src -L../external/glfw3/lib/ -I../external/openal_soft/lib/ + LFLAGS = -L. -L../src +# external libraries to link with +# GLFW3 + LFLAGS += -L../external/glfw3/lib/$(LIBPATH) +# GLEW + LFLAGS += -L../external/openal_soft/lib/$(LIBPATH) +# OpenAL Soft + LFLAGS += -L../external/glew/lib/$(LIBPATH) endif # define any libraries to link into executable # if you want to link libraries (libname.so or libname.a), use the -lname ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(SUBPLATFORM),LINUX) + ifeq ($(PLATFORM_OS),LINUX) # libraries for Debian GNU/Linux desktop compiling # requires the following packages: # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal endif - ifeq ($(SUBPLATFORM),OSX) + ifeq ($(PLATFORM_OS),OSX) # libraries for OS X 10.9 desktop compiling # requires the following packages: # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev @@ -101,7 +123,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) else # libraries for Windows desktop compiling # NOTE: GLFW3 and OpenAL Soft libraries should be installed - LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 endif endif ifeq ($(PLATFORM),PLATFORM_RPI) @@ -114,7 +136,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # define additional parameters and flags for windows -ifeq ($(PLATFORM),PLATFORM_DESKTOP) +ifeq ($(PLATFORM_OS),WINDOWS) # resources file contains windows exe icon # -Wl,--subsystem,windows hides the console window WINFLAGS = ../src/resources -Wl,--subsystem,windows @@ -290,10 +312,11 @@ audio_music_stream: audio_music_stream.c # clean everything clean: ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(SUBPLATFORM),OSX) + ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -delete rm -f *.o else - ifeq ($(SUBPLATFORM),LINUX) + ifeq ($(PLATFORM_OS),LINUX) find . -type f -executable -delete rm -f *.o else diff --git a/external/glew/lib/libglew32.a b/external/glew/lib/win32/libglew32.a similarity index 100% rename from external/glew/lib/libglew32.a rename to external/glew/lib/win32/libglew32.a diff --git a/external/glew/lib/libglew32dll.a b/external/glew/lib/win32/libglew32dll.a similarity index 100% rename from external/glew/lib/libglew32dll.a rename to external/glew/lib/win32/libglew32dll.a diff --git a/external/glfw3/lib/libglfw.3.dylib b/external/glfw3/lib/libglfw.3.dylib deleted file mode 120000 index cd20112e..00000000 --- a/external/glfw3/lib/libglfw.3.dylib +++ /dev/null @@ -1 +0,0 @@ -libglfw.3.0.dylib \ No newline at end of file diff --git a/external/glfw3/lib/libglfw.dylib b/external/glfw3/lib/libglfw.dylib deleted file mode 120000 index d4bd51e1..00000000 --- a/external/glfw3/lib/libglfw.dylib +++ /dev/null @@ -1 +0,0 @@ -libglfw.3.dylib \ No newline at end of file diff --git a/external/glfw3/lib/libglfw.3.0.dylib b/external/glfw3/lib/osx/libglfw.3.0.dylib old mode 100755 new mode 100644 similarity index 100% rename from external/glfw3/lib/libglfw.3.0.dylib rename to external/glfw3/lib/osx/libglfw.3.0.dylib diff --git a/external/glfw3/lib/osx/libglfw.3.dylib b/external/glfw3/lib/osx/libglfw.3.dylib new file mode 100644 index 00000000..cd20112e --- /dev/null +++ b/external/glfw3/lib/osx/libglfw.3.dylib @@ -0,0 +1 @@ +libglfw.3.0.dylib \ No newline at end of file diff --git a/external/glfw3/lib/osx/libglfw.dylib b/external/glfw3/lib/osx/libglfw.dylib new file mode 100644 index 00000000..d4bd51e1 --- /dev/null +++ b/external/glfw3/lib/osx/libglfw.dylib @@ -0,0 +1 @@ +libglfw.3.dylib \ No newline at end of file diff --git a/external/glfw3/lib/libglfw3.a b/external/glfw3/lib/win32/libglfw3.a similarity index 100% rename from external/glfw3/lib/libglfw3.a rename to external/glfw3/lib/win32/libglfw3.a diff --git a/external/glfw3/lib/libglfw3dll.a b/external/glfw3/lib/win32/libglfw3dll.a similarity index 100% rename from external/glfw3/lib/libglfw3dll.a rename to external/glfw3/lib/win32/libglfw3dll.a diff --git a/external/openal_soft/lib/libopenal32.a b/external/openal_soft/lib/win32/libopenal32.a similarity index 100% rename from external/openal_soft/lib/libopenal32.a rename to external/openal_soft/lib/win32/libopenal32.a diff --git a/src/makefile b/src/makefile index 8566abe4..a726b92e 100644 --- a/src/makefile +++ b/src/makefile @@ -25,18 +25,18 @@ # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB PLATFORM ?= PLATFORM_DESKTOP -# determine SUBPLATFORM in case PLATFORM_DESKTOP selected +# determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) - SUBPLATFORM=WINDOWS + PLATFORM_OS=WINDOWS else UNAMEOS:=$(shell uname) ifeq ($(UNAMEOS),Linux) - SUBPLATFORM=LINUX + PLATFORM_OS=LINUX else ifeq ($(UNAMEOS),Darwin) - SUBPLATFORM=OSX + PLATFORM_OS=OSX endif endif endif @@ -82,7 +82,14 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) INCLUDES = -I. -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads else - INCLUDES = -I. -I../external/glfw3/include/ -I../external/openal_soft/include/ + INCLUDES = -I. -I../src +# external libraries headers +# GLFW3 + INCLUDES += -I../external/glfw3/include +# GLEW + INCLUDES += -I../external/glew/include +# OpenAL Soft + INCLUDES += -I../external/openal_soft/include endif # define all object files required @@ -144,10 +151,10 @@ stb_vorbis.o: stb_vorbis.c # clean everything clean: ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(SUBPLATFORM),OSX) + ifeq ($(PLATFORM_OS),OSX) rm -f *.o libraylib.a else - ifeq ($(SUBPLATFORM),LINUX) + ifeq ($(PLATFORM_OS),LINUX) find . -type f -executable -delete rm -f *.o libraylib.a else From 31934ac374d0e7ca90037794ed3057c6e84e4c8a Mon Sep 17 00:00:00 2001 From: David Gallardo Date: Thu, 8 Jan 2015 22:09:29 +0100 Subject: [PATCH 2/3] Improved support for mac. Reference to libglfw dylib fixed --- examples/makefile | 20 +++++++++++++++----- external/glfw3/lib/osx/libglfw.3.0.dylib | Bin 127856 -> 127856 bytes 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/makefile b/examples/makefile index 500ba715..b4d7bfa3 100644 --- a/examples/makefile +++ b/examples/makefile @@ -99,10 +99,12 @@ else # external libraries to link with # GLFW3 LFLAGS += -L../external/glfw3/lib/$(LIBPATH) -# GLEW - LFLAGS += -L../external/openal_soft/lib/$(LIBPATH) -# OpenAL Soft - LFLAGS += -L../external/glew/lib/$(LIBPATH) + ifneq ($(PLATFORM_OS),OSX) + # OpenAL Soft + LFLAGS += -L../external/openal_soft/lib/$(LIBPATH) + # GLEW + LFLAGS += -L../external/glew/lib/$(LIBPATH) + endif endif # define any libraries to link into executable @@ -177,6 +179,8 @@ EXAMPLES = \ models_cubicmap \ audio_sound_loading \ audio_music_stream \ + fix_dylib \ + #core_input_gamepad \ @@ -309,11 +313,17 @@ audio_sound_loading: audio_sound_loading.c audio_music_stream: audio_music_stream.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) +# fix dylib install path name for each executable (MAC) +fix_dylib: +ifeq ($(PLATFORM_OS),OSX) + find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file +endif + # clean everything clean: ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),OSX) - find . -type f -perm +ugo+x -delete + find . -type f -perm +ugo+x -delete rm -f *.o else ifeq ($(PLATFORM_OS),LINUX) diff --git a/external/glfw3/lib/osx/libglfw.3.0.dylib b/external/glfw3/lib/osx/libglfw.3.0.dylib index 963d716d127232cb0f65aeee06c70e6fa92d5739..15674573ccc9efbce8df1b54042dca0604158db2 100644 GIT binary patch delta 73 zcmezHjQzti_6Z`478^ykb7&YaFfd2}F(VK&FffC0PG(YiPFlI1v7UimN+pm76y2=C VnPW700k1*x1ncb+tQj9{2LP-26Vd2nb3`OCFfd2}F(VK&FffC$erR!OQL%neVo737VrF)teo$&b zesN|=eov3_brNorAEVvc@#PFlIKeokf*41)ypjP+6~fnuA#aO4;@Pq5xT!J6^G Fb^s`_CsP0b From bb8c1826d3d3c02cc8e91d6187cd5035a440a6ac Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 10 Jan 2015 13:26:34 +0100 Subject: [PATCH 3/3] Uploaded basic window example for web --- examples/core_basic_window_web.c | 89 ++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 examples/core_basic_window_web.c diff --git a/examples/core_basic_window_web.c b/examples/core_basic_window_web.c new file mode 100644 index 00000000..b35c07e6 --- /dev/null +++ b/examples/core_basic_window_web.c @@ -0,0 +1,89 @@ +/******************************************************************************************* +* +* raylib [core] example - Basic window +* +* Welcome to raylib! +* +* To test examples, just press F6 and execute raylib_compile_execute script +* Note that compiled executable is placed in the same folder as .c file +* +* You can find all basic examples on C:\raylib\raylib\examples folder or +* raylib official webpage: www.raylib.com +* +* Enjoy using raylib. :) +* +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +#if defined(PLATFORM_WEB) + #include +#endif + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +int screenWidth = 800; +int screenHeight = 450; + +//---------------------------------------------------------------------------------- +// Module Functions Declaration +//---------------------------------------------------------------------------------- +void UpdateDrawFrame(void); // Update and Draw one frame + +//---------------------------------------------------------------------------------- +// Main Enry Point +//---------------------------------------------------------------------------------- +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); + +#if defined(PLATFORM_WEB) + emscripten_set_main_loop(UpdateDrawFrame, 0, 1); +#else + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + UpdateDrawFrame(); + } +#endif + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +//---------------------------------------------------------------------------------- +// Module Functions Definition +//---------------------------------------------------------------------------------- +void UpdateDrawFrame(void) +{ + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- +} \ No newline at end of file