#include <assert.h>
#include "miniglut.h"
#include "app.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);
int main(int argc, char **argv)
{
glutInit(&argc, argv);
- glutInitWindowSize(1024, 768);
+ glutInitWindowSize(640, 480);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow("RetroRay");
- glutDisplayFunc(app_display);
+ glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keydown);
glutKeyboardUpFunc(keyup);
wgl_swap_interval_ext = wglGetProcAddress("wglSwapIntervalEXT");
#endif
- app_reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
+ win_width = glutGet(GLUT_WINDOW_WIDTH);
+ win_height = glutGet(GLUT_WINDOW_HEIGHT);
+ win_aspect = (float)win_width / win_height;
+
+ init_logger();
if(app_init() == -1) {
return 1;
void app_swap_buffers(void)
{
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glRasterPos2i(-1, 1);
+ 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);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+
glutSwapBuffers();
assert(glGetError() == GL_NO_ERROR);
}
#endif
+static void display(void)
+{
+ app_display();
+ app_swap_buffers();
+}
static void reshape(int x, int y)
{
case GLUT_KEY_PAGE_UP:
return KEY_PGUP;
case GLUT_KEY_PAGE_DOWN:
- return KEY_PGDOWN;
+ return KEY_PGDN;
case GLUT_KEY_HOME:
return KEY_HOME;
case GLUT_KEY_END: