Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

CodeDoes/nimgl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub stars Buy Me A Coffee GitHub last commit license 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 graphic developments. We try to keep this bindings as similar to the originals but we do have some usefull toolkits or some variations on functions to help with the development.

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.

NimGL is under heavy development so expect drastic changes and improvements

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
  • Mac High Sierra

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 or bindings or anything related, feel free to PR any feature or open an issue with the specification and if you can some links to the docs so I can have an idea on how to implement it.
Thank you so much :D

Bindings Currently Supported

Library Description
GLFW It provides a simple API for creating windows, contexts and surfaces, receiving input and events.
OpenGL Bindings to GLEW. GLEW is a cross-platform open-source extension loading library
Math A linear algebra library to interact directly with opengl (WIP)
ImGUI Bloat-free graphical user interface library (WIP)
stb_image Image loading/decoding library (WIP)

How it Looks

An example that spawns a green window

import
  nimgl/[glfw, math, opengl]

proc keyProc(window: Window, key: Key, scancode: int32, action: KeyAction, mods: KeyMod): void {.cdecl.} =
  if key == keyESCAPE and action == kaPress:
    window.setWindowShouldClose(true)

proc main =
  if not glfw.init():
    quit(-1)

  windowHint whContextVersionMajor, 4
  windowHint whContextVersionMinor, 1
  windowHint whOpenglForwardCompat, GLFW_TRUE
  windowHint whOpenglProfile      , GLFW_OPENGL_CORE_PROFILE
  windowHint whResizable          , GLFW_FALSE

  var w: Window = createWindow(800, 600, "NimGL")
  if w == nil:
    quit(-1)

  w.setKeyCallback(keyProc)
  w.makeContextCurrent

  if opengl.init() != GLEW_OK:
    quit(-1)

  var bg = vec(178f, 255f, 89f).rgb

  while not w.windowShouldClose:
    clearColor(bg.r, bg.g, bg.b, 1f)
    clear(GL_COLOR_BUFFER_BIT)

    w.swapBuffers
    glfw.pollEvents()

  w.destroyWindow

  glfw.terminate()

main()

About

Nim Game Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 72.8%
  • C++ 15.2%
  • Nim 9.8%
  • Objective-C 1.9%
  • Other 0.3%