nimgl

Nim Game Library


Keywords
glfw, imgui, opengl, bindings, gl, graphics, nim, nimgl, stb-image
License
MIT
Install
nimble install nimgl

Documentation

circleci docs

Nim Game Library (WIP) nimble

NimGL (Nim Game Library) is a collection of bindings for popular APIs, mostly used in computer graphics.

This collection of bindings is heavily inspired by LWJGL3, it enables low level access and it is not a framework, so we highly encourage you to use other game engines if you don’t have experience working with low level graphics developments. We try to keep this bindings as similar to the originals but we do have some usefull toolkits or some variations on procedures to help with development and suit it to the language.

Install

You will need nimble to install this library.

nimble install nimgl

After that you can access all the bindings by importing them like.

import nimgl/<binding>

It is currently being developed and tested on

  • Windows 10

  • MacOS Mojave

  • Linux Ubuntu 18.10

Contribute

I’m only one person and I use this library almost daily for school and personal projects. If you are missing some extension, procedures, bindings or anything related feel free to PR them or open an Issue with the specification and if you can some examples to have an idea on how to implement it.
Thank you so much 🎉

Read the Contribution Guide for more information.

Bindings Currently Supported

Library Description

GLFW

It provides a simple API for creating windows, contexts and surfaces, receiving input and events.

OpenGL

Open Graphics Library is a cross-language, cross-platform application programming interface for rendering 2D and 3D vector graphics. NimGL supports modern OpenGL.

ImGUI

Bloat-free graphical user interface library

stb_image

Image loading/decoding library (WIP)

How it Looks

An example that spawns a green window:

import nimgl/[glfw, opengl]

proc keyProc(window: GLFWWindow, key: GLFWKey, scancode: int32, action: GLFWKeyAction, mods: GLFWKeyMod): void {.cdecl.} =
  if key == keyESCAPE and action == kaPress:
    window.setWindowShouldClose(true)

proc main() =
  assert glfwInit()

  glfwWindowHint(whContextVersionMajor, 3)
  glfwWindowHint(whContextVersionMinor, 2)
  glfwWindowHint(whOpenglForwardCompat, GLFW_TRUE)
  glfwWindowHint(whOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
  glfwWindowHint(whResizable, GLFW_FALSE)

  let w: GLFWWindow = glfwCreateWindow(800, 600, "NimGL", nil, nil)
  if w == nil:
    quit(-1)

  discard w.setKeyCallback(keyProc)
  w.makeContextCurrent()

  assert glInit()

  while not w.windowShouldClose:
    glfwPollEvents()
    glClearColor(0.68f, 1f, 0.34f, 1f)
    glClear(GL_COLOR_BUFFER_BIT)
    w.swapBuffers()

  w.destroyWindow()
  glfwTerminate()

main()

License

NimGL is open source and is under the MIT License, we highly encourage every developer that uses it to make improvements and fork them here.

Contributors

Thank you to every contributor that has spent their time improving this library.