//initialise the display settings void myInit() { createMesh(); generateWinterMesh(); generateFallMesh(); generateSummerMesh(); generateSpringMesh(); produceTrees_spring(); produceTrees_summer(); produceTrees_autumn(); produceTrees_winter(); generateCloud(); drawTrees(); GLfloat lightIntensity[] = { 0.8, 0.8, 0.8, 1.0f}; GLfloat lightIntensity2[] = { 0.8, 0.8, 0.8, 1.0f }; GLfloat lightPosition[] = {0.0f, 1.0f, 0.0f, 0.0f}; GLfloat lightPosition2[] = { 0.0f, -1.0f, 0.0f, 0.0f }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glLightfv(GL_LIGHT0, GL_AMBIENT, lightIntensity); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2); glLightfv(GL_LIGHT1, GL_AMBIENT, lightIntensity2); Point3 eye, look; Vector3 up; eye.set(1,1,1); //set the eye location look.set(0,0,0); //set the look at coord up.set(0,1,0); //specify the up vector cam.set(eye, look, up); // make the initial camera cam.slide(0,0, 1.5); cam.setShape(30.0f, 1.0f, 0.5f, 50.0f); }
void Map::Draw() { _d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, COLOR_GREY, 1.0f, 0); drawRightMenu(); drawMap(); drawEagle(); BulletManager::getInstance()->Draw(); drawIce(); drawPlayer(); drawEnemy(); drawTrees(); drawPowerUp(); EffectManager::getInstance(0)->Draw(); if (_player->getLife() < 0 || _eagle->getEagleStatus() == EAGLE_STATUS::DEAD) { _text->drawText("GAME\nOVER", _posGameOverText, COLOR_RED, 30, DT_CENTER, 0, 2); } }
void display () { if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); enter3D(); gluLookAt(camera.x, camera.y, camera.z, cameraLookAt.x, cameraLookAt.y, cameraLookAt.z, cameraUp.x, cameraUp.y, cameraUp.z); glPushMatrix(); glScaled(1.0, -1.0, 1.0); if (showSky) { drawSky(); } // Draw coordinate axis // glCallList(axisList); for (int i = 0; i < 9; i ++) { gravitationalForce[i].draw(); } if (showGround) { drawGround(); } if (showPipe) { glPushMatrix(); drawSprinkler(emitterSpacing * emitterCount, sprinkerHeight, 100, 5.0, 40.0); glPopMatrix(); } if (showMountains) { drawMoutains(3000, 0, 0); drawMoutains(4000, 180, -200); drawMoutains(5600, 45, -500); } if (showTrees) { drawTrees(); } if (renderMode == PARTICLERENDERMODE_TEXTURESPRITE) { Texture::set("shine"); glBlendFunc(GL_SRC_ALPHA, GL_ONE); } particleSystem.draw(); if (renderMode == PARTICLERENDERMODE_TEXTURESPRITE) { Texture::done(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } /*glPushMatrix(); glColor3f(1.0, 1.0, 1.0); glTranslatef(0.0, -100.0, 0.0); glScalef(100.0, -100.0, 100.0); drawModel(); glPopMatrix();*/ if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } glDisable(GL_DEPTH_TEST); enter2D(); glColor4d(0.0, 0.0, 0.0, 1.0); sprintf(fpsText, "FPS:%4.2f", fps); drawText(GLUT_BITMAP_HELVETICA_18, windowWidth - 100, 20, fpsText); if (showHUD) { drawText(GLUT_BITMAP_HELVETICA_18, 10, 20, "Water sprinkler"); sprintf(cameraText, "%4.2f %4.2f %4.2f", camera.x, camera.y, camera.z); drawText(GLUT_BITMAP_HELVETICA_12, 10, 60, cameraText); sprintf(particleText, "Particles: %llu", particleSystem.getParticleCount()); drawText(GLUT_BITMAP_HELVETICA_12, 10, 100, particleText); if (menu) { // Current option glColor4d(0.2, 0.2, 0.2, 0.8); glRectd(10, windowHeight - 40, 120, windowHeight - 10); glColor4d(1.0, 1.0, 1.0, 1.0); drawText(GLUT_BITMAP_HELVETICA_12, 20, windowHeight - 20, options[currentOption]); // Current option value glColor4d(0.4, 0.4, 0.4, 0.8); glRectd(120, windowHeight - 40, 240, windowHeight - 10); glColor4d(1.0, 1.0, 1.0, 1.0); switch (currentOption) { case 0: sprintf(optionValue, "%4.2f", Particle::initialVelocity); break; case 1: sprintf(optionValue, "%d", initialColour); break; case 2: sprintf(optionValue, "%d", gravityIntensity); break; case 3: sprintf(optionValue, "%d", Particle::startLifeSpan); break; case 4: sprintf(optionValue, "%s", renderModes[renderMode]); break; case 5: sprintf(optionValue, "%d", emitterCount); break; case 6: sprintf(optionValue, "%d", emitterSpacing); break; case 7: sprintf(optionValue, "%s", cameras[currentCamera]); break; case 8: sprintf(optionValue, "%4.2f", Particle::airResistance); break; case 9: sprintf(optionValue, "%s", cycleColours ? "On" : "Off"); break; case 10: sprintf(optionValue, "%d", emitFrequency); break; case 11: sprintf(optionValue, "%4.2f", ParticleEmitter::emitSpread); break; case 12: sprintf(optionValue, "%d", ParticleSystem::perEmit); break; case 13: sprintf(optionValue, "%s", ParticleEmitter::show ? "Yes" : "No"); break; case 14: sprintf(optionValue, "%s", wireframe ? "Yes" : "No"); break; case 15: sprintf(optionValue, "%s", showMountains ? "On" : "Off"); break; case 16: sprintf(optionValue, "%s", showTrees ? "On" : "Off"); break; case 17: sprintf(optionValue, "%s", showSky ? "On" : "Off"); break; case 18: sprintf(optionValue, "%s", showGround ? "On" : "Off"); break; case 19: sprintf(optionValue, "%s", demos[demo]->name.c_str()); break; case 20: sprintf(optionValue, "%1.1f", Particle::bounce); break; case 21: sprintf(optionValue, "%s", skyTexture ? "On" : "Off"); break; case 22: sprintf(optionValue, "%s", grassTexture ? "On" : "Off"); break; case 23: sprintf(optionValue, "%s", showPipe ? "On" : "Off"); break; case 24: sprintf(optionValue, "%s", ParticleEmitter::randomness ? "On" : "Off"); break; case 25: sprintf(optionValue, "%s", Tree::drawLeaves ? "On" : "Off"); break; default: sprintf(optionValue, "%s", ""); break; } drawText(GLUT_BITMAP_HELVETICA_12, 130, windowHeight - 20, optionValue); } else { glColor4d(1.0, 1.0, 1.0, 1.0); drawText(GLUT_BITMAP_HELVETICA_12, 20, windowHeight - 20, "Press m to toggle menu"); } for (int i = 1; i < 10; i++) { if (selectedGravitationalForce == i - 1) { glColor4d(1.0, 0.4, 0.4, 0.8); } else { glColor4d(0.4, 0.4, 1.0, 0.2); } glRectd(200 + ((i - 1) * 50), 10, 230 + ((i - 1) * 50), 40); glColor4d(0.0, 0.0, 0.0, 1.0); sprintf(n, "%d", i); drawText(GLUT_BITMAP_HELVETICA_18, 210 + ((i - 1) * 50), 30, n); } } if (currentCamera == 3) { glBegin(GL_LINES); glColor3d(0.8, 0.8, 0.8); glVertex2d((windowWidth / 2) - 30, windowHeight / 2); glVertex2d((windowWidth / 2) + 30, windowHeight / 2); glVertex2d(windowWidth / 2, (windowHeight / 2) - 30); glVertex2d(windowWidth / 2, (windowHeight / 2) + 30); glEnd(); } glPopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void renderScene(void) { mainPlane.manageHealth(); //GLfloat lightpos[] = {-x,-z,-y}; //glTranslatef(lightpos[0], lightpos[1], lightpos[2]); glColor3f(1, 1, 1); //glutSolidSphere(30, 20, 20); //glTranslatef(-lightpos[0], -lightpos[1], -lightpos[2]); //glLightfv(GL_LIGHT0, GL_POSITION, lightpos); if (deltaMove) moveMeFlat(deltaMove); if (deltaAngle) { angle += deltaAngle; orientMe(angle); //rotateMe(angle); } if (rotationAngleDelta) { rotationAngle+=rotationAngleDelta; rotationAngleDelta=0; rotateMe(rotationAngle); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw ground glPushMatrix(); //glLoadIdentity(); //glTranslatef(x, y, z); //glRotatef(rotationAngle+90, 0, 1, 0); explosives.drawExplosions(); //glTranslatef(-x, -y, -z); glPopMatrix(); float minX=200000,maxX=0,minY=20000,maxY=0; glBegin(GL_QUADS); for (int i = 20; i <tiles.size()-20; i++) { for (int j = 20; j <tiles.size()-20; j++) { if(tiles[i][j].xMax>maxX) maxX = tiles[i][j].xMax; if(tiles[i][j].yMax>maxY) maxY = tiles[i][j].yMax; if(tiles[i][j].x<minX) minX = tiles[i][j].x; if(tiles[i][j].y<minY) minY = tiles[i][j].y; if (tiles[i][j].z>-.7) { tiles[i][j].drawTile(); } } } drawWater(maxX*40,maxY*40,minX*40,minY*40); glEnd(); drawTrees(); drawBuildings(); advanceLevel(); drawPlane(); //drawSilos(); drawCarrierGroup(); calculateFPS(); glutSwapBuffers(); //std::cout<<"hello"; indexer++; if (loadBuildings) { loadBuildings = 0; cDetector.buildings = &buildings; } cDetector.detectCollisions(); //glLoadIdentity(); }