]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/BoxSetGL.cxx
Removed ';' from ClassImp pragmas.
[u/mrichter/AliRoot.git] / EVE / Reve / BoxSetGL.cxx
1 // $Header$
2
3 #include "BoxSetGL.h"
4 #include <Reve/BoxSet.h>
5
6 #include <TGLDrawFlags.h>
7 #ifdef WIN32
8 #include "Windows4root.h"
9 #endif
10 #include <GL/gl.h>
11 #include <GL/glu.h>
12
13 using namespace Reve;
14
15 //______________________________________________________________________
16 // BoxSetGL
17 //
18
19 ClassImp(BoxSetGL)
20
21 BoxSetGL::BoxSetGL()
22 {
23   // fCached = false; // Disable display list.
24 }
25
26 BoxSetGL::~BoxSetGL()
27 {}
28
29 /**************************************************************************/
30
31 Bool_t BoxSetGL::SetModel(TObject* obj)
32 {
33   return set_model(obj, "Reve::BoxSet");
34 }
35
36 void BoxSetGL::SetBBox()
37 {
38   set_axis_aligned_bbox(((BoxSet*)fExternalObj)->AssertBBox());
39 }
40
41 /**************************************************************************/
42
43 void BoxSetGL::DirectDraw(const TGLDrawFlags& /*flags*/) const
44 {
45   BoxSet& mB = * (BoxSet*) fExternalObj;
46   // printf("BoxSetGL::DirectDraw N boxes %d\n", mB.fBoxes.size());
47
48   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
49   glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
50   glEnable(GL_COLOR_MATERIAL);
51   glDisable(GL_CULL_FACE);
52
53   Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
54
55   glBegin(GL_QUADS);
56   for(std::vector<Box>::iterator q=mB.fBoxes.begin(); q!=mB.fBoxes.end(); ++q) {
57     UChar_t* c = (UChar_t*) &q->color;
58     glColor3ub(c[0], c[1], c[2]);
59
60     // bottom: 3210
61     glNormal3f(0, 0, -1);
62     glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices + 6);
63     glVertex3fv(q->vertices + 3);  glVertex3fv(q->vertices);
64     // top:   4567
65     glNormal3f(0, 0, 1);
66     glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 15);
67     glVertex3fv(q->vertices + 18); glVertex3fv(q->vertices + 21);
68     // front: 0154
69     glNormal3f(0, -1, 0);
70     glVertex3fv(q->vertices);      glVertex3fv(q->vertices + 3);
71     glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 12);
72     // back:  7623
73     glNormal3f(0, 1, 0);
74     glVertex3fv(q->vertices + 21); glVertex3fv(q->vertices + 18);
75     glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 9);
76     // left:  4730
77     glNormal3f(-1, 0, 0);
78     glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 21);
79     glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices);
80     // right: 5126
81     glNormal3f(1, 0, 0);
82     glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 3);
83     glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 18);
84   }
85   glEnd();
86
87   glPopAttrib();
88 }