1
0
Fork 0

Moved winWidth and winHeight out of FGViewer since these are set on a

per-application level.  We can have multiple viewers ...
Cleaned up fov mistake on startup with panel activated.
This commit is contained in:
curt 2000-10-19 23:09:33 +00:00
parent 01c44cbb99
commit 152a5902c8
26 changed files with 84 additions and 106 deletions

View file

@ -33,8 +33,6 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <Main/options.hxx>
#include STL_STRING
#include STL_FUNCTIONAL
#include STL_ALGORITHM

View file

@ -42,8 +42,6 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <Main/options.hxx>
#include STL_STRING
#include STL_FUNCTIONAL
#include STL_ALGORITHM

View file

@ -41,7 +41,6 @@
#include <Main/bfi.hxx>
#include <Main/fg_init.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Navaids/fixlist.hxx>
#include "auto_gui.hxx"

View file

@ -38,7 +38,6 @@
#include <FDM/flight.hxx>
#include <Main/bfi.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Scenery/scenery.hxx>
#include "newauto.hxx"

View file

@ -30,7 +30,7 @@
#endif
#include <GL/glut.h>
#include <simgear/xgl/xgl.h>
// #include <simgear/xgl/xgl.h>
#include <stdlib.h>
#include <stdio.h>
@ -45,7 +45,6 @@
#include <Include/general.hxx>
#include <FDM/ADA.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
#include <GUI/gui.h>
@ -700,8 +699,8 @@ void fgCockpitUpdate( void ) {
"Cockpit: code " << ac_cockpit->code() << " status "
<< ac_cockpit->status() );
int iwidth = globals->get_current_view()->get_winWidth();
int iheight = globals->get_current_view()->get_winHeight();
int iwidth = globals->get_options()->get_xsize();
int iheight = globals->get_options()->get_ysize();
float width = iwidth;
float height = iheight;
@ -721,33 +720,35 @@ void fgCockpitUpdate( void ) {
// sprintf(buf,"%-4.1f %7.0f %7.0f", fps, tris, culled);
sprintf(buf,"%-5.1f", fps);
glMatrixMode(GL_PROJECTION);
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, width, 0, height);
glMatrixMode(GL_MODELVIEW);
gluOrtho2D( 0, globals->get_options()->get_xsize(),
0, globals->get_options()->get_ysize() );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable( GL_DEPTH_TEST );
glDisable( GL_LIGHTING );
glColor3f (0.9, 0.4, 0.2);
glColor3f( 0.9, 0.4, 0.2 );
guiFnt.drawString( buf,
// width/2 - guiFnt.getStringWidth(buf)/2,
int(width - guiFnt.getStringWidth(buf) - 10),
10 );
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glEnable( GL_DEPTH_TEST );
glEnable( GL_LIGHTING );
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
}
#endif // #ifdef DISPLAY_COUNTER
xglViewport( 0, 0, iwidth, iheight );
glViewport( 0, 0,
globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
if (current_panel != 0)
current_panel->update();

View file

@ -46,7 +46,7 @@
#include <Aircraft/aircraft.hxx>
#include <Autopilot/newauto.hxx>
#include <GUI/gui.h>
#include <Main/options.hxx>
#include <Main/globals.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#endif

View file

@ -34,7 +34,6 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgpath.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Objects/texload.h>
#include "hud.hxx"
@ -305,8 +304,8 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
}
// Scale for the real window size.
x = int(((float)x / globals->get_current_view()->get_winWidth()) * _winw);
y = int(_winh - (((float)y / globals->get_current_view()->get_winHeight())
x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
y = int(_winh - (((float)y / globals->get_options()->get_ysize())
* _winh));
// Adjust for offsets.

View file

@ -33,8 +33,8 @@
#include <simgear/math/sg_types.hxx>
#include <simgear/misc/props.hxx>
#include <Aircraft/aircraft.hxx>
#include <Main/options.hxx>
#include <Main/bfi.hxx>
#include <Main/globals.hxx>
#include <NetworkOLK/features.hxx>
FG_USING_NAMESPACE(std);

View file

@ -52,7 +52,7 @@ HISTORY
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Main/options.hxx>
#include <Main/globals.hxx>
#include "Balloon.h"

View file

@ -38,7 +38,7 @@
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Main/options.hxx>
#include <Main/globals.hxx>
#include <FDM/JSBSim/FGFDMExec.h>
#include <FDM/JSBSim/FGAircraft.h>

View file

@ -28,7 +28,7 @@
#include <simgear/math/sg_geodesy.hxx>
#include <FDM/LaRCsim/ls_interface.h>
#include <Main/options.hxx>
#include <Main/globals.hxx>
#include <Time/timestamp.hxx>
#include "External.hxx"

View file

@ -68,7 +68,6 @@
#include <Main/fg_init.hxx>
#include <Main/fg_io.hxx>
#include <Main/globals.hxx>
#include <Main/options.hxx>
#include <Main/save.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
@ -299,8 +298,8 @@ static inline void TurnCursorOn( void )
}
#endif
#if defined(X_CURSOR_TWEAKS)
glutWarpPointer( globals->get_current_view()->get_winWidth()/2,
globals->get_current_view()->get_winHeight()/2);
glutWarpPointer( globals->get_options()->get_xsize()/2,
globals->get_options()->get_ysize()/2);
#endif
}
@ -310,8 +309,8 @@ static inline void TurnCursorOff( void )
#if defined(WIN32_CURSOR_TWEAKS)
glutSetCursor(GLUT_CURSOR_NONE);
#elif defined(X_CURSOR_TWEAKS)
glutWarpPointer( globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight());
glutWarpPointer( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
#endif
}
@ -382,8 +381,8 @@ void guiMotionFunc ( int x, int y )
// reset left click MOUSE_VIEW toggle feature
_mVtoggle = 0;
ww = globals->get_current_view()->get_winWidth();
wh = globals->get_current_view()->get_winHeight();
ww = globals->get_options()->get_xsize();
wh = globals->get_options()->get_ysize();
switch (mouse_mode) {
case MOUSE_YOKE:
@ -558,10 +557,11 @@ void guiMouseFunc(int button, int updown, int x, int y)
_quat[1] = curquat[1];
_quat[2] = curquat[2];
_quat[3] = curquat[3];
x = globals->get_current_view()->get_winWidth()/2;
y = globals->get_current_view()->get_winHeight()/2;
x = globals->get_options()->get_xsize()/2;
y = globals->get_options()->get_ysize()/2;
Quat0();
_view_offset = globals->get_current_view()->get_goal_view_offset();
_view_offset =
globals->get_current_view()->get_goal_view_offset();
globals->get_current_view()->set_goal_view_offset(0.0);
#ifdef NO_SMOOTH_MOUSE_VIEW
globals->get_current_view()->set_view_offset(0.0);
@ -580,8 +580,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
_savedX = x;
_savedY = y;
// start with zero point in center of screen
_mX = globals->get_current_view()->get_winWidth()/2;
_mY = globals->get_current_view()->get_winHeight()/2;
_mX = globals->get_options()->get_xsize()/2;
_mY = globals->get_options()->get_ysize()/2;
// try to have the MOUSE_YOKE position
// reflect the current stick position
@ -597,8 +597,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
case MOUSE_YOKE:
mouse_mode = MOUSE_VIEW;
globals->get_options()->set_control_mode( FGOptions::FG_JOYSTICK );
x = globals->get_current_view()->get_winWidth()/2;
y = globals->get_current_view()->get_winHeight()/2;
x = globals->get_options()->get_xsize()/2;
y = globals->get_options()->get_ysize()/2;
_mVtoggle = 0;
Quat0();
build_rotmatrix(quat_mat, curquat);
@ -966,8 +966,8 @@ void fgDumpSnapShot () {
}
fgInitVisuals();
fgReshape( globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight() );
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
// we need two render frames here to clear the menu and cursor
// ... not sure why but doing an extra fgFenderFrame() shoulnd't

View file

@ -55,7 +55,6 @@
#endif
#include "globals.hxx"
#include "options.hxx"
#include "save.hxx"
#include "fg_init.hxx"
#include <simgear/misc/props.hxx>

View file

@ -93,7 +93,6 @@
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "globals.hxx"
#include "options.hxx"
#include "bfi.hxx"
#if defined(FX) && defined(XMESA)
@ -104,6 +103,9 @@ FG_USING_STD(string);
extern const char *default_root;
// from main.cxx
extern void fgReshape( int width, int height );
// Read in configuration (file and command line) and just set fg_root
bool fgInitFGRoot ( int argc, char **argv ) {

View file

@ -70,7 +70,6 @@
#include "bfi.hxx"
#include "globals.hxx"
#include "keyboard.hxx"
#include "options.hxx"
#include "save.hxx"
// From main.cxx
@ -437,8 +436,8 @@ void GLUTkey(unsigned char k, int x, int y) {
v->set_view_offset( FG_PI * 1.75 );
globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
}
fgReshape( globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight() );
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
return;
case 120: // x key
fov = globals->get_options()->get_fov();
@ -539,14 +538,14 @@ void GLUTspecialkey(int k, int x, int y) {
}
case GLUT_KEY_F5: {
current_panel->setYOffset(current_panel->getYOffset() - 5);
fgReshape(globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight());
fgReshape(globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
return;
}
case GLUT_KEY_F6: {
current_panel->setYOffset(current_panel->getYOffset() + 5);
fgReshape(globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight());
fgReshape(globals->get_options()->get_xsize(),
globals->get_options()->get_ysize());
return;
}
case GLUT_KEY_F7: {

View file

@ -115,7 +115,6 @@ ssgTransform *ship_pos = NULL;
#include "fg_io.hxx"
#include "globals.hxx"
#include "keyboard.hxx"
#include "options.hxx"
#include "splash.hxx"
@ -143,6 +142,9 @@ static bool initial_freeze = true;
// Another hack
int use_signals = 0;
// forward declaration
void fgReshape( int width, int height );
// Global structures for the Audio library
#ifdef ENABLE_AUDIO_SUPPORT
slEnvelope pitch_envelope ( 1, SL_SAMPLE_ONE_SHOT ) ;
@ -1120,6 +1122,10 @@ static void fgIdleFunction ( void ) {
// sleep(1);
idle_state = 1000;
cout << "Panel visible = " << fgPanelVisible() << endl;
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
}
if ( idle_state == 1000 ) {
@ -1151,8 +1157,8 @@ void fgReshape( int width, int height ) {
(GLint)(width), (GLint)(view_h) );
}
globals->get_current_view()->set_winWidth( width );
globals->get_current_view()->set_winHeight( height );
globals->get_options()->set_xsize( width );
globals->get_options()->set_ysize( height );
globals->get_current_view()->force_update_fov_math();
// set these fov to be the same as in fgRenderFrame()
@ -1315,7 +1321,8 @@ int main( int argc, char **argv ) {
// seed the random number generater
fg_srandom();
// needs to happen before we parse command line options
// Allocate global data structures. This needs to happen before
// we parse command line options
globals = new FGGlobals;
SGRoute *route = new SGRoute;

View file

@ -60,7 +60,7 @@ bool global_fullscreen = true;
FG_USING_STD(string);
FG_USING_NAMESPACE(std);
// from GLUTmain.cxx
// from main.cxx
extern void fgReshape( int width, int height );
inline double
@ -185,10 +185,6 @@ FGOptions::FGOptions() :
wireframe(0),
xsize(800),
ysize(600),
xmin(0),
ymin(0),
xmax(800),
ymax(600),
bpp(16),
view_mode(FG_VIEW_PILOT),
default_view_offset(0),
@ -271,9 +267,7 @@ FGOptions::toggle_panel() {
fov *= (1.0 / 0.4232);
} */
// fgReshape( xsize, ysize);
fgReshape( globals->get_current_view()->get_winWidth(),
globals->get_current_view()->get_winHeight() );
fgReshape( xsize, ysize);
if( !freeze )
globals->set_freeze( false );
@ -826,10 +820,6 @@ int FGOptions::parse_option( const string& arg ) {
FG_LOG( FG_GENERAL, FG_ALERT,
"Setting geometry to " << xsize << 'x' << ysize << '\n');
}
xmin = ymin = 0;
xmax = xsize;
ymax = ysize;
} else if ( arg.find( "--bpp=" ) != string::npos ) {
string bits_per_pix = arg.substr( 6 );
if ( bits_per_pix == "16" ) {

View file

@ -180,8 +180,6 @@ private:
bool textures; // Textures enabled/disabled
bool wireframe; // Wireframe mode enabled/disabled
int xsize, ysize; // window size derived from geometry string
int xmin, ymin; // upper left corner of window to draw in
int xmax, ymax; // lower right corner of window to draw in
int bpp; // bits per pixel
fgViewMode view_mode; // view mode
double default_view_offset; // default forward view offset (for use by
@ -288,10 +286,6 @@ public:
inline bool get_wireframe() const { return wireframe; }
inline int get_xsize() const { return xsize; }
inline int get_ysize() const { return ysize; }
inline int get_xmin() const { return xmin; }
inline int get_ymin() const { return ymin; }
inline int get_xmax() const { return xmax; }
inline int get_ymax() const { return ymax; }
inline int get_bpp() const { return bpp; }
inline fgViewMode get_view_mode() const { return view_mode; }
inline double get_default_view_offset() const {

View file

@ -109,15 +109,15 @@ void fgSplashUpdate ( double progress ) {
int xsize = 480;
int ysize = 380;
if ( !globals->get_current_view()->get_winWidth()
|| !globals->get_current_view()->get_winHeight() ) {
if ( !globals->get_options()->get_xsize()
|| !globals->get_options()->get_ysize() ) {
return;
}
xmin = (globals->get_current_view()->get_winWidth() - xsize) / 2;
xmin = (globals->get_options()->get_xsize() - xsize) / 2;
xmax = xmin + xsize;
ymin = (globals->get_current_view()->get_winHeight() - ysize) / 2;
ymin = (globals->get_options()->get_ysize() - ysize) / 2;
ymax = ymin + ysize;
// first clear the screen;
@ -128,8 +128,8 @@ void fgSplashUpdate ( double progress ) {
xglMatrixMode(GL_PROJECTION);
xglPushMatrix();
xglLoadIdentity();
gluOrtho2D(0, globals->get_current_view()->get_winWidth(),
0, globals->get_current_view()->get_winHeight());
gluOrtho2D(0, globals->get_options()->get_xsize(),
0, globals->get_options()->get_ysize());
xglMatrixMode(GL_MODELVIEW);
xglPushMatrix();
xglLoadIdentity();

View file

@ -40,7 +40,7 @@
#include <Cockpit/panel.hxx>
#include <Scenery/scenery.hxx>
#include "options.hxx"
#include "globals.hxx"
#include "viewer.hxx"
@ -86,10 +86,8 @@ void FGViewer::Init( void ) {
view_offset = goal_view_offset = globals->get_options()->get_default_view_offset();
sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
winWidth = globals->get_options()->get_xsize();
winHeight = globals->get_options()->get_ysize();
set_win_ratio( winHeight / winWidth );
set_win_ratio( globals->get_options()->get_xsize() /
globals->get_options()->get_ysize() );
#ifndef USE_FAST_VIEWROT
// This never changes -- NHV
@ -158,13 +156,16 @@ void FGViewer::UpdateViewParams( const FGInterface& f ) {
UpdateViewMath(f);
if ( ! fgPanelVisible() ) {
xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) );
xglViewport( 0, 0 ,
(GLint)(globals->get_options()->get_xsize()),
(GLint)(globals->get_options()->get_ysize()) );
} else {
int view_h =
int((current_panel->getViewHeight() - current_panel->getYOffset())
* (winHeight / 768.0));
glViewport(0, (GLint)(winHeight - view_h),
(GLint)(winWidth), (GLint)(view_h) );
* (globals->get_options()->get_ysize() / 768.0));
glViewport( 0, (GLint)(globals->get_options()->get_ysize() - view_h),
(GLint)(globals->get_options()->get_xsize()),
(GLint)(view_h) );
}
}

View file

@ -41,7 +41,6 @@
#include <FDM/flight.hxx>
#include <Time/light.hxx>
#include "options.hxx"
FG_USING_STD(list);
@ -70,7 +69,7 @@ private:
double win_ratio;
// width & height of window
int winWidth, winHeight;
// int winWidth, winHeight;
// absolute view position in earth coordinates
Point3D abs_view_pos;
@ -165,10 +164,10 @@ public:
inline void set_goal_view_offset( double a) { goal_view_offset = a; }
inline double get_win_ratio() const { return win_ratio; }
inline void set_win_ratio( double r ) { win_ratio = r; }
inline int get_winWidth() const { return winWidth; }
inline void set_winWidth( int w ) { winWidth = w; }
inline int get_winHeight() const { return winHeight; }
inline void set_winHeight( int h ) { winHeight = h; }
// inline int get_winWidth() const { return winWidth; }
// inline void set_winWidth( int w ) { winWidth = w; }
// inline int get_winHeight() const { return winHeight; }
// inline void set_winHeight( int h ) { winHeight = h; }
inline Point3D get_abs_view_pos() const { return abs_view_pos; }
inline Point3D get_view_pos() const { return view_pos; }
inline float *get_pilot_offset() { return pilot_offset; }

View file

@ -41,7 +41,7 @@
#include <Cockpit/panel.hxx>
#include <Scenery/scenery.hxx>
#include "options.hxx"
#include "globals.hxx"
#include "views.hxx"

View file

@ -41,8 +41,6 @@
#include <FDM/flight.hxx>
#include <Time/light.hxx>
#include "options.hxx"
FG_USING_STD(list);

View file

@ -51,7 +51,6 @@
#include <Aircraft/aircraft.hxx>
#include <GUI/gui.h>
#include <Main/options.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
@ -63,7 +62,6 @@ extern "C" {
*/
#include <Main/options.hxx>
#include <Cockpit/hud.hxx>
#include <NetworkOLK/network.h>

View file

@ -50,7 +50,6 @@
#include <Aircraft/aircraft.hxx>
#include <GUI/gui.h>
#include <Main/options.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>

View file

@ -37,8 +37,6 @@
#include <simgear/debug/logstream.hxx>
#include <Main/options.hxx>
#include "scenery.hxx"