From ebde46bc82bebf478db67abef5b7dc88c014706b Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 3 Jan 2017 00:30:28 -0600 Subject: 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/ --- src/graphics_opengl.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/graphics_opengl.c (limited to 'src/graphics_opengl.c') 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 +#include +#include +#include + +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. */ +} -- cgit v1.2.3