Got clang to build parity with msvc

This commit is contained in:
Edward R. Gonzalez 2023-10-24 00:42:55 -04:00
parent 4ab64e2c17
commit 2a660da1d8
8 changed files with 32 additions and 13 deletions

View File

@ -14,7 +14,7 @@
"label": "Static Data"
},
{
"line": 1001,
"line": 1011,
"column": 0,
"label": "Main Loop : End"
}

View File

@ -34,7 +34,9 @@
"UNICODE",
"_UNICODE",
"GEN_TIME",
"INTELLISENSE_DIRECTIVES"
"INTELLISENSE_DIRECTIVES",
"Build_Debug",
"Build_Development"
],
"windowsSdkVersion": "10.0.22621.0",
"compilerPath": "clang.exe",

View File

@ -238,12 +238,12 @@ void draw_bitmap( OffscreenBuffer* buffer, Vec2 pos, Bitmap* bitmap )
{
s32 half_width = bitmap->width / 2;
s32 half_height = bitmap->height / 2;
Vec2i pos_rounded { round(pos.x), round(pos.y) };
Vec2i bmp_half_size { bitmap->width / 2, bitmap->height / 2 };
Vec2i min = pos_rounded - bmp_half_size;
Vec2i max = pos_rounded + bmp_half_size;
s32 max_x = round( pos.x ) + half_width;
s32 max_y = round( pos.y ) + half_height;
@ -306,7 +306,7 @@ inline
void draw_debug_point(OffscreenBuffer* back_buffer, World* world, TileMapPos pos, f32 red, f32 green, f32 blue)
{
TileMap* tile_map = world->tile_map;
Vec2 min {
pos.rel_pos.x * world->tile_meters_to_pixels + world->tile_lower_left_x + scast(f32, pos.tile_x * world->tile_size_in_pixels),
pos.rel_pos.y * world->tile_meters_to_pixels + world->tile_lower_left_y + scast(f32, pos.tile_y * world->tile_size_in_pixels)
@ -1035,7 +1035,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
Vec2 screen_center {
scast(f32, back_buffer->width) * 0.5f,
scast(f32, back_buffer->width) * 0.5f,
scast(f32, back_buffer->height) * 0.5f
};
@ -1058,7 +1058,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
s32 tile_id = TileMap_get_tile_value( tile_map, col, row, game_state->camera_pos.tile_z );
f32 color[3] = { 0.15f, 0.15f, 0.15f };
if ( tile_id > 1 || row == player->position.tile_y && col == player->position.tile_x )
if ( tile_id > 1 || (row == player->position.tile_y && col == player->position.tile_x) )
// if ( tile_id > 1 )
{
if ( tile_id == 2 )
@ -1125,7 +1125,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
f32 player_blue = 0.3f;
TileMapPos player_to_camera = subtract( player->position, game_state->camera_pos );
Vec2 player_to_screenspace {
player_to_camera.rel_pos.x + scast(f32, player_to_camera.tile_x) * world->tile_map->tile_size_in_meters,
-1 * (player_to_camera.rel_pos.y + scast(f32, player_to_camera.tile_y) * world->tile_map->tile_size_in_meters)
@ -1140,7 +1140,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
player_ground_pos.y - player->height * world->tile_meters_to_pixels,
};
Vec2 player_collision_max {
player_ground_pos.x + player_half_width * world->tile_meters_to_pixels,
player_ground_pos.x + player_half_width * world->tile_meters_to_pixels,
player_ground_pos.y
};

View File

@ -27,4 +27,5 @@
#pragma clang diagnostic ignored "-Wvarargs"
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif

View File

@ -59,7 +59,7 @@ enum CS : UINT
CS_Horizontal_Redraw = CS_HREDRAW,
CS_Vertical_Redraw = CS_VREDRAW,
};
enum CW : s32
{
CW_Use_Default = CW_USEDEFAULT,

View File

@ -503,6 +503,9 @@ engine::ModuleAPI load_engine_module_api()
{
OutputDebugStringA( "Loaded engine module API\n" );
}
else {
fatal( "Failed to load engine module API!\n" );
}
return engine_api;
}
@ -865,6 +868,13 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
}
}
// Populate an initial polling state for the inputs
poll_input( window_handle, & input, jsl_num_devices, jsl_device_handles
, old_keyboard, new_keyboard
, old_mouse, new_mouse
, old_xpads, new_xpads
, old_ds_pads, new_ds_pads );
engine_api.startup( rcast(engine::OffscreenBuffer*, & Surface_Back_Buffer.memory), & engine_memory, & platform_api );
u64 last_frame_clock = timing_get_wall_clock();

View File

@ -2,6 +2,10 @@
#include "platform.hpp"
#include "jsl.hpp"
#include "win32.hpp"
NS_PLATFORM_BEGIN
using namespace win32;
NS_PLATFORM_END
#endif
NS_PLATFORM_BEGIN
@ -127,8 +131,10 @@ b32 file_read_content( File* file )
return {};
}
// This has to be done or for some reason file_handle will be consumed to null by `GetFileSizeEx` (Clang bug?)
HANDLE file_handle_clang_bug = file_handle;
u32 size;
GetFileSizeEx( file_handle, rcast(LARGE_INTEGER*, &size) );
GetFileSizeEx( file_handle_clang_bug, rcast(LARGE_INTEGER*, &size) );
if ( size == 0 )
{
// TODO(Ed) : Logging

View File

@ -250,10 +250,10 @@ function build-engine
$local:compiler_args = $script:compiler_args
$compiler_args += ($flag_define + 'Build_DLL=1' )
if ( $vendor -eq 'msvc' ) {
if ( $IsWindows ) {
$compiler_args += ($flag_define + 'Engine_API=__declspec(dllexport)')
}
if ( $vendor -eq 'clang' ) {
else {
$compiler_args += ($flag_define + 'Engine_API=__attribute__((visibility("default")))')
}