Skip to content

Commit 5751fc3

Browse files
committed
update to new per-project premake
1 parent fb3b3e7 commit 5751fc3

28 files changed

+311
-224
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,5 @@ MigrationBackup/
351351
*.vcxproj
352352
*.make
353353
*.filters
354+
/camera_clamp/*.sln
355+
/raylib-master

.gitmodules

-3
This file was deleted.

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
Examples and samples made for raylib using C
44

55
## Building
6-
The examples use premake, assumes a raylib folder is created manualy or using the submodule. Get premake5 for your system and run it for your build target. Batch file for visual studio is included.
6+
The examples use premake. Each example is a project on it's own. Premake will setup the build systems for each project for you, and download any needed libraries (raylib and box2d)
7+
8+
### For Visual Studio
9+
Run premake-VisualStudio.bat. When it is done each example folder will have a .sln file in it that you can open and run.
10+
11+
### For MinGW
12+
Run premake-mingw.bat. When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.
13+
14+
### For GCC On Linux
15+
Run "premake5 gmake2". When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.
16+
17+
### For GCC On MacOs
18+
Run "premake5.osx gmake2". When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.
719

820
# Circle In View 2D
921
Code showing how to check if a circle is inside a view cone. Shows examples of using dot products to find what side of a vector a point is on, and how to compute the nearest point on a vector to another point.

_app/main.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "raylib.h"
2+
3+
int main ()
4+
{
5+
InitWindow(1280,800,"Example");
6+
7+
while (!WindowShouldClose())
8+
{
9+
BeginDrawing();
10+
ClearBackground(BLACK);
11+
12+
EndDrawing();
13+
}
14+
CloseWindow();
15+
return 0;
16+
}

camera_clamp/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

camera_world_rect/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

circle_in_view_2d/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

full_3d_billboard/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

mouse_zoom/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

premake-2019 - OpenGL 4.3.bat

-1
This file was deleted.

premake-2019.bat

-1
This file was deleted.

premake-VisualStudio.bat

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
premake5.exe vs2022
2+
pause

premake-mingw.bat

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
premake5.exe gmake2
2+
pause

premake5

2.11 MB
Binary file not shown.

premake5.exe

1.33 MB
Binary file not shown.

premake5.lua

+92-38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11

2+
newoption
3+
{
4+
trigger = "graphics",
5+
value = "OPENGL_VERSION",
6+
description = "version of OpenGL to build raylib against",
7+
allowed = {
8+
{ "opengl11", "OpenGL 1.1"},
9+
{ "opengl21", "OpenGL 2.1"},
10+
{ "opengl33", "OpenGL 3.3"},
11+
{ "opengl43", "OpenGL 4.3"}
12+
},
13+
default = "opengl33"
14+
}
15+
216
function define_C()
317
language "C"
418
end
@@ -8,54 +22,94 @@ function define_Cpp()
822
end
923

1024
function string.starts(String,Start)
11-
return string.sub(String,1,string.len(Start))==Start
25+
return string.sub(String,1,string.len(Start))==Start
1226
end
1327

1428
function link_to(lib)
15-
links (lib)
16-
includedirs ("../"..lib)
29+
links (lib)
30+
includedirs ("../"..lib,"../"..lib.."/include" )
1731
end
1832

19-
baseName = path.getbasename(os.getcwd())
33+
function download_progress(total, current)
34+
local ratio = current / total;
35+
ratio = math.min(math.max(ratio, 0), 1);
36+
local percent = math.floor(ratio * 100);
37+
print("Download progress (" .. percent .. "%/100%)")
38+
end
2039

21-
workspace (baseName)
22-
configurations { "Debug","Debug.DLL", "Release", "Release.DLL" }
23-
platforms { "x64", "x86"}
40+
function check_raylib()
41+
if(os.isdir("raylib") == false and os.isdir("raylib-master") == false) then
42+
if(not os.isfile("raylib-master.zip")) then
43+
print("Raylib not found, downloading from github")
44+
local result_str, response_code = http.download("https://github.com/raysan5/raylib/archive/refs/heads/master.zip", "raylib-master.zip", {
45+
progress = download_progress,
46+
headers = { "From: Premake", "Referer: Premake" }
47+
})
48+
end
49+
print("Unzipping to " .. os.getcwd())
50+
zip.extract("raylib-master.zip", os.getcwd())
51+
os.remove("raylib-master.zip")
52+
end
53+
end
2454

25-
filter "configurations:Debug"
26-
defines { "DEBUG" }
27-
symbols "On"
28-
29-
filter "configurations:Debug.DLL"
30-
defines { "DEBUG" }
31-
symbols "On"
55+
function defineWorkspace(baseName)
56+
workspace (baseName)
57+
configurations { "Debug", "Release"}
58+
platforms { "x64", "x86"}
3259

33-
filter "configurations:Release"
34-
defines { "NDEBUG" }
35-
optimize "On"
36-
37-
filter "configurations:Release.DLL"
38-
defines { "NDEBUG" }
39-
optimize "On"
40-
41-
filter { "platforms:x64" }
42-
architecture "x86_64"
60+
filter "configurations:Debug"
61+
defines { "DEBUG" }
62+
symbols "On"
63+
64+
filter "configurations:Release"
65+
defines { "NDEBUG" }
66+
optimize "On"
67+
68+
filter { "platforms:x64" }
69+
architecture "x86_64"
70+
71+
filter {}
4372

44-
targetdir "bin/%{cfg.buildcfg}/"
45-
73+
targetdir "_bin/%{cfg.buildcfg}/"
74+
75+
startproject(baseName)
76+
77+
defineRaylibProject()
78+
79+
project (baseName)
80+
kind "ConsoleApp"
81+
location "_build"
82+
targetdir "_bin/%{cfg.buildcfg}"
83+
84+
filter "action:vs*"
85+
debugdir "$(SolutionDir)"
86+
87+
filter {"action:vs*", "configurations:Release"}
88+
kind "WindowedApp"
89+
entrypoint "mainCRTStartup"
90+
91+
filter{}
92+
93+
vpaths
94+
{
95+
["Header Files/*"] = { "include/**.h", "include/**.hpp", "src/**.h", "src/**.hpp", "**.h", "**.hpp"},
96+
["Source Files/*"] = {"src/**.c", "src/**.cpp","**.c", "**.cpp"},
97+
}
98+
files {"**.c", "**.cpp", "**.h", "**.hpp"}
99+
100+
includedirs { "./"}
101+
link_raylib();
102+
end
103+
46104
include ("raylib_premake5.lua")
105+
check_raylib()
47106

48107
folders = os.matchdirs("*")
49-
50108
for _, folderName in ipairs(folders) do
51-
if (folderName ~= "raylib"
52-
and folderName ~= "resources"
53-
and folderName ~= "build"
54-
and folderName ~= "bin"
55-
and string.starts(folderName, "_") == false
56-
and string.starts(folderName, ".") == false)
57-
then
58-
print(folderName)
59-
include (folderName)
60-
end
61-
end
109+
if (string.starts(folderName, "raylib") == false and string.starts(folderName, "_") == false and string.starts(folderName, ".") == false) then
110+
if (os.isfile(folderName .. "/premake5.lua")) then
111+
print(folderName)
112+
include (folderName)
113+
end
114+
end
115+
end

premake5.osx

1.27 MB
Binary file not shown.

ray2d_rect_intersection/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

raylib

-1
This file was deleted.

0 commit comments

Comments
 (0)