void display(void) { GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat sun_ambient[] = { 1.0, 1.0, 0.0, 1.0 }; GLfloat mat_ambient_color[] = { 0.8, 0.8, 0.2, 1.0 }; GLfloat sun_diffuse[] = { 0.6, 0.6, 0.0, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat no_shininess[] = { 0.0 }; GLfloat low_shininess[] = { 5.0 }; GLfloat sun_shininess[] = { 70.0 }; GLfloat sun_emission[] = {0.3, 0.3, 0.0, 0.0}; GLfloat mercury_ambient[] = { 0.6, 0.1, 0.0, 1.0 }; GLfloat mercury_diffuse[] = { 0.6, 0.1, 0.0, 1.0 }; GLfloat mercury_shininess[] = { 30.0 }; GLfloat mercury_emission[] = {0.2, 0.2, 0.0, 0.0}; GLfloat venus_ambient[] = { 0.6, 0.3, 0.0, 1.0 }; GLfloat venus_diffuse[] = { 0.6, 0.3, 0.0, 1.0 }; GLfloat venus_shininess[] = { 30.0 }; GLfloat venus_emission[] = {0.2, 0.3, 0.0, 0.0}; GLfloat earth_ambient[] = { 0.2, 0.2, 0.55, 1.0 }; GLfloat earth_diffuse[] = { 0.2, 0.2, 0.55, 1.0 }; GLfloat earth_shininess[] = { 40.0 }; GLfloat earth_emission[] = {0.1, 0.1, 0.45, 0.0}; GLfloat mars_ambient[] = { 0.75, 0.2, 0.02, 1.0 }; GLfloat mars_diffuse[] = { 0.75, 0.2, 0.02, 1.0 }; GLfloat mars_shininess[] = { 30.0 }; GLfloat mars_emission[] = {0.3, 0.2, 0.0, 0.0}; GLfloat jupitor_ambient[] = { 0.9, 0.7, 0.3, 1.0 }; GLfloat jupitor_diffuse[] = { 0.9, 0.7, 0.3, 1.0 }; GLfloat jupitor_shininess[] = { 20.0 }; GLfloat jupitor_emission[] = {0.1, 0.1, 0.0, 0.0}; GLfloat saturn_ambient[] = { 0.6, 0.6, 0.4, 1.0 }; GLfloat saturn_diffuse[] = { 0.6, 0.6, 0.4, 1.0 }; GLfloat saturn_shininess[] = { 20.0 }; GLfloat saturn_emission[] = {0.2, 0.2, 0.0, 0.0}; GLfloat uranus_ambient[] = { 0.4, 0.6, 0.8, 1.0 }; GLfloat uranus_diffuse[] = { 0.4, 0.6, 0.8, 1.0 }; GLfloat uranus_shininess[] = { 20.0 }; GLfloat uranus_emission[] = {0.1, 0.2, 0.5, 0.0}; GLfloat neptune_ambient[] = { 0.4, 0.0, 0.6, 1.0 }; GLfloat neptune_diffuse[] = { 0.4, 0.0, 0.6, 1.0 }; GLfloat neptune_shininess[] = { 20.0 }; GLfloat neptune_emission[] = {0.1, 0.1, 0.2, 0.0}; GLfloat pluto_ambient[] = { 0.4, 0.1, 0.7, 1.0 }; GLfloat pluto_diffuse[] = { 0.4, 0.1, 0.7, 1.0 }; GLfloat pluto_shininess[] = { 20.0 }; GLfloat pluto_emission[] = {0.0, 0.2, 0.3, 0.0}; if (deltaMove) computePos(deltaMove); if (deltaAngle) computeDir(deltaAngle); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); //glRotatef(5.0,1.0,0.0,0.0); glPushMatrix(); gluLookAt( x, 1.0f, z, x+lx, 1.0f, z+lz, 0.0f, 1.0f, 0.0f); glRotatef(rotateScene,1.0,0.0,0.0); if(flag==1) displayPath(); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, sun_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, sun_diffuse); //glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, sun_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, sun_emission); glBindTexture(GL_TEXTURE_2D, texture[0]); gluSphere(sun,1.5,20,20); //glutSolidSphere(1.5, 20, 20); /* draw sun */ glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) mercuryRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, mercury_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mercury_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS, mercury_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, mercury_emission); glTranslatef (2.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, texture[1]); gluSphere(mercury,.2,20,18); glPopMatrix(); if(mercuryRot>=360.0) mercuryRot=0.0; mercuryRot=mercuryRot+1.0 ; glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) venusRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, venus_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, venus_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS, venus_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, venus_emission); glTranslatef (4.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, texture[2]); gluSphere(venus,.4,20,18); glPopMatrix(); venusRot=venusRot+.800; if(venusRot>=360.0) venusRot=0.0; glPopMatrix(); glPushMatrix(); glRotatef(rotateAstroid,0.0,1.0,0.0); makeAstroidBelt(); rotateAstroid+=0.3; glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) earthRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, earth_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, earth_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,earth_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, earth_emission); glTranslatef (6.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, texture[3]); //earth gluSphere(earth,.5,20,18); earthRot=earthRot+.5; if(earthRot>=360.0) earthRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) marsRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, mars_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mars_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,mars_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, mars_emission); glTranslatef (8.0, 0.0, 0.0); //glutSolidSphere(0.65, 20, 18); //mars glBindTexture(GL_TEXTURE_2D, texture[4]); gluSphere(mars,.65,20,18); marsRot=marsRot+0.53; if(marsRot>=360.0) marsRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) jupitorRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glRotatef (90.0,1.0,0.0,0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, jupitor_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, jupitor_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,jupitor_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, jupitor_emission); glTranslatef (10.0, 0.0, 0.0); //glutSolidSphere(0.8, 20, 18); //jupiter glBindTexture(GL_TEXTURE_2D, texture[5]); gluSphere(jupiter,.9,20,18); jupitorRot=jupitorRot+0.084; if(jupitorRot>=360.0) jupitorRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) saturnRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, saturn_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, saturn_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,saturn_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, saturn_emission); glTranslatef (12.0, 0.0, 0.0); circle(0.0,0.0,0.0,0.9); circle(0.0,0.0,0.0,0.85); circle(0.0,0.0,0.0,0.95); circle(0.0,0.0,0.0,1.0); circle(0.0,0.0,0.0,1.05); circle(0.0,0.0,0.0,1.10); circle(0.0,0.0,0.0,1.15); //glutSolidSphere(0.7, 20, 18); //saturn glBindTexture(GL_TEXTURE_2D, texture[6]); gluSphere(saturn,.7,20,18); saturnRot= saturnRot+ 0.034; if(saturnRot>=360.0) saturnRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) uranusRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, uranus_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, uranus_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,uranus_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, uranus_emission); glTranslatef (14.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, texture[7]); gluSphere(uranus,.6,20,18); uranusRot=uranusRot+0.012; if(uranusRot>=360.0) uranusRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) neptuneRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, neptune_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, neptune_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,neptune_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, neptune_emission); glTranslatef (16.0, 0.0, 0.0); // glutSolidSphere(0.3, 20, 18); //neptune glBindTexture(GL_TEXTURE_2D, texture[8]); gluSphere(neptune,.3,20,18); neptuneRot=neptuneRot+0.007; if(neptuneRot>=360.0) neptuneRot=0.0; glPopMatrix(); glPopMatrix(); glPushMatrix(); glRotatef ((GLfloat) plutoRot, 0.0, 1.0, 0.0); glRotatef ((GLfloat) day, 0.0, 1.0, 0.0); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, pluto_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, pluto_diffuse); glMaterialfv(GL_FRONT, GL_SHININESS,pluto_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, pluto_emission); glTranslatef (18.0, 0.0, 0.0); //glutSolidSphere(0.3, 20, 18); //pluto glBindTexture(GL_TEXTURE_2D, texture[9]); gluSphere(pluto,.3,20,18); plutoRot=plutoRot+0.004; if(plutoRot>=360.0) plutoRot=0.0; glPopMatrix(); glPopMatrix(); glFlush(); glPopMatrix(); skyBox(); glutSwapBuffers(); }
int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//wyzerowanie bufora kolorow i glebokosci glBindFramebuffer(GL_FRAMEBUFFER, FBO->OutName());//tu zaczynam FBO glLoadIdentity(); //unsetShader(); float proba = yrota / (180 * 90); glPushMatrix(); glUseProgramObjectARB(0); glTranslated(0, -2, 0); glRotatef(xrota / 180, 0, 1 - proba, proba); glRotatef(yrota / 180, 1, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); skyBox(); ///---------------------------------------> glUseProgramObjectARB(p); if(LIGHTS) podstawowy_shader->Use(); //system("pause"); glPopMatrix(); glTranslatef(-25, -30, ze); glRotatef(xrota / 180, 0, 1 - proba, proba); glRotatef(yrota / 180, 1, 0, 0); static float r = 0; glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "lightPos"), 40 + 50 * sin(r += 0.01), 50, 150); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "mambient"), opcje[0], opcje[0], opcje[0]); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "mdiffuse"), opcje[1], opcje[1], opcje[1]); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "mspecular"), opcje[2], opcje[2], opcje[2]); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "lambient"), opcje[0], opcje[0], opcje[0]); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "ldiffuse"), opcje[1] * 2, opcje[1] * 2, opcje[1] * 2); glUniform3f(glGetUniformLocation(podstawowy_shader->Out(), "lspecular"), opcje[2] * 2, opcje[2] * 2, opcje[2] * 2); glUniform1f(glGetUniformLocation(podstawowy_shader->Out(), "shininess"), opcje[3] * 50); menu(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgramObjectARB(0); if (BLOOM) { glBindFramebuffer(GL_FRAMEBUFFER, pingpong->OutNamePong()[0]); bright_shader->Use(); } glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, FBO->OutColor()); glUniform1i(glGetUniformLocation(bright_shader->Out(), "texture"), 0); glUniform2f(glGetUniformLocation(bright_shader->Out(), "pixelSize"), 1.0 / width, 1.0 / height); glLoadIdentity(); glOrtho(-1, 1, -1, 1, 0, 1); glNormal3f(0.0, 0.0, 1.0); glBegin(GL_TRIANGLE_STRIP);//podobno wydajniej niz quad glNormal3f(0.0, 0.0, 1.0); glTexCoord2d(0, 0); glVertex3d(-1.885, -0.965, 2.25); glTexCoord2d(1, 0); glVertex3d(1.915, -0.965, 2.25); glTexCoord2d(0, 1); glVertex3d(-1.885, 1.035, 2.25); glTexCoord2d(1, 1); glVertex3d(1.915, 1.035, 2.25); glEnd(); glBindFramebuffer(GL_FRAMEBUFFER, 0); if (BLOOM) { blur_shader->Use(); GLuint amount = 6; GLboolean horizontal = false, first_iteration = true; glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, FBO->OutDepth()); glUniform1i(glGetUniformLocation(blur_shader->Out(), "depth"), 1); for (GLuint i = 0; i < amount; i++) { glBindFramebuffer(GL_FRAMEBUFFER, pingpong->OutNamePong()[horizontal]); glUniform1i(glGetUniformLocation(blur_shader->Out(), "horizontal"), horizontal); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, first_iteration ? pingpong->OutColorPong()[0] : pingpong->OutColorPong()[!horizontal]); glUniform1i(glGetUniformLocation(blur_shader->Out(), "texture"), 0); //RENDER HERE glLoadIdentity(); glOrtho(-1, 1, -1, 1, 0, 1); glNormal3f(0.0, 0.0, 1.0); glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0, 0.0, 1.0); glTexCoord2d(0, 0); glVertex3d(-1.885, -0.965, 2.25); glTexCoord2d(1, 0); glVertex3d(1.915, -0.965, 2.25); glTexCoord2d(0, 1); glVertex3d(-1.885, 1.035, 2.25); glTexCoord2d(1, 1); glVertex3d(1.915, 1.035, 2.25); glEnd(); //ENDRENDERINGUNG horizontal = !horizontal; if (first_iteration) first_iteration = false; } glBindFramebuffer(GL_FRAMEBUFFER, 0); } glLoadIdentity(); glOrtho(-1, 1, -1, 1, 0, 1); if(BLOOM) blend_shader->Use(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, pingpong->OutColorPong()[1]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, FBO->OutColor()); glUniform1i(glGetUniformLocation(blend_shader->Out(), "scene"), 0); glUniform1i(glGetUniformLocation(blend_shader->Out(), "bloomBlur"), 1); glNormal3f(0.0, 0.0, 1.0); glBegin(GL_TRIANGLE_STRIP);//podobno wydajniej niz quad glNormal3f(0.0, 0.0, 1.0); glTexCoord2d(0, 0); glVertex3d(-1.885, -0.965, 2.25); glTexCoord2d(1, 0); glVertex3d(1.915, -0.965, 2.25); glTexCoord2d(0, 1); glVertex3d(-1.885, 1.035, 2.25); glTexCoord2d(1, 1); glVertex3d(1.915, 1.035, 2.25); glEnd(); return 1; }