61 lines
1.1 KiB
C
61 lines
1.1 KiB
C
#include "gpu.h"
|
|
|
|
#include <assert.h>
|
|
#include <math.h>
|
|
|
|
static const vertex_t vertices[] = {
|
|
{ { 0.0, -0.5 }, { 1.0, 0.0, 0.0 } },
|
|
{ { 0.5, 0.5 }, { 0.0, 1.0, 0.0 } },
|
|
{ { -0.5, 0.5 }, { 0.0, 0.0, 1.0 } },
|
|
};
|
|
|
|
static void
|
|
key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
|
{
|
|
(void)window;
|
|
(void)scancode;
|
|
(void)mods;
|
|
|
|
switch (key) {
|
|
case GLFW_KEY_Q:
|
|
if (action == GLFW_PRESS)
|
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
|
break;
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
// Set up window
|
|
glfwInit();
|
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
|
GLFWwindow *window = glfwCreateWindow(800, 600, "Foo", nullptr, nullptr);
|
|
assert(window);
|
|
|
|
// Register input callbacks
|
|
glfwSetKeyCallback(window, key_callback);
|
|
|
|
// Initialise GPU
|
|
const gpu_config_t gpu_config = {
|
|
.application_name = "Foo",
|
|
.window = window,
|
|
.vertex_data = vertices,
|
|
.vertex_data_size = sizeof(vertices),
|
|
};
|
|
gpu_ctx_t gpu;
|
|
gpu_init(&gpu, &gpu_config);
|
|
|
|
while (!glfwWindowShouldClose(window)) {
|
|
glfwPollEvents();
|
|
gpu_render(&gpu);
|
|
}
|
|
|
|
// Clean up
|
|
gpu_cleanup(&gpu);
|
|
glfwDestroyWindow(window);
|
|
glfwTerminate();
|
|
|
|
return 0;
|
|
}
|