1977f13908
Donload the archive, unpack, start VisualC and press F5 to compile and run the demo and all other test programs... . browser: wouldn't find sample file CubeView: calls fluid in custom build step, unintialised position fast_slow: build calls fluid forms: added plastic buttons (cute) inactive: build calls fluid keyboard: build calls fluid, added mousewheel mandelbrot: build calls fluid resize: build calls fluid radio: build calls fluid shiny: build calls fluid tabs: build calls fluid valuators: build calls fluid, tiny scrollbar bug demo: debug on VC finds correct menu file git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1796 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
172 lines
4.3 KiB
C++
172 lines
4.3 KiB
C++
//
|
|
// "$Id: CubeView.cxx,v 1.4.2.4.2.1 2001/12/01 01:54:30 matthiaswm Exp $"
|
|
//
|
|
// CubeView class implementation for the Fast Light Tool Kit (FLTK).
|
|
//
|
|
// Copyright 1998-2001 by Bill Spitzak and others.
|
|
//
|
|
// This library is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU Library General Public
|
|
// License as published by the Free Software Foundation; either
|
|
// version 2 of the License, or (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// Library General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Library General Public
|
|
// License along with this library; if not, write to the Free Software
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
// USA.
|
|
//
|
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
|
//
|
|
|
|
#include "CubeView.h"
|
|
#include <math.h>
|
|
|
|
|
|
#if HAVE_GL
|
|
CubeView::CubeView(int x,int y,int w,int h,const char *l)
|
|
: Fl_Gl_Window(x,y,w,h,l)
|
|
#else
|
|
CubeView::CubeView(int x,int y,int w,int h,const char *l)
|
|
: Fl_Box(x,y,w,h,l)
|
|
#endif /* HAVE_GL */
|
|
{
|
|
vAng = 0.0;
|
|
hAng=0.0;
|
|
size=10.0;
|
|
xshift=0.0;
|
|
yshift=0.0;
|
|
|
|
/* The cube definition. These are the vertices of a unit cube
|
|
* centered on the origin.*/
|
|
|
|
boxv0[0] = -0.5; boxv0[1] = -0.5; boxv0[2] = -0.5;
|
|
boxv1[0] = 0.5; boxv1[1] = -0.5; boxv1[2] = -0.5;
|
|
boxv2[0] = 0.5; boxv2[1] = 0.5; boxv2[2] = -0.5;
|
|
boxv3[0] = -0.5; boxv3[1] = 0.5; boxv3[2] = -0.5;
|
|
boxv4[0] = -0.5; boxv4[1] = -0.5; boxv4[2] = 0.5;
|
|
boxv5[0] = 0.5; boxv5[1] = -0.5; boxv5[2] = 0.5;
|
|
boxv6[0] = 0.5; boxv6[1] = 0.5; boxv6[2] = 0.5;
|
|
boxv7[0] = -0.5; boxv7[1] = 0.5; boxv7[2] = 0.5;
|
|
|
|
#if !HAVE_GL
|
|
label("OpenGL is required for this demo to operate.");
|
|
align(FL_ALIGN_WRAP | FL_ALIGN_INSIDE);
|
|
#endif /* !HAVE_GL */
|
|
}
|
|
|
|
#if HAVE_GL
|
|
void CubeView::drawCube() {
|
|
/* Draw a colored cube */
|
|
#define ALPHA 0.5
|
|
glShadeModel(GL_FLAT);
|
|
|
|
glBegin(GL_QUADS);
|
|
glColor4f(0.0, 0.0, 1.0, ALPHA);
|
|
glVertex3fv(boxv0);
|
|
glVertex3fv(boxv1);
|
|
glVertex3fv(boxv2);
|
|
glVertex3fv(boxv3);
|
|
|
|
glColor4f(1.0, 1.0, 0.0, ALPHA);
|
|
glVertex3fv(boxv0);
|
|
glVertex3fv(boxv4);
|
|
glVertex3fv(boxv5);
|
|
glVertex3fv(boxv1);
|
|
|
|
glColor4f(0.0, 1.0, 1.0, ALPHA);
|
|
glVertex3fv(boxv2);
|
|
glVertex3fv(boxv6);
|
|
glVertex3fv(boxv7);
|
|
glVertex3fv(boxv3);
|
|
|
|
glColor4f(1.0, 0.0, 0.0, ALPHA);
|
|
glVertex3fv(boxv4);
|
|
glVertex3fv(boxv5);
|
|
glVertex3fv(boxv6);
|
|
glVertex3fv(boxv7);
|
|
|
|
glColor4f(1.0, 0.0, 1.0, ALPHA);
|
|
glVertex3fv(boxv0);
|
|
glVertex3fv(boxv3);
|
|
glVertex3fv(boxv7);
|
|
glVertex3fv(boxv4);
|
|
|
|
glColor4f(0.0, 1.0, 0.0, ALPHA);
|
|
glVertex3fv(boxv1);
|
|
glVertex3fv(boxv5);
|
|
glVertex3fv(boxv6);
|
|
glVertex3fv(boxv2);
|
|
glEnd();
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
glBegin(GL_LINES);
|
|
glVertex3fv(boxv0);
|
|
glVertex3fv(boxv1);
|
|
|
|
glVertex3fv(boxv1);
|
|
glVertex3fv(boxv2);
|
|
|
|
glVertex3fv(boxv2);
|
|
glVertex3fv(boxv3);
|
|
|
|
glVertex3fv(boxv3);
|
|
glVertex3fv(boxv0);
|
|
|
|
glVertex3fv(boxv4);
|
|
glVertex3fv(boxv5);
|
|
|
|
glVertex3fv(boxv5);
|
|
glVertex3fv(boxv6);
|
|
|
|
glVertex3fv(boxv6);
|
|
glVertex3fv(boxv7);
|
|
|
|
glVertex3fv(boxv7);
|
|
glVertex3fv(boxv4);
|
|
|
|
glVertex3fv(boxv0);
|
|
glVertex3fv(boxv4);
|
|
|
|
glVertex3fv(boxv1);
|
|
glVertex3fv(boxv5);
|
|
|
|
glVertex3fv(boxv2);
|
|
glVertex3fv(boxv6);
|
|
|
|
glVertex3fv(boxv3);
|
|
glVertex3fv(boxv7);
|
|
glEnd();
|
|
}//drawCube
|
|
|
|
void CubeView::draw() {
|
|
if (!valid()) {
|
|
glLoadIdentity();
|
|
glViewport(0,0,w(),h());
|
|
glOrtho(-10,10,-10,10,-20010,10000);
|
|
glEnable(GL_BLEND);
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
}
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(xshift, yshift, 0);
|
|
glRotatef(hAng,0,1,0); glRotatef(vAng,1,0,0);
|
|
glScalef(float(size),float(size),float(size));
|
|
|
|
drawCube();
|
|
|
|
glPopMatrix();
|
|
}
|
|
#endif /* HAVE_GL */
|
|
|
|
//
|
|
// End of "$Id: CubeView.cxx,v 1.4.2.4.2.1 2001/12/01 01:54:30 matthiaswm Exp $".
|
|
//
|