Changeset 32043


Ignore:
Timestamp:
Jul 8, 2008, 2:32:12 AM (16 years ago)
Author:
martinl
Message:

nvizlib: conditional references to x11 and aqua added (TODO: wgl)

Location:
grass/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/include/nviz.h

    r32033 r32043  
    11#ifndef GRASS_NVIZ_H
    22#define GRASS_NVIZ_H
    3 
    4 #include <grass/gsurf.h>
    5 #include <grass/gstypes.h>
    63
    74/*** Windows headers ***/
     
    3431#  error Unsupported platform, or confused platform defines...
    3532#endif
     33
     34#include <grass/gsurf.h>
     35#include <grass/gstypes.h>
    3636
    3737#define MAP_OBJ_UNDEFINED 0
     
    110110
    111111struct render_window {
     112#if defined(OPENGL_X11)
    112113    Display *displayId;   /* display connection */
    113114    GLXContext contextId; /* GLX rendering context */
     115    GLXPixmap windowId;
    114116    Pixmap pixmap;
    115     GLXPixmap windowId;
     117#elif defined(OPENGL_AQUA)
     118    AGLPixelFmtID displayId;
     119    AGLContext contextId;
     120    AGLPixmap windowId;
     121    GWorldPtr pixmap;
     122#elif defined(OPENGL_WGL)
     123    /* TODO */
     124#endif
    116125};
    117126
  • grass/trunk/lib/nviz/render.c

    r31945 r32043  
    1010  for details.
    1111
    12   Based on visualization/nviz/src/togl.c etc.
     12  Based on visualization/nviz/src/togl.c
    1313
    1414  \author Updated/modified by Martin Landa <landa.martin gmail.com> (Google SoC 2008)
     
    5858void Nviz_destroy_render_window(struct render_window *rwin)
    5959{
     60#if defined(OPENGL_X11)
    6061    glXDestroyContext(rwin->displayId, rwin->contextId);
     62    glXDestroyGLXPixmap(rwin->displayId, rwin->windowId);
    6163    XFreePixmap(rwin->displayId, rwin->pixmap);
     64#elif defined(OPENGL_AQUA)
     65    aglDestroyContext(rwin->contextId);
     66    aglDestroyAGLPixmap(rwin->windowId);
     67    /* TODO FreePixMap */
     68#elif defined(OPENGL_WGL)
     69    /* TODO: wglDeleteContext( HRC hrc ) */
     70#endif
    6271
    6372    G_free ((void *) rwin);
     
    7988                              int width, int height)
    8089{
     90#if defined(OPENGL_X11)
    8191    XVisualInfo  *v;
     92#elif defined(OPENGL_AQUA)
     93    AGLPixelFmtID v;
     94#elif defined(OPENGL_WGL)
     95    int v;
     96#endif
    8297
    8398    int attributeList[] = { GLX_RGBA, GLX_RED_SIZE, 1,
     
    86101
    87102    /* get the default display connection */
     103#if defined(OPENGL_X11)
    88104    rwin->displayId = XOpenDisplay((char *) display);
     105#elif defined(OPENGL_AQUA)
     106    /* TODO */
     107#elif defined(OPENGL_WGL)
     108    /* TODO */
     109#endif
     110
    89111    if (!rwin->displayId) {
    90         G_fatal_error (_("Bad X server connection"));
     112        G_fatal_error (_("Bad server connection"));
    91113    }
    92114
    93115    /* get visual info and set up pixmap buffer */
     116#if defined(OPENGL_X11)
    94117    v = glXChooseVisual(rwin->displayId,
    95118                        DefaultScreen(rwin->displayId),
     
    97120
    98121    rwin->contextId = glXCreateContext(rwin->displayId,
    99                                       v, NULL, GL_FALSE);
     122                                       v, NULL, GL_FALSE);
     123#elif defined(OPENGL_AQUA)
     124    /* TODO */
     125    rwin->displayId = aglChoosePixelFmt(GDHandle *dev, int ndev, attributeList);
     126   
     127    rwin->contextId = aglCreateContext(rwin->display, NULL);
     128#elif defined(OPENGL_WGL)
     129    /* TODO int ChoosePixelFormat( HDC hdc, PIXELFORMATDESCRIPTOR *pfd ) */
     130#endif
     131
    100132    if (!rwin->contextId) {
    101         G_fatal_error (_("Unable to create GLX rendering context"));
     133        G_fatal_error (_("Unable to create rendering context"));
    102134    }
    103135
     136
     137#if defined(OPENGL_X11)
    104138    /* create win pixmap to render to (same depth as RootWindow) */
    105139    rwin->pixmap = XCreatePixmap(rwin->displayId,
     
    112146    rwin->windowId = glXCreateGLXPixmap(rwin->displayId,
    113147                                        v, rwin->pixmap);
     148#elif defined(OPENGL_AQUA)
     149    /* create win pixmap to render to (same depth as RootWindow) */
     150    rwin->pixmap = NULL; /* TODO */
     151    /* create an off-screen AGL rendering area */
     152    rwin->windowId = aglCreateAGLPixmap(rwin->displayId,
     153                                        rwin->pixmap);
     154#elif defined(OPENGL_WGL)
     155    /* TODO */
     156#endif
    114157
    115158    if (v) {
     
    133176        return 0;
    134177
     178#if defined(OPENGL_X11)
    135179    if (rwin->contextId == glXGetCurrentContext())
    136180        return 1;
     
    138182    glXMakeCurrent(rwin->displayId, rwin->windowId,
    139183                   rwin->contextId);
     184#elif defined(OPENGL_AQUA)
     185    if (rwin->contextId == aglGetCurrentContext())
     186        return 1;
    140187
    141     /* TODO: AQUA */
     188    aglMakeCurrent(rwin->windowId, rwin->contextId);
     189#elif defined(OPENGL_WGL)
     190    /* TODO wglMakeCurrent( HDC hdc, HGLRC hrc ) */
     191#endif
    142192
    143193    return 1;
Note: See TracChangeset for help on using the changeset viewer.