From 47e62b3c6eecb2ed36c4baafe22e52ec66d1a56f Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 25 May 2006 09:22:58 +0000 Subject: [PATCH] Removed all GLUT dependencies! --- wrap/gl/addons.h | 6 +- wrap/gl/gl_geometry.h | 221 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 wrap/gl/gl_geometry.h diff --git a/wrap/gl/addons.h b/wrap/gl/addons.h index 6db17d73..9e3bc18f 100644 --- a/wrap/gl/addons.h +++ b/wrap/gl/addons.h @@ -23,12 +23,14 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.11 2006/03/29 07:54:03 cignoni +Wrong matrix type in cone (thx Maarten) + ****************************************************************************/ #ifndef __VCG_GLADDONS #define __VCG_GLADDONS -#include #include #include #include @@ -36,7 +38,7 @@ $Log: not supported by cvs2svn $ namespace vcg { - +#include "gl_geometry.h" /** Class Add_Ons. This is class draw 3d icons on the screen */ diff --git a/wrap/gl/gl_geometry.h b/wrap/gl/gl_geometry.h new file mode 100644 index 00000000..9befe4df --- /dev/null +++ b/wrap/gl/gl_geometry.h @@ -0,0 +1,221 @@ +/* Portion of this file were more or less adapted from + * freeglut_geometry.c + * + * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + * that was Written by Pawel W. Olszta, + */ + +#include +#include + +/* + * Compute lookup table of cos and sin values forming a cirle + * + * Notes: + * It is the responsibility of the caller to free these tables + * The size of the table is (n+1) to form a connected loop + * The last entry is exactly the same as the first + * The sign of n can be flipped to get the reverse loop + */ + +static void fghCircleTable(double **sint,double **cost,const int n) +{ + int i; + + /* Table size, the sign of n flips the circle direction */ + + const int size = abs(n); + + /* Determine the angle between samples */ + + const double angle = 2*M_PI/(double)( ( n == 0 ) ? 1 : n ); + + /* Allocate memory for n samples, plus duplicate of first entry at the end */ + + *sint = (double *) calloc(sizeof(double), size+1); + *cost = (double *) calloc(sizeof(double), size+1); + + /* Bail out if memory allocation fails, fgError never returns */ + + if (!(*sint) || !(*cost)) + { + free(*sint); + free(*cost); + abort(); //fgError("Failed to allocate memory in fghCircleTable"); + } + + /* Compute cos and sin around the circle */ + + (*sint)[0] = 0.0; + (*cost)[0] = 1.0; + + for (i=1; i0)?1:0]; + r0 = 0.0; + r1 = sint2[(stacks>0)?1:0]; + + glBegin(GL_TRIANGLE_FAN); + + glNormal3d(0,0,1); + glVertex3d(0,0,radius); + + for (j=slices; j>=0; j--) + { + glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 ); + glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius); + } + + glEnd(); + + /* Cover each stack with a quad strip, except the top and bottom stacks */ + + for( i=1; i