Archive for May, 2010

This ISA test post from my iPad

May 28, 2010

This is just a test post to try the WordPress app on my iPad.

Minimal OpenGL Program on RedHat EL 4.0

May 12, 2010

Here is a minimal OpenGL program on RedHat EL 4.0. The Makefile:

all:
	gcc -L/usr/X11R6/lib -L/usr/X11R6/lib/modules/extensions exampleGlx.c -o dssglx -lX11 -lglx -lGL

And the program:

#include 
#include  
#include 
#include 

static  int  attributeListSgl[]  = {      GLX_RGBA,      GLX_RED_SIZE, 1,      GLX_GREEN_SIZE, 1,      GLX_BLUE_SIZE,  1,      None }; 
static  int  attributeListDbl[]  =  {        GLX_RGBA,        GLX_DOUBLEBUFFER,         GLX_RED_SIZE,      1,         GLX_GREEN_SIZE,   1, GLX_BLUE_SIZE,  1,      None };

static Bool WaitForNotify(Display *d, XEvent *e, char *arg) 
{   
    return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
}

int main(int argc, char **argv) 
{
    Display *dpy;
    XVisualInfo *vi;
    Colormap cmap;
    XSetWindowAttributes swa;
    Window win;
    GLXContext cx;
    XEvent event;
    int swap_flag = FALSE;

    dpy = XOpenDisplay(0);

    vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeListSgl);
    if (vi == NULL) 
    { 
        vi  =  glXChooseVisual(dpy,  DefaultScreen(dpy), attributeListDbl);
        swap_flag = TRUE;
    }
    cx = glXCreateContext(dpy, vi, 0, GL_TRUE);

    cmap   =   XCreateColormap(dpy,    RootWindow(dpy,    vi->screen), vi->visual, AllocNone);
    swa.colormap = cmap;
    swa.border_pixel = 0;
    swa.event_mask = StructureNotifyMask;
    win  =  XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 100, 100,
                        0, vi->depth, InputOutput, vi->visual,
                        CWBorderPixel|CWColormap|CWEventMask, &swa);
    XMapWindow(dpy, win);
    XIfEvent(dpy, &event, WaitForNotify, (char*)win);

    glXMakeCurrent(dpy, win, cx);
    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
    if (swap_flag) glXSwapBuffers(dpy,win);
    sleep(10);
}


Advertisement