示例#1
0
// OpenGL initialization
void
init()
{
    program = InitShader( "/home/GONZAGA/yerion/Documents/ACAR/LgsparksCar/vertex.glsl", "/home/GONZAGA/yerion/Documents/ACAR/LgsparksCar/fragment.glsl" );
    glUseProgram( program );

    // Uniform variables: color and viewing parameters
    model_color = glGetUniformLocation( program, "model_color" );
    model_view = glGetUniformLocation( program, "model_view" );
    projection = glGetUniformLocation( program, "projection" );

    // Create multiple vertex array objects using an array of vertex array objects
    GLuint vao[6];
    glGenVertexArrays( 6, vao );

    //********  Create the VAOs ************//

    myCube.createVAO(vao[0],program);
    myWireCube.createVAO(vao[1],program);
    myDisk.createVAO(vao[2],program);
    myWireDisk.createVAO(vao[3],program);
    myCylinder.createVAO(vao[4],program);
    myWireCylinder.createVAO(vao[5],program);

    glUniform4fv( model_color, 1,vec4(1,1,1,1) ); // set color to white initially

    glLineWidth(4);
    glEnable( GL_DEPTH_TEST );
    glClearColor( 0.5, 0.5, 0.5, 1.0 );
}
示例#2
0
void frameworkSetup()
{
	// todo: move this to a one time call only
	pCamera = new Camera();

	// Initially setup the camera - this might not be needed since ChangeSize is always called at the beginning
	pCamera->setViewport( 0, 0, 800, 600);
	pCamera->setPerspective( 35.0f, float(800)/float(600), 1.0f, 500.0f);
	// pCamera->setOrientAndPosition( Vect(0.0f, 1.0f, 0.0f), Vect(0.0f, 0.0f, -1.0f), Vect(0.0f, 0.0f, 7.0f) );
 
#if ANIMATION
    AnimationManager* animManager = AnimationManager::GetInstance();

    // create animations and add 'em to animList in manager
    // can add them in each anim's ctor
    Anim* bearWalk = new BearWalk();
    animManager->AddAnim(bearWalk); 

    // Anim* bearIdle = new BearIdle();
    // animManager->AddAnim(bearIdle);

    // Anim* twoBone = new AnimTwoBone();
    // animManager->AddAnim(twoBone);

#endif

#if MODEL_VIEWER

    GraphicsObjectManager *goMgr = GraphicsObjectManager::getInstance();
    createFBXModels(goMgr);

    // PieWedge* pPieWedge = new PieWedge();  
    // pPieWedge->loadTexture();
    // pPieWedge->createVAO();   
    // createPieWedgeObjects(pPieWedge, goMgr);
    // 
    // Pyramid* pPyramid = new Pyramid();
    // pPyramid->loadTexture();
    // pPyramid->createVAO();
    // createPyramidObjects(pPyramid, goMgr);   
    // 
    //     // ***Geometry*** - create models - cube here for Collision_Demo
    // Cube* pCube = new Cube();
    // // allocates a texture object with an ID, binds it, and sets up the texture state via call to LoadTGATexture()
    // pCube->loadTexture();
    // pCube->createVAO(); 
    // createCubeObjects(pCube, goMgr);

#endif

#if COLLISION_DEMO

    GraphicsObjectManager *goMgr = GraphicsObjectManager::getInstance();

    //  ***Geometry*** - create models - cube here for Collision_Demo
    Cube* pCube = new Cube();
    // allocates a texture object with an ID, binds it, and sets up the texture state via call to LoadTGATexture()
    pCube->loadTexture();
    pCube->createVAO(); 

    // CubeObject *c = new CubeObject("Cube A");
    collisionCube = new CubeObject("Collision Cube", pCube);
    // collisionCube->setPos( Vect(0.0f, 0.0f, 0.0f) );
    collisionCube->setLightPos( Vect(1.0f, 1.0f, 0.0f) );
    collisionCube->setLightColor( Vect(0.0f, 1.0f, 0.0f, 1.0f) );
    collisionCube->setTexture(TEX1);
    collisionCube->setShader(POINT_LIGHT_DIFF);
    goMgr->addObject(collisionCube);

#endif
}