void init(int* argc, char** argv) { glutInit(argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); mainWindow = glutCreateWindow("Qix"); const Qix::Color FrameColor = 0xff999999; const Qix::Color PlayerColor = 0xffff0000; sceneTransform = Qix::Transformation( Qix::Vector3(0, 0, -2), Qix::Vector3(0.1, 0.1, 0.1), Qix::Vector3(0, 0, 0) ); light = Qix::Light(Qix::Vector4(6, 8, 0, 0)); light.ambient = 0xff333333; walls.push_back(Qix::Wall(Qix::Cube( Qix::Transformation( Qix::Vector3(0, -6, 0), Qix::Vector3(18, 1, 1), Qix::Vector3(0, 0, 0) ), FrameColor ) )); walls.push_back(Qix::Wall(Qix::Cube( Qix::Transformation( Qix::Vector3(-8.5, 0, 0), Qix::Vector3(1, 11, 1), Qix::Vector3(0, 0, 0) ), FrameColor ) )); walls.push_back(Qix::Wall(Qix::Cube( Qix::Transformation( Qix::Vector3(8.5, 0, 0), Qix::Vector3(1, 11, 1), Qix::Vector3(0, 0, 0) ), FrameColor ) )); walls.push_back(Qix::Wall(Qix::Cube( Qix::Transformation( Qix::Vector3(0, 6, 0), Qix::Vector3(18, 1, 1), Qix::Vector3(0, 0, 0) ), FrameColor ) )); bouncy = Qix::Bouncy(Qix::Sphere( Qix::Transformation( Qix::Vector3(0, 0, 0), Qix::Vector3(0.4, 0.4, 0.4), Qix::Vector3(0, 0, 0) ), PlayerColor ) ); bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2; prepareScene(); // Enable depth checking. glEnable(GL_DEPTH_TEST); //glutIdleFunc(idle); glutTimerFunc(10, animate, 1); glutReshapeFunc(reshape); glutDisplayFunc(display); GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50); GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings"); GLUI_Panel* pan; pan = new GLUI_Panel(mainPan, "Ambient"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel])); pan = new GLUI_Panel(mainPan, "Diffuse"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel])); pan = new GLUI_Panel(mainPan, "Specular"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel])); mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE); pan = new GLUI_Panel(mainPan, "Sphere Settings"); pan->set_alignment(GLUI_ALIGN_LEFT); mainPan->set_w(500); new GLUI_Column(mainPan, false); createAngleSelector(pan, "Initial Angle", &ballAngle); createResetButton(pan, "Reset"); pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE); new GLUI_StaticText(pan, " "); new GLUI_Column(mainPan, false); pan = new GLUI_Panel(mainPan, "Other"); new GLUI_Column(mainPan, false); pan->set_alignment(GLUI_ALIGN_RIGHT); createExitButton(pan, "Exit"); glui->set_main_gfx_window(mainWindow); GLUI_Master.set_glutIdleFunc(idle); glutMainLoop(); }
void init(int* argc, char** argv) { memset(keys, 0, sizeof(keys)); glutInit(argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); mainWindow = glutCreateWindow("Qix"); const Qix::Color FrameColor = 0xff999999; const Qix::Color BouncyColor = 0xffff0000; frameTexture = Qix::Texture::loadImage("grasstiles.dat"); sceneTransform = Qix::Transformation( Qix::Vector3(0, 0, -2), Qix::Vector3(0.1, 0.1, 0.1), Qix::Vector3(0, 0, 0) ); light = Qix::Light(Qix::Vector4(6, 8, 0, 4)); light.ambient = 0xff666666; map.init(frameTexture); bouncy = Qix::Bouncy(Qix::Sphere( Qix::Transformation( Qix::Vector3(0, 0, 0), Qix::Vector3(0.2, 0.2, 0.2), Qix::Vector3(0, 0, 0) ), BouncyColor ) ); bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2; player.init(); prepareScene(); // Enable depth checking. glEnable(GL_DEPTH_TEST); //glutIdleFunc(idle); glutTimerFunc(10, animate, 1); glutReshapeFunc(reshape); glutDisplayFunc(display); GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50); GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings"); GLUI_Panel* pan; pan = new GLUI_Panel(mainPan, "Ambient"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel])); pan = new GLUI_Panel(mainPan, "Diffuse"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel])); pan = new GLUI_Panel(mainPan, "Specular"); new GLUI_Column(mainPan, false); createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel])); createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel])); createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel])); mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE); pan = new GLUI_Panel(mainPan, "Sphere Settings"); pan->set_alignment(GLUI_ALIGN_LEFT); mainPan->set_w(500); new GLUI_Column(mainPan, false); createAngleSelector(pan, "Initial Angle", &ballAngle); createResetButton(pan, "Reset"); pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE); new GLUI_StaticText(pan, " "); new GLUI_Column(mainPan, false); pan = new GLUI_Panel(mainPan, "Other"); new GLUI_Column(mainPan, false); pan->set_alignment(GLUI_ALIGN_RIGHT); createExitButton(pan, "Exit"); glutIgnoreKeyRepeat(true); glutKeyboardFunc(keyboard); glutKeyboardUpFunc(release); glui->set_main_gfx_window(mainWindow); GLUI_Master.set_glutIdleFunc(idle); glutMainLoop(); }