From 3e4fda5bd527f00063c9ce3170cff2918582c7f5 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 29 May 2011 19:26:37 -0700 Subject: [PATCH] okay, so maybe OpenGL was a bad choice for the C++-themed repo... --- opengl/Makefile | 19 ---------- opengl/src/demo.c | 92 ----------------------------------------------- 2 files changed, 111 deletions(-) delete mode 100644 opengl/Makefile delete mode 100644 opengl/src/demo.c diff --git a/opengl/Makefile b/opengl/Makefile deleted file mode 100644 index e9705f8..0000000 --- a/opengl/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CPPC := g++ -BINDIR := $(PWD)/bin - -ALL_TARGETS = $(BINDIR)/demo - - -all: $(ALL_TARGETS) - - -clean: - rm -vf ./bin/* - - -$(BINDIR)/demo: - cd src && \ - gcc -o $(BINDIR)/demo demo.c -lX11 -lGL -lGLU - - -.PHONY: all clean diff --git a/opengl/src/demo.c b/opengl/src/demo.c deleted file mode 100644 index ff72857..0000000 --- a/opengl/src/demo.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -Display *dpy; -Window root; -GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; -XVisualInfo *vi; -Colormap cmap; -XSetWindowAttributes swa; -Window win; -GLXContext glc; -XWindowAttributes gwa; -XEvent xev; - - -void DrawAQuad() { - glClearColor(1.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1., 1., -1., 1., 1., 20.); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.); - - glBegin(GL_QUADS); - glColor3f(1., 0., 0.); glVertex3f(-.75, -.75, 0.); - glColor3f(0., 1., 0.); glVertex3f( .75, -.75, 0.); - glColor3f(0., 0., 1.); glVertex3f( .75, .75, 0.); - glColor3f(1., 1., 0.); glVertex3f(-.75, .75, 0.); - glEnd(); -} - -int main(int argc, char *argv[]) { - - dpy = XOpenDisplay(NULL); - - if(dpy == NULL) { - printf("\n\tcannot connect to X server\n\n"); - exit(0); - } - - root = DefaultRootWindow(dpy); - - vi = glXChooseVisual(dpy, 0, att); - - if(vi == NULL) { - printf("\n\tno appropriate visual found\n\n"); - exit(0); } - else { - printf("\n\tvisual %p selected\n", (void *)vi->visualid); } /* %p creates hexadecimal output like in glxinfo */ - - cmap = XCreateColormap(dpy, root, vi->visual, AllocNone); - - swa.colormap = cmap; - swa.event_mask = ExposureMask | KeyPressMask; - - win = XCreateWindow(dpy, root, 0, 0, 600, 600, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa); - - XMapWindow(dpy, win); - - XStoreName(dpy, win, "VERY SIMPLE APPLICATION"); - - glc = glXCreateContext(dpy, vi, NULL, GL_TRUE); - glXMakeCurrent(dpy, win, glc); - - glEnable(GL_DEPTH_TEST); - - while(1) { - XNextEvent(dpy, &xev); - - if(xev.type == Expose) { - XGetWindowAttributes(dpy, win, &gwa); - glViewport(0, 0, gwa.width, gwa.height); - DrawAQuad(); - glXSwapBuffers(dpy, win); } - - else if(xev.type == KeyPress) { - glXMakeCurrent(dpy, None, NULL); - glXDestroyContext(dpy, glc); - XDestroyWindow(dpy, win); - XCloseDisplay(dpy); - exit(0); } - } /* this closes while(1) { */ -} /* this is the } which closes int main(int argc, char *argv[]) { */