void display() { glClear(GL_COLOR_BUFFER_BIT); drawLine(0,0,540,540, 40, 40, 40); rotateHouse(); drawPlanet(380, 380, 70, 0, 100, 255); //земля drawPlanet(540, 540, 20, 127, 127, 127); //луна drawPlanet(-99, -99, 400, 255, 255, 0); //солнце drawStar(30, 500); drawStar(240, 400); drawStar(350, 680); drawStar(400, 600); drawStar(580, 100); drawStar(600, 300); glFlush(); glFinish(); }
void processList() { for(jrPlanet *pPlanet=g_pHead; pPlanet; pPlanet=pPlanet->m_pNext) { drawPlanet(pPlanet); } if (g_pFollowing != 0) { camInputFly(g_Input, true); followPlanet(g_pFollowing); } }
void display(void) { int i=0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawText(); glCallList(textList); glPushMatrix(); glTranslatef(xx, yy, -zoom); glRotatef(rotx, 1.0, 0.0, 0.0); glRotatef(roty, 0.0, 1.0, 0.0); glRotatef(rotz, 0.0, 0.0, 1.0); GLfloat ambient1[] = {0.15f, 0.15f, 0.15f, 1.0f}; GLfloat diffuse1[] = {0.8f, 0.8f, 0.8f, 1.0f}; GLfloat specular1[] = {1.0f, 1.0f, 1.0f, 1.0f}; GLfloat position1[] = {0.0f, 0.0f, 20.0f, 1.0f}; glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1); glLightfv(GL_LIGHT1, GL_DIFFUSE, specular1); glLightfv(GL_LIGHT1, GL_POSITION, position1); glEnable(GL_LIGHT1); if (axe) { drawAxes(); } for (i=0; i<sampleSize; i++) { if (planetsList[i].displayed) { drawPlanet(planetsList[i], i); } if (trace) { if (planetsList[i].selected) { drawPath(planetsList[i]); } } if (allTraces) { drawPath(planetsList[i]); } } glPopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset transformations glLoadIdentity(); // look at the origin spot (0,0,0) from camera position, moved by mouse gluLookAt( startX+deltaX, startY+deltaY, startZ+deltaZ, //camera pos 0.0, 0.0, 0.0, //looking at 0.0, 1.0, 0.0); //up orientation // draw model elements (stars and planet) drawStar(&universe); drawStar(&sun); drawPlanet(&p1); drawPlanet(&p2); drawPlanet(&p3); drawPlanet(&p4); drawPlanet(&p5); drawPlanet(&p6); drawPlanet(&p7); drawPlanet(&p8); // draw time char time[10000]; int int_hours = (int)(hours); int int_days = int_hours/24; int int_years = int_days/365; sprintf(time, "Time:\tY-%d\tD-%d\tH-%d", int_years, int_days%365, int_hours%24); draw2DText(1.0,GLUT_WINDOW_HEIGHT*1.89, time); // draw legend char legend[10000]; sprintf(legend, "\"ESC\" for exit, \"t\" for planet label, \"s\" for step animation, \"r\" for running animation, Mouse moves camera (wheel or ctrl | shift | alt for zoom) "); draw2DText(1.0, 1.0, legend); glFlush(); glutSwapBuffers(); }
virtual void draw() { drawLight(); drawPlanet(); drawStar(); }
// RENDERING DEL SISTEMA SOLARE void solarScene(void){ // ogni volta che disegno incremento il numero dei frame g_frames++; // Do all your OpenGL rendering here // cancelliamo il buffer video e lo z buffer glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* ------------------------------------------------------------------------- */ // attiva il viewport principale glViewport( 0, 0, width, height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); g_camera.look(); // chiama la gluLookAt con i parametri opportuni // posizionando la luce dopo la telecamera la luce risulta fissa nel mondo glLightfv(GL_LIGHT0, GL_POSITION, g_light0_pos); glLightfv(GL_LIGHT1, GL_POSITION, g_light1_pos); glLightfv(GL_LIGHT2, GL_POSITION, g_light2_pos); glDisable(GL_CULL_FACE); // texture dello sfondo { GLUquadric* a = gluNewQuadric(); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_TEXTURE_2D); Point3 poscam = g_camera.getPos(); glPushMatrix(); glTranslatef(poscam.x, poscam.y, poscam.z); gluQuadricOrientation(a, GLU_INSIDE); glBindTexture(GL_TEXTURE_2D, g_textureSfondo[0]); gluQuadricTexture(a, GL_TRUE); gluSphere(a, 900, 24, 24); glPopMatrix(); glDisable(GL_TEXTURE_2D); glPopAttrib(); } glEnable(GL_CULL_FACE); /* PIANETI */ drawPlanet(posPlanet[0], radius[0], g_texturePlanet[0]); // mercury drawPlanet(posPlanet[1], radius[1], g_texturePlanet[1]); // venus drawPlanet(posPlanet[2], radius[2], g_texturePlanet[2]); // earth drawPlanet(posPlanet[3], radius[3], g_texturePlanet[3]); // mars drawPlanet(posPlanet[4], radius[4], g_texturePlanet[4]); // jupiter drawPlanet(posPlanet[5], radius[5], g_texturePlanet[5]); // saturn drawPlanet(posPlanet[6], radius[6], g_texturePlanet[6]); // uranus drawPlanet(posPlanet[7], radius[7], g_texturePlanet[7]); // neptune drawPlanet(posPlanet[8], radius[8], g_texturePlanet[8]); // pluto /* SATELLITI */ drawSatellite(&satellite[0], 'y', 0.00012, g_textureSatellite[0]); // moon //drawShield(satellite[0].pos, satellite[0].rad+1); drawSatellite(&satellite[1], 'z', 0.00024, g_textureSatellite[1]); // io drawSatellite(&satellite[2], 'y', 0.00012, g_textureSatellite[2]); // europa /* ANELLI DI SATURNO */ drawRing(posPlanet[5], 85, 120); // anello saturno // HENRY // gestione dei nemici: posizione, movimenti, inseguimenti // FILE: enemy_police.c insertEnemy(); insertPolice(); //ALBERTO // disegno di tutte le collisioni se attivate // FILE explosion.c insertExplosion(); //ALBERTO LASER // disegno di tutti i laser e controllo collisioni // FILE shooting.c hitEnemy=laserHitEnemy(); hitPolice=laserHitPolice(); insertRemoveLaser(); // se siamo stati colpiti dal laser nemico si decrementa la vita shooted(); // inseriamo il super-sparo insertSuperShoot(); glPopMatrix(); }
int main(int argc, char *argv[]) { chdir("/Users/tjgreen/Documents/OpenGL/Sol"); GLFWwindow *window = setupGLFW(); GLuint skyboxTexture = initCubemap(); //GLFWwindow* window2 = glfwCreateWindow(500, 500, "SolarSystem", NULL, NULL); //glfwMakeContextCurrent(window2); /*Cross platform compatibility stuff uncomment if not on mac GLenum err = glewInit(); if (GLEW_OK != err) { printf(stderr, "Error: %s\n", glewGetErrorString(err)); }*/ sunTexture = loadTexture("include/textures/Planets/sun2.jpg"); sunNormal = loadTexture("include/textures/Planets/sunNormal.png"); planetBuilder(); init(); createPerspectiveMatrix(); initializePlanetButtons(); glEnable(GL_CULL_FACE); glEnable(GL_MULTISAMPLE); glCullFace(GL_BACK); attachGUIShaders(); float fpsFrames= 0; float lastTime = 0; while(!glfwWindowShouldClose(window)) { GLfloat currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; fpsFrames++; if(currentFrame - lastTime >= 1.0) { //printf("%f\n", 1000/fpsFrames); fpsFrames = 0; lastTime += 1.0; } glfwPollEvents(); doMovement(); glfwPollEvents(); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, WIDTH, HEIGHT); drawSkybox(skyboxTexture); drawSun(); drawPlanet(); //glFrontFace(GL_CW); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); drawAtmosphere(); glDisable(GL_BLEND); //glFrontFace(GL_CCW); drawObj(); drawMoon(); //drawButton(button1); //drawPlanetButtons(); if(stopRotation == 0){ for(int i = 0; i < 11; i++) { orbitSpeedArray[i] += 0.1/planetInstanceArray[i].orbit; } for(int i = 0; i < 11; i++) { rotationSpeedArray[i] += 0.1/planetInstanceArray[i].day; } thetaY += 0.1; } glfwSwapBuffers(window); } glDeleteVertexArrays(1, &planetVAO); glDeleteBuffers(1, &planetVBO); glfwTerminate(); return 0; }