mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2025-07-01 03:11:04 -07:00
Day 38 complete
This commit is contained in:
@ -15,36 +15,30 @@
|
||||
/* Platform OS */
|
||||
|
||||
#if defined( _WIN32 ) || defined( _WIN64 )
|
||||
# ifndef SYSTEM_WINDOWS
|
||||
# define SYSTEM_WINDOWS 1
|
||||
# ifndef System_Windows
|
||||
# define System_Windows 1
|
||||
# endif
|
||||
#elif defined( __APPLE__ ) && defined( __MACH__ )
|
||||
# ifndef SYSTEM_OSX
|
||||
# define SYSTEM_OSX 1
|
||||
# ifndef System_OSX
|
||||
# define System_OSX 1
|
||||
# endif
|
||||
# ifndef SYSTEM_MACOS
|
||||
# define SYSTEM_MACOS 1
|
||||
# endif
|
||||
# include <TargetConditionals.h>
|
||||
# if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
|
||||
# ifndef SYSTEM_IOS
|
||||
# define SYSTEM_IOS 1
|
||||
# endif
|
||||
# ifndef System_MacOS
|
||||
# define System_MacOS 1
|
||||
# endif
|
||||
#elif defined( __unix__ )
|
||||
# ifndef SYSTEM_UNIX
|
||||
# define GEN_SYSTEM_UNIX 1
|
||||
# ifndef System_Unix
|
||||
# define System_Unix 1
|
||||
# endif
|
||||
# if defined( ANDROID ) || defined( __ANDROID__ )
|
||||
# ifndef SYSTEM_ANDROID
|
||||
# define SYSTEM_ANDROID 1
|
||||
# ifndef System_Android
|
||||
# define System_Android 1
|
||||
# endif
|
||||
# ifndef SYSTEM_LINUX
|
||||
# define SYSTEM_LINUX 1
|
||||
# define System_Linux 1
|
||||
# endif
|
||||
# elif defined( __linux__ )
|
||||
# ifndef SYSTEM_LINUX
|
||||
# define SYSTEM_LINUX 1
|
||||
# ifndef System_Linux
|
||||
# define System_linux 1
|
||||
# endif
|
||||
# else
|
||||
# error This UNIX operating system is not supported
|
||||
@ -56,11 +50,11 @@
|
||||
/* Platform compiler */
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
# define COMPILER_MSVC 1
|
||||
# define Compiler_MSVC 1
|
||||
#elif defined( __clang__ )
|
||||
# define COMPILER_CLANG 1
|
||||
# define Compiler_Clang 1
|
||||
#else
|
||||
# error Unknown compiler
|
||||
# error "Unknown compiler"
|
||||
#endif
|
||||
|
||||
#if defined( __has_attribute )
|
||||
@ -76,7 +70,7 @@
|
||||
# include <stdarg.h>
|
||||
# include <stddef.h>
|
||||
|
||||
# if defined( SYSTEM_WINDOWS )
|
||||
# if defined( System_Windows )
|
||||
# include <intrin.h>
|
||||
# endif
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#if INTELLISENSE_DIRECTIVES
|
||||
#include <math.h>
|
||||
#include "grime.hpp"
|
||||
#endif
|
||||
|
||||
// TODO(Ed) : Convert all of these to platform-efficient versions
|
||||
@ -33,21 +34,50 @@ s32 truncate( f32 value )
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
inline
|
||||
f32 sine( f32 angle )
|
||||
{
|
||||
f32 result = sinf( angle );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
f32 cosine( f32 angle )
|
||||
{
|
||||
f32 result = cosf( angle );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
f32 arc_tangent( f32 Y, f32 X )
|
||||
{
|
||||
f32 result = atan2f( Y, X );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
b32 bitscan_forward( u32* index, u32 value )
|
||||
{
|
||||
b32 found = false;
|
||||
|
||||
// TODO(Ed) : This file can technically be generated with a metaprogram or via the preprocessor..
|
||||
// We can keep The definitions for each of these based on the platform and
|
||||
// Choose which one gets added to te project that way (keeps the runtime definition clean)
|
||||
#if Compiler_MSVC
|
||||
found = _BitScanForward( rcast(unsigned long*, index), value );
|
||||
#elif Compiler_Clang
|
||||
*index = __builtin_ctz( value );
|
||||
found = index;
|
||||
#else
|
||||
for ( u32 test = 0; test < 32; ++ test )
|
||||
{
|
||||
if ( value & (1 << test ))
|
||||
{
|
||||
*index = test;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return found;
|
||||
}
|
||||
|
@ -3,18 +3,18 @@
|
||||
// Joyshock grime wrapper
|
||||
// JoyShock does not provide a proper c-linkage definition for its structs, so we have to push this warning ignore.
|
||||
|
||||
#ifdef COMPILER_CLANG
|
||||
#ifdef Compiler_Clang
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
#elif COMPILER_MSVC
|
||||
#elif Compiler_MSVC
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4820 )
|
||||
#endif
|
||||
|
||||
#include "dependencies/JoyShockLibrary/JoyShockLibrary.h"
|
||||
|
||||
#ifdef COMPILER_CLANG
|
||||
#ifdef Compiler_Clang
|
||||
# pragma clang diagnostic pop
|
||||
#elif COMPILER_MSVC
|
||||
#elif Compiler_MSVC
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user