2 // "$Id: CubeView.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // CubeView class implementation for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
33 CubeView::CubeView(int x
,int y
,int w
,int h
,const char *l
)
34 : Fl_Gl_Window(x
,y
,w
,h
,l
)
36 CubeView::CubeView(int x
,int y
,int w
,int h
,const char *l
)
46 /* The cube definition. These are the vertices of a unit cube
47 * centered on the origin.*/
49 boxv0
[0] = -0.5; boxv0
[1] = -0.5; boxv0
[2] = -0.5;
50 boxv1
[0] = 0.5; boxv1
[1] = -0.5; boxv1
[2] = -0.5;
51 boxv2
[0] = 0.5; boxv2
[1] = 0.5; boxv2
[2] = -0.5;
52 boxv3
[0] = -0.5; boxv3
[1] = 0.5; boxv3
[2] = -0.5;
53 boxv4
[0] = -0.5; boxv4
[1] = -0.5; boxv4
[2] = 0.5;
54 boxv5
[0] = 0.5; boxv5
[1] = -0.5; boxv5
[2] = 0.5;
55 boxv6
[0] = 0.5; boxv6
[1] = 0.5; boxv6
[2] = 0.5;
56 boxv7
[0] = -0.5; boxv7
[1] = 0.5; boxv7
[2] = 0.5;
59 label("OpenGL is required for this demo to operate.");
60 align(FL_ALIGN_WRAP
| FL_ALIGN_INSIDE
);
65 void CubeView::drawCube() {
66 /* Draw a colored cube */
68 glShadeModel(GL_FLAT
);
71 glColor4f(0.0, 0.0, 1.0, ALPHA
);
77 glColor4f(1.0, 1.0, 0.0, ALPHA
);
83 glColor4f(0.0, 1.0, 1.0, ALPHA
);
89 glColor4f(1.0, 0.0, 0.0, ALPHA
);
95 glColor4f(1.0, 0.0, 1.0, ALPHA
);
101 glColor4f(0.0, 1.0, 0.0, ALPHA
);
108 glColor3f(1.0, 1.0, 1.0);
148 void CubeView::draw() {
151 glViewport(0,0,w(),h());
152 glOrtho(-10,10,-10,10,-20050,10000);
154 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
157 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
161 glTranslatef(xshift
, yshift
, 0);
162 glRotatef(hAng
,0,1,0); glRotatef(vAng
,1,0,0);
163 glScalef(float(size
),float(size
),float(size
));
172 // End of "$Id: CubeView.cxx 7903 2010-11-28 21:06:39Z matt $".