1
0
Fork 0

Add my own version of gluLookAt() (which is nearly identical to the

Mesa/glu version.)  But, by calculating the Model View matrix our selves
we can save this matrix without having to read it back in from the video
card.  This hopefully allows us to save a few cpu cycles when rendering
out the fragments because we can just use glLoadMatrixd() with the
precalculated matrix for each tile rather than doing a push(), translate(),
pop() for every fragment.

Panel status defaults to off for now until it gets a bit more developed.

Extract OpenGL driver info on initialization.
This commit is contained in:
curt 1998-07-04 00:52:22 +00:00
parent e3cd2005ba
commit 2be63aa0fb
5 changed files with 164 additions and 5 deletions

View file

@ -192,28 +192,28 @@ static void fgUpdateViewParams( void ) {
xglLoadIdentity(); xglLoadIdentity();
// set up our view volume (default) // set up our view volume (default)
gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z, fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->view_forward[0], v->view_pos.x + v->view_forward[0],
v->view_pos.y + v->view_forward[1], v->view_pos.y + v->view_forward[1],
v->view_pos.z + v->view_forward[2], v->view_pos.z + v->view_forward[2],
v->view_up[0], v->view_up[1], v->view_up[2]); v->view_up[0], v->view_up[1], v->view_up[2]);
// look almost straight up (testing and eclipse watching) // look almost straight up (testing and eclipse watching)
/* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z, /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->view_up[0] + .001, v->view_pos.x + v->view_up[0] + .001,
v->view_pos.y + v->view_up[1] + .001, v->view_pos.y + v->view_up[1] + .001,
v->view_pos.z + v->view_up[2] + .001, v->view_pos.z + v->view_up[2] + .001,
v->view_up[0], v->view_up[1], v->view_up[2]); */ v->view_up[0], v->view_up[1], v->view_up[2]); */
// lock view horizontally towards sun (testing) // lock view horizontally towards sun (testing)
/* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z, /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->surface_to_sun[0], v->view_pos.x + v->surface_to_sun[0],
v->view_pos.y + v->surface_to_sun[1], v->view_pos.y + v->surface_to_sun[1],
v->view_pos.z + v->surface_to_sun[2], v->view_pos.z + v->surface_to_sun[2],
v->view_up[0], v->view_up[1], v->view_up[2]); */ v->view_up[0], v->view_up[1], v->view_up[2]); */
// lock view horizontally towards south (testing) // lock view horizontally towards south (testing)
/* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z, /* fg_gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->surface_south[0], v->view_pos.x + v->surface_south[0],
v->view_pos.y + v->surface_south[1], v->view_pos.y + v->surface_south[1],
v->view_pos.z + v->surface_south[2], v->view_pos.z + v->surface_south[2],
@ -745,6 +745,19 @@ int main( int argc, char **argv ) {
// $Log$ // $Log$
// Revision 1.29 1998/07/04 00:52:22 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
// we can save this matrix without having to read it back in from the video
// card. This hopefully allows us to save a few cpu cycles when rendering
// out the fragments because we can just use glLoadMatrixd() with the
// precalculated matrix for each tile rather than doing a push(), translate(),
// pop() for every fragment.
//
// Panel status defaults to off for now until it gets a bit more developed.
//
// Extract OpenGL driver info on initialization.
//
// Revision 1.28 1998/06/27 16:54:32 curt // Revision 1.28 1998/06/27 16:54:32 curt
// Replaced "extern displayInstruments" with a entry in fgOPTIONS. // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
// Don't change the view port when displaying the panel. // Don't change the view port when displaying the panel.

View file

@ -180,6 +180,10 @@ int fgInitGeneral( void ) {
fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" ); fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" ); fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
g->glVendor = glGetString ( GL_VENDOR );
g->glRenderer = glGetString ( GL_RENDERER );
g->glVersion = glGetString ( GL_VERSION );
if ( !strlen(o->fg_root) ) { if ( !strlen(o->fg_root) ) {
// No root path set? Then assume, we will exit if this is // No root path set? Then assume, we will exit if this is
// wrong when looking for support files. // wrong when looking for support files.
@ -383,6 +387,19 @@ int fgInitSubsystems( void ) {
// $Log$ // $Log$
// Revision 1.22 1998/07/04 00:52:25 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
// we can save this matrix without having to read it back in from the video
// card. This hopefully allows us to save a few cpu cycles when rendering
// out the fragments because we can just use glLoadMatrixd() with the
// precalculated matrix for each tile rather than doing a push(), translate(),
// pop() for every fragment.
//
// Panel status defaults to off for now until it gets a bit more developed.
//
// Extract OpenGL driver info on initialization.
//
// Revision 1.21 1998/06/27 16:54:33 curt // Revision 1.21 1998/06/27 16:54:33 curt
// Replaced "extern displayInstruments" with a entry in fgOPTIONS. // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
// Don't change the view port when displaying the panel. // Don't change the view port when displaying the panel.

View file

@ -69,7 +69,7 @@ fgOPTIONS::fgOPTIONS( void ) {
// Features // Features
hud_status = 1; hud_status = 1;
panel_status = 1; panel_status = 0;
// Rendering options // Rendering options
fog = 2; // nicest fog = 2; // nicest
@ -434,6 +434,19 @@ fgOPTIONS::~fgOPTIONS( void ) {
// $Log$ // $Log$
// Revision 1.14 1998/07/04 00:52:26 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
// we can save this matrix without having to read it back in from the video
// card. This hopefully allows us to save a few cpu cycles when rendering
// out the fragments because we can just use glLoadMatrixd() with the
// precalculated matrix for each tile rather than doing a push(), translate(),
// pop() for every fragment.
//
// Panel status defaults to off for now until it gets a bit more developed.
//
// Extract OpenGL driver info on initialization.
//
// Revision 1.13 1998/06/27 16:54:34 curt // Revision 1.13 1998/06/27 16:54:34 curt
// Replaced "extern displayInstruments" with a entry in fgOPTIONS. // Replaced "extern displayInstruments" with a entry in fgOPTIONS.
// Don't change the view port when displaying the panel. // Don't change the view port when displaying the panel.

View file

@ -375,7 +375,99 @@ fgVIEW::~fgVIEW( void ) {
} }
// Basically, this is a modified version of the Mesa gluLookAt()
// function that's been modified slightly so we can capture the result
// before sending it off to OpenGL land.
void fg_gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz,
GLdouble upx, GLdouble upy, GLdouble upz )
{
GLdouble *m;
GLdouble x[3], y[3], z[3];
GLdouble mag;
m = current_view.MODEL_VIEW;
/* Make rotation matrix */
/* Z vector */
z[0] = eyex - centerx;
z[1] = eyey - centery;
z[2] = eyez - centerz;
mag = sqrt( z[0]*z[0] + z[1]*z[1] + z[2]*z[2] );
if (mag) { /* mpichler, 19950515 */
z[0] /= mag;
z[1] /= mag;
z[2] /= mag;
}
/* Y vector */
y[0] = upx;
y[1] = upy;
y[2] = upz;
/* X vector = Y cross Z */
x[0] = y[1]*z[2] - y[2]*z[1];
x[1] = -y[0]*z[2] + y[2]*z[0];
x[2] = y[0]*z[1] - y[1]*z[0];
/* Recompute Y = Z cross X */
y[0] = z[1]*x[2] - z[2]*x[1];
y[1] = -z[0]*x[2] + z[2]*x[0];
y[2] = z[0]*x[1] - z[1]*x[0];
/* mpichler, 19950515 */
/* cross product gives area of parallelogram, which is < 1.0 for
* non-perpendicular unit-length vectors; so normalize x, y here
*/
mag = sqrt( x[0]*x[0] + x[1]*x[1] + x[2]*x[2] );
if (mag) {
x[0] /= mag;
x[1] /= mag;
x[2] /= mag;
}
mag = sqrt( y[0]*y[0] + y[1]*y[1] + y[2]*y[2] );
if (mag) {
y[0] /= mag;
y[1] /= mag;
y[2] /= mag;
}
#define M(row,col) m[col*4+row]
M(0,0) = x[0]; M(0,1) = x[1]; M(0,2) = x[2]; M(0,3) = 0.0;
M(1,0) = y[0]; M(1,1) = y[1]; M(1,2) = y[2]; M(1,3) = 0.0;
M(2,0) = z[0]; M(2,1) = z[1]; M(2,2) = z[2]; M(2,3) = 0.0;
M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0;
#undef M
// Translate Eye to Origin
// replaces: glTranslated( -eyex, -eyey, -eyez );
m[12] = m[0] * -eyex + m[4] * -eyey + m[8] * -eyez + m[12];
m[13] = m[1] * -eyex + m[5] * -eyey + m[9] * -eyez + m[13];
m[14] = m[2] * -eyex + m[6] * -eyey + m[10] * -eyez + m[14];
m[15] = m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15];
// xglMultMatrixd( m );
xglLoadMatrixd( m );
}
// $Log$ // $Log$
// Revision 1.13 1998/07/04 00:52:27 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
// we can save this matrix without having to read it back in from the video
// card. This hopefully allows us to save a few cpu cycles when rendering
// out the fragments because we can just use glLoadMatrixd() with the
// precalculated matrix for each tile rather than doing a push(), translate(),
// pop() for every fragment.
//
// Panel status defaults to off for now until it gets a bit more developed.
//
// Extract OpenGL driver info on initialization.
//
// Revision 1.12 1998/06/03 00:47:15 curt // Revision 1.12 1998/06/03 00:47:15 curt
// Updated to compile in audio support if OSS available. // Updated to compile in audio support if OSS available.
// Updated for new version of Steve's audio library. // Updated for new version of Steve's audio library.

View file

@ -135,6 +135,9 @@ public:
// coordinates to eye coordinates // coordinates to eye coordinates
MAT3mat WORLD_TO_EYE; MAT3mat WORLD_TO_EYE;
// Current model view matrix;
GLdouble MODEL_VIEW[16];
// Constructor // Constructor
fgVIEW( void ); fgVIEW( void );
@ -158,10 +161,31 @@ public:
extern fgVIEW current_view; extern fgVIEW current_view;
// Basically, this is a modified version of the Mesa gluLookAt()
// function that's been modified slightly so we can capture the result
// before sending it off to OpenGL land.
void fg_gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz,
GLdouble upx, GLdouble upy, GLdouble upz );
#endif // _VIEWS_HXX #endif // _VIEWS_HXX
// $Log$ // $Log$
// Revision 1.9 1998/07/04 00:52:27 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
// we can save this matrix without having to read it back in from the video
// card. This hopefully allows us to save a few cpu cycles when rendering
// out the fragments because we can just use glLoadMatrixd() with the
// precalculated matrix for each tile rather than doing a push(), translate(),
// pop() for every fragment.
//
// Panel status defaults to off for now until it gets a bit more developed.
//
// Extract OpenGL driver info on initialization.
//
// Revision 1.8 1998/05/27 02:24:06 curt // Revision 1.8 1998/05/27 02:24:06 curt
// View optimizations by Norman Vine. // View optimizations by Norman Vine.
// //