[GRASS-SVN] r72997 - in grass/trunk: include lib/nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 19 07:18:06 PDT 2018
Author: hcho
Date: 2018-07-19 07:18:06 -0700 (Thu, 19 Jul 2018)
New Revision: 72997
Modified:
grass/trunk/include/nviz.h
grass/trunk/lib/nviz/render.c
Log:
nviz: offscreen rendering for Windows (Fix #2114)
Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h 2018-07-19 03:07:40 UTC (rev 72996)
+++ grass/trunk/include/nviz.h 2018-07-19 14:18:06 UTC (rev 72997)
@@ -134,7 +134,6 @@
#elif defined(OPENGL_WINDOWS)
HDC displayId; /* display context */
HGLRC contextId; /* rendering context */
- HBITMAP bitmapId;
#endif
int width, height;
};
Modified: grass/trunk/lib/nviz/render.c
===================================================================
--- grass/trunk/lib/nviz/render.c 2018-07-19 03:07:40 UTC (rev 72996)
+++ grass/trunk/lib/nviz/render.c 2018-07-19 14:18:06 UTC (rev 72997)
@@ -50,7 +50,6 @@
#elif defined(OPENGL_WINDOWS)
rwin->displayId = NULL;
rwin->contextId = NULL;
- rwin->bitmapId = NULL;
#endif
rwin->width = 0;
@@ -77,7 +76,6 @@
#elif defined(OPENGL_WINDOWS)
wglDeleteContext(rwin->contextId);
DeleteDC(rwin->displayId);
- DeleteObject(rwin->bitmapId);
#endif
G_free((void *)rwin);
@@ -147,12 +145,14 @@
/* create an off-screen AGL rendering area */
aglCreatePBuffer(width, height, GL_TEXTURE_2D, GL_RGBA, 0, &(rwin->windowId));
#elif defined(OPENGL_WINDOWS)
+ WNDCLASS wc = {0};
+ HWND hWnd;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, /* version number */
PFD_DRAW_TO_WINDOW | /* support window */
- PFD_SUPPORT_OPENGL | /* support OpenGL */
- PFD_DOUBLEBUFFER, /* double buffered */
+ PFD_SUPPORT_OPENGL | /* support OpenGL */
+ PFD_DOUBLEBUFFER, /* double buffered */
PFD_TYPE_RGBA, /* RGBA type */
24, /* 24-bit color depth */
0, 0, 0, 0, 0, 0, /* color bits ignored */
@@ -169,13 +169,27 @@
};
int iPixelFormat;
- rwin->displayId = CreateCompatibleDC(NULL);
+ wc.lpfnWndProc = DefWindowProc;
+ wc.lpszClassName = "nviz";
+
+ if (!RegisterClass(&wc)) {
+ G_warning(_("Unable to register window class"));
+ return -1;
+ }
+
+ hWnd = CreateWindow(wc.lpszClassName, wc.lpszClassName, WS_POPUP,
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, wc.hInstance, NULL);
+
+ if (!hWnd) {
+ G_warning(_("Unable to create window"));
+ return -1;
+ }
+
+ rwin->displayId = GetDC(hWnd);
iPixelFormat = ChoosePixelFormat(rwin->displayId, &pfd);
SetPixelFormat(rwin->displayId, iPixelFormat, &pfd);
- rwin->bitmapId = CreateCompatibleBitmap(rwin->displayId, width, height);
- SelectObject(rwin->displayId, rwin->bitmapId);
rwin->contextId = wglCreateContext(rwin->displayId);
- /* TODO */
#endif
rwin->width = width;
More information about the grass-commit
mailing list