Exemplo n.º 1
0
void initGraphics()
{
    trackball(curquat, 0.0, 0.0, 0.0, 0.0);

#ifdef __APPLE__
    // Seems to be needed on Apple platforms using Intel
	// integrated graphics but not elsewhere
    // If you're getting unexpected seg faults on Apple,
    // comment this out and recompile
	// If you're not seeing the mesh on a Windows box that
	// uses Intel integrated graphics, try enabling this
	// for your machine
    glEnableClientState(GL_COLOR_ARRAY);
#endif
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnable(GL_DEPTH_TEST);
    glPixelStorei(GL_PACK_ALIGNMENT, 1);  // avoid GL's dumb default of 4
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);  // avoid GL's dumb default of 4
    glClearColor(0.1, 0.1, 0.2, 0.0);

    scene = ScenePtr(new Scene(Camera(40, 1, 0.1, 100),
                               View(eye_vector,
                                    at_vector,
                                    up_vector))); 

    material = MaterialPtr(new Material());
    // A little hacky - pick initial values from menu items
    materialMenu(0);
    bumpyMenu(0);
    decalMenu(0);
    envMapMenu(0);

    Mesh2DPtr mesh2d = Mesh2DPtr(new Mesh2D(float2(0,0), float2(1,1), int2(4,4)));

    TorusPtr torus = TorusPtr(new Torus(Transform(), material));
    scene->addObject(torus);

    light = LightPtr(new Light());
    light->setCenter(float3(0,0,0));
    light->setRadius(3.5);
    light->setAngleInDegrees(60.0);
    // A little hacky - pick initial value from menu item
    lightMenu(1);
    scene->addLight(light);
}