Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Premake for building, change README, change folder architecture #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ CMakeSettings.json
# Build files
.cache/
target/
build/
build/
bin/
bin-int/
.vs/
README.md.backup
27 changes: 27 additions & 0 deletions .premakebin/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2003-2022 Jason Perkins and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of Premake nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ if(NOT CUDA_FOUND AND APPLE)
endif()

# Adding our source files
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.c" "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/src/*.cc" "${CMAKE_CURRENT_LIST_DIR}/src/*.cxx" "${CMAKE_CURRENT_LIST_DIR}/src/*.cu") # Define PROJECT_SOURCES as a list of all source files
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/kiwi/src/*.c" "${CMAKE_CURRENT_LIST_DIR}/kiwi/src/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/kiwi/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/kiwi/src/*.cxx" "${CMAKE_CURRENT_LIST_DIR}/kiwi/src/*.cu") # Define PROJECT_SOURCES as a list of all source files
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
# Adding our include files
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/kiwi/include)

# Setting ASSETS_PATH
target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") # Set the asset path macro to the absolute path on the dev machine
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ A three-dimensional graphics library from scratch written in C++13 and accelerat

### Prerequisites

Before attempting to build this project, make sure you have [Simple DirectMedia Layer (SDL 2)](https://wiki.libsdl.org/SDL2/Installation), [GNU Make](https://www.gnu.org/software/make/), and [CMake](https://cmake.org) installed on your machine.
Before attempting to build this project, make sure you have [Simple DirectMedia Layer (SDL 2)](https://wiki.libsdl.org/SDL2/Installation), [GNU Make](https://www.gnu.org/software/make/), and [CMake](https://cmake.org) installed on your machine, unless you are on windows then everything should be provided in the project.


### Installation
Expand All @@ -69,7 +69,11 @@ To get a local copy of the project up and running on your machine, follow these

2. Build and execute the project
```sh
--- With cmake
clear && cmake CMakeLists.txt && make && ./target/release/kiwigl

--- With premake
run build.bat and open the generated project
```

## Usage
Expand Down Expand Up @@ -107,13 +111,16 @@ To interact with the graphics library, use the following keyboard shortcuts:

```sh
graphics/
├── .github/ - GitHub Actions CI/CD workflows
├── include/ - project header files
├── src/ - project source files
│ └── main.c - Entry point, main function
├── CMakeLists.txt - CMake build script
├── LICENSE - project license
└── README.md - you are here
├──── .github/ - GitHub Actions CI/CD workflows
├──── kiwi/ - All project files
│ └── include/ - Project header files
│ └── src/ - Project source files
│ └── main.cpp - Entry point, main function
├──── vendor/ - Libraries used with premake building
├──── CMakeLists.txt - CMake build script
├──── premake5.lua - Premake build script
├──── LICENSE - Project license
└──── README.md - You are here!
```

## License
Expand Down
2 changes: 2 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
call .premakebin\premake5.exe vs2022
PAUSE
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion include/display.hpp → kiwi/include/display.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <SDL2/SDL.h>
#include <SDL.h>
#include <stdio.h>
#include <stdlib.h>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
131 changes: 131 additions & 0 deletions kiwi/kiwi.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{798A997C-65C1-9A0D-0EAE-8010FAC3160F}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>kiwi</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\bin\Debug-windows-x86_64\kiwi\</OutDir>
<IntDir>..\bin-int\Debug-windows-x86_64\kiwi\</IntDir>
<TargetName>kiwi</TargetName>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\bin\Release-windows-x86_64\kiwi\</OutDir>
<IntDir>..\bin-int\Release-windows-x86_64\kiwi\</IntDir>
<TargetName>kiwi</TargetName>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\vendor\SDL2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<LanguageStandard>stdcpp17</LanguageStandard>
<ExternalWarningLevel>Level3</ExternalWarningLevel>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>SDL2.lib;SDL2main.lib;SDL2test.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\vendor\SDL2\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>copy /B /Y ..\vendor\SDL2\lib\x64\SDL2.dll ..\bin\Debug-windows-x86_64\kiwi
IF NOT EXIST ..\bin\Debug-windows-x86_64\kiwi\assets (mkdir ..\bin\Debug-windows-x86_64\kiwi\assets)
xcopy /Q /E /Y /I ..\assets ..\bin\Debug-windows-x86_64\kiwi\assets</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\vendor\SDL2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<LanguageStandard>stdcpp17</LanguageStandard>
<ExternalWarningLevel>Level3</ExternalWarningLevel>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>SDL2.lib;SDL2main.lib;SDL2test.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\vendor\SDL2\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
<PostBuildEvent>
<Command>copy /B /Y ..\vendor\SDL2\lib\x64\SDL2.dll ..\bin\Release-windows-x86_64\kiwi
IF NOT EXIST ..\bin\Release-windows-x86_64\kiwi\assets (mkdir ..\bin\Release-windows-x86_64\kiwi\assets)
xcopy /Q /E /Y /I ..\assets ..\bin\Release-windows-x86_64\kiwi\assets</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="include\color.hpp" />
<ClInclude Include="include\constants.hpp" />
<ClInclude Include="include\display.hpp" />
<ClInclude Include="include\face.hpp" />
<ClInclude Include="include\frame_buffer.hpp" />
<ClInclude Include="include\mesh.hpp" />
<ClInclude Include="include\texture.hpp" />
<ClInclude Include="include\triangle.hpp" />
<ClInclude Include="include\vector2d.hpp" />
<ClInclude Include="include\vector3d.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="src\color.cpp" />
<ClCompile Include="src\display.cpp" />
<ClCompile Include="src\face.cpp" />
<ClCompile Include="src\frame_buffer.cpp" />
<ClCompile Include="src\mesh.cpp" />
<ClCompile Include="src\texture.cpp" />
<ClCompile Include="src\trangle.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
67 changes: 67 additions & 0 deletions kiwi/kiwi.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="include">
<UniqueIdentifier>{89AF369E-F58E-B539-FEA6-40106A051C9B}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{2DAB880B-99B4-887C-2230-9F7C8E38947C}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\color.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\constants.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\display.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\face.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\frame_buffer.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\mesh.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\texture.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\triangle.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\vector2d.hpp">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="include\vector3d.hpp">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="src\color.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\display.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\face.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\frame_buffer.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\mesh.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\texture.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\trangle.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions kiwi/kiwi.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/main.cpp → kiwi/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stddef.h>
#include <stdio.h>

#include "../include/display.hpp"
#include "../kiwi/include/display.hpp"

#ifdef USE_METAL
#include <cassert>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/display.cpp → kiwi/src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "../include/display.metal"
#endif

#include <SDL2/SDL.h>
#include <SDL.h>

#include <string>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions kiwiGL.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwi", "kiwi\kiwi.vcxproj", "{798A997C-65C1-9A0D-0EAE-8010FAC3160F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{798A997C-65C1-9A0D-0EAE-8010FAC3160F}.Debug|x64.ActiveCfg = Debug|x64
{798A997C-65C1-9A0D-0EAE-8010FAC3160F}.Debug|x64.Build.0 = Debug|x64
{798A997C-65C1-9A0D-0EAE-8010FAC3160F}.Release|x64.ActiveCfg = Release|x64
{798A997C-65C1-9A0D-0EAE-8010FAC3160F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading