1 // Computergraphik I
2 // Prof. Dr. Juergen Doellner
3 // Sommersemester 2001
4 //
5 // Rahmenprogramm fuer Aufgabenzettel 8
6
7 #include "attribute.h"
8
9 #include <iostream.h>
10 #include <GL/glut.h>
11
12 //
13 // Hilfsfunktionen
14 //
15
16 static inline double clamp(double min, double max, double value) {
17 return (value < min) ? min : ((value > max) ? max : value);
18 }
19
20 //
21 // Color
22 //
23
24 Color::Color(double red, double green, double blue) {
25 color_[0] = clamp(0.0, 1.0, red);
26 color_[1] = clamp(0.0, 1.0, green);
27 color_[2] = clamp(0.0, 1.0, blue);
28 }
29
30 void Color::set() {
31 glPushAttrib(GL_CURRENT_BIT); // Merke u.a. die aktuelle Farbe
32 glColor3dv(color_); // Setze neue Farbe
33 }
34
35 void Color::unset() {
36 glPopAttrib(); // Restauriere die gemerkte Farbe
37 }
38
39 //
40 // Style
41 //
42
43 Style::Style(FaceStyle frontFace, FaceStyle backFace)
44 : frontFace_(frontFace), backFace_(backFace) {
45 }
46
47 void Style::set() {
48 // Hinweis: siehe GL_POLYGON_BIT und glPolygonMode()
49 cerr << "Style::set() not yet implemented!" << endl;
50 }
51
52 void Style::unset() {
53 cerr << "Style::unset() not yet implemented!" << endl;
54 }
55
56