Giter Site home page Giter Site logo

nim-glfw's Introduction

nim-glfw

nim-glfw provides a nice idiomatic Nim API to GLFW, the cross-platform OpenGL, OpenGL ES & Vulkan library.

Not all functionality is available through the Nim API yet; in those cases, you can just use the native C bindings directly (by importing glfw/wrapper). Please raise a ticket about such the missing functionality so we can add it, or even better yet, give a shot at implementing it yourself and raise a PR! :sunglasses:

Versioning

Versioning follows the x.y.z.w scheme, where x.y.z corresponds to the GLFW version being wrapped (e.g. 3.4.0) and w to the patch version of the Nim wrapper (e.g. 3.4.0.2).

Installation

The best way to install the latest version of the package is via nimble:

nimble install glfw

Examples

All examples except minimal.nim and events.nim depend on nim-glm.

You can install nim-glm with the following command:

nimble install glm

Compile and run any of the examples by running the following command in the examples directory:

nim c -r -d:glfwStaticLib <example>

Alternatively, you can invoke the examplesStatic or examples (for dynamic linking) nimble task in the project root directory to compile all examples:

nimble examplesStatic

Usage

A minimal example to display a window for one second and then terminate:

import std/os
import glfw

proc main =
  glfw.initialize()

  var c = DefaultOpenglWindowConfig
  c.title = "Minimal Nim-GLFW example"

  var w = newWindow(c)

  sleep(1000)

  w.destroy()
  glfw.terminate()

main()

Check out the examples directory for more complex examples!

Statically linking to GLFW

To link statically against GLFW (the C sources are bundled with the module), define the conditional symbol glfwStaticLib (-d:glfwStaticLib or --define:glfwStaticLib).

Documentation

No documentation exists currently, but a symbol list can be generated by invoking these commands from the root directory:

nim doc glfw
nim doc glfw/wrapper

Checking out the examples is probably the best way to get started with the library. If you have some familiarity with GLFW, reading the official GLFW documentation in conjunction with the Nim sources should make everything clear.

Creating high-quality documentation is a lot of work, so if you would like to help the project, writing documentation would be a great way to contribute!

Contributors

ephja: Original author and maintainer until v3.2.

johnnovak: Current maintainer and ports of some of the official GLFW examples.

def-: Support for static linking.

AntonioArtigas: GLFW 3.3 update.

nim-glfw's People

Contributors

johnnovak avatar antonioartigas avatar def- avatar nleseul avatar asheb avatar spotlightkid avatar codedoes avatar choltreppe avatar iffy avatar wickedshell avatar irskep avatar luntik2012 avatar matkuki avatar hauzer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.