-
Notifications
You must be signed in to change notification settings - Fork 0
/
Food.cpp
25 lines (23 loc) · 967 Bytes
/
Food.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "Food.h"
#include <gl/glut.h>
#include "utils.h"
void Food::draw() {
// Âèçíà÷åííÿ âëàñòèâîñòåé ìàòåð³àëó :
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, getAmbiColor());
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, getDiffColor());
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, getSpecColor());
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, GraphUtils::shininess);
// Çàïèñ ïîòî÷íî¿ ìàòðèö³ â ñòåê
// (çáåðåæåííÿ âì³ñòó ïîòî÷íî¿ ìàòðèö³ äëÿ ïîäàëüøîãî âèêîðèñòàííÿ):
glPushMatrix();
glTranslatef(getXCenter(), getYCenter() + getYSize() / 2, getZCenter());
// Öèë³íäð ïîâèíåí áóòè ðîçòàøîâàíèé ó âåðòèêàëüíîìó íàïðÿìêó:
glRotatef(90, 1, 0, 0);
glutSolidCube(side);
// Äèñê ïîâèíåí áóòè íàìàëüîâàíèé çîâí³øíüîþ ãðàííþ äîãîðè:
glRotatef(180, 1, 0, 0);
// Ìàëþºìî äèñê çâåðõó:
glTranslatef(0, 0, -getYSize());
// ³äíîâëåííÿ ïîòî÷íî¿ ìàòðèö³ ç³ ñòåêà:
glPopMatrix();
}