Commit 3ce833b4 authored by pixhawk's avatar pixhawk

Removed dependency from GLUT

parent 564591c1
......@@ -113,8 +113,7 @@ linux-g++ {
-lflite_cmulex \
-lflite \
-lSDL \
-lSDLmain \
-lglut
-lSDLmain
#-lflite_cmu_us_rms \
#-lflite_cmu_us_slt \
......@@ -156,8 +155,7 @@ linux-g++-64 {
-lflite_cmulex \
-lflite \
-lSDL \
-lSDLmain \
-lglut
-lSDLmain
}
......
......@@ -164,8 +164,7 @@ HEADERS += src/MG.h \
src/ui/map3D/Q3DWidget.h \
src/ui/map3D/CheetahModel.h \
src/ui/map3D/CheetahGL.h \
src/ui/map3D/QMap3DWidget.h \
src/ui/map3D/QGCGlut.h
src/ui/map3D/QMap3DWidget.h
SOURCES += src/main.cc \
src/Core.cc \
src/uas/UASManager.cc \
......
......@@ -864,3 +864,157 @@ Q3DWidget::closeEvent(QCloseEvent *)
{
// exit application
}
void Q3DWidget::wireSphere(double radius, int slices, int stacks)
{
// Make sure quad object exists
if(!quadObj) quadObj = gluNewQuadric();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void Q3DWidget::solidSphere(double radius, int slices, int stacks)
{
// Make sure quad object exists
if(!quadObj) quadObj = gluNewQuadric();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void Q3DWidget::wireCone(double base, double height, int slices, int stacks)
{
// Make sure quad object exists
if(!quadObj) quadObj = gluNewQuadric();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
void Q3DWidget::solidCone(double base, double height, int slices, int stacks)
{
// Make sure quad object exists
if(!quadObj) quadObj = gluNewQuadric();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
void Q3DWidget::drawBox(float size, GLenum type)
{
static GLfloat n[6][3] =
{
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{1.0, 0.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static GLint faces[6][4] =
{
{0, 1, 2, 3},
{3, 2, 6, 7},
{7, 6, 5, 4},
{4, 5, 1, 0},
{5, 6, 2, 1},
{7, 4, 0, 3}
};
GLfloat v[8][3];
GLint i;
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
for (i = 5; i >= 0; i--) {
glBegin(type);
glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
glVertex3fv(&v[faces[i][3]][0]);
glEnd();
}
}
void Q3DWidget::wireCube(double size)
{
drawBox(size, GL_LINE_LOOP);
}
void Q3DWidget::solidCube(double size)
{
drawBox(size, GL_QUADS);
}
void Q3DWidget::doughnut(float r, float R, int nsides, int rings)
{
int i, j;
GLfloat theta, phi, theta1;
GLfloat cosTheta, sinTheta;
GLfloat cosTheta1, sinTheta1;
GLfloat ringDelta, sideDelta;
ringDelta = 2.0 * M_PI / rings;
sideDelta = 2.0 * M_PI / nsides;
theta = 0.0;
cosTheta = 1.0;
sinTheta = 0.0;
for (i = rings - 1; i >= 0; i--) {
theta1 = theta + ringDelta;
cosTheta1 = cos(theta1);
sinTheta1 = sin(theta1);
glBegin(GL_QUAD_STRIP);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
GLfloat cosPhi, sinPhi, dist;
phi += sideDelta;
cosPhi = cos(phi);
sinPhi = sin(phi);
dist = R + r * cosPhi;
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
}
glEnd();
theta = theta1;
cosTheta = cosTheta1;
sinTheta = sinTheta1;
}
}
void Q3DWidget::wireTorus(double innerRadius, double outerRadius,
int nsides, int rings)
{
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
doughnut(innerRadius, outerRadius, nsides, rings);
glPopAttrib();
}
void Q3DWidget::solidTorus(double innerRadius, double outerRadius,
int nsides, int rings)
{
doughnut(innerRadius, outerRadius, nsides, rings);
}
......@@ -37,6 +37,8 @@ This file is part of the QGROUNDCONTROL project
#include <QtOpenGL>
#include <QtGui>
//class GLUquadricObj;
enum CameraState
{
IDLE = 0,
......@@ -163,6 +165,19 @@ protected:
float r2d(float angle);
float d2r(float angle);
void Q3DWidget::wireSphere(double radius, int slices, int stacks);
void solidSphere(double radius, int slices, int stacks);
void wireCone(double base, double height, int slices, int stacks);
void solidCone(double base, double height, int slices, int stacks);
void drawBox(float size, GLenum type);
void wireCube(double size);
void solidCube(double size);
void doughnut(float r, float R, int nsides, int rings);
void wireTorus(double innerRadius, double outerRadius, int nsides, int rings);
void solidTorus(double innerRadius, double outerRadius, int nsides, int rings);
GLUquadricObj* quadObj;
private:
// QGLWidget events
void initializeGL(void);
......
......@@ -48,7 +48,10 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <cmath>
#include "glu.h"
#include "OpenGL/glu.h"
namespace sgi
{
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
......@@ -597,6 +600,6 @@ glutSolidTetrahedron(void)
}
/* ENDCENTRY */
}
#endif // QGCGLUT_H
......@@ -31,15 +31,10 @@ This file is part of the QGROUNDCONTROL project
#include "QMap3DWidget.h"
//#if (defined __APPLE__) & (defined __MACH__)
//#include <GLUT/glut.h>
//#else
//#include <GL/glut.h>
//#endif
#include <QCheckBox>
#include <sys/time.h>
#include "QGCGlut.h"
//#include "QGCGlut.h"
#include "CheetahModel.h"
#include "UASManager.h"
#include "UASInterface.h"
......@@ -531,7 +526,15 @@ QMap3DWidget::drawTarget(float x, float y, float z)
glTranslatef(targetPosition.x - x, targetPosition.y - y, 0.0f);
glColor3f(0.0f, 0.7f, 1.0f);
glLineWidth(1.0f);
glutWireSphere(radius, 10, 10);
// Make sure quad object exists
if(!quadObj) quadObj = gluNewQuadric();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, 10, 10);
if (expand)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment