Skip to content
Permalink
Browse files

Add rewrite of GLFW for 3.3 together with the update of other modules…

… to support it
  • Loading branch information...
lmariscal committed Sep 29, 2019
1 parent 7634074 commit 6f81c7c3a5fc60be8916e2edacb94c31d05dd321
Showing with 4,744 additions and 951 deletions.
  1. +14 −8 examples/tglfw.nim
  2. +6 −6 examples/timgui.nim
  3. +10 −10 examples/topengl.nim
  4. +4,569 −859 src/nimgl/glfw.nim
  5. +79 −3 src/nimgl/imgui.nim
  6. +66 −65 src/nimgl/imgui/impl_glfw.nim
@@ -8,18 +8,24 @@ if os.getEnv("CI") != "":
proc main =
assert glfwInit()

glfwWindowHint(whContextVersionMajor, 3)
glfwWindowHint(whContextVersionMinor, 3)
glfwWindowHint(whOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(whOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(whResizable, GLFW_FALSE)
glfwWindowHint(GLFWContextVersionMajor, 3)
glfwWindowHint(GLFWContextVersionMinor, 3)
glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFWResizable, GLFW_FALSE)

let w = glfwCreateWindow(800, 600)
var monitor = glfwGetPrimaryMonitor()

var videoMode = monitor.getVideoMode()
echo videoMode.width
echo videoMode.height

let w = glfwCreateWindow(800, 600, "NimGL", nil, nil)
assert w != nil

w.makeContextCurrent
w.makeContextCurrent()

while not w.windowShouldClose:
while not w.windowShouldClose():
w.swapBuffers()
glfwPollEvents()
w.setWindowShouldClose(true)
@@ -6,11 +6,11 @@ import nimgl/[opengl, glfw]
proc main() =
assert glfwInit()

glfwWindowHint(whContextVersionMajor, 3)
glfwWindowHint(whContextVersionMinor, 3)
glfwWindowHint(whOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(whOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(whResizable, GLFW_FALSE)
glfwWindowHint(GLFWContextVersionMajor, 3)
glfwWindowHint(GLFWContextVersionMinor, 3)
glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFWResizable, GLFW_FALSE)

var w: GLFWWindow = glfwCreateWindow(1280, 720)
if w == nil:
@@ -26,7 +26,7 @@ proc main() =
assert igGlfwInitForOpenGL(w, true)
assert igOpenGL3Init()

igStyleColorsDark()
igStyleColorsCherry()

var show_demo: bool = true
var somefloat: float32 = 0.0f
@@ -8,11 +8,11 @@ import os
if os.getEnv("CI") != "":
quit()

proc keyProc(window: GLFWWindow, key: GLFWKey, scancode: cint, action: GLFWKeyAction, mods: GLFWKeyMod): void {.cdecl.} =
if key == keyESCAPE and action == kaPress:
proc keyProc(window: GLFWWindow, key: int32, scancode: int32, action: int32, mods: int32): void {.cdecl.} =
if key == GLFWKey.Escape and action == GLFWPress:
window.setWindowShouldClose(true)
if key == keySpace:
glPolygonMode(GL_FRONT_AND_BACK, if action != kaRelease: GL_LINE else: GL_FILL)
if key == GLFWKey.Space:
glPolygonMode(GL_FRONT_AND_BACK, if action != GLFWRelease: GL_LINE else: GL_FILL)

proc statusShader(shader: uint32) =
var status: int32
@@ -31,13 +31,13 @@ proc main =
# GLFW
assert glfwInit()

glfwWindowHint(whContextVersionMajor, 3)
glfwWindowHint(whContextVersionMinor, 3)
glfwWindowHint(whOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(whOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(whResizable, GLFW_FALSE)
glfwWindowHint(GLFWContextVersionMajor, 3)
glfwWindowHint(GLFWContextVersionMinor, 3)
glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFWResizable, GLFW_FALSE)

let w: GLFWWindow = glfwCreateWindow(800, 600)
let w: GLFWWindow = glfwCreateWindow(800, 600, "NimGL", nil, nil)
assert w != nil

discard w.setKeyCallback(keyProc)

0 comments on commit 6f81c7c

Please sign in to comment.
You can’t perform that action at this time.