void draw() { // clear the color and depth in the frame buffer glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // use the loaded shader program // Don't change unless you know what you are doing glUseProgram (programID); // Eye - Location of camera. Don't change unless you are sure!! // glm::vec3 eye ( 5*cos(camera_rotation_angle*M_PI/180.0f), 0, 5*sin(camera_rotation_angle*M_PI/180.0f) ); // Target - Where is the camera looking at. Don't change unless you are sure!! // glm::vec3 target (0, 0, 0); // Up - Up vector defines tilt of camera. Don't change unless you are sure!! // glm::vec3 up (0, 1, 0); // Compute Camera matrix (view) // Matrices.view = glm::lookAt( eye, target, up ); // Rotating Camera for 3D // Don't change unless you are sure!! Matrices.view = glm::lookAt(glm::vec3(0, 0, 3), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0)); // Fixed camera for 2D (ortho) in XY plane // Compute ViewProject matrix as view/camera might not be changed for this frame (basic scenario) // Don't change unless you are sure!! glm::mat4 VP = Matrices.projection * Matrices.view; // Send our transformation to the currently bound shader, in the "MVP" uniform // For each model you render, since the MVP will be different (at least the M part) // Don't change unless you are sure!! glm::mat4 MVP; // MVP = Projection * View * Model // Scene render trap1.draw(VP); ball1.draw(VP); flr.draw(VP); trampoline1.draw(VP); trampoline2.draw(VP); if(level==1) { trampoline3.draw(VP); trampoline4.draw(VP); trap2.draw(VP); } for(int i=0;i<10;i++) if(!enemy[level][i].hitflag) enemy[level][i].draw(VP); }
void onDisplay(void) { // cams.projection(winW, winH); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); cams.look(); lights.display(&pacman); //draw stuff maze.draw(); if (!maze.getPacmanDeathTime()) { //pacman is alive pacman.draw(); } else particles.draw(); mazeFloor.draw(); ghosts.draw(); hud.draw(winW, winH, &maze); glFlush(); }
void ColoredCubeApp::drawScene() { D3DApp::drawScene(); // Restore default states, input layout and primitive topology // because mFont->DrawText changes them. Note that we can // restore the default states by passing null. md3dDevice->OMSetDepthStencilState(0, 0); float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f}; md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff); md3dDevice->IASetInputLayout(mVertexLayout); D3DXVECTOR3 pos(0.0f,45.0f,-50.0f); // set lighting shader variables mfxEyePosVar->SetRawValue(&pos, 0, sizeof(Vector3)); mfxLightVar->SetRawValue(&lights[0], 0, sizeof(Light)); mfxLightType->SetInt(lightType); // set some variables for the shader // set the point to the shader technique D3D10_TECHNIQUE_DESC techDesc; mTech->GetDesc(&techDesc); //setting the color flip variable in the shader //draw the floor floor.draw(mView, mProj, mfxWVPVar, mfxWorldVar, mTech); ////// New Stuff added by Steve ////// mWVP = player.getWorldMatrix() *mView*mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&player.getWorldMatrix()); player.setMTech(mTech); player.draw(); for (int i = 0; i < numberOfObstacles; i++) { mWVP = obstacles[i].getWorldMatrix() * mView * mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&obstacles[i].getWorldMatrix()); obstacles[i].setMTech(mTech); obstacles[i].draw(); } //Spectrum HUD for(int i = 0; i < 6; i++) { D3DXMATRIX a; D3DXMatrixRotationY(&a, 1.573f); mWVP = a * spectrum[i].getWorldMatrix() * mView * mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&spectrum[i].getWorldMatrix()); spectrum[i].setMTech(mTech); spectrum[i].draw(); } mWVP = cursor.getWorldMatrix() * mView * mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&cursor.getWorldMatrix()); cursor.setMTech(mTech); cursor.draw(); ////////////////////////////////////// /////Text Drawing Section // We specify DT_NOCLIP, so we do not care about width/height of the rect. RECT R = {5, 5, 0, 0}; RECT R1 = {0, 0, 800, 600}; RECT R2 = {0, 540, 800, 600}; std::wostringstream outs; outs.precision(6); string Hud = score.getString(); /*outs << score.getString() << L"\n"; outs << L"Blobs Available: " << ammo << L"\n"; outs << L"Gallons Left: " << lives; std::wstring text = outs.str(); mFont->DrawText(0, text.c_str(), -1, &R, DT_NOCLIP, BLACK);*/ timesNew.draw(Hud, Vector2(5, 5)); if (gameOver) { mFont->DrawText(0, L"Game Over!", -1, &R1, DT_CENTER | DT_VCENTER, BLACK); } float gameTime = mTimer.getGameTime(); if (gameTime < 3.0f) { mFont->DrawText(0, L"Move your Box LEFT and RIGHT with A & D to avoid hitting the obstacles", -1, &R2, DT_CENTER | DT_VCENTER, BLACK); } else if (gameTime < 6.0f) { mFont->DrawText(0, L"Change the color of your Box by pressing the J and L keys.", -1, &R2, DT_CENTER | DT_VCENTER, BLACK); } else if (gameTime < 9.0f) { mFont->DrawText(0, L"The closer the color of your cube is to the floor, the higher the score multiplier!", -1, &R2, DT_CENTER | DT_VCENTER, BLACK); } if (activeMessage) { mFont->DrawText(0, message.c_str(), -1, &R2, DT_CENTER | DT_VCENTER, BLACK); } mSwapChain->Present(0, 0); }