Add simple example
This commit is contained in:
parent
23d45d1c9f
commit
cb5066b3ae
2 changed files with 29 additions and 1 deletions
28
examples/ex1.nim
Normal file
28
examples/ex1.nim
Normal file
|
|
@ -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()
|
||||||
|
|
@ -10,4 +10,4 @@ srcDir = "src"
|
||||||
|
|
||||||
# Dependencies
|
# 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"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue