Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnnovak/nim-glfw
GLFW 3 wrapper for Nim
https://github.com/johnnovak/nim-glfw
glfw graphics nim opengl wrapper
Last synced: 3 months ago
JSON representation
GLFW 3 wrapper for Nim
- Host: GitHub
- URL: https://github.com/johnnovak/nim-glfw
- Owner: johnnovak
- License: mit
- Created: 2020-10-24T03:04:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-17T00:40:10.000Z (5 months ago)
- Last Synced: 2024-10-31T22:50:18.677Z (3 months ago)
- Topics: glfw, graphics, nim, opengl, wrapper
- Language: C
- Homepage:
- Size: 2.46 MB
- Stars: 39
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nim-glfw
**nim-glfw** provides a nice idiomatic Nim API to [GLFW](https://www.glfw.org/),
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](https://github.com/stavenko/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](/examples) directory:
~~~
nim c -r -d:glfwStaticLib
~~~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](/examples/minimal.nim) to display a window for one second
and then terminate:```nim
import std/os
import glfwproc 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](/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](https://github.com/ephja): Original author and maintainer until v3.2.
[johnnovak](http://github.com/johnnovak): Current maintainer and ports of some
of the [official GLFW examples](https://github.com/glfw/glfw/tree/master/examples).[def-](http://github.com/def-): Support for static linking.
[AntonioArtigas](https://github.com/AntonioArtigas): GLFW 3.3 update.