diff --git a/dub.json b/dub.json index 08956f4..85315f5 100644 --- a/dub.json +++ b/dub.json @@ -13,6 +13,9 @@ "targetType": "library", + "sourcePaths": ["scripts"], + "sourceFiles": ["source/dcv/package.d"], + "buildTypes": { "unittest-release": { "buildOptions": ["unittests", "releaseMode", "optimize", "inline"] @@ -83,7 +86,9 @@ "versions": ["ggplotd"] } ], - "libs": ["gl", "glfw"] + "libs": ["glfw"], + "libs-linux": ["gl"], + "lflags-osx": ["-framework", "OpenGL"] } ] } diff --git a/source/dcv/plot/bindings/glfw.d b/source/dcv/plot/bindings/glfw.d index d6b5a4b..f15abe5 100644 --- a/source/dcv/plot/bindings/glfw.d +++ b/source/dcv/plot/bindings/glfw.d @@ -279,6 +279,7 @@ extern (C) void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); void glfwSetWindowSize(GLFWwindow* window, int width, int height); void glfwWindowHint(int target, int hint); + void glfwGetFramebufferSize (GLFWwindow * window, int *width, int *height); GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun); diff --git a/source/dcv/plot/figure.d b/source/dcv/plot/figure.d index eec1ecd..15c77fa 100644 --- a/source/dcv/plot/figure.d +++ b/source/dcv/plot/figure.d @@ -651,16 +651,21 @@ class Figure { glfwMakeContextCurrent(_glfwWindow); + int fBufWidth, fBufHeight; + glfwGetFramebufferSize(_glfwWindow, &fBufWidth, &fBufHeight); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_DEPTH_TEST); - glViewport(0, 0, width, height); + glViewport(0, 0, fBufWidth, fBufHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width, 0, height, 0.1, 1); - glPixelZoom(1, -1); + + glPixelZoom(fBufWidth / width, -fBufHeight / height); + glRasterPos3f(0, height - 1, -0.3); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);