From cb5066b3aed121c5744b62f1804806f809d3d291 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sun, 13 Sep 2020 20:28:17 -0600 Subject: [PATCH] Add simple example --- examples/ex1.nim | 28 ++++++++++++++++++++++++++++ glew.nimble | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 examples/ex1.nim diff --git a/examples/ex1.nim b/examples/ex1.nim new file mode 100644 index 0000000..dbf9969 --- /dev/null +++ b/examples/ex1.nim @@ -0,0 +1,28 @@ +import opengl +import glfw +import glew + +proc main() = + initHint(CONTEXT_VERSION_MAJOR, 3) + initHint(CONTEXT_VERSION_MINOR, 2) + when defined(macosx): + initHint(OPENGL_FORWARD_COMPAT, 1) + initHint(OPENGL_PROFILE, OPENGL_CORE_PROFILE) + + discard glfw.init() + + windowHint(CONTEXT_VERSION_MAJOR, 3) + windowHint(CONTEXT_VERSION_MINOR, 2) + when defined(macosx): + windowHint(OPENGL_FORWARD_COMPAT, 1) + windowHint(OPENGL_PROFILE, OPENGL_CORE_PROFILE) + + var w = createWindow(800, 600, "Minimal Nim-GLFW Example", nil, nil) + w.makeContextCurrent() + + let code = glew.init() + + if code != GLEW_OK: + raise newException(CatchableError, "Glew not initialized properly") + +main() diff --git a/glew.nimble b/glew.nimble index d2f5cb7..c40c19e 100644 --- a/glew.nimble +++ b/glew.nimble @@ -10,4 +10,4 @@ srcDir = "src" # Dependencies -requires "nim >= 1.0.6", "https://github.com/jyapayne/nimterop#head" +requires "nim >= 1.0.6", "https://github.com/jyapayne/nimterop#head", "https://github.com/jyapayne/nim-glfw#head"