From 5c61995d1ceb3141e22d722ce930d89a40f64455 Mon Sep 17 00:00:00 2001 From: k Date: Sat, 3 May 2025 16:50:20 -0400 Subject: [PATCH] Basic window --- .envrc | 1 + main.cc | 39 +++++++++++++++++++++++++++++++++++++++ shell.nix | 16 ++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .envrc create mode 100644 main.cc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/main.cc b/main.cc new file mode 100644 index 0000000..3158739 --- /dev/null +++ b/main.cc @@ -0,0 +1,39 @@ +#include +#include + +#define X 16 +#define Y 16 +#define GRID_SIZE X*Y + +#define STR_EXPAND(tok) #tok +#define STR(tok) STR_EXPAND(tok) + +int main() { + if (!glfwInit()) + return -1; + + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); + + GLFWwindow *w = glfwCreateWindow(800, 800, "game of life", NULL, NULL); + if (!w) + return -2; + + glfwMakeContextCurrent(w); + + if (glewInit() != GLEW_OK) + return -3; + + glfwShowWindow(w); + glViewport(0, 0, 800, 800); + + while (!glfwWindowShouldClose(w)) { + glfwPollEvents(); + glClear(GL_COLOR_BUFFER_BIT); + glfwSwapBuffers(w); + } + + glfwTerminate(); + return 0; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..04b81f4 --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{pkgs ? import {}}: +with pkgs; + mkShell rec { + packages = [gdb clang-tools]; + nativeBuildInputs = [ + pkg-config + gcc + gnumake + ]; + buildInputs = [ + glfw3 + glm + glew + ]; + LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; + }