generated from treeform/nimtemplate
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
791 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
name: Run tests | ||
name: Github Actions | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Cache choosenim | ||
id: cache-choosenim | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.choosenim | ||
key: ${{ runner.os }}-choosenim-stable | ||
|
||
- name: Cache nimble | ||
id: cache-nimble | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.nimble | ||
key: ${{ runner.os }}-nimble-stable | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jiro4989/setup-nim-action@v1 | ||
|
||
- run: nimble test -y | ||
- run: nimble test --gc:orc -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ nimcache | |
*.pdb | ||
*.ilk | ||
.* | ||
*.dll | ||
__pycache__ | ||
bindings/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
# You can use this nim template to jump start your nim library or project. | ||
# Windy | ||
|
||
This template includes: | ||
* MIT licence | ||
* src directory and a private common.nim | ||
* test directory | ||
* GitHub Actions to run the tests on GitHub | ||
This library is still in development and is not ready to be used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import genny, windy | ||
|
||
var lastError: ref WindyError | ||
|
||
proc takeError(): string = | ||
result = lastError.msg | ||
lastError = nil | ||
|
||
proc checkError(): bool = | ||
result = lastError != nil | ||
|
||
proc isVisible(window: Window): bool = | ||
window.visible | ||
|
||
proc show(window: Window) = | ||
window.visible = true | ||
|
||
proc hide(window: Window) = | ||
window.visible = false | ||
|
||
exportProcs: | ||
checkError | ||
takeError | ||
|
||
exportRefObject App: | ||
discard | ||
|
||
exportRefObject Window: | ||
constructor: | ||
newWindow | ||
procs: | ||
show | ||
hide | ||
isVisible | ||
makeContextCurrent | ||
swapBuffers | ||
|
||
exportProcs: | ||
getApp | ||
init | ||
|
||
writeFiles("bindings/generated", "Windy") | ||
|
||
include generated/internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import boxy, opengl, windy | ||
|
||
let app = getApp() | ||
app.init() | ||
|
||
let | ||
windowSize = ivec2(1280, 800) | ||
window = app.newWindow("Windy + Boxy", windowSize.x, windowSize.y) | ||
|
||
window.makeContextCurrent() | ||
loadExtensions() | ||
|
||
window.visible = true | ||
|
||
echo "GL_VERSION: ", cast[cstring](glGetString(GL_VERSION)) | ||
echo "GL_VENDOR: ", cast[cstring](glGetString(GL_VENDOR)) | ||
echo "GL_RENDERER: ", cast[cstring](glGetString(GL_RENDERER)) | ||
echo "GL_SHADING_LANGUAGE_VERSION: ", cast[cstring](glGetString(GL_SHADING_LANGUAGE_VERSION)) | ||
|
||
let bxy = newBoxy() | ||
|
||
proc display() = | ||
bxy.beginFrame(windowSize) | ||
bxy.drawRect(rect(vec2(0, 0), windowSize.vec2), color(1, 1, 1, 1)) | ||
bxy.drawRect(rect(vec2(100, 100), vec2(200, 200)), color(1, 0, 1, 1)) | ||
bxy.endFrame() | ||
window.swapBuffers() | ||
|
||
while true: | ||
# pollEvents() | ||
display() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import windy/common | ||
|
||
export common | ||
|
||
when defined(windows): | ||
import windy/platforms/win32/platform | ||
|
||
type | ||
App* = ref object | ||
platform: PlatformApp | ||
|
||
Window* = ref object | ||
platform: PlatformWindow | ||
|
||
let app = App() | ||
|
||
proc getApp*(): App = | ||
app | ||
|
||
proc init*(app: App) {.raises: [WindyError]} = | ||
if app.platform != nil: | ||
raise newException(WindyError, "Windy is already initialized") | ||
app.platform = newPlatformApp() | ||
|
||
proc newWindow*( | ||
app: App, windowTitle: string, width, height: int | ||
): Window {.raises: [WindyError]} = | ||
result = Window() | ||
result.platform = app.platform.newWindow(windowTitle, width, height) | ||
|
||
proc makeContextCurrent*(window: Window) {.raises: [WindyError]} = | ||
window.platform.makeContextCurrent() | ||
|
||
proc swapBuffers*(window: Window) {.raises: [WindyError]} = | ||
window.platform.swapBuffers() | ||
|
||
proc `visible`*(window: Window): bool = | ||
discard | ||
|
||
proc `visible=`*(window: Window, visible: bool) = | ||
if visible: | ||
window.platform.show() | ||
else: | ||
window.platform.hide() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type WindyError* = object of ValueError |
Oops, something went wrong.