Add intrinsics.

This commit is contained in:
2026-04-09 00:12:56 -07:00
parent 530c437837
commit d3cee7409c
2 changed files with 40 additions and 13 deletions
+1 -13
View File
@@ -2,7 +2,7 @@
#include "handmade.h"
#include "sdl_handmade.h"
#include <math.h>
#include "handmade_intrinsics.h"
#include <string.h> /* memset */
static void GameOutputSound(game_state *GameState,
@@ -51,18 +51,6 @@ static void ClearBackground(game_offscreen_buffer *Buffer)
}
}
static S32 RoundF32toS32(F32 Real32)
{
S32 Result = (S32)(Real32 + 0.5f);
return Result;
}
static S32 FloorF32toS32(F32 Real32)
{
S32 Result = (S32)floorf(Real32);
return Result;
}
static void DrawRectangle(game_offscreen_buffer *Buffer,
F32 RealMinX, F32 RealMinY,
F32 RealMaxX, F32 RealMaxY,
+39
View File
@@ -0,0 +1,39 @@
#ifndef HANDMADE_INTRINSICS_H_SENTRY
#define HANDMADE_INTRINSICS_H_SENTRY
/* TODO: Re-implement these functions so we do not have to rely on
math.h. */
#include <math.h>
S32 RoundF32toS32(F32 Real32)
{
S32 Result = (S32)(Real32 + 0.5f);
return Result;
}
S32 FloorF32toS32(F32 Real32)
{
S32 Result = (S32)floorf(Real32);
return Result;
}
F32 Sin(F32 Angle)
{
F32 Result = sinf(Angle);
return Result;
}
F32 Cos(F32 Angle)
{
F32 Result = cosf(Angle);
return Result;
}
F32 ATan2(F32 Y, F32 X)
{
F32 Result = atan2f(Y, X);
return Result;
}
#endif