mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-18 00:35:45 +01:00
implement some basic rendering boilerplate
This commit is contained in:
25
src/main.c
25
src/main.c
@@ -1,10 +1,25 @@
|
|||||||
|
#include "GLFW/glfw3.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "window/render.h"
|
||||||
|
|
||||||
|
struct renderdat rdat; // contains the relevant data needed for rendering, contains rubbish data until init was
|
||||||
|
|
||||||
|
static inline int init(void) {
|
||||||
|
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE); // disable joystick buttons
|
||||||
|
|
||||||
|
if (!glfwInit()) return 1; // initialize GLFW
|
||||||
|
if (render_init(&rdat)) return 1; // initialize the rendering and create a window
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void quit(void) {
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
(void)argc, (void)argv;
|
(void)argc, (void)argv;
|
||||||
debug("%s", "owo");
|
if (init()) fatal("failed to initialize!");
|
||||||
info("%s", "owo");
|
while (1);
|
||||||
warn("%s", "owo");
|
quit();
|
||||||
error("%s", "owo");
|
|
||||||
fatal("%s", "owo");
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/window/render.c
Normal file
21
src/window/render.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "render.h"
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// macros for ease of access
|
||||||
|
#define WIN_NAME "MCA Selector Lite"
|
||||||
|
#define WIN_DEFAULT_WIDTH 640
|
||||||
|
#define WIN_DEFAULT_HEIGHT 480
|
||||||
|
|
||||||
|
int render_init(struct renderdat* restrict rdat) {
|
||||||
|
GLFWwindow* const win = glfwCreateWindow(WIN_DEFAULT_WIDTH, WIN_DEFAULT_HEIGHT, WIN_NAME, NULL, NULL);
|
||||||
|
if (win == NULL) return 1;
|
||||||
|
rdat->win = win;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_free(struct renderdat* restrict rdat) {
|
||||||
|
glfwDestroyWindow(rdat->win);
|
||||||
|
}
|
||||||
10
src/window/render.h
Normal file
10
src/window/render.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
struct renderdat {
|
||||||
|
GLFWwindow* win;
|
||||||
|
};
|
||||||
|
|
||||||
|
int render_init(struct renderdat* restrict rdat);
|
||||||
|
void render_free(struct renderdat* restrict rdat);
|
||||||
Reference in New Issue
Block a user