mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2024-12-21 22:14:43 -08:00
Day 11 complete.
This commit is contained in:
parent
97c2a46805
commit
9831c46739
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "handmade-hero-notes"]
|
|
||||||
path = handmade-hero-notes
|
|
||||||
url = https://github.com/Ed94/handmade-hero-notes
|
|
7
docs/Day 001.md
Normal file
7
docs/Day 001.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Day 1
|
||||||
|
|
||||||
|
Project initially setup. Followed the video and the book.
|
||||||
|
|
||||||
|
I went extra since I already have a perferred setup I've recently grown accoustmed to and I'm going to take advantage of the metaprogramming library I've recently made for myself. Although I doubt it'll see much action...
|
||||||
|
|
||||||
|
I'll be keeping the code pretty C like as Casey does in the series. Main purpose is to be able to use whitebox.
|
9
docs/Day 002.md
Normal file
9
docs/Day 002.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Day 2
|
||||||
|
|
||||||
|
Pretty smooth so far, modular header library is showing its limitations...
|
||||||
|
|
||||||
|
I have enough practice messsing with forwards and library linkage now that it wasn't much of a show stopper at least. All the mess is quarantined in the in win32.h and so far it looks like it will be enough to keep it all there.
|
||||||
|
|
||||||
|
I added extra stuff in `grime.h`, `macros.h`, and `types.h` that he will either go over soon from my vauge memory last time I just watched him (instead of doing) + stuff from gencpp's version of the zpl library.
|
||||||
|
|
||||||
|
![img](https://files.catbox.moe/wxasgz.png)
|
4
docs/Day 003.md
Normal file
4
docs/Day 003.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Day 3
|
||||||
|
|
||||||
|
Was able to follow along just fine, lots of more `Gdi32`` stuff to forward in `win32.h`.
|
||||||
|
|
2
docs/Day 004.md
Normal file
2
docs/Day 004.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Day 4
|
||||||
|
|
4
docs/Day 011.md
Normal file
4
docs/Day 011.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Day 11
|
||||||
|
|
||||||
|
Architecture discussion was great. Did some diagramming of it.
|
||||||
|
|
BIN
docs/Visuals.afdesign
Normal file
BIN
docs/Visuals.afdesign
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Subproject commit 5d1c77a44299fb8eddc4417cfe5e899289e555af
|
|
61
project/engine.cpp
Normal file
61
project/engine.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include "engine.h"
|
||||||
|
|
||||||
|
NS_ENGINE_BEGIN
|
||||||
|
|
||||||
|
internal void
|
||||||
|
render_weird_graident(OffscreenBuffer* buffer, u32 x_offset, u32 y_offset )
|
||||||
|
{
|
||||||
|
// TODO(Ed): See if with optimizer if buffer should be passed by value.
|
||||||
|
|
||||||
|
struct Pixel {
|
||||||
|
u8 Blue;
|
||||||
|
u8 Green;
|
||||||
|
u8 Red;
|
||||||
|
u8 Alpha;
|
||||||
|
};
|
||||||
|
|
||||||
|
u8* row = rcast( u8*, buffer->Memory);
|
||||||
|
local_persist float wildcard = 0;
|
||||||
|
for ( u32 y = 0; y < buffer->Height; ++ y )
|
||||||
|
{
|
||||||
|
// u8* pixel = rcast(u8*, row);
|
||||||
|
// Pixel* pixel = rcast( Pixel*, row );
|
||||||
|
u32* pixel = rcast(u32*, row);
|
||||||
|
for ( u32 x = 0; x < buffer->Width; ++ x )
|
||||||
|
{
|
||||||
|
/* Pixel in memory:
|
||||||
|
-----------------------------------------------
|
||||||
|
Pixel + 0 Pixel + 1 Pixel + 2 Pixel + 3
|
||||||
|
RR GG GG XX
|
||||||
|
-----------------------------------------------
|
||||||
|
x86-64 : Little Endian Arch
|
||||||
|
0x XX BB GG RR
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
u8 blue = scast(u8, x + x_offset * u8(wildcard) % 256);
|
||||||
|
u8 green = scast(u8, y + y_offset - u8(wildcard) % 128);
|
||||||
|
u8 red = scast(u8, wildcard) % 256 - x * 0.4f;
|
||||||
|
#else
|
||||||
|
u8 blue = scast(u8, x + x_offset);
|
||||||
|
u8 green = scast(u8, y + y_offset);
|
||||||
|
u8 red = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
*pixel++ = (red << 16) | (green << 8) | blue;
|
||||||
|
}
|
||||||
|
wildcard += 0.5375f;
|
||||||
|
row += buffer->Pitch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal
|
||||||
|
void update_and_render( OffscreenBuffer* back_buffer
|
||||||
|
// Temp (for feature parity)
|
||||||
|
, u32 x_offset, u32 y_offset
|
||||||
|
)
|
||||||
|
{
|
||||||
|
render_weird_graident( back_buffer, x_offset, y_offset );
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_ENGINE_END
|
30
project/engine.h
Normal file
30
project/engine.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Services the engine provides to the platform layer
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#define NS_ENGINE_BEGIN namespace engine {
|
||||||
|
#define NS_ENGINE_END }
|
||||||
|
|
||||||
|
NS_ENGINE_BEGIN
|
||||||
|
|
||||||
|
struct OffscreenBuffer
|
||||||
|
{
|
||||||
|
void* Memory; // Lets use directly mess with the "pixel's memory buffer"
|
||||||
|
u32 Width;
|
||||||
|
u32 Height;
|
||||||
|
u32 Pitch;
|
||||||
|
u32 BytesPerPixel;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Needs a contextual reference to four things:
|
||||||
|
// Timing, Input, Bitmap Buffer, Sound Buffer
|
||||||
|
void update_and_render( OffscreenBuffer* back_buffer
|
||||||
|
// Temp (for feature parity)
|
||||||
|
, u32 x_offset, u32 y_offset
|
||||||
|
);
|
||||||
|
|
||||||
|
NS_ENGINE_END
|
8
project/handmace.cpp
Normal file
8
project/handmace.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
Hnadmade Hero game code layer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "engine.h"
|
||||||
|
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
TODO : This is not a final platform layer
|
||||||
|
|
||||||
|
- Saved game locations
|
||||||
|
- Getting a handle to our own executable file
|
||||||
|
- Asset loading path
|
||||||
|
- Threading (launch a thread)
|
||||||
|
- Raw Input (support for multiple keyboards)
|
||||||
|
- Sleep / timeBeginPeriod
|
||||||
|
- ClipCursor() (for multimonitor support)
|
||||||
|
- Fullscreen support
|
||||||
|
- WM_SETCURSOR (control cursor visibility)
|
||||||
|
- QueryCancelAutoplay
|
||||||
|
- WM_ACTIVATEAPP (for when not active)
|
||||||
|
- Blit speed improvemnts (BitBlt)
|
||||||
|
- Hardware acceleration ( OpenGL or Direct3D or both )
|
||||||
|
- GetKeyboardLayout (for French keyboards, international WASD support)
|
||||||
|
*/
|
||||||
|
|
||||||
#if __clang__
|
#if __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
#pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||||
@ -6,21 +25,19 @@
|
|||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
#pragma clang diagnostic ignored "-Wvarargs"
|
#pragma clang diagnostic ignored "-Wvarargs"
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
#pragma clang diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "grime.h"
|
#include <math.h> // TODO : Implement math ourselves
|
||||||
#include "macros.h"
|
|
||||||
#include "types.h"
|
|
||||||
#include "math_constants.h"
|
|
||||||
|
|
||||||
// #include <stdio.h>
|
|
||||||
|
|
||||||
// TODO : Implement sound ourselves
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
// Platform Layer headers
|
||||||
|
#include "platform.h"
|
||||||
|
#include "jsl.h" // Using this to get dualsense controllers
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
// Using this to get dualsense controllers
|
|
||||||
#include "JoyShockLibrary/JoyShockLibrary.h"
|
// Engine layer headers
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
|
|
||||||
// TOOD(Ed): Redo these macros properly later.
|
// TOOD(Ed): Redo these macros properly later.
|
||||||
|
|
||||||
@ -47,7 +64,6 @@ ensure_impl( bool condition, char const* message ) {
|
|||||||
JslSetLightColour( 0, (255 << 8 ) ); \
|
JslSetLightColour( 0, (255 << 8 ) ); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
NS_WIN32_BEGIN
|
NS_WIN32_BEGIN
|
||||||
|
|
||||||
// TODO(Ed) : This is a global for now.
|
// TODO(Ed) : This is a global for now.
|
||||||
@ -248,51 +264,6 @@ get_window_dimensions( HWND window_handle )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
|
||||||
render_weird_graident(OffscreenBuffer* buffer, u32 x_offset, u32 y_offset )
|
|
||||||
{
|
|
||||||
// TODO(Ed): See if with optimizer if buffer should be passed by value.
|
|
||||||
|
|
||||||
struct Pixel {
|
|
||||||
u8 Blue;
|
|
||||||
u8 Green;
|
|
||||||
u8 Red;
|
|
||||||
u8 Alpha;
|
|
||||||
};
|
|
||||||
|
|
||||||
u8* row = rcast( u8*, buffer->Memory);
|
|
||||||
local_persist float wildcard = 0;
|
|
||||||
for ( u32 y = 0; y < buffer->Height; ++ y )
|
|
||||||
{
|
|
||||||
// u8* pixel = rcast(u8*, row);
|
|
||||||
// Pixel* pixel = rcast( Pixel*, row );
|
|
||||||
u32* pixel = rcast(u32*, row);
|
|
||||||
for ( u32 x = 0; x < buffer->Width; ++ x )
|
|
||||||
{
|
|
||||||
/* Pixel in memory:
|
|
||||||
-----------------------------------------------
|
|
||||||
Pixel + 0 Pixel + 1 Pixel + 2 Pixel + 3
|
|
||||||
RR GG GG XX
|
|
||||||
-----------------------------------------------
|
|
||||||
x86-64 : Little Endian Arch
|
|
||||||
0x XX BB GG RR
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
u8 blue = scast(u8, x + x_offset * u8(wildcard) % 256);
|
|
||||||
u8 green = scast(u8, y + y_offset - u8(wildcard) % 128);
|
|
||||||
u8 red = scast(u8, wildcard) % 256 - x * 0.4f;
|
|
||||||
#else
|
|
||||||
u8 blue = scast(u8, x + x_offset);
|
|
||||||
u8 green = scast(u8, y + y_offset);
|
|
||||||
u8 red = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*pixel++ = (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
wildcard += 0.5375f;
|
|
||||||
row += buffer->Pitch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
resize_dib_section( OffscreenBuffer* buffer, u32 width, u32 height )
|
resize_dib_section( OffscreenBuffer* buffer, u32 width, u32 height )
|
||||||
@ -357,7 +328,7 @@ main_window_callback(
|
|||||||
LPARAM l_param
|
LPARAM l_param
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LRESULT result;
|
LRESULT result = 0;
|
||||||
|
|
||||||
switch ( system_messages )
|
switch ( system_messages )
|
||||||
{
|
{
|
||||||
@ -528,10 +499,9 @@ WinMain(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
|
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
|
||||||
|
|
||||||
WNDCLASS
|
WNDCLASSW
|
||||||
window_class {};
|
window_class {};
|
||||||
window_class.style = CS_Horizontal_Redraw | CS_Vertical_Redraw;
|
window_class.style = CS_Horizontal_Redraw | CS_Vertical_Redraw;
|
||||||
window_class.lpfnWndProc = main_window_callback;
|
window_class.lpfnWndProc = main_window_callback;
|
||||||
@ -742,10 +712,10 @@ WinMain(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
engine::update_and_render( rcast(engine::OffscreenBuffer*, & BackBuffer.Memory), x_offset, y_offset );
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
{
|
{
|
||||||
render_weird_graident( &BackBuffer, x_offset, y_offset );
|
|
||||||
|
|
||||||
WinDimensions dimensions = get_window_dimensions( window_handle );
|
WinDimensions dimensions = get_window_dimensions( window_handle );
|
||||||
HDC device_context = GetDC( window_handle );
|
HDC device_context = GetDC( window_handle );
|
||||||
display_buffer_in_window( device_context, dimensions.Width, dimensions.Height, &BackBuffer
|
display_buffer_in_window( device_context, dimensions.Width, dimensions.Height, &BackBuffer
|
||||||
@ -865,3 +835,6 @@ WinMain(
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Engine layer translation unit.
|
||||||
|
#include "engine.cpp"
|
12
project/platform/jsl.h
Normal file
12
project/platform/jsl.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Joyshock grime wrapper
|
||||||
|
|
||||||
|
#if __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "JoyShockLibrary/JoyShockLibrary.h"
|
||||||
|
|
||||||
|
#if __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
11
project/platform/platform.h
Normal file
11
project/platform/platform.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
Platform abstraction layer for the project.
|
||||||
|
Services the platform provides to the engine & game.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "grime.h"
|
||||||
|
#include "macros.h"
|
||||||
|
#include "math_constants.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Alternative header for windows.h
|
Windows dependency header
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@ Push-Location $path_root
|
|||||||
|
|
||||||
#region Arguments
|
#region Arguments
|
||||||
$vendor = $null
|
$vendor = $null
|
||||||
$release = $null
|
$optimized = $false
|
||||||
|
$debug = $false
|
||||||
|
$analysis = $false
|
||||||
|
|
||||||
[array] $vendors = @( "clang", "msvc" )
|
[array] $vendors = @( "clang", "msvc" )
|
||||||
|
|
||||||
@ -16,12 +18,13 @@ Push-Location $path_root
|
|||||||
|
|
||||||
if ( $args ) { $args | ForEach-Object {
|
if ( $args ) { $args | ForEach-Object {
|
||||||
switch ($_){
|
switch ($_){
|
||||||
{ $_ -in $vendors } { $vendor = $_; break }
|
{ $_ -in $vendors } { $vendor = $_; break }
|
||||||
"release" { $release = $true }
|
"optimized" { $optimized = $true }
|
||||||
"debug" { $release = $false }
|
"debug" { $debug = $true }
|
||||||
|
"analysis" { $analysis = $true }
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
#endregion Arguments
|
#endregion Argument
|
||||||
|
|
||||||
#region Configuration
|
#region Configuration
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
@ -47,10 +50,9 @@ function run-compiler
|
|||||||
{
|
{
|
||||||
param( $compiler, $unit, $compiler_args )
|
param( $compiler, $unit, $compiler_args )
|
||||||
|
|
||||||
$compiler_args += @(
|
if ( $analysis ) {
|
||||||
($flag_define + 'UNICODE'),
|
$compiler_args += $flag_syntax_only
|
||||||
($flag_define + '_UNICODE')
|
}
|
||||||
)
|
|
||||||
|
|
||||||
write-host "`Compiling $unit"
|
write-host "`Compiling $unit"
|
||||||
write-host "Compiler config:"
|
write-host "Compiler config:"
|
||||||
@ -109,28 +111,34 @@ function run-linker
|
|||||||
if ( $vendor -match "clang" )
|
if ( $vendor -match "clang" )
|
||||||
{
|
{
|
||||||
# https://clang.llvm.org/docs/ClangCommandLineReference.html
|
# https://clang.llvm.org/docs/ClangCommandLineReference.html
|
||||||
|
$flag_all_c = '/TC'
|
||||||
|
$flag_all_cpp = '/TP'
|
||||||
$flag_compile = '-c'
|
$flag_compile = '-c'
|
||||||
$flag_color_diagnostics = '-fcolor-diagnostics'
|
$flag_color_diagnostics = '-fcolor-diagnostics'
|
||||||
$flag_no_color_diagnostics = '-fno-color-diagnostics'
|
$flag_no_color_diagnostics = '-fno-color-diagnostics'
|
||||||
$flag_debug = '-g'
|
$flag_debug = '-g'
|
||||||
$flag_debug_codeview = '-gcodeview'
|
$flag_debug_codeview = '-gcodeview'
|
||||||
$flag_define = '-D'
|
$flag_define = '-D'
|
||||||
$flag_exceptions_disabled = '-fno-exceptions'
|
$flag_exceptions_disabled = '-fno-exceptions'
|
||||||
$flag_preprocess = '-E'
|
$flag_preprocess = '-E'
|
||||||
$flag_include = '-I'
|
$flag_include = '-I'
|
||||||
$flag_library = '-l'
|
$flag_library = '-l'
|
||||||
$flag_library_path = '-L'
|
$flag_library_path = '-L'
|
||||||
$flag_link_win = '-Wl,'
|
$flag_link_win = '-Wl,'
|
||||||
$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE'
|
$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE'
|
||||||
|
$flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS'
|
||||||
$flag_link_win_machine_32 = '/MACHINE:X86'
|
$flag_link_win_machine_32 = '/MACHINE:X86'
|
||||||
$flag_link_win_machine_64 = '/MACHINE:X64'
|
$flag_link_win_machine_64 = '/MACHINE:X64'
|
||||||
$flag_link_win_debug = '/DEBUG'
|
$flag_link_win_debug = '/DEBUG'
|
||||||
$flag_link_win_pdb = '/PDB:'
|
$flag_link_win_pdb = '/PDB:'
|
||||||
$flag_link_win_path_output = '/OUT:'
|
$flag_link_win_path_output = '/OUT:'
|
||||||
$flag_no_optimization = '-O0'
|
$flag_no_optimization = '-O0'
|
||||||
|
$flag_optimize_fast = '-O2'
|
||||||
|
$flag_optimize_size = '-O1'
|
||||||
$flag_path_output = '-o'
|
$flag_path_output = '-o'
|
||||||
$flag_preprocess_non_intergrated = '-no-integrated-cpp'
|
$flag_preprocess_non_intergrated = '-no-integrated-cpp'
|
||||||
$flag_profiling_debug = '-fdebug-info-for-profiling'
|
$flag_profiling_debug = '-fdebug-info-for-profiling'
|
||||||
|
$flag_syntax_only = '-fsyntax-only'
|
||||||
$flag_target_arch = '-target'
|
$flag_target_arch = '-target'
|
||||||
$flag_wall = '-Wall'
|
$flag_wall = '-Wall'
|
||||||
$flag_warning = '-W'
|
$flag_warning = '-W'
|
||||||
@ -169,10 +177,15 @@ if ( $vendor -match "clang" )
|
|||||||
$flag_preprocess_non_intergrated,
|
$flag_preprocess_non_intergrated,
|
||||||
( $flag_path_output + $object )
|
( $flag_path_output + $object )
|
||||||
)
|
)
|
||||||
if ( $release -eq $false ) {
|
if ( $optimized ) {
|
||||||
|
$compiler_args += $flag_optimize_fast
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$compiler_args += $flag_no_optimization
|
||||||
|
}
|
||||||
|
if ( $debug ) {
|
||||||
$compiler_args += ( $flag_define + 'Build_Debug' )
|
$compiler_args += ( $flag_define + 'Build_Debug' )
|
||||||
$compiler_args += $flag_debug, $flag_debug_codeview, $flag_profiling_debug
|
$compiler_args += $flag_debug, $flag_debug_codeview, $flag_profiling_debug
|
||||||
$compiler_args += $flag_no_optimization
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$warning_ignores | ForEach-Object {
|
$warning_ignores | ForEach-Object {
|
||||||
@ -187,12 +200,10 @@ if ( $vendor -match "clang" )
|
|||||||
$flag_link_win_machine_64,
|
$flag_link_win_machine_64,
|
||||||
$( $flag_link_win_path_output + $executable )
|
$( $flag_link_win_path_output + $executable )
|
||||||
)
|
)
|
||||||
if ( $release -eq $false ) {
|
if ( $debug ) {
|
||||||
$linker_args += $flag_link_win_debug
|
$linker_args += $flag_link_win_debug
|
||||||
$linker_args += $flag_link_win_pdb + $pdb
|
$linker_args += $flag_link_win_pdb + $pdb
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
}
|
|
||||||
|
|
||||||
$libraries | ForEach-Object {
|
$libraries | ForEach-Object {
|
||||||
$linker_args += $_ + '.lib'
|
$linker_args += $_ + '.lib'
|
||||||
@ -209,11 +220,13 @@ if ( $vendor -match "clang" )
|
|||||||
if ( $vendor -match "msvc" )
|
if ( $vendor -match "msvc" )
|
||||||
{
|
{
|
||||||
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
|
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
|
||||||
|
$flag_all_c = '/TC'
|
||||||
|
$flag_all_cpp = '/TP'
|
||||||
$flag_compile = '/c'
|
$flag_compile = '/c'
|
||||||
$flag_debug = '/Zi'
|
$flag_debug = '/Zi'
|
||||||
$flag_define = '/D'
|
$flag_define = '/D'
|
||||||
$flag_exceptions_disabled = '/EHs-c-'
|
$flag_exceptions_disabled = '/EHs-c-'
|
||||||
$flag_RTTI_disabled = '/GR-'
|
$flag_RTTI_disabled = '/GR-'
|
||||||
$flag_include = '/I'
|
$flag_include = '/I'
|
||||||
$flag_full_src_path = '/FC'
|
$flag_full_src_path = '/FC'
|
||||||
$flag_nologo = '/nologo'
|
$flag_nologo = '/nologo'
|
||||||
@ -232,11 +245,15 @@ if ( $vendor -match "msvc" )
|
|||||||
$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE'
|
$flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE'
|
||||||
$flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS'
|
$flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS'
|
||||||
$flag_no_optimization = '/Od'
|
$flag_no_optimization = '/Od'
|
||||||
|
$flag_optimize_fast = '/O2'
|
||||||
|
$flag_optimize_size = '/O1'
|
||||||
|
$flag_optimized_debug = '/Zo'
|
||||||
$flag_out_name = '/OUT:'
|
$flag_out_name = '/OUT:'
|
||||||
$flag_path_interm = '/Fo'
|
$flag_path_interm = '/Fo'
|
||||||
$flag_path_debug = '/Fd'
|
$flag_path_debug = '/Fd'
|
||||||
$flag_path_output = '/Fe'
|
$flag_path_output = '/Fe'
|
||||||
$flag_preprocess_conform = '/Zc:preprocessor'
|
$flag_preprocess_conform = '/Zc:preprocessor'
|
||||||
|
$flag_syntax_only = '/Zs'
|
||||||
|
|
||||||
# This works because this project uses a single unit to build
|
# This works because this project uses a single unit to build
|
||||||
function build-simple
|
function build-simple
|
||||||
@ -249,6 +266,7 @@ if ( $vendor -match "msvc" )
|
|||||||
|
|
||||||
$compiler_args += @(
|
$compiler_args += @(
|
||||||
$flag_nologo,
|
$flag_nologo,
|
||||||
|
$flag_all_cpp,
|
||||||
$flag_exceptions_disabled,
|
$flag_exceptions_disabled,
|
||||||
( $flag_define + '_HAS_EXCEPTIONS=0' ),
|
( $flag_define + '_HAS_EXCEPTIONS=0' ),
|
||||||
$flag_RTTI_disabled,
|
$flag_RTTI_disabled,
|
||||||
@ -257,19 +275,33 @@ if ( $vendor -match "msvc" )
|
|||||||
( $flag_path_interm + $path_build + '\' ),
|
( $flag_path_interm + $path_build + '\' ),
|
||||||
( $flag_path_output + $path_build + '\' )
|
( $flag_path_output + $path_build + '\' )
|
||||||
)
|
)
|
||||||
if ( $release -eq $false ) {
|
|
||||||
|
if ( $optimize ) {
|
||||||
|
$compiler_args += $flag_optimize_fast
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$compiler_args += $flag_no_optimization
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $debug )
|
||||||
|
{
|
||||||
$compiler_args += $flag_debug
|
$compiler_args += $flag_debug
|
||||||
$compiler_args += ( $flag_define + 'Build_Debug' )
|
$compiler_args += ( $flag_define + 'Build_Debug' )
|
||||||
$compiler_args += ( $flag_path_debug + $path_build + '\' )
|
$compiler_args += ( $flag_path_debug + $path_build + '\' )
|
||||||
$compiler_args += $flag_link_win_rt_static_debug
|
$compiler_args += $flag_link_win_rt_static_debug
|
||||||
$compiler_args += $flag_no_optimization
|
|
||||||
|
if ( $optimized ) {
|
||||||
|
$compiler_args += $flag_optimized_debug
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$compiler_args += $flag_link_win_rt_static
|
$compiler_args += $flag_link_win_rt_static
|
||||||
}
|
}
|
||||||
|
|
||||||
$compiler_args += $includes | ForEach-Object { $flag_include + $_ }
|
$compiler_args += $includes | ForEach-Object { $flag_include + $_ }
|
||||||
$compiler_args += $flag_compile, $unit
|
$compiler_args += $unit
|
||||||
run-compiler $compiler $unit $compiler_args
|
# $compiler_args += $flag_compile, $unit
|
||||||
|
# run-compiler $compiler $unit $compiler_args
|
||||||
|
|
||||||
$linker_args += @(
|
$linker_args += @(
|
||||||
$flag_nologo,
|
$flag_nologo,
|
||||||
@ -284,7 +316,11 @@ if ( $vendor -match "msvc" )
|
|||||||
}
|
}
|
||||||
|
|
||||||
$linker_args += $object
|
$linker_args += $object
|
||||||
run-linker $linker $executable $linker_args
|
# run-linker $linker $executable $linker_args
|
||||||
|
|
||||||
|
$compiler_args += $flag_linker
|
||||||
|
$compiler_args += $linker_args
|
||||||
|
run-compiler $compiler $unit $compiler_args
|
||||||
}
|
}
|
||||||
|
|
||||||
$compiler = 'cl'
|
$compiler = 'cl'
|
||||||
@ -354,10 +390,13 @@ $lib_user32 = 'User32.lib'
|
|||||||
# Github
|
# Github
|
||||||
$lib_jsl = Join-Path $path_deps 'JoyShockLibrary/x64/JoyShockLibrary.lib'
|
$lib_jsl = Join-Path $path_deps 'JoyShockLibrary/x64/JoyShockLibrary.lib'
|
||||||
|
|
||||||
$unit = Join-Path $path_project 'handmade_win32.cpp'
|
$unit = Join-Path $path_platform 'handmade_win32.cpp'
|
||||||
$executable = Join-Path $path_build 'handmade_win32.exe'
|
$executable = Join-Path $path_build 'handmade_win32.exe'
|
||||||
|
|
||||||
$compiler_args = @()
|
$compiler_args = @(
|
||||||
|
($flag_define + 'UNICODE'),
|
||||||
|
($flag_define + '_UNICODE')
|
||||||
|
)
|
||||||
|
|
||||||
$linker_args = @(
|
$linker_args = @(
|
||||||
$lib_gdi32,
|
$lib_gdi32,
|
||||||
|
Loading…
Reference in New Issue
Block a user