Beispiel #1
0
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;

	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, -6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(-8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, 6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Sphere(
			Qix::Transformation(
				Qix::Vector3(-5, 3, 0),
				Qix::Vector3(0.4, 0.4, 0.4),
				Qix::Vector3(0, 0, 0)
			),
			PlayerColor
		)
	);

	prepareScene();

	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

	//glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLUI* glui = GLUI_Master.create_glui("Light Controls", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    
    
    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]));
    
    createExitButton(glui, "Exit");
	

	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	glutMainLoop();
}
Beispiel #2
0
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();
}
Beispiel #3
0
void PopupPurchase::initButtons()
{
    createExitButton("btn_back.png", "btn_back.png", 380, 530);
    
}
Beispiel #4
0
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Heightmaps");

    

    /*std::cout << "P2" << std::endl;
    std::cout << map->width << std::endl;
    std::cout << map->height << std::endl;
    std::cout << map->depth << std::endl;
    for(int i = 0; i < map->width * map->height; i++)
    {
        std::cout << map->data[i] << std::endl;
    }*/
    
	sceneTransform = Transformation(
		Vector3(0, 0, -100),
		Vector3(0.3, 0.3, 0.3),
		Vector3(0, 0, 0)
	);
	light = Light(Vector4(10, 10, -10, 0));
	prepareScene();    
	sceneTransform.rotation.data[0] = -35;
    
	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

    glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);

	glui = GLUI_Master.create_glui("Heightmap Controls", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    
    
    GLUI_Panel* pan;
    createStaticText(mainPan, "Heightmap Utility");
    createStaticText(mainPan, "by Andrew Crowell");
    createStaticText(mainPan, "for CIS*4800 A4, 2010");
    createStaticText(mainPan, "");
    createStaticText(mainPan, "The W and A keys rotate the map.");
    pan = new GLUI_Panel(mainPan, "Heightmap");
    
    createTextField(pan, "Filename", mapFilename, loadMap);
	createFloatSpinner(pan, "R", &mapColor.data[Color::RedChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "G", &mapColor.data[Color::GreenChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "B", &mapColor.data[Color::BlueChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "Z Scale", &mapScaleZ, refreshGeometry);
	createCheckbox(pan, "Randomize", &mapRandomize, refreshGeometry);
	
    pan = new GLUI_Panel(mainPan, "Message");
    errorMessageLabel = createStaticText(pan, "                                                ");
        
    createExitButton(glui, "Exit");
    
	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	loadMap(0);
	glutMainLoop();
	
    return 0;
}
Beispiel #5
0
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();
}