Ejemplo n.º 1
0
/**
 * @brief Main run function for this stage. Performs all processing.
 *
*/
void BoxesStage::run(void)
{
	//Save state for next draw call
	glPushMatrix();

	//Save state to change back to 2D after switching to 3D
	glPushMatrix();

	//Switch to 3D
	setup3D();

	//Disable blending temporarily so we can draw the teapot. Draw the teapot, and enable it again.
	glDisable(GL_BLEND);
	drawTeapot();	
	glEnable(GL_BLEND);

	//Switch back for 2D
	glPopMatrix();
	
	//Draw GUI on top
	drawGUI();
	
	//And revert for the next draw call
	glPopMatrix();
}
Ejemplo n.º 2
0
void MirrorDemo::drawScene()
{
	// Clear the backbuffer and depth buffer.
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER |
		D3DCLEAR_STENCIL, 0xffeeeeee, 1.0f, 0));

	HR(gd3dDevice->BeginScene());

	HR(mFX->SetTechnique(mhTech));
	HR(mFX->SetValue(mhLightVecW, &mLightVecW, sizeof(D3DXVECTOR3)));
	HR(mFX->SetValue(mhDiffuseLight, &mDiffuseLight, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhAmbientLight, &mAmbientLight, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhSpecularLight, &mSpecularLight, sizeof(D3DXCOLOR)));

	// All objects use the same material.
	HR(mFX->SetValue(mhAmbientMtrl, &mWhiteMtrl.ambient, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhDiffuseMtrl, &mWhiteMtrl.diffuse, sizeof(D3DXCOLOR)));
	HR(mFX->SetValue(mhSpecularMtrl, &mWhiteMtrl.spec, sizeof(D3DXCOLOR)));
	HR(mFX->SetFloat(mhSpecularPower, mWhiteMtrl.specPower));

	drawRoom();
	drawMirror();
	drawTeapot();

	drawReflectedTeapot();

	mGfxStats->display();

	HR(gd3dDevice->EndScene());

	// Present the backbuffer.
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
Ejemplo n.º 3
0
void DrawGLScene(void)
{
  double stretch,height,position,rotation;

  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

  glLoadIdentity();
  gluLookAt(5.0, 5.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

  position=cos((double)frame*speed)*2;
  height=fabs(sin((double)frame*speed)*10)+1;
  rotation=cos((double)frame*speed)*90;
  stretch=1+0.3*sin((double)frame*speed/2);

  if(useMyTransformations) {
    if(doTranslate) myTranslatef(position,height-5,0.0);
    if(doRotate) myRotatef(rotation,0.2,0.6,0.77);
    if(doScale) myScalef(1/sqrt(stretch),stretch,1/sqrt(stretch));
  } else {
    if(doTranslate) glTranslatef(position,height-5,0.0);
    if(doRotate) glRotatef(rotation,0.2,0.6,0.77);
    if(doScale) glScalef(1/sqrt(stretch),stretch,1/sqrt(stretch));
  }

  //drawCube();
  drawTeapot();

  frame++;

  glutSwapBuffers();
}
Ejemplo n.º 4
0
void MirrorDemo::drawReflectedTeapot()
{
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILENABLE,    true));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILFUNC,      D3DCMP_ALWAYS));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILREF,       0x1));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILMASK,      0xffffffff));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILWRITEMASK, 0xffffffff));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILZFAIL,     D3DSTENCILOP_KEEP));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILFAIL,      D3DSTENCILOP_KEEP));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILPASS,      D3DSTENCILOP_REPLACE));

	// Disable writes to the depth and back buffers
	HR(gd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false));
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true));
	HR(gd3dDevice->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_ZERO));
	HR(gd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE));

	// Draw mirror to stencil only.
	drawMirror();

	// Re-enable depth writes
	HR(gd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, true ));

	// Only draw reflected teapot to the pixels where the mirror
	// was drawn to.
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILFUNC,  D3DCMP_EQUAL));
	HR(gd3dDevice->SetRenderState(D3DRS_STENCILPASS,  D3DSTENCILOP_KEEP));

	// Build Reflection transformation.
	D3DXMATRIX R;
	D3DXPLANE plane(0.0f, 0.0f, 1.0f, 0.0f); // xy plane
	D3DXMatrixReflect(&R, &plane);

	// Save the original teapot world matrix.
	D3DXMATRIX oldTeapotWorld = mTeapotWorld;

	// Add reflection transform.
	mTeapotWorld = mTeapotWorld * R;

	// Reflect light vector also.
	D3DXVECTOR3 oldLightVecW = mLightVecW;
	D3DXVec3TransformNormal(&mLightVecW, &mLightVecW, &R);
	HR(mFX->SetValue(mhLightVecW, &mLightVecW, sizeof(D3DXVECTOR3)));

	// Disable depth buffer and render the reflected teapot.
	HR(gd3dDevice->SetRenderState(D3DRS_ZENABLE, false));
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false));

	// Finally, draw the reflected teapot
	HR(gd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW));
	drawTeapot();
	mTeapotWorld = oldTeapotWorld;
	mLightVecW   = oldLightVecW;

	// Restore render states.
	HR(gd3dDevice->SetRenderState(D3DRS_ZENABLE, true));
	HR(gd3dDevice->SetRenderState( D3DRS_STENCILENABLE, false));
	HR(gd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW));
}
Ejemplo n.º 5
0
/*******************************************************************************
 The main routine for displaying the scene.  Gets the latest snapshot of state
 from the haptic thread and uses it for displaying a 3D cursor.  Draws the
 anchor visual if the anchor is presently active.
*******************************************************************************/
void drawSceneGraphics()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);        
    
    drawCursor();

    drawSphere();
    drawTorus();
    drawTeapot();
}
Ejemplo n.º 6
0
///////////////////////////////////////////////////////////////////////////////
// draw upper window (view from the camera)
///////////////////////////////////////////////////////////////////////////////
void ModelGL::drawSub1()
{
    // set upper viewport
    setViewportSub(0, windowHeight/2, windowWidth, windowHeight/2, 1, 10);

    // clear buffer
    glClearColor(0.1f, 0.1f, 0.1f, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glPushMatrix();

    // set view matrix ========================================================
    // copy the matrix to OpenGL GL_MODELVIEW matrix
    // Note that OpenGL uses column-major matrix, so transpose the matrix first
    // See updateViewMatrix() how matrixView is constructed. The equivalent
    // OpenGL calls are;
    //    glLoadIdentity();
    //    glRotatef(-cameraAngle[2], 0, 0, 1); // roll
    //    glRotatef(-cameraAngle[1], 0, 1, 0); // heading
    //    glRotatef(-cameraAngle[0], 1, 0, 0); // pitch
    //    glTranslatef(-cameraPosition[0], -cameraPosition[1], -cameraPosition[2]);
    glLoadMatrixf(matrixView.getTranspose());

    // always draw the grid at the origin (before any modeling transform)
    drawGrid(10, 1);

    // transform objects ======================================================
    // From now, all transform will be for modeling matrix only.
    // (from object space to world space)
    // See updateModelMatrix() how matrixModel is constructed. The equivalent
    // OpenGL calls are;
    //    glLoadIdentity();
    //    glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]);
    //    glRotatef(modelAngle[0], 1, 0, 0);
    //    glRotatef(modelAngle[1], 0, 1, 0);
    //    glRotatef(modelAngle[2], 0, 0, 1);

    // compute GL_MODELVIEW matrix by multiplying matrixView and matrixModel
    // before drawing the object:
    // ModelView_M = View_M * Model_M
    // This modelview matrix transforms the objects from object space to eye space.
    // copy modelview matrix to OpenGL after transpose
    glLoadMatrixf(matrixModelView.getTranspose());

    // draw a teapot after ModelView transform
    // v' = Mmv * v
    drawAxis(4);
    drawTeapot();

    glPopMatrix();
}
Ejemplo n.º 7
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) // HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow
{
	config = _CONFIG(1024, 768, {0.0f,1.2f,10.f}, {}, 60.f, 0.01f, 40.f);
	_WINDOW wnd = _WINDOW(hInstance, "Main Window");

	if (wnd.isInitialized())
	{
		//load file
		Model teapot(getFilenameFromCurrentDirectory("teapot.obj"), {0,3,1}, {}, {.5f, .5f, .5f});
		Model ball(getFilenameFromCurrentDirectory("sphere.obj"), {}, {}, {.8f,.8f,.8f});

		float rotOfTeapot[3] = {0.0f, 0.0f, 0.0f};
		while (true)
		{
			while (PeekMessage(&wnd.msg, nullptr, 0, 0, PM_REMOVE) > 0)
			{
				TranslateMessage(&wnd.msg);
				DispatchMessage(&wnd.msg);
			}

			//Background
			DrawWindowElements::ClearZBuffer();
			DrawWindowElements::FillRectangle(MyColor::LIGHTBLUE);
			//DrawWindowElements::DrawGrid(32, MyColor::BLACK);

			//Setting visual and camera
			DrawCommon::SetProjection();
			DrawCommon::SetViewMatrix();

			//Drawing models
			drawTeapot(teapot, rotOfTeapot);
			drawBalls(ball);

			DrawMyWindow(wnd.hwndMain);
			Controller::OverlayHUD(wnd.hwndMain);

			Sleep(20);
			if (wnd.msg.message == WM_QUIT) return EXIT_SUCCESS;
		}
	}
	return EXIT_FAILURE;
}
Ejemplo n.º 8
0
///////////////////////////////////////////////////////////////////////////////
// draw bottom window (3rd person view)
///////////////////////////////////////////////////////////////////////////////
void ModelGL::drawSub2()
{
    // set bottom viewport
    setViewportSub(0, 0, windowWidth, windowHeight/2, NEAR_PLANE, FAR_PLANE);

    // clear buffer
    glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]);   // background color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glPushMatrix();

    // First, transform the camera (viewing matrix) from world space to eye space
    glTranslatef(0, 0, -cameraDistance);
    glRotatef(cameraAngleX, 1, 0, 0); // pitch
    glRotatef(cameraAngleY, 0, 1, 0); // heading

    // draw grid
    drawGrid(10, 1);

    // draw a teapot
    glPushMatrix();
    glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]);
    glRotatef(modelAngle[0], 1, 0, 0);
    glRotatef(modelAngle[1], 0, 1, 0);
    glRotatef(modelAngle[2], 0, 0, 1);
    drawAxis(4);
    drawTeapot();
    glPopMatrix();

    // draw the camera
    glPushMatrix();
    glTranslatef(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
    glRotatef(cameraAngle[0], 1, 0, 0);
    glRotatef(cameraAngle[1], 0, 1, 0);
    glRotatef(cameraAngle[2], 0, 0, 1);
    drawCamera();
    drawFrustum(FOV_Y, 1, 1, 10);
    glPopMatrix();

    glPopMatrix();
}
Ejemplo n.º 9
0
/*******************************************************************************
 The main routine for haptically rendering the scene.
*******************************************************************************/
void drawSceneHaptics()
{
    hlBeginFrame();
    
    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, gSphereShapeId);
    hlTouchableFace(HL_FRONT);
    drawSphere();
    hlEndShape();

    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, gTorusShapeId);
    hlTouchableFace(HL_FRONT);
    drawTorus();
    hlEndShape();

    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, gTeapotShapeId);
    hlTouchableFace(HL_BACK);
    drawTeapot();
    hlEndShape();

    hlEndFrame();

    // Call any event callbacks that have been triggered.
    hlCheckEvents();
}
Ejemplo n.º 10
0
///////////////////////////////////////////////////////////////////////////////
// draw upper window (view from the camera)
///////////////////////////////////////////////////////////////////////////////
void ModelGL::drawSub1()
{
    // set upper viewport
    setViewportSub(0, windowHeight/2, windowWidth, windowHeight/2, 1, 10);

    // clear buffer
    glClearColor(0.1f, 0.1f, 0.1f, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // initialze ModelView matrix
    glPushMatrix();
    glLoadIdentity();

    // ModelView matrix is product of viewing matrix and modeling matrix
    // ModelView_M = View_M * Model_M
    // First, transform the camera (viewing matrix) from world space to eye space
    // Notice all values are negated, because we move the whole scene with the
    // inverse of camera transform
    glRotatef(-cameraAngle[2], 0, 0, 1); // roll
    glRotatef(-cameraAngle[1], 0, 1, 0); // heading
    glRotatef(-cameraAngle[0], 1, 0, 0); // pitch
    glTranslatef(-cameraPosition[0], -cameraPosition[1], -cameraPosition[2]);

    // we have set viewing matrix upto this point. (Matrix from world space to eye space)
    // save the view matrix only
    glGetFloatv(GL_MODELVIEW_MATRIX, matrixView); // save viewing matrix
    //=========================================================================


    // always draw the grid at the origin (before any modeling transform)
    drawGrid(10, 1);

    // In order to get the modeling matrix only, reset GL_MODELVIEW matrix
    glLoadIdentity();

    // transform the object
    // From now, all transform will be for modeling matrix only. (transform from object space to world space)
    glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]);
    glRotatef(modelAngle[0], 1, 0, 0);
    glRotatef(modelAngle[1], 0, 1, 0);
    glRotatef(modelAngle[2], 0, 0, 1);

    // save modeling matrix
    glGetFloatv(GL_MODELVIEW_MATRIX, matrixModel);
    //=========================================================================


    // re-strore GL_MODELVIEW matrix by multiplying matrixView and matrixModel before drawing the object
    // ModelView_M = View_M * Model_M
    glLoadMatrixf(matrixView);              // Mmv = Mv
    glMultMatrixf(matrixModel);             // Mmv *= Mm

    // save ModelView matrix
    glGetFloatv(GL_MODELVIEW_MATRIX, matrixModelView);
    //=========================================================================


    // draw a teapot after ModelView transform
    // v' = Mmv * v
    drawAxis(4);
    drawTeapot();

    glPopMatrix();
}
Ejemplo n.º 11
0
//Exibe tudo na tela
void Display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef (-80, 80, zoom);

    board();
    drawTeapot();
    drawSphere();
    drawCat();
    drawTable();

    if(gameOver && scoreRecorde > 0)
    {
        char tmp_str[40];

        glColor3f(1, 1, 0);
        glRasterPos2f(30, 10);

        sprintf(tmp_str, "Recorde: Level %d - Score %d", lvlRecorde, scoreRecorde);
        write(tmp_str);
    }

    char tmp_menu1[40];
    char tmp_menu2[40];
    char tmp_menu3[40];
    char tmp_menu4[40];
    char tmp_menu5[40];
    char tmp_menu6[40];
    char tmp_menu7[40];
    char tmp_menu8[40];
    char tmp_menu9[40];
    char tmp_menu10[40];
    char tmp_menu11[40];


    glColor3f(1.0, 0.0, 0.0);
    glRasterPos2f(0, 300);
    sprintf(tmp_menu1, "Creepy Cat");
    write(tmp_menu1);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 270);
    sprintf(tmp_menu2, "- Objetivo: empurrar o teapot para fora dos limites da mesa");
    write(tmp_menu2);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 240);
    sprintf(tmp_menu3, "- Cada teapot derrubado incrementa 100 pontos no score");
    write(tmp_menu3);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 210);
    sprintf(tmp_menu4, "- A cada 500 pontos acumulados, o jogador sobe um level");
    write(tmp_menu4);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 180);
    sprintf(tmp_menu5, "- A cada level, aumenta a velocidade do gato e podem surgir obstaculos");
    write(tmp_menu5);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 150);
    sprintf(tmp_menu6, "- O jogador perde a partida se o gato ultrapassar os limites da mesa");
    write(tmp_menu6);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 120);
    sprintf(tmp_menu7, "- Controle do gato pelas teclas direcionais (UP, DOWN, LEFT, RIGHT)");
    write(tmp_menu7);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 90);
    sprintf(tmp_menu8, "- Controle da camera pelas teclas numericas (1, 2, 3, 4, 5, 6)");
    write(tmp_menu8);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 60);
    sprintf(tmp_menu9, "- Para redefinir a camera pressione < E N T E R >");
    write(tmp_menu9);

    glColor3f(1, 1, 0);
    glRasterPos2f(-230, 30);
    sprintf(tmp_menu10, "- Para sair do jogo pressione < E S C > a qualquer momento");
    write(tmp_menu10);

    glColor3f(1, 1, 1);
    glRasterPos2f(-130, -200);
    sprintf(tmp_menu11, "Pressione < E N T E R >  para iniciar a partida" );
    write(tmp_menu11);

    char tmp_nomes[40];

    glColor3f(1.0, 0.0, 0.0);
    glRasterPos2f(-130, -400);
    sprintf(tmp_nomes, "Criado por: Luan De Nale e Raffaela Monteiro" );
    write(tmp_nomes);

    glutPostRedisplay();
    glutSwapBuffers();
}
Ejemplo n.º 12
0
Archivo: main.cpp Proyecto: hgl888/glfw
void displayCB()
{
    // get the total elapsed time
    playTime = (float)timer.getElapsedTime();

    // compute rotation angle
    const float ANGLE_SPEED = 10;   // degree/s
    float angle = ANGLE_SPEED * playTime;

    // render to texture //////////////////////////////////////////////////////
    t1.start();

    // adjust viewport and projection matrix to texture dimension
    glViewport(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0f, (float)(TEXTURE_WIDTH)/TEXTURE_HEIGHT, 1.0f, 100.0f);
    glMatrixMode(GL_MODELVIEW);

    // camera transform
    glLoadIdentity();
    glTranslatef(0, 0, -CAMERA_DISTANCE);

    // with MSAA
    // render to MSAA FBO
    if(msaaUsed)
    {
        // set the rendering destination to FBO
        glBindFramebuffer(GL_FRAMEBUFFER, fboMsaaId);

        // clear buffer
        glClearColor(1, 1, 1, 1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // draw a rotating object at the origin
        glPushMatrix();
        glRotatef(angle*0.5f, 1, 0, 0);
        glRotatef(angle, 0, 1, 0);
        glRotatef(angle*0.7f, 0, 0, 1);
        glTranslatef(0, -1.575f, 0);
        drawTeapot();
        glPopMatrix();

        // copy rendered image from MSAA (multi-sample) to normal (single-sample) FBO
        // NOTE: The multi samples at a pixel in read buffer will be converted
        // to a single sample at the target pixel in draw buffer.
        glBindFramebuffer(GL_READ_FRAMEBUFFER, fboMsaaId);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboId);
        glBlitFramebuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT,  // src rect
                          0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT,  // dst rect
                          GL_COLOR_BUFFER_BIT, // buffer mask
                          GL_LINEAR);                           // scale filter

        // trigger mipmaps generation explicitly
        // NOTE: If GL_GENERATE_MIPMAP is set to GL_TRUE, then glCopyTexSubImage2D()
        // triggers mipmap generation automatically. However, the texture attached
        // onto a FBO should generate mipmaps manually via glGenerateMipmap().
        glBindTexture(GL_TEXTURE_2D, textureId);
        glGenerateMipmap(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, 0);

        // back to normal window-system-provided framebuffer
        glBindFramebuffer(GL_FRAMEBUFFER, 0); // unbind
    }

    // without MSAA
    // render to non MSAA FBO
    else
    {
        // set the rendering destination to FBO
        glBindFramebuffer(GL_FRAMEBUFFER, fboId);

        // clear buffer
        glClearColor(1, 1, 1, 1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // draw a rotating object at the origin
        glPushMatrix();
        glRotatef(angle*0.5f, 1, 0, 0);
        glRotatef(angle, 0, 1, 0);
        glRotatef(angle*0.7f, 0, 0, 1);
        glTranslatef(0, -1.575f, 0);
        drawTeapot();
        glPopMatrix();

        // trigger mipmaps generation explicitly
        // NOTE: If GL_GENERATE_MIPMAP is set to GL_TRUE, then glCopyTexSubImage2D()
        // triggers mipmap generation automatically. However, the texture attached
        // onto a FBO should generate mipmaps manually via glGenerateMipmap().
        glBindTexture(GL_TEXTURE_2D, textureId);
        glGenerateMipmap(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, 0);

        // back to normal window-system-provided framebuffer
        glBindFramebuffer(GL_FRAMEBUFFER, 0); // unbind
    }

    // measure the elapsed time of render-to-texture
    t1.stop();
    renderToTextureTime = t1.getElapsedTimeInMilliSec();
    ///////////////////////////////////////////////////////////////////////////


    // rendering as normal ////////////////////////////////////////////////////

    // back to normal viewport and projection matrix
    toPerspective();

    // tramsform camera
    glTranslatef(0, 0, -cameraDistance);
    glRotatef(cameraAngleX, 1, 0, 0);   // pitch
    glRotatef(cameraAngleY, 0, 1, 0);   // heading

    // clear framebuffer
    glClearColor(0, 0, 0, 0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glPushMatrix();

    // draw a cube with the dynamic texture
    draw();

    glPopMatrix();

    // draw info messages
    showInfo();
    showFPS();
    glutSwapBuffers();
}