#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props_io.hxx>
-#include <osg/GLU>
+#include <osg/Matrixf>
#include <GUI/new_gui.hxx> // FGFontCache
#include <Main/globals.hxx>
void fgUpdateHUDVirtual(osg::State* state)
{
+ using namespace osg;
FGViewer* view = globals->get_current_view();
// Standard fgfs projection, with essentially meaningless clip
// planes (we'll map the whole HUD plane to z=-1)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadIdentity();
- gluPerspective(view->get_v_fov(), 1/view->get_aspect_ratio(), 0.1, 10);
+ Matrixf proj
+ = Matrixf::perspective(view->get_v_fov(), 1/view->get_aspect_ratio(),
+ 0.1, 10);
+ glLoadMatrix(proj.ptr());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- glLoadIdentity();
// Standard fgfs view direction computation
- float lookat[3];
+ Vec3f lookat;
lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg());
lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
if (fabs(lookat[1]) > 9999)
lookat[1] = 9999; // FPU sanity
- gluLookAt(0, 0, 0, lookat[0], lookat[1], lookat[2], 0, 1, 0);
+ Matrixf mv = Matrixf::lookAt(Vec3f(0.0, 0.0, 0.0), lookat,
+ Vec3f(0.0, 1.0, 0.0));
+ glLoadMatrix(mv.ptr());
// Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.
// This is the default fgfs field of view, which the HUD files are
void fgUpdateHUD( osg::State* state, GLfloat x_start, GLfloat y_start,
GLfloat x_end, GLfloat y_end )
{
+ using namespace osg;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadIdentity();
- gluOrtho2D(x_start, x_end, y_start, y_end);
+ Matrixf proj = Matrixf::ortho2D(x_start, x_end, y_start, y_end);
+ glLoadMatrix(proj.ptr());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
#include <ATCDCL/ATCutils.hxx>
#include <Main/viewer.hxx>
-#include <osg/GLU>
-
+#include <simgear/math/project.hxx>
// int x, int y, int width, int height, float scale_data, bool working)
//Calculate the 2D points via gluProject
int result = GL_TRUE;
for (int i = 0; i < 6; i++) {
- result = gluProject(points3d[i][0], points3d[i][1], points3d[i][2], mm,
- pm, view, &points2d[i][0], &points2d[i][1], &points2d[i][2]);
+ result = simgear::project(points3d[i][0], points3d[i][1], points3d[i][2],
+ mm, pm, view,
+ &points2d[i][0], &points2d[i][1], &points2d[i][2]);
}
//set the line width based on our distance from the runway
setLineWidth();
sgdVec3 newPt;
sgdCopyVec3(newPt, a1);
sgdAddVec3(newPt, vec);
- if (gluProject(newPt[0], newPt[1], newPt[2], mm, pm, view, &p2[0], &p2[1], &p2[2])
+ if (simgear::project(newPt[0], newPt[1], newPt[2], mm, pm, view,
+ &p2[0], &p2[1], &p2[2])
&& (p2[2] > 0 && p2[2] < 1.0)) {
boundPoint(p1, p2);
glBegin(GL_LINES);
sgdVec3 newPt;
sgdCopyVec3(newPt, a2);
sgdAddVec3(newPt, vec);
- if (gluProject(newPt[0], newPt[1], newPt[2], mm, pm, view, &p1[0], &p1[1], &p1[2])
+ if (simgear::project(newPt[0], newPt[1], newPt[2], mm, pm, view,
+ &p1[0], &p1[1], &p1[2])
&& (p1[2] > 0 && p1[2] < 1.0)) {
boundPoint(p2, p1);
glBegin(GL_LINES);
#include <osg/CullFace>
#include <osg/Depth>
#include <osg/Material>
+#include <osg/Matrixf>
#include <osg/TexEnv>
#include <osg/PolygonOffset>
void
FGPanel::update (osg::State& state, GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh)
{
+ using namespace osg;
// Calculate accelerations
// and jiggle the panel accordingly
// The factors and bounds are just
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadIdentity();
+ Matrixf proj;
if ( _flipx->getBoolValue() ) {
- gluOrtho2D(winx + winw, winx, winy + winh, winy); /* up side down */
+ proj = Matrixf::ortho2D(winx + winw, winx, winy + winh, winy); /* up side down */
} else {
- gluOrtho2D(winx, winx + winw, winy, winy + winh); /* right side up */
+ proj = Matrixf::ortho2D(winx, winx + winw, winy, winy + winh); /* right side up */
}
+ glLoadMatrix(proj.ptr());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
void HUD::draw3D()
{
+ using namespace osg;
FGViewer* view = globals->get_current_view();
// Standard fgfs projection, with essentially meaningless clip
// planes (we'll map the whole HUD plane to z=-1)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadIdentity();
- gluPerspective(view->get_v_fov(), 1.0 / view->get_aspect_ratio(), 0.1, 10);
+ Matrixf proj
+ = Matrixf::perspective(view->get_v_fov(), 1/view->get_aspect_ratio(),
+ 0.1, 10);
+ glLoadMatrix(proj.ptr());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- glLoadIdentity();
// Standard fgfs view direction computation
- float lookat[3];
+ Vec3f lookat;
lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg());
lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
if (fabs(lookat[1]) > 9999)
lookat[1] = 9999; // FPU sanity
- gluLookAt(0, 0, 0, lookat[0], lookat[1], lookat[2], 0, 1, 0);
+ Matrixf mv = Matrixf::lookAt(Vec3f(0.0, 0.0, 0.0), lookat,
+ Vec3f(0.0, 1.0, 0.0));
+ glLoadMatrix(mv.ptr());
// Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.
// This is the default fgfs field of view, which the HUD files are
void HUD::draw2D(GLfloat x_start, GLfloat y_start, GLfloat x_end, GLfloat y_end)
{
+ using namespace osg;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
- glLoadIdentity();
- gluOrtho2D(x_start, x_end, y_start, y_end);
+ Matrixf proj = Matrixf::ortho2D(x_start, x_end, y_start, y_end);
+ glLoadMatrix(proj.ptr());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
#include <simgear/compiler.h>
#include <simgear/math/sg_geodesy.hxx>
-#include <osg/GLU>
+#include <simgear/math/project.hxx>
#include <Main/globals.hxx>
#include <Scenery/scenery.hxx>
//Calculate the 2D points via gluProject
int result = GL_TRUE;
for (int i = 0; i < 6; i++) {
- result = gluProject(_points3d[i][0], _points3d[i][1], _points3d[i][2], _mm,
- _pm, _view, &_points2d[i][0], &_points2d[i][1], &_points2d[i][2]);
+ result = simgear::project(_points3d[i][0], _points3d[i][1], _points3d[i][2],
+ _mm, _pm, _view,
+ &_points2d[i][0], &_points2d[i][1], &_points2d[i][2]);
}
//set the line width based on our distance from the runway
setLineWidth();
sgdVec3 newPt;
sgdCopyVec3(newPt, a1);
sgdAddVec3(newPt, vec);
- if (gluProject(newPt[0], newPt[1], newPt[2], _mm, _pm, _view, &p2[0], &p2[1], &p2[2])
+ if (simgear::project(newPt[0], newPt[1], newPt[2], _mm, _pm, _view,
+ &p2[0], &p2[1], &p2[2])
&& (p2[2] > 0 && p2[2] < 1.0)) {
boundPoint(p1, p2);
glBegin(GL_LINES);
sgdVec3 newPt;
sgdCopyVec3(newPt, a2);
sgdAddVec3(newPt, vec);
- if (gluProject(newPt[0], newPt[1], newPt[2], _mm, _pm, _view, &p1[0], &p1[1], &p1[2])
+ if (simgear::project(newPt[0], newPt[1], newPt[2], _mm, _pm, _view,
+ &p1[0], &p1[1], &p1[2])
&& (p1[2] > 0 && p1[2] < 1.0)) {
boundPoint(p2, p1);
glBegin(GL_LINES);
# include <windows.h>
#endif
-#include <osg/GLU>
+#include <osg/Matrixf>
#include <math.h>
#include <zlib.h>
void
SGTexture::resize(unsigned int width, unsigned int height)
{
+ using namespace osg;
GLfloat aspect;
// Make sure that we don't get a divide by zero exception
// Go to the projection matrix, this gets modified by the perspective
// calulations
glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
// Do the perspective calculations
- gluPerspective(45.0, aspect, 1.0, 400.0);
+ Matrixf proj = Matrixf::perspective(45.0, aspect, 1.0, 400.0);
+ glLoadMatrix(proj.ptr());
// Return to the modelview matrix
glMatrixMode(GL_MODELVIEW);