X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmodern%2Fmain.c;h=91178bfe841db3d8f600b9592da3cfc95f4645b9;hb=HEAD;hp=65b5eed83305c5307ce6ee71e9d025948f856ded;hpb=8b26b033e3709d820996a23008435632fa7922bf;p=retroray diff --git a/src/modern/main.c b/src/modern/main.c index 65b5eed..91178bf 100644 --- a/src/modern/main.c +++ b/src/modern/main.c @@ -20,8 +20,11 @@ along with this program. If not, see . #include #include "miniglut.h" #include "app.h" +#include "options.h" +#include "rtk.h" #include "logger.h" +static void display(void); static void reshape(int x, int y); static void keydown(unsigned char key, int x, int y); static void keyup(unsigned char key, int x, int y); @@ -44,16 +47,20 @@ static void (*glx_swap_interval_sgi)(); static PROC wgl_swap_interval_ext; #endif +static rtk_rect rband; int main(int argc, char **argv) { glutInit(&argc, argv); - glutInitWindowSize(640, 480); + + load_options(CFGFILE); + + glutInitWindowSize(opt.xres, opt.yres); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("RetroRay"); - glutDisplayFunc(app_display); + glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keydown); glutKeyboardUpFunc(keyup); @@ -83,6 +90,7 @@ int main(int argc, char **argv) win_aspect = (float)win_width / win_height; init_logger(); + add_log_stream(stdout); if(app_init() == -1) { return 1; @@ -92,32 +100,54 @@ int main(int argc, char **argv) return 0; } -long app_getmsec(void) +unsigned long get_msec(void) { - return glutGet(GLUT_ELAPSED_TIME); + return (unsigned long)glutGet(GLUT_ELAPSED_TIME); } -void app_redisplay(void) +void app_redisplay(int x, int y, int w, int h) { + /*dbgmsg("fakeupd: %d,%d (%dx%d)\n", x, y, w, h);*/ glutPostRedisplay(); } void app_swap_buffers(void) { + glViewport(0, 0, win_width, win_height); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glOrtho(0, win_width, win_height, 0, -1, 1); - glRasterPos2i(-1, 1); + glRasterPos2i(0, 0); glPixelZoom(1, -1); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); glDrawPixels(win_width, win_height, GL_BGRA, GL_UNSIGNED_BYTE, framebuf); glDisable(GL_ALPHA_TEST); - glMatrixMode(GL_PROJECTION); + if(rband.width | rband.height) { + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + + glBegin(GL_LINE_LOOP); + glColor3f(1, 1, 1); + glVertex2f(rband.x, rband.y); + glVertex2f(rband.x + rband.width, rband.y); + glVertex2f(rband.x + rband.width, rband.y + rband.height); + glVertex2f(rband.x, rband.y + rband.height); + glEnd(); + + glPopAttrib(); + } + glPopMatrix(); glMatrixMode(GL_MODELVIEW); @@ -177,7 +207,22 @@ void app_vsync(int vsync) } #endif +void app_rband(int x, int y, int w, int h) +{ + rband.x = x; + rband.y = y; + rband.width = w; + rband.height = h; + + glutPostRedisplay(); +} + +static void display(void) +{ + app_display(); + app_swap_buffers(); +} static void reshape(int x, int y) {