Skip to content

Commit 3e049a9

Browse files
committed
initial commit
0 parents  commit 3e049a9

276 files changed

Lines changed: 165906 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Build files
2+
build/
3+
*.sln
4+
*.vcxproj
5+
*.vcxproj.filters
6+
*.vcxproj.user
7+
*.suo
8+
*.sdf
9+
*.opensdf
10+
*.aps
11+
12+
# IDE files
13+
.idea/
14+
.vs/
15+
.vscode/
16+
17+
18+
# Object files
19+
*.obj
20+
*.o
21+
*.pch
22+
23+
# Intermediate files
24+
*.ilk
25+
*.pdb
26+
*.idb
27+
28+
# Log files
29+
*.log
30+
31+
# Temporary files
32+
*.tmp
33+
*.temp
34+
*~
35+
36+
# OS generated files
37+
Thumbs.db
38+
.DS_Store
39+
40+
41+
42+
# MacOS generated files
43+
.DS_Store
44+
45+
# Linux generated files
46+
*~
47+
48+
# IDE files
49+
.idea/
50+
.vs/
51+
.vscode/
52+
53+
# Test files
54+
Testing/

2DPhysics.rc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Icon
2+
// Icon
3+
IDI_ICON1 ICON "assets/icon.ico"
4+
5+
// Version Information
6+
1 VERSIONINFO
7+
FILEVERSION 0,0,1,0
8+
PRODUCTVERSION 0,0,1,0
9+
FILEFLAGSMASK 0x3fL
10+
#ifdef _DEBUG
11+
FILEFLAGS 0x1L
12+
#else
13+
FILEFLAGS 0x0L
14+
#endif
15+
FILEOS 0x40004L
16+
FILETYPE 0x1L
17+
FILESUBTYPE 0x0L
18+
BEGIN
19+
BLOCK "StringFileInfo"
20+
BEGIN
21+
BLOCK "040904b0"
22+
BEGIN
23+
VALUE "CompanyName", "TheUserWW"
24+
VALUE "FileDescription", "2D Physics"
25+
VALUE "FileVersion", "0.0.1.0"
26+
VALUE "InternalName", "2DPhysics"
27+
VALUE "LegalCopyright", "Copyright (C) 2025 TheUserWW"
28+
VALUE "OriginalFilename", "2DPhysics.exe"
29+
VALUE "ProductName", "2D Physics"
30+
VALUE "ProductVersion", "0.0.1.0"
31+
END
32+
END
33+
BLOCK "VarFileInfo"
34+
BEGIN
35+
VALUE "Translation", 0x409, 1200
36+
END
37+
END

CMakeLists.txt

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
cmake_minimum_required(VERSION 3.31)
2+
project(2DPhysics)
3+
4+
set(CMAKE_CXX_STANDARD 23)
5+
6+
# Set optimization level to O2 for Release builds
7+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
8+
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
9+
endif()
10+
11+
# Enable static linking for Windows to avoid DLL dependencies
12+
if(WIN32)
13+
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
14+
endif()
15+
16+
# Enable C++20 modules support for GCC
17+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmodules-ts")
19+
endif()
20+
21+
# Set GLFW dependencies paths
22+
set(GLFW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/Dependencies/include")
23+
set(GLFW_LIB_DIR "${CMAKE_SOURCE_DIR}/Dependencies/lib-mingw-w64")
24+
25+
# Set GLEW dependencies paths
26+
set(GLEW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/Dependencies/GLEW/include")
27+
set(GLEW_LIB_DIR "${CMAKE_SOURCE_DIR}/Dependencies/GLEW/lib/Release/x64")
28+
29+
# Set ImGui dependencies paths
30+
set(IMGUI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/Dependencies/include/imgui")
31+
set(IMGUI_BACKENDS_DIR "${CMAKE_SOURCE_DIR}/Dependencies/include/imgui/backends")
32+
33+
# Set cPhysics dependencies path
34+
set(CPHYSICS_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/Dependencies/cPhysics/include")
35+
set(CPHYSICS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/Dependencies/cPhysics/src")
36+
37+
# Include GLFW, GLEW, ImGui and cPhysics headers
38+
include_directories(${GLFW_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${IMGUI_INCLUDE_DIR} ${IMGUI_BACKENDS_DIR} ${CPHYSICS_INCLUDE_DIR})
39+
40+
# Add ImGui source files
41+
set(IMGUI_SOURCES
42+
${IMGUI_INCLUDE_DIR}/imgui.cpp
43+
${IMGUI_INCLUDE_DIR}/imgui_demo.cpp
44+
${IMGUI_INCLUDE_DIR}/imgui_draw.cpp
45+
${IMGUI_INCLUDE_DIR}/imgui_tables.cpp
46+
${IMGUI_INCLUDE_DIR}/imgui_widgets.cpp
47+
${IMGUI_BACKENDS_DIR}/imgui_impl_glfw.cpp
48+
${IMGUI_BACKENDS_DIR}/imgui_impl_opengl3.cpp
49+
)
50+
51+
# Add cPhysics source files
52+
set(CPHYSICS_SOURCES
53+
${CPHYSICS_SOURCE_DIR}/field.c
54+
${CPHYSICS_SOURCE_DIR}/entity.c
55+
${CPHYSICS_SOURCE_DIR}/plog.c
56+
)
57+
58+
# Check if ImGui source files exist
59+
foreach(IMGUI_SOURCE ${IMGUI_SOURCES})
60+
if(NOT EXISTS ${IMGUI_SOURCE})
61+
message(WARNING "ImGui source file not found: ${IMGUI_SOURCE}")
62+
endif()
63+
endforeach()
64+
65+
# Set project sources
66+
set(SOURCES src/main.cpp ${IMGUI_SOURCES} ${CPHYSICS_SOURCES} 2DPhysics.rc)
67+
68+
add_executable(2DPhysics ${SOURCES})
69+
70+
# Set resource file working directory to find icon files
71+
set_source_files_properties(2DPhysics.rc PROPERTIES
72+
COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}"
73+
)
74+
75+
# 设置为Windows子系统,隐藏控制台窗口
76+
set_target_properties(2DPhysics PROPERTIES WIN32_EXECUTABLE TRUE)
77+
78+
# Add GLFW library directory
79+
target_link_directories(2DPhysics PRIVATE ${GLFW_LIB_DIR})
80+
81+
# Link GLEW library with Windows-specific configuration
82+
if(WIN32)
83+
# For Windows, link against the static library for pure static compilation
84+
target_link_directories(2DPhysics PRIVATE ${GLEW_LIB_DIR})
85+
target_link_libraries(2DPhysics ${GLEW_LIB_DIR}/glew32s.lib)
86+
87+
# Link GLFW and other required libraries
88+
target_link_libraries(2DPhysics ${GLFW_LIB_DIR}/libglfw3.a opengl32 gdi32 stdc++exp)
89+
90+
# Add static compilation flags for GLEW
91+
target_compile_definitions(2DPhysics PRIVATE GLEW_STATIC)
92+
93+
# Check for GLFW library and provide download instructions if missing
94+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/Dependencies/lib-mingw-w64/libglfw3.a")
95+
message(WARNING "GLFW library files are missing. Please download GLFW binaries from https://www.glfw.org/download.html")
96+
message(STATUS "For Windows, download the MinGW-w64 binaries and extract to Dependencies/lib-mingw-w64/")
97+
endif()
98+
99+
# Check for GLEW static library
100+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/Dependencies/GLEW/lib/Release/x64/glew32s.lib")
101+
message(WARNING "GLEW static library (glew32s.lib) is required for static compilation")
102+
endif()
103+
else()
104+
# For other platforms, use the static library
105+
target_link_libraries(2DPhysics glfw)
106+
endif()

CMakeSettings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "x64-Debug",
5+
"generator": "Ninja",
6+
"configurationType": "Debug",
7+
"inheritEnvironments": [ "msvc_x64_x64" ],
8+
"buildRoot": "${projectDir}\\out\\build\\${name}",
9+
"installRoot": "${projectDir}\\out\\install\\${name}",
10+
"cmakeCommandArgs": "",
11+
"buildCommandArgs": "",
12+
"ctestCommandArgs": ""
13+
}
14+
]
15+
}

Dependencies/GLEW/LICENSE.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
The OpenGL Extension Wrangler Library
2+
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
3+
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
4+
Copyright (C) 2002, Lev Povalahev
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* The name of the author may be used to endorse or promote products
16+
derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28+
THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
31+
Mesa 3-D graphics library
32+
Version: 7.0
33+
34+
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
35+
36+
Permission is hereby granted, free of charge, to any person obtaining a
37+
copy of this software and associated documentation files (the "Software"),
38+
to deal in the Software without restriction, including without limitation
39+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
40+
and/or sell copies of the Software, and to permit persons to whom the
41+
Software is furnished to do so, subject to the following conditions:
42+
43+
The above copyright notice and this permission notice shall be included
44+
in all copies or substantial portions of the Software.
45+
46+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
47+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49+
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
50+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
51+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52+
53+
54+
Copyright (c) 2007 The Khronos Group Inc.
55+
56+
Permission is hereby granted, free of charge, to any person obtaining a
57+
copy of this software and/or associated documentation files (the
58+
"Materials"), to deal in the Materials without restriction, including
59+
without limitation the rights to use, copy, modify, merge, publish,
60+
distribute, sublicense, and/or sell copies of the Materials, and to
61+
permit persons to whom the Materials are furnished to do so, subject to
62+
the following conditions:
63+
64+
The above copyright notice and this permission notice shall be included
65+
in all copies or substantial portions of the Materials.
66+
67+
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
68+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
69+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
70+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
71+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
72+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
73+
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
423 KB
Binary file not shown.
451 KB
Binary file not shown.
298 KB
Binary file not shown.
462 KB
Binary file not shown.
527 KB
Binary file not shown.

0 commit comments

Comments
 (0)