Add platform layer with hooks into engine

This commit is contained in:
austin committed 2020-07-01 17:42:43 -07:00
1 parent e3f7b8e781
commit b024d821f5
7 files changed
+488

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#ifndef ENGINE_H
#include <cstdint>
// ENUMS
enum Engine_Input
{
TRANSLATE_X_POS,
TRANSLATE_X_NEG,
TRANSLATE_Y_POS,
TRANSLATE_Y_NEG,
TRANSLATE_Z_POS,
TRANSLATE_Z_NEG,
ROTATE_X_POS,
ROTATE_X_NEG,
ROTATE_Y_POS,
ROTATE_Y_NEG,
ROTATE_Z_POS,
ROTATE_Z_NEG,
SCALE_UP,
SCALE_DOWN
};
// STRUCTURES
struct Engine_Buffer
{
uint32_t *pixels;
int width;
int height;
};
// FUNCTIONS
int Engine_Init(char *filename);
void Engine_Render(Engine_Buffer &buffer, uint32_t input);
void Engine_Shutdown(void);
#define ENGINE_H
#endif
+44
View File
@@ -0,0 +1,44 @@
#ifndef PLATFORM_H
#include <SDL2/SDL.h>
// ENUMERATIONS
enum Platform_Status
{
PLATFORM_ERROR = -1,
PLATFORM_OK,
PLATFORM_QUIT
};
// STRUCTURES
struct Platform
{
SDL_Window *window;
SDL_Surface *surface;
uint32_t input;
uint32_t framerateMillis;
uint32_t frameStartMillis;
};
// FUNCTIONS
int Platform_Init(Platform &platform, int width, int height);
int Platform_CheckForEvents(Platform &platform);
void Platform_ClearWindow(Platform &platform);
void Platform_UpdateWindow(Platform &platform);
void Platform_GetFrameTime(Platform &platform);
void Platform_SyncToFramerate(Platform &platform);
void Platform_Shutdown(Platform &platform);
#define PLATFORM_H
#endif
+12
View File
@@ -0,0 +1,12 @@
#ifndef UTIL_H
// MACROS
#define SET_BIT(x, bit) (x |= (1UL << bit))
#define CLEAR_BIT(x, bit) (x &= ~(1UL << bit))
#define CHECK_BIT(x, bit) (x & (1UL << bit))
#define UTIL_H
#endif