Skip to content

Instantly share code, notes, and snippets.

@taesiri
Last active August 29, 2015 13:57
Show Gist options
  • Save taesiri/9564366 to your computer and use it in GitHub Desktop.
Save taesiri/9564366 to your computer and use it in GitHub Desktop.
OpenGL with D - Mac Os X
Installing dub using brew
$ brew install dub
Create project using dub
$ dub init hello_opengl
After compiling glfw, put a local copy of libglfw.dylib (glfw/build/src/libglfw.dylib) in hello_opengl directory
import std.stdio;
import derelict.opengl3.gl3;
import derelict.glfw3.glfw3;
void main(string[] args)
{
DerelictGL3.load();
DerelictGLFW3.load();
if (!glfwInit()) throw new Exception("Failed to initialize GLFW");
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello DerelictGLFW3", null, null);
if (!window) throw new Exception("Window failed to create");
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
}
glfwTerminate();
}
git clone https://github.com/glfw/glfw
cd glfw
mkdir build
cd build
export MACOSX_DEPLOYMENT_TARGET=10.9
cmake -D GLFW_NATIVE_API=1 -D CMAKE_OSX_ARCHITECTURES="i386;x86_64" -D BUILD_SHARED_LIBS=ON -D CMAKE_C_COMPILER=clang ../
make
dub.json
{
"name": "hello_opengl",
"description": "A minimal D application.",
"copyright": "Copyright © 2014, taesiri",
"authors": ["taesiri"],
"dependencies": {
"derelict-gl3" : "~master",
"derelict-glfw3" : "~master"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment