# HG changeset patch # User John Tsiombikas # Date 1377832114 -10800 # Node ID c7b50cd7184c901b46f054c822c80bc1cd947bde initial commit diff -r 000000000000 -r c7b50cd7184c Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Fri Aug 30 06:08:34 2013 +0300 @@ -0,0 +1,21 @@ +src = $(wildcard src/*.cc) +obj = $(src:.cc=.o) +bin = oculus1 + +CXXFLAGS = -pedantic -Wall -g -I/usr/local/include +LDFLAGS = -L/usr/local/lib $(libgl) $(ovrlibs) -lm + +ifeq ($(shell uname -s), Darwin) + libgl = -framework OpenGL -framework GLUT -lGLEW + ovrlibs = -lovr -framework CoreFoundation -framework ApplicationServices -framework IOKit +else + libgl = -lGL -lGLU -lglut -lGLEW + ovrlibs = -lovr +endif + +$(bin): $(obj) + $(CXX) -o $@ $(obj) $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) diff -r 000000000000 -r c7b50cd7184c src/camera.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/camera.h Fri Aug 30 06:08:34 2013 +0300 @@ -0,0 +1,8 @@ +#ifndef CAMERA_H_ +#define CAMERA_H_ + +class Camera { +public: +}; + +#endif // CAMERA_H_ diff -r 000000000000 -r c7b50cd7184c src/main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cc Fri Aug 30 06:08:34 2013 +0300 @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#ifdef __APPLE__ +#include +#else +#include +#endif +#include +#include "camera.h" + +static bool init(); +static void cleanup(); +static void disp(); +static void idle(); +static void reshape(int x, int y); +static void keyb(unsigned char key, int x, int y); +static void sball_rotate(int rx, int ry, int rz); + +static Camera cam; +static int width, height; +static OVR::DeviceManager *ovr_devman; + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitWindowSize(1280, 800); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutCreateWindow("oculus test 01"); + + glutDisplayFunc(disp); + glutIdleFunc(idle); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyb); + glutSpaceballRotateFunc(sball_rotate); + + glewInit(); + + if(!init()) { + return 1; + } + atexit(cleanup); + + glutMainLoop(); + return 0; +} + +static bool init() +{ + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_CULL_FACE); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + + // initialize Oculus SDK + OVR::System::Init(); + if(!(ovr_devman = OVR::DeviceManager::Create())) { + fprintf(stderr, "failed to create OVR device manager\n"); + return false; + } + + return true; +} + +static void cleanup() +{ +} + +static void disp() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, (float)width / (float)height, 0.5, 500.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -8); + + float lpos[] = {0, 60, 0, 1}; + glLightfv(GL_LIGHT0, GL_POSITION, lpos); + + glFrontFace(GL_CW); + glutSolidTeapot(1.0); + glFrontFace(GL_CCW); + + glutSwapBuffers(); + assert(glGetError() == GL_NO_ERROR); +} + +static void idle() +{ + glutPostRedisplay(); +} + + +static void reshape(int x, int y) +{ + width = x; + height = y; +} + +static void keyb(unsigned char key, int x, int y) +{ + switch(key) { + case 27: + exit(0); + } +} + +static void sball_rotate(int rx, int ry, int rz) +{ +}