Skip to content

Commit f373c88

Browse files
Merge pull request #93 from ljubobratovicrelja/mac-fix
dcv:plot fix with high res displays
2 parents abdc9b8 + e7c7e0f commit f373c88

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

dub.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
"targetType": "library",
1515

16+
"sourcePaths": ["scripts"],
17+
"sourceFiles": ["source/dcv/package.d"],
18+
1619
"buildTypes": {
1720
"unittest-release": {
1821
"buildOptions": ["unittests", "releaseMode", "optimize", "inline"]
@@ -83,7 +86,9 @@
8386
"versions": ["ggplotd"]
8487
}
8588
],
86-
"libs": ["gl", "glfw"]
89+
"libs": ["glfw"],
90+
"libs-linux": ["gl"],
91+
"lflags-osx": ["-framework", "OpenGL"]
8792
}
8893
]
8994
}

source/dcv/plot/bindings/glfw.d

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ extern (C)
279279
void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
280280
void glfwSetWindowSize(GLFWwindow* window, int width, int height);
281281
void glfwWindowHint(int target, int hint);
282+
void glfwGetFramebufferSize (GLFWwindow * window, int *width, int *height);
282283

283284
GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
284285
GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);

source/dcv/plot/figure.d

+7-2
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,21 @@ class Figure
651651
{
652652
glfwMakeContextCurrent(_glfwWindow);
653653

654+
int fBufWidth, fBufHeight;
655+
glfwGetFramebufferSize(_glfwWindow, &fBufWidth, &fBufHeight);
656+
654657
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
655658
glDisable(GL_DEPTH_TEST);
656659

657-
glViewport(0, 0, width, height);
660+
glViewport(0, 0, fBufWidth, fBufHeight);
658661

659662
glMatrixMode(GL_PROJECTION);
660663
glLoadIdentity();
661664

662665
glOrtho(0, width, 0, height, 0.1, 1);
663-
glPixelZoom(1, -1);
666+
667+
glPixelZoom(fBufWidth / width, -fBufHeight / height);
668+
664669
glRasterPos3f(0, height - 1, -0.3);
665670

666671
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

0 commit comments

Comments
 (0)