Vulkan hard :(

This commit is contained in:
2021-02-16 19:22:12 +11:00
commit 1407d028e8
13 changed files with 876 additions and 0 deletions

32
test/game/game.c Normal file
View File

@ -0,0 +1,32 @@
#include "game.h"
game_t * gameInit(char *gameName) {
// Create the game instance
game_t *game = malloc(sizeof(game_t));
if(game == NULL) return NULL;
// Setup the renderer
game->render = renderInit(640, 480, gameName);
if(game->render == NULL) {
free(game);
return NULL;
}
return game;
}
void gameStart(game_t *game) {
while(!glfwWindowShouldClose(game->render->window)) {
renderFrame(game->render);
glfwSwapBuffers(game->render->window);
glfwPollEvents();
}
}
bool gameDispose(game_t *game) {
if(!renderDispose(game->render)) return false;
free(game);
return true;
}

33
test/game/game.h Normal file
View File

@ -0,0 +1,33 @@
#pragma once
#include <stdbool.h>
#include "../display/render.h"
/** Information about the current game context. */
typedef struct {
/** Renderer for the game */
render_t *render;
} game_t;
/**
* Initialize the game context.
*
* @param gameName Name of the game being initialized.
* @return The game instance context.
*/
game_t * gameInit(char *gameName);
/**
* Start the main game loop.
*
* @param game The game to start the loop for.
*/
void gameStart(game_t *game);
/**
* Cleanup a previously constructed.
*
* @param game The game to cleanup.
* @return True if successful or not.
*/
bool gameDispose(game_t *game);