Initial wrapper commit
This commit is contained in:
parent
427ce66139
commit
d270e2b9fb
14 changed files with 5188 additions and 23 deletions
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
|
|
@ -5,7 +5,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- name: Checkout repository and submodules
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Cache choosenim
|
- name: Cache choosenim
|
||||||
id: cache-choosenim
|
id: cache-choosenim
|
||||||
|
|
@ -23,4 +26,12 @@ jobs:
|
||||||
|
|
||||||
- uses: jiro4989/setup-nim-action@v1
|
- uses: jiro4989/setup-nim-action@v1
|
||||||
|
|
||||||
- run: nimble test -y
|
- uses: openrndr/setup-opengl@v1.1
|
||||||
|
|
||||||
|
- name: Install GUI
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y build-essential libalut-dev libasound2-dev libc6-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev mesa-utils pkg-config xorg-dev xvfb libllvm6.0
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
xvfb-run -a nimble test -y
|
||||||
|
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -9,3 +9,6 @@ nimcache
|
||||||
*.pdb
|
*.pdb
|
||||||
*.ilk
|
*.ilk
|
||||||
.*
|
.*
|
||||||
|
|
||||||
|
*.out
|
||||||
|
.DS_Store
|
||||||
|
|
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "src/glfw"]
|
||||||
|
path = src/glfw
|
||||||
|
url = https://github.com/glfw/glfw
|
||||||
11
README.md
11
README.md
|
|
@ -1,7 +1,6 @@
|
||||||
# You can use this nim template to jump start your nim library or project.
|
# Nim wrapper for static glfw
|
||||||
|
|
||||||
This template includes:
|
|
||||||
* MIT licence
|
Another wrapper for glfw. Creates a static binary based on the C code in `src/glfw`.
|
||||||
* src directory and a private common.nim
|
|
||||||
* test directory
|
See example in the example directory for usage.
|
||||||
* GitHub Actions to run the tests on GitHub
|
|
||||||
|
|
|
||||||
41
examples/draganddrop.nim
Normal file
41
examples/draganddrop.nim
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
import staticglfw
|
||||||
|
import opengl
|
||||||
|
|
||||||
|
# Init GLFW
|
||||||
|
if init() == 0:
|
||||||
|
raise newException(Exception, "Failed to Initialize GLFW")
|
||||||
|
|
||||||
|
# Open window.
|
||||||
|
var window = createWindow(800, 600, "GLFW3 WINDOW", nil, nil)
|
||||||
|
# Connect the GL context.
|
||||||
|
window.makeContextCurrent()
|
||||||
|
# This must be called to make any GL function work
|
||||||
|
loadExtensions()
|
||||||
|
|
||||||
|
proc dropCallback(window: Window, count: cint, paths: cstringArray) {.cdecl.} =
|
||||||
|
echo "dropCallback"
|
||||||
|
for i in 0 ..< count:
|
||||||
|
echo paths[i]
|
||||||
|
|
||||||
|
window.setDropCallback(dropCallback)
|
||||||
|
|
||||||
|
# Run while window is open.
|
||||||
|
while windowShouldClose(window) == 0:
|
||||||
|
|
||||||
|
# Draw red color screen.
|
||||||
|
glClearColor(1, 0, 0, 1)
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT)
|
||||||
|
|
||||||
|
# Swap buffers (this will display the red color)
|
||||||
|
window.swapBuffers()
|
||||||
|
|
||||||
|
# Check for events.
|
||||||
|
pollEvents()
|
||||||
|
# If you get ESC key quit.
|
||||||
|
if window.getKey(KEY_ESCAPE) == 1:
|
||||||
|
window.setWindowShouldClose(1)
|
||||||
|
|
||||||
|
# Destroy the window.
|
||||||
|
window.destroyWindow()
|
||||||
|
# Exit GLFW.
|
||||||
|
terminate()
|
||||||
|
|
@ -1 +1,44 @@
|
||||||
## Include an example on how to use your library
|
import staticglfw
|
||||||
|
import opengl
|
||||||
|
|
||||||
|
# Init GLFW
|
||||||
|
if init() == 0:
|
||||||
|
raise newException(Exception, "Failed to Initialize GLFW")
|
||||||
|
|
||||||
|
# Open window.
|
||||||
|
var window = createWindow(800, 600, "GLFW3 WINDOW", nil, nil)
|
||||||
|
# Connect the GL context.
|
||||||
|
window.makeContextCurrent()
|
||||||
|
# This must be called to make any GL function work
|
||||||
|
loadExtensions()
|
||||||
|
|
||||||
|
let monitor = getPrimaryMonitor()
|
||||||
|
|
||||||
|
var count: cint
|
||||||
|
let vids = monitor.getVideoModes(count.addr)
|
||||||
|
echo count
|
||||||
|
for i in 0..<count:
|
||||||
|
echo vids[i]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Run while window is open.
|
||||||
|
while windowShouldClose(window) == 0:
|
||||||
|
|
||||||
|
# Draw red color screen.
|
||||||
|
glClearColor(1, 0, 0, 1)
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT)
|
||||||
|
|
||||||
|
# Swap buffers (this will display the red color)
|
||||||
|
window.swapBuffers()
|
||||||
|
|
||||||
|
# Check for events.
|
||||||
|
pollEvents()
|
||||||
|
# If you get ESC key quit.
|
||||||
|
if window.getKey(KEY_ESCAPE) == 1:
|
||||||
|
window.setWindowShouldClose(1)
|
||||||
|
|
||||||
|
# Destroy the window.
|
||||||
|
window.destroyWindow()
|
||||||
|
# Exit GLFW.
|
||||||
|
terminate()
|
||||||
|
|
|
||||||
2
examples/nim.cfg
Normal file
2
examples/nim.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
--path:"../src/"
|
||||||
|
--passL:"-lm -pthread -lpthread"
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
version = "0.0.0"
|
|
||||||
author = "Your name"
|
|
||||||
description = "Description of your library"
|
|
||||||
license = "MIT"
|
|
||||||
|
|
||||||
srcDir = "src"
|
|
||||||
|
|
||||||
requires "nim >= 1.2.2"
|
|
||||||
1
src/glfw
Submodule
1
src/glfw
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 114776a24605418e6d719d2f30141e351e93c6e0
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
## Public interface to you library.
|
|
||||||
|
|
||||||
import nimtemplate/common
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
## Add private variables or functions here that you don't want to export.
|
|
||||||
5043
src/staticglfw.nim
Normal file
5043
src/staticglfw.nim
Normal file
File diff suppressed because it is too large
Load diff
8
staticglfw.nimble
Normal file
8
staticglfw.nimble
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Joey Yakimowich-Payne"
|
||||||
|
description = "Complete static wrapper around glfw"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
srcDir = "src"
|
||||||
|
|
||||||
|
requires "nim >= 1.4.0"
|
||||||
|
|
@ -1,3 +1,26 @@
|
||||||
## Put your tests here.
|
import staticglfw
|
||||||
|
|
||||||
import nimtemplate
|
# Init GLFW
|
||||||
|
if init() == 0:
|
||||||
|
var desc: cstring
|
||||||
|
getError(desc.addr)
|
||||||
|
raise newException(Exception, "Failed to Initialize GLFW: " & $desc)
|
||||||
|
|
||||||
|
# Open window.
|
||||||
|
var window = createWindow(800, 600, "GLFW3 WINDOW", nil, nil)
|
||||||
|
# Connect the GL context.
|
||||||
|
window.makeContextCurrent()
|
||||||
|
|
||||||
|
# Swap buffers (this will display the red color)
|
||||||
|
window.swapBuffers()
|
||||||
|
|
||||||
|
# Check for events.
|
||||||
|
pollEvents()
|
||||||
|
# If you get ESC key quit.
|
||||||
|
if window.getKey(KEY_ESCAPE) == 1:
|
||||||
|
window.setWindowShouldClose(1)
|
||||||
|
|
||||||
|
# Destroy the window.
|
||||||
|
window.destroyWindow()
|
||||||
|
# Exit GLFW.
|
||||||
|
terminate()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue