Skip to content

Commit

Permalink
Merge pull request #93 from ljubobratovicrelja/mac-fix
Browse files Browse the repository at this point in the history
dcv:plot fix with high res displays
  • Loading branch information
ljubobratovicrelja authored Dec 12, 2016
2 parents abdc9b8 + e7c7e0f commit f373c88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

"targetType": "library",

"sourcePaths": ["scripts"],
"sourceFiles": ["source/dcv/package.d"],

"buildTypes": {
"unittest-release": {
"buildOptions": ["unittests", "releaseMode", "optimize", "inline"]
Expand Down Expand Up @@ -83,7 +86,9 @@
"versions": ["ggplotd"]
}
],
"libs": ["gl", "glfw"]
"libs": ["glfw"],
"libs-linux": ["gl"],
"lflags-osx": ["-framework", "OpenGL"]
}
]
}
1 change: 1 addition & 0 deletions source/dcv/plot/bindings/glfw.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions source/dcv/plot/figure.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f373c88

Please sign in to comment.