Updated not to use v3f() macro.

No longer use glColor4ub(), as 1) Sun's compilers have trouble with their
own headers with this (glColor4ub is a macro, a VERY bad thing to do!), and
2) it's an OpenGL 1.1 feature, and not all platforms support it.

Also optimized the QUAD and LINE primitives.


git-svn-id: file:///fltk/svn/fltk/trunk@404 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 1999-03-10 16:40:19 +00:00
parent 51c3b154dd
commit 2b4b055204
2 changed files with 83 additions and 23 deletions

View File

@ -1,5 +1,5 @@
//
// "$Id: CubeView.cxx,v 1.3 1999/03/04 20:26:00 mike Exp $"
// "$Id: CubeView.cxx,v 1.4 1999/03/10 16:40:19 mike Exp $"
//
// CubeView class implementation for the Fast Light Tool Kit (FLTK).
//
@ -57,25 +57,88 @@ CubeView::CubeView(int x,int y,int w,int h,const char *l)
#endif /* !HAVE_GL */
};
// The color used for the edges of the bounding cube.
#define CUBECOLOR 255,255,255,255
#if HAVE_GL
void CubeView::drawCube() {
/* Draw a colored cube */
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd();
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv5); v3f(boxv4); v3f(boxv7); v3f(boxv6); glEnd();
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd();
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv2); v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd();
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd();
glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv1); v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd();
#define ALPHA 128
glBegin(GL_QUADS); glColor4ub( 0, 0, 255, ALPHA); v3f(boxv0); v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd();
glBegin(GL_QUADS); glColor4ub(255, 255, 0, ALPHA); v3f(boxv0); v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd();
glBegin(GL_QUADS); glColor4ub( 0, 255, 255, ALPHA); v3f(boxv2); v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd();
glBegin(GL_QUADS); glColor4ub(255, 0, 0, ALPHA); v3f(boxv4); v3f(boxv5); v3f(boxv6); v3f(boxv7); glEnd();
glBegin(GL_QUADS); glColor4ub(255, 0, 255, ALPHA); v3f(boxv0); v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd();
glBegin(GL_QUADS); glColor4ub( 0, 255, 0, ALPHA); v3f(boxv1); v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd();
#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() {
@ -102,5 +165,5 @@ void CubeView::draw() {
#endif /* HAVE_GL */
//
// End of "$Id: CubeView.cxx,v 1.3 1999/03/04 20:26:00 mike Exp $".
// End of "$Id: CubeView.cxx,v 1.4 1999/03/10 16:40:19 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: CubeView.h,v 1.3 1999/03/04 20:26:00 mike Exp $"
// "$Id: CubeView.h,v 1.4 1999/03/10 16:40:19 mike Exp $"
//
// CubeView class definitions for the Fast Light Tool Kit (FLTK).
//
@ -37,9 +37,6 @@
#include <stdlib.h>
// shorthand to save some bits.
#define v3f(x) glVertex3fv(x)
#if HAVE_GL
class CubeView : public Fl_Gl_Window {
#else
@ -122,5 +119,5 @@ private:
#endif
//
// End of "$Id: CubeView.h,v 1.3 1999/03/04 20:26:00 mike Exp $".
// End of "$Id: CubeView.h,v 1.4 1999/03/10 16:40:19 mike Exp $".
//