Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boomer.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "MIT"
srcDir = "src"
bin = @["boomer"]

requires "nim >= 0.18.0", "x11 >= 1.1", "opengl >= 1.2.3"
requires "nim >= 0.18.0", "x11 >= 1.1"
1 change: 1 addition & 0 deletions src/nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--path:"../vendor/opengl/src"
1 change: 1 addition & 0 deletions vendor/opengl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nimcache/
21 changes: 21 additions & 0 deletions vendor/opengl/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions vendor/opengl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# opengl
An OpenGL interface

# Extension loading
``loadExtensions()`` must be executed after the creation of a rendering context and before any OpenGL extension procs are used.

# Automatic error checking
The OpenGL procs do perform automatic error checking by default. This can be disabled at compile-time by defining the conditional symbol ``noAutoGLerrorCheck`` (-d:noAutoGLerrorCheck), in which case the error checking code will be omitted from the binary; or at run-time by executing this statement: ``enableAutoGLerrorCheck(false)``.

# Building with x11 (linux)
When receiving the following error:
```
<path-to-opengl>/opengl/private/prelude.nim(5, 10) Error: cannot open file: X
```
Version 1.2.0 is broken for Linux builds, as x11 is imported incorrectly - use 1.2.2 or greater!
110 changes: 110 additions & 0 deletions vendor/opengl/examples/glut_example.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# OpenGL example using glut
# On windows: Requires glut32.dll or freeglut.dll
import opengl/glut
import opengl
import opengl/glu

proc display() {.cdecl.} =
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) # Clear color and depth buffers
glMatrixMode(GL_MODELVIEW) # To operate on model-view matrix
glLoadIdentity() # Reset the model-view matrix
glTranslatef(1.5, 0.0, -7.0) # Move right and into the screen

# Render a cube consisting of 6 quads
# Each quad consists of 2 triangles
# Each triangle consists of 3 vertices

glBegin(GL_TRIANGLES) # Begin drawing of triangles

# Top face (y = 1.0f)
glColor3f(0.0, 1.0, 0.0) # Green
glVertex3f( 1.0, 1.0, -1.0)
glVertex3f(-1.0, 1.0, -1.0)
glVertex3f(-1.0, 1.0, 1.0)
glVertex3f( 1.0, 1.0, 1.0)
glVertex3f( 1.0, 1.0, -1.0)
glVertex3f(-1.0, 1.0, 1.0)

# Bottom face (y = -1.0f)
glColor3f(1.0, 0.5, 0.0) # Orange
glVertex3f( 1.0, -1.0, 1.0)
glVertex3f(-1.0, -1.0, 1.0)
glVertex3f(-1.0, -1.0, -1.0)
glVertex3f( 1.0, -1.0, -1.0)
glVertex3f( 1.0, -1.0, 1.0)
glVertex3f(-1.0, -1.0, -1.0)

# Front face (z = 1.0f)
glColor3f(1.0, 0.0, 0.0) # Red
glVertex3f( 1.0, 1.0, 1.0)
glVertex3f(-1.0, 1.0, 1.0)
glVertex3f(-1.0, -1.0, 1.0)
glVertex3f( 1.0, -1.0, 1.0)
glVertex3f( 1.0, 1.0, 1.0)
glVertex3f(-1.0, -1.0, 1.0)

# Back face (z = -1.0f)
glColor3f(1.0, 1.0, 0.0) # Yellow
glVertex3f( 1.0, -1.0, -1.0)
glVertex3f(-1.0, -1.0, -1.0)
glVertex3f(-1.0, 1.0, -1.0)
glVertex3f( 1.0, 1.0, -1.0)
glVertex3f( 1.0, -1.0, -1.0)
glVertex3f(-1.0, 1.0, -1.0)

# Left face (x = -1.0f)
glColor3f(0.0, 0.0, 1.0) # Blue
glVertex3f(-1.0, 1.0, 1.0)
glVertex3f(-1.0, 1.0, -1.0)
glVertex3f(-1.0, -1.0, -1.0)
glVertex3f(-1.0, -1.0, 1.0)
glVertex3f(-1.0, 1.0, 1.0)
glVertex3f(-1.0, -1.0, -1.0)

# Right face (x = 1.0f)
glColor3f(1.0, 0.0, 1.0) # Magenta
glVertex3f(1.0, 1.0, -1.0)
glVertex3f(1.0, 1.0, 1.0)
glVertex3f(1.0, -1.0, 1.0)
glVertex3f(1.0, -1.0, -1.0)
glVertex3f(1.0, 1.0, -1.0)
glVertex3f(1.0, -1.0, 1.0)

glEnd() # End of drawing

glutSwapBuffers() # Swap the front and back frame buffers (double buffering)

proc reshape(width: GLsizei, height: GLsizei) {.cdecl.} =
# Compute aspect ratio of the new window
if height == 0:
return # To prevent divide by 0

# Set the viewport to cover the new window
glViewport(0, 0, width, height)

# Set the aspect ratio of the clipping volume to match the viewport
glMatrixMode(GL_PROJECTION) # To operate on the Projection matrix
glLoadIdentity() # Reset
# Enable perspective projection with fovy, aspect, zNear and zFar
gluPerspective(45.0, width / height, 0.1, 100.0)

var argc: cint = 0
glutInit(addr argc, nil)
glutInitDisplayMode(GLUT_DOUBLE)
glutInitWindowSize(640, 480)
glutInitWindowPosition(50, 50)
discard glutCreateWindow("OpenGL Example")

glutDisplayFunc(display)
glutReshapeFunc(reshape)

loadExtensions()

glClearColor(0.0, 0.0, 0.0, 1.0) # Set background color to black and opaque
glClearDepth(1.0) # Set background depth to farthest
glEnable(GL_DEPTH_TEST) # Enable depth testing for z-culling
glDepthFunc(GL_LEQUAL) # Set the type of depth-test
glShadeModel(GL_SMOOTH) # Enable smooth shading
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # Nice perspective corrections

glutMainLoop()
1 change: 1 addition & 0 deletions vendor/opengl/examples/nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--path:"../src"
13 changes: 13 additions & 0 deletions vendor/opengl/opengl.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Package

version = "1.2.9"
author = "Andreas Rumpf"
description = "an OpenGL wrapper"
license = "MIT"

srcDir = "src"

# Dependencies

requires "nim >= 0.11.0"
requires "x11 >= 1.1"
19 changes: 19 additions & 0 deletions vendor/opengl/src/opengl.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
#
# Nim's Runtime Library
# (c) Copyright 2012-2017 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#

## This module is a wrapper around `opengl`:idx:. If you define the symbol
## ``useGlew`` this wrapper does not use Nim's ``dynlib`` mechanism,
## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even
## extension loading for the different operating systems is handled here.
##
## You need to call ``loadExtensions`` after a rendering context has been
## created to load any extension proc that your code uses.

include opengl/private/prelude, opengl/private/types,
opengl/private/errors, opengl/private/procs, opengl/private/constants
Loading