void onDisplay( ) { glClearColor(0.6f, 0.6f, 1.0f, 1.0f); // torlesi szin beallitasa glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // kepernyo torles glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (float)screenWidth / (float)screenHeight, 1.0, 200.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(heliPos.x,heliPos.y+8,heliPos.z+16, heliPos.x,heliPos.y,heliPos.z, 0,1,-0.5); float ambientColor[] = {0.5f, 0.5f, 0.5f, 1.0f}; float lightColor0[] = {1.0f, 1.0f, 1.0f, 1.0f}; float lightPos0[] = {0.0f, 20.0f, 20.0f, 0.0f}; glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); glLightfv(GL_LIGHT0, GL_SPECULAR, lightColor0); glLightfv(GL_LIGHT0, GL_POSITION, lightPos0); drawLand(); glPushMatrix(); glTranslatef(0.0f,-10.0f,-40.0f); drawBuilding(2.0f); glPopMatrix(); glPushMatrix(); glTranslatef(10.0f,-10.0f,-40.0f); drawBuilding(2.0f); glPopMatrix(); glPushMatrix(); glTranslatef(-5.0f,-10.0f,-60.0f); drawBuilding(2.0f); glPopMatrix(); glPushMatrix(); glTranslatef(10.0f,-10.0f,-60.0f); drawBuilding(2.0f); glPopMatrix(); glPushMatrix(); glTranslatef(10.0f,-10.0f,-25.0f); drawBuilding(2.0f); glPopMatrix(); glPushMatrix(); glTranslatef(-10.0f,-10.0f,-25.0f); drawBuilding(2.0f); glPopMatrix(); drawQuaternion(); drawHelicopter(); glutSwapBuffers(); // Buffercsere: rajzolas vege }
void graphics_display(building_st* buildArr, int selX, int selY, inventory_st* inv) { werase(win); for (int i = 0; i < GRID_SIZE_X; i++){ for (int j = 0; j < GRID_SIZE_Y; j++){ int index = (i*GRID_SIZE_Y)+j; if(buildArr[index].exist) drawBuilding(&(buildArr[index])); } } mvwprintw(win, 1+selY*(GRID_SCALE_Y), 1+(selX*GRID_SCALE_X), "*"); wrefresh(win); //TODO: if updated inv included in entity list update tempInv tempInv = inv; displayInventory(); }
void redraw() { glClear(GL_COLOR_BUFFER_BIT); glLineWidth(3.0); glColor3f(0.7, 0.7, 0.7); for( int i=0; i<numBuildings; i++ ) drawBuilding( &(buildings[i]) ); glColor3f(0.7, 0.7, 0.7); glBegin(GL_LINE_STRIP); glVertex2i( 50, GROUND ); glVertex2i( 950, GROUND ); glEnd(); drawSkyline( &skyline ); glFlush(); }
void display(){ //clear the display glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(BLACK, 0); //color black glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /******************** / set-up camera here ********************/ //load the correct matrix -- MODEL-VIEW matrix glMatrixMode(GL_MODELVIEW); //initialize the matrix glLoadIdentity(); //now give three info //1. where is the camera (viewer)? //2. where is the camera is looking? //3. Which direction is the camera's UP direction? //instead of CONSTANT information, we will define a circular path. gluLookAt(200*cos(cameraAngle), 200*sin(cameraAngle), 150, 0,0,0, 0,0,1); //NOTE: the camera still CONSTANTLY looks at the center // cameraAngle is in RADIAN, since you are using inside COS and SIN //again select MODEL-VIEW glMatrixMode(GL_MODELVIEW); /**************************** / Add your objects from here ****************************/ //border glColor3f(1,1,1); glBegin(GL_LINES);{ glVertex3f(-100, -100, 0); glVertex3f(-100, 100, 0); glVertex3f(-100, 100, 0); glVertex3f(100, 100, 0); glVertex3f(100, 100, 0); glVertex3f(100, -100, 0); glVertex3f(100, -100, 0); glVertex3f(-100, -100, 0); }glEnd(); //roads glColor3f(1,1,1); glBegin(GL_QUADS);{ glVertex3f(-100,-20,0); glVertex3f(-100,20,0); glVertex3f(100,20,0); glVertex3f(100,-20,0); }glEnd(); glColor3f(1,1,1); glBegin(GL_QUADS);{ glVertex3f(-20,100,0); glVertex3f(20,100,0); glVertex3f(20,-100,0); glVertex3f(-20,-100,0); }glEnd(); //moving car pos1 += .1; if(pos1>180) pos1 = 0; car1(pos1); pos2 += .05; if(pos2>180) pos2 = 0; car2(pos2); pos3 += .075; if(pos3>180) pos3 = 0; car3(pos3); //top left buildings 1st row drawBuilding(-90, -90, -90, -70, 50); drawBuilding(-90, -60, -90, -40, 30); //top left buildings 2nd row drawBuilding(-60, -90, -60, -70, 60); drawBuilding(-55, -60, -55, -40, 40); //top right buildings 1st row drawBuilding(-90, 90, -90, 70, 70); drawBuilding(-90, 60, -90, 40, 50); //top right buildings 2nd row drawBuilding(-60, 90, -60, 75, 80); drawBuilding(-60, 70, -60, 35, 45); //middle left buildings drawBuilding(40, -90, 40, -70, 40); drawBuilding(40, -60, 40, -40, 50); //middle right buildings drawBuilding(30, 90, 30, 70, 30); drawBuilding(30, 60, 30, 40, 50); //bottom left buildings drawBuilding(70, -90, 70, -70, 30); drawBuilding(75, -60, 75, -40, 30); //bottom right buildings drawBuilding(70, 90, 70, 70, 90); drawBuilding(70, 65, 70, 40, 30); //ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE) glutSwapBuffers(); }