Created
April 18, 2013 08:14
-
-
Save nlguillemot/5411073 to your computer and use it in GitHub Desktop.
GLFWcursorposfun test
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
import std.stdio; | |
import derelict.opengl3.gl3; | |
import derelict.glfw3.glfw3; | |
static bool playing = true; | |
extern (C) void keyCallback(GLFWwindow* w, int key, int action) | |
{ | |
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { | |
playing = false; | |
} | |
} | |
extern (C) void mouseButtonCallback(GLFWwindow* w, int button, int action) { | |
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { | |
writeln("Left clicked."); | |
} | |
} | |
extern (C) void cursorPosCallback(GLFWwindow* w, double x, double y) { | |
writefln("Cursor now at (%s,%s)", x, y); | |
} | |
void main(){ | |
DerelictGL3.load(); | |
DerelictGLFW3.load(); | |
glfwInit(); | |
GLFWwindow* window = glfwCreateWindow(640,480,"Hello, World!",null,null); | |
glfwSetKeyCallback(window, &keyCallback); | |
glfwSetMouseButtonCallback(window, &mouseButtonCallback); | |
glfwSetCursorPosCallback(window, &cursorPosCallback); | |
while (playing) { | |
glfwPollEvents(); | |
glClear(GL_COLOR_BUFFER_BIT); | |
glfwSwapBuffers(window); | |
} | |
glfwDestroyWindow(window); | |
glfwTerminate(); | |
} |
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
all: | |
dmd main.d -L-lDerelictGL3 -L-lDerelictGLFW3 -L-lDerelictUtil -L-ldl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment