This commit was generated by cvs2svn to compensate for changes in r13732,
[u/mrichter/AliRoot.git] / EVE / Reve / QuadSetGL.cxx
1 // $Header$
2
3 #include "QuadSetGL.h"
4 #include <Reve/QuadSet.h>
5
6 #include <TGLDrawFlags.h>
7
8 #include <GL/gl.h>
9 #include <GL/glu.h>
10
11 using namespace Reve;
12
13 //______________________________________________________________________
14 // QuadSetGL
15 //
16
17 ClassImp(QuadSetGL)
18
19 /**************************************************************************/
20
21 QuadSetGL::QuadSetGL() : TGLObject()
22 {
23   // fCached = false; // Disable DL.
24 }
25
26 QuadSetGL::~QuadSetGL()
27 {}
28
29 /**************************************************************************/
30
31 Bool_t QuadSetGL::SetModel(TObject* obj)
32 {
33   return set_model(obj, "Reve::QuadSet");
34 }
35
36 void QuadSetGL::SetBBox()
37 {
38   set_axis_aligned_bbox(((QuadSet*)fExternalObj)->AssertBBox());
39 }
40
41 /**************************************************************************/
42
43 void QuadSetGL::DirectDraw(const TGLDrawFlags & ) const
44 {
45   // printf("QuadSetGLRenderer::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
46
47   QuadSet& Q = * (QuadSet*) fExternalObj;
48
49   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
50
51   glDisable(GL_LIGHTING);
52   glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
53   glEnable(GL_COLOR_MATERIAL);
54   glPolygonMode(GL_FRONT, GL_LINE);
55   glPolygonMode(GL_BACK,  GL_LINE);
56   glDisable(GL_CULL_FACE);
57
58   Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
59   //  UChar_t alpha = (UChar_t)(255*c[3]);
60
61   glBegin(GL_QUADS);
62   for(std::vector<Quad>::iterator q=Q.fQuads.begin(); q!=Q.fQuads.end(); ++q) {
63     UChar_t* c = (UChar_t*) &q->color;
64     //glColor4ub(c[0], c[1], c[2], (c[3]*alpha) >> 8);
65     glColor3ub(c[0], c[1], c[2]);
66     glVertex3fv(q->vertices);
67     glVertex3fv(q->vertices + 3);
68     glVertex3fv(q->vertices + 6);
69     glVertex3fv(q->vertices + 9);
70   }
71   glEnd();
72
73   glPopAttrib();
74 }