polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 642f128baf2124eda2fac1eba89543efa94de25b
Author: William Casarin <bill@casarin.me>
Date:   Mon, 23 Mar 2015 23:20:50 -0700

Initial glfw project

Diffstat:
AMakefile | 23+++++++++++++++++++++++
Adefault.nix | 22++++++++++++++++++++++
Amain.cc | 37+++++++++++++++++++++++++++++++++++++
Ashell.nix | 1+
4 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,23 @@ + +BIN ?= polycraft +PREFIX ?= /usr/local +LDFLAGS = -lglfw3 -lX11 -lGL -lXi -lXrandr -lXxf86vm + +all: $(BIN) + +%.o: %.c + $(CXX) -o $@ -c $< + +$(BIN): $(OBJS) + $(CXX) $^ main.cc $(LDFLAGS) -o $@ + +install: $(BIN) + install -d $(PREFIX)/bin + install $(BIN) $(PREFIX)/bin + +nixbuild: + nix-build shell.nix + +clean: + find . -name '*.o' -exec rm -f {} \; + rm -f csv diff --git a/default.nix b/default.nix @@ -0,0 +1,22 @@ +{clangStdenv, glfw, mesa, xlibs}: + +let + stdenv = clangStdenv; +in stdenv.mkDerivation rec { + name = "polycraft"; + version = "0.1"; + + src = ./.; + + makeFlags = "PREFIX=$(out)"; + + buildInputs = [ glfw mesa ] + ++ (with xlibs; [ libX11 libXi libXrandr libXxf86vm ] ); + + meta = with stdenv.lib; { + description = "Procedural low poly fun"; + homepage = "https://jb55.com/polycraft"; + maintainers = with maintainers; [ jb55 ]; + license = licenses.gpl2; + }; +} diff --git a/main.cc b/main.cc @@ -0,0 +1,37 @@ + +#include <GLFW/glfw3.h> + +int main(void) +{ + GLFWwindow* window; + + /* Initialize the library */ + if (!glfwInit()) + return -1; + + /* Create a windowed mode window and its OpenGL context */ + window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); + if (!window) + { + glfwTerminate(); + return -1; + } + + /* Make the window's context current */ + glfwMakeContextCurrent(window); + + /* Loop until the user closes the window */ + while (!glfwWindowShouldClose(window)) + { + /* Render here */ + + /* Swap front and back buffers */ + glfwSwapBuffers(window); + + /* Poll for and process events */ + glfwPollEvents(); + } + + glfwTerminate(); + return 0; +} diff --git a/shell.nix b/shell.nix @@ -0,0 +1 @@ +with import <nixpkgs> {}; callPackage ./default.nix {}