From 781ecd6529505e4bf1fd400634ee83bcb9a07c81 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 19 Mar 2017 04:51:01 -0500 Subject: I have no idea why I am doing this... --- src/graphics_c2_opengl.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 src/graphics_c2_opengl.c (limited to 'src/graphics_c2_opengl.c') diff --git a/src/graphics_c2_opengl.c b/src/graphics_c2_opengl.c new file mode 100644 index 0000000..3429193 --- /dev/null +++ b/src/graphics_c2_opengl.c @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include + +#include "common.h" +#include "graphics_cs.h" +#include "graphics_c2.h" +#include "graphics_c3.h" + +extern struct gra_global gra_global; + +GLenum doubleBuffer; +GLubyte ubImage[65536]; + +#define RIGHT 320.0 +#define LEFT -320.0 +#define TOP 240.0 +#define BOTTOM -240.0 + +int c2sX(real x) { return (gra_global.width/(gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen: 1))) * ((x + RIGHT) / (RIGHT *2)) + gra_global.xoff; } +int s2cX(real x) { return (x/(gra_global.width/(gra_global.split_screen / (gra_global.red_and_blue?gra_global.split_screen :1))))*(RIGHT*2)-RIGHT; } + +int c2sY(real y) { return gra_global.height * ((TOP-y) / (TOP*2)); } +int s2cY(real y) { return -((y/gra_global.height) * (TOP*2) - TOP); } + +cs_t c2_to_cs(c2_t p) { + return (cs_t){c2sX(p.x),c2sY(p.y)}; +} + +c2_t cs_to_c2(cs_t p) { + return (c2_t){s2cX(p.x),s2cY(p.y)}; +} + +void set_aspect_ratio(int w,int h) { + glViewport(0,0,w,h); +// glMatrixMode(GL_PROJECTION); +// glLoadIdentity(); +// glOrtho(LEFT,RIGHT,BOTTOM,TOP,0,0); +// glTranslatef(0,-h,0); +} + +void set_color_based_on_distance(real d) { + //scale this color based on distance... closer is lighter. +// float g; +// g=d/100.0 + glColor3f(0.0, 1.0, 0.0); +} + +void set_clipping_rectangle(int x,int y,int w,int h) { + +} + +void draw_c2_line(c2_t p1,c2_t p2) { + //glBegin(GL_TRIANGLES); + glBegin(GL_LINES); + glColor3f(0.0, 1.0, 0.0); + glVertex2i(p1.x,p1.y); + glVertex2i(p2.x,p2.y); + //glVertex2i(p2.x,p2.y); + glEnd(); +} + +void draw_c2_text(c2_t p,char *s) { +// printf("@%lF,%lF: %s\n",p.x,p.y,s); +} + +void draw_c2_shape(c2_s_t s) { + int i; +// printf("drawing shaep!\n"); + for(i=0;i