[GRASS-SVN] r32043 - in grass/trunk: include lib/nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 8 05:32:12 EDT 2008
Author: martinl
Date: 2008-07-08 05:32:12 -0400 (Tue, 08 Jul 2008)
New Revision: 32043
Modified:
grass/trunk/include/nviz.h
grass/trunk/lib/nviz/render.c
Log:
nvizlib: conditional references to x11 and aqua added (TODO: wgl)
Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h 2008-07-07 14:24:39 UTC (rev 32042)
+++ grass/trunk/include/nviz.h 2008-07-08 09:32:12 UTC (rev 32043)
@@ -1,9 +1,6 @@
#ifndef GRASS_NVIZ_H
#define GRASS_NVIZ_H
-#include <grass/gsurf.h>
-#include <grass/gstypes.h>
-
/*** Windows headers ***/
#if defined(OPENGL_WINDOWS)
# define WIN32_LEAN_AND_MEAN
@@ -34,6 +31,9 @@
# error Unsupported platform, or confused platform defines...
#endif
+#include <grass/gsurf.h>
+#include <grass/gstypes.h>
+
#define MAP_OBJ_UNDEFINED 0
#define MAP_OBJ_SURF 1
#define MAP_OBJ_VOL 2
@@ -109,10 +109,19 @@
} nv_clientdata;
struct render_window {
+#if defined(OPENGL_X11)
Display *displayId; /* display connection */
GLXContext contextId; /* GLX rendering context */
+ GLXPixmap windowId;
Pixmap pixmap;
- GLXPixmap windowId;
+#elif defined(OPENGL_AQUA)
+ AGLPixelFmtID displayId;
+ AGLContext contextId;
+ AGLPixmap windowId;
+ GWorldPtr pixmap;
+#elif defined(OPENGL_WGL)
+ /* TODO */
+#endif
};
/* change_view.c */
Modified: grass/trunk/lib/nviz/render.c
===================================================================
--- grass/trunk/lib/nviz/render.c 2008-07-07 14:24:39 UTC (rev 32042)
+++ grass/trunk/lib/nviz/render.c 2008-07-08 09:32:12 UTC (rev 32043)
@@ -9,7 +9,7 @@
License (>=v2). Read the file COPYING that comes with GRASS
for details.
- Based on visualization/nviz/src/togl.c etc.
+ Based on visualization/nviz/src/togl.c
\author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
@@ -57,8 +57,17 @@
*/
void Nviz_destroy_render_window(struct render_window *rwin)
{
+#if defined(OPENGL_X11)
glXDestroyContext(rwin->displayId, rwin->contextId);
+ glXDestroyGLXPixmap(rwin->displayId, rwin->windowId);
XFreePixmap(rwin->displayId, rwin->pixmap);
+#elif defined(OPENGL_AQUA)
+ aglDestroyContext(rwin->contextId);
+ aglDestroyAGLPixmap(rwin->windowId);
+ /* TODO FreePixMap */
+#elif defined(OPENGL_WGL)
+ /* TODO: wglDeleteContext( HRC hrc ) */
+#endif
G_free ((void *) rwin);
@@ -78,29 +87,54 @@
int Nviz_create_render_window(struct render_window *rwin, void *display,
int width, int height)
{
+#if defined(OPENGL_X11)
XVisualInfo *v;
+#elif defined(OPENGL_AQUA)
+ AGLPixelFmtID v;
+#elif defined(OPENGL_WGL)
+ int v;
+#endif
int attributeList[] = { GLX_RGBA, GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1, None };
/* get the default display connection */
+#if defined(OPENGL_X11)
rwin->displayId = XOpenDisplay((char *) display);
+#elif defined(OPENGL_AQUA)
+ /* TODO */
+#elif defined(OPENGL_WGL)
+ /* TODO */
+#endif
+
if (!rwin->displayId) {
- G_fatal_error (_("Bad X server connection"));
+ G_fatal_error (_("Bad server connection"));
}
/* get visual info and set up pixmap buffer */
+#if defined(OPENGL_X11)
v = glXChooseVisual(rwin->displayId,
DefaultScreen(rwin->displayId),
attributeList);
rwin->contextId = glXCreateContext(rwin->displayId,
- v, NULL, GL_FALSE);
+ v, NULL, GL_FALSE);
+#elif defined(OPENGL_AQUA)
+ /* TODO */
+ rwin->displayId = aglChoosePixelFmt(GDHandle *dev, int ndev, attributeList);
+
+ rwin->contextId = aglCreateContext(rwin->display, NULL);
+#elif defined(OPENGL_WGL)
+ /* TODO int ChoosePixelFormat( HDC hdc, PIXELFORMATDESCRIPTOR *pfd ) */
+#endif
+
if (!rwin->contextId) {
- G_fatal_error (_("Unable to create GLX rendering context"));
+ G_fatal_error (_("Unable to create rendering context"));
}
+
+#if defined(OPENGL_X11)
/* create win pixmap to render to (same depth as RootWindow) */
rwin->pixmap = XCreatePixmap(rwin->displayId,
RootWindow(rwin->displayId, v->screen),
@@ -111,6 +145,15 @@
/* create an off-screen GLX rendering area */
rwin->windowId = glXCreateGLXPixmap(rwin->displayId,
v, rwin->pixmap);
+#elif defined(OPENGL_AQUA)
+ /* create win pixmap to render to (same depth as RootWindow) */
+ rwin->pixmap = NULL; /* TODO */
+ /* create an off-screen AGL rendering area */
+ rwin->windowId = aglCreateAGLPixmap(rwin->displayId,
+ rwin->pixmap);
+#elif defined(OPENGL_WGL)
+ /* TODO */
+#endif
if (v) {
XFree(v);
@@ -132,13 +175,20 @@
if (!rwin->displayId || !rwin->contextId)
return 0;
+#if defined(OPENGL_X11)
if (rwin->contextId == glXGetCurrentContext())
return 1;
glXMakeCurrent(rwin->displayId, rwin->windowId,
rwin->contextId);
+#elif defined(OPENGL_AQUA)
+ if (rwin->contextId == aglGetCurrentContext())
+ return 1;
- /* TODO: AQUA */
+ aglMakeCurrent(rwin->windowId, rwin->contextId);
+#elif defined(OPENGL_WGL)
+ /* TODO wglMakeCurrent( HDC hdc, HGLRC hrc ) */
+#endif
return 1;
}
More information about the grass-commit
mailing list