Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if !defined(HANDMADE_H)
- /*
- HANDMADE_INTERNAL:
- 0 - Build for public release
- 1 - Developer only build
- HANDMADE_SLOW
- 0 - No slow code
- 1 - Slow code allowed
- */
- #include <math.h>
- #include <stdint.h>
- #define PI32 3.14159265359f
- #if HANDMADE_INTERNAL
- struct debug_read_file_result
- {
- uint32_t contentSize;
- void * contents;
- };
- #define DEBUG_PLATFORM_READ_ENTIRE_FILE(name) debug_read_file_result name(char *fileName)
- typedef DEBUG_PLATFORM_READ_ENTIRE_FILE(debug_platform_read_entire_file);
- #define DEBUG_PLATFORM_WRITE_ENTIRE_FILE(name) int name(char *fileName, void *memory, uint32_t memorySize)
- typedef DEBUG_PLATFORM_WRITE_ENTIRE_FILE(debug_platform_write_entire_file);
- #define DEBUG_PLATFORM_FREE_FILE_MEMORY(name) void name(void *memory)
- typedef DEBUG_PLATFORM_FREE_FILE_MEMORY(debug_platform_free_file_memory);
- #endif
- #if HANDMADE_SLOW
- #define Assert(Expression) if(!(Expression)){*(int *)0 = 0;}
- #else
- #define Assert(Expression)
- #endif
- #define kiloBytes(num) ((num) * 1024LL)
- #define megaBytes(num) ((kiloBytes(num)) * 1024LL)
- #define gigaBytes(num) ((megaBytes(num)) * 1024LL)
- #define teraBytes(num) ((gigaBytes(num)) * 1024LL)
- #define arrayCount(array) (sizeof(array) / sizeof((array)[0]))
- inline uint32_t safeTruncateUint64(uint64_t value)
- {
- Assert(value <= 0xFFFFFFFF);
- return (uint32_t)value;
- }
- struct game_offscreen_buffer
- {
- void *memory;
- int width;
- int height;
- int pitch;
- int bytesPerPixel;
- };
- struct game_sound_output_buffer
- {
- int sampleCount;
- int samplesPerSecond;
- int16_t *samples;
- };
- struct game_button_state
- {
- int halfTransitionCount;
- int endedDown;
- };
- struct game_controller_input
- {
- int isAnalog;
- int isConnected;
- float stickAverageX;
- float stickAverageY;
- union
- {
- game_button_state buttons[12];
- struct{
- game_button_state moveUp;
- game_button_state moveDown;
- game_button_state moveLeft;
- game_button_state moveRight;
- game_button_state actionUp;
- game_button_state actionDown;
- game_button_state actionLeft;
- game_button_state actionRight;
- game_button_state leftShoulder;
- game_button_state rightShoulder;
- game_button_state back;
- game_button_state start;
- };
- };
- };
- struct game_input
- {
- //float gameClock;
- game_controller_input controllers[5];
- };
- inline game_controller_input *getController(game_input *input, int controllerIndex)
- {
- Assert(controllerIndex < arrayCount(input->controllers));
- game_controller_input *controller = &input->controllers[controllerIndex];
- return controller;
- }
- struct game_memory
- {
- int isInitialized;
- long long permanantStorageSize;
- void *permanantStorage; //Required to be initialized to 0
- long long transientStorageSize;
- void* transientStorage; //Required to be initialized to 0
- debug_platform_read_entire_file *DEBUGPlatformReadEntireFile;
- debug_platform_write_entire_file *DEBUGPlatformWriteEntireFile;
- debug_platform_free_file_memory *DEBUGPlatformFreeFileMemory;
- };
- #define GAME_UPDATE_AND_RENDER(name) void name(game_memory *gameMemory, game_offscreen_buffer *buffer, game_input *input)
- typedef GAME_UPDATE_AND_RENDER(game_update_and_render);
- GAME_UPDATE_AND_RENDER(gameUpdateAndRenderStub)
- {
- }
- // Need timer, controler/keyboard input, bitmap buffer to use, sound buffer to use
- extern "C" void gameUpdateAndRender(game_memory *gameMemory, game_offscreen_buffer *buffer, game_input *input);
- #define GAME_GET_SOUND_SAMPLES(name) void name(game_memory *gameMemory, game_sound_output_buffer *soundBuffer)
- typedef GAME_GET_SOUND_SAMPLES(game_get_sound_samples);
- GAME_GET_SOUND_SAMPLES(gameGetSoundSamplesStub)
- {
- }
- //Note: At the moment. this has to be a very fast function. It cannot take longer than 1 MS or so.
- extern "C" void gameGetSoundSamples(game_memory *gameMemory, game_sound_output_buffer *soundBuffer);
- /////
- struct game_state
- {
- int toneHz;
- int greenOffset;
- int blueOffset;
- float tSine;
- int playerX;
- int playerY;
- float tJump;
- };
- #define HANDMADE_H
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement