Basic window
This commit is contained in:
commit
5c61995d1c
3 changed files with 56 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use nix
|
||||
39
main.cc
Normal file
39
main.cc
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
16
shell.nix
Normal file
16
shell.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{pkgs ? import <nixpkgs> {}}:
|
||||
with pkgs;
|
||||
mkShell rec {
|
||||
packages = [gdb clang-tools];
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
gcc
|
||||
gnumake
|
||||
];
|
||||
buildInputs = [
|
||||
glfw3
|
||||
glm
|
||||
glew
|
||||
];
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue