void FeatureDemo::onFrameRender() { beginTestFrame(); if (mpSceneRenderer) { beginFrame(); { PROFILE(updateScene); mpSceneRenderer->update(mCurrentTime); } depthPass(); shadowPass(); mpState->setFbo(mpMainFbo); renderSkyBox(); lightingPass(); antiAliasing(); postProcess(); ambientOcclusion(); endFrame(); } else { mpRenderContext->clearFbo(mpDefaultFBO.get(), vec4(0.2f, 0.4f, 0.5f, 1), 1, 0); } endTestFrame(); }
void NMS_SceneRenderer::render() { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); SDL_LockMutex(sceneGraphGuard); Matrix m = Matrix(); EmptySceneVisitor v = EmptySceneVisitor(); if(skybox) renderSkyBox(); current_camera->backtrack_to_root(&v, &m); sceneGraphRoot->traverse_df(this, &m); //debug drawing physics->getDynamicsWorld()->debugDrawWorld(); SDL_UnlockMutex(sceneGraphGuard); SDL_GL_SwapBuffers(); }
void display() { // This function is called whenever it is time to render // a new frame; due to the idle()-function below, this // function will get called several times per second // Clear framebuffer & zbuffer glClearColor(0.3, 0.4, 0.5, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setup projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90, 1, 0.01, 500); // Setup object matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Enable textures. glEnable(GL_TEXTURE_2D); // Fix the SkyBox to the camera. renderSkyBox(); glPushAttrib(GL_ALL_ATTRIB_BITS); // Position light 0 GLfloat light_position[] = { 0.0, 1.0, 0.0, 0.0 }; // Directional from above glLightfv(GL_LIGHT0, GL_POSITION, light_position); // Set default material properties GLfloat mat_shininess[] = { 50.0 }; GLfloat mat_diffuseColor[] = { 1.0, 1.0, 1.0, 0.5 }; glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuseColor); // Enable lighting and light 0 glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); // Enable Z-buffering glEnable(GL_DEPTH_TEST); // Enable Gouraud shading glShadeModel(GL_SMOOTH); // Enable backface culling glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glPushMatrix(); // Enable texturing glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); // Render the terrain renderTerrain(); // Render some random props (like trees) renderProps(); // Check if the helicopter hits the ground (if so, exit!) handleCollisions(); // Update the camera (and helicopter) position updatePosition(); // Render the helicopter renderHelicopter(); glPopAttrib(); // Swap front- and backbuffers glutSwapBuffers(); }
void AeroCraftGUI:: draw(){ glClearColor( 0.5f, 0.5f, 0.5f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); if(world->staticTest) return; world->update(); // ALL PHYSICS COMPUTATION DONE HERE camera (); renderSkyBox(world->myCraft->pos.x, world->myCraft->pos.y-1000, world->myCraft->pos.z ); glEnable(GL_DEPTH_TEST); glEnable (GL_LIGHTING); glShadeModel(GL_FLAT); world->myCraft->render(); //glDisable (GL_LIGHTING); glShadeModel(GL_SMOOTH); if ( world->buildings_shape >0 ) glCallList( world->buildings_shape ); if ( world->terrain_shape >0) { glCallList( world->terrain_shape ); } else { // terrain float groundsz = VIEW_DEPTH; glBegin(GL_QUADS); glColor3f( 0.3, 0.6, 0.1 ); glNormal3f(0,1,0); glVertex3f( -groundsz, 0, -groundsz ); glVertex3f( +groundsz, 0, -groundsz ); glVertex3f( +groundsz, 0, +groundsz ); glVertex3f( -groundsz, 0, +groundsz ); glEnd(); }; //Draw3D::drawAxis( 1000 ); /* glColor4f(1.0f,1.0f,1.0f,0.9f); char str[256]; sprintf(str, "speed %3.3f\0",world->myCraft->vel.norm()); Draw3D::drawText(str, world->myCraft->pos, fontTex, 0.2, 0, 0 ); //Draw3D::drawText( "AHOJ!\0", world->myCraft->pos, fontTex, 0.2, 0, 0 ); //Draw3D::drawText( "AHOJ!\0", {0.0,0.0,0.0}, fontTex, 0.5, 0, 0 ); */ if(autoPilot){ //printf("autoPiloting frame %i\n", frameCount); world->autoPilot1.control(world->dt); return; } if(mouseSteer){ if (first_person){ double dpitch=mouseY*0.005; double dyaw =mouseX*0.002; double droll =0.2*dyaw; world->resetSteer( ); world->myCraft->steerTo(droll, dpitch , dyaw); }else{ Mat3d matCam; qCamera.toMatrix_T( matCam ); Draw3D::drawMatInPos(matCam, world->myCraft->pos); world->steerToDir( matCam.c ); } } };