summaryrefslogtreecommitdiff
path: root/src/graphics_opengl.c
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-01-03 00:30:28 -0600
committerepoch <epoch@hacking.allowed.org>2017-01-03 00:30:28 -0600
commitebde46bc82bebf478db67abef5b7dc88c014706b (patch)
tree77121f0c18b1845b8c3cfdfec962e9c5b2ec7e67 /src/graphics_opengl.c
parentf7353ec277198b295c6c842a4a4a07b403b2a572 (diff)
downloadhackvr-ebde46bc82bebf478db67abef5b7dc88c014706b.tar.gz
hackvr-ebde46bc82bebf478db67abef5b7dc88c014706b.zip
lots and lots of shit. opengl shit is barely worked on. new pl script to obj2hackvr using more than just triangles.http://hackaday.com/blog/http://hackaday.com/blog/
Diffstat (limited to 'src/graphics_opengl.c')
-rw-r--r--src/graphics_opengl.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/graphics_opengl.c b/src/graphics_opengl.c
new file mode 100644
index 0000000..9e200de
--- /dev/null
+++ b/src/graphics_opengl.c
@@ -0,0 +1,96 @@
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <GL/glut.h>
+
+GLenum doubleBuffer;
+GLubyte ubImage[65536];
+
+void draw_cs_line(cs_t p1,cs_t p2) {
+
+}
+
+void draw_cs_text() {
+
+}
+
+void draw_c3_shape() {
+ //oh lawdy... this should be draw_cs_shape...
+}
+
+static void
+graphics_init(void)
+{
+ GLenum type;
+ int j;
+ GLubyte *img;
+ GLsizei imgWidth = 128;
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+ glutCreateWindow("ABGR extension");
+ if (!glutExtensionSupported("GL_EXT_abgr")) {
+ printf("Couldn't find abgr extension.\n");
+ exit(0);
+ }
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(60.0, 1.0, 0.1, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+ glDisable(GL_DITHER);
+
+ glutKeyboardFunc(keypress_handler);
+ glutDisplayFunc(draw_screen);
+
+}
+
+/* ARGSUSED1 */
+static void
+keypress_handler(unsigned char key, int x, int y)
+{
+ switch (key) {
+ case 27:
+ exit(0);
+ }
+}
+
+static void draw_screen(void)
+{
+
+ glClearColor(0.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+
+ glRasterPos3f(0.2, -0.8, -1.5);
+ glDrawPixels(128, 128, GL_RGBA, GL_UNSIGNED_BYTE, ubImage);
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ } else {
+ glFlush();
+ }
+}
+
+static void
+Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_TRUE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ }
+ }
+}
+
+void graphics_event_handler() {
+ glutMainLoopUpdate();
+ return 0; /* ANSI C requires main to return int. */
+}