[Opengc-devel] First impressions and some patches.
Status: Pre-Alpha
Brought to you by:
madmartigan
From: Lance W. <lan...@lo...> - 2001-10-26 10:29:47
|
Some observations (based on Windows version). As it stands, OpenGC is painfully slow. The hardware I ran it on is not the greatest (P200, 48 Mb with some strange on-board graphics card - well hey, it was free :-), but with FreeFd I could get a usable 5 fps - OpenGC ran at less that ONE fps. Bummer. So I started delving and turned line and font smoothing off, but it was still horribly slow. More delving turned up the cause of the problem in the FSUIPCDataSource. In the idle function, it reads and processes the whole 15k data block available from fsuipc, EVERY TIME! This is a major stumbling block. When I trimmed the idle function down to only read the variables that are used, there was a vast speed improvement, better than FreeFd - so I suggest there is room for improvement here. Also in its present form I think it might overload WideClient/WideServer. Several times FS would stop completely, until I killed ogc. Patches. While I was in there I implemented the standard magenta cross hair flight director. Code follows... I've also snaffled a file from the fltk library to get rid of the console window for WIN32 release versions. Cheers Lance P.S.'s If you don't want stuff submitted like this, just yell - always willing to oblige :-) By the way, I'm willing to be a fully paid up, card carrying project member if you like. Is there a list of who's doing what so we don't tread on other peoples toes? P.P.S. As a sideline I built & ran it on Linux, just to see if it would - it did! (I did change the template bit though). ogcDataSource.h -------------------------------------------------------------- 239,244d238 < < // Flight Director < unsigned int Director_Active; < double Director_Bank; < double Director_Pitch; < --------------------------------------------------------------- ogcBoeing777ArtificialHorizon.cpp --------------------------------------------------------------- 469,494d468 < //----------------Flight Director---------------- < // Reset the modelview matrix < glPopMatrix(); < glPushMatrix(); < if (m_pDataSource->Director_Active == 1) < { < // Move to the center of the window < glTranslated(47,49,0); < glColor3ub(255,0,255); < glLineWidth(3.0); < glPushMatrix(); < glTranslated(0,(m_pDataSource->Director_Pitch-m_pDataSource->Pitch)*2.0,0); < glBegin(GL_LINES); < glVertex2f(-20,0); < glVertex2f(20,0); < glEnd(); < glPopMatrix(); < glPushMatrix(); < glTranslated((m_pDataSource->Director_Bank-m_pDataSource->Bank),0,0); < glRotated(90.0, 0, 0, 1); < glBegin(GL_LINES); < glVertex2f(-20,0); < glVertex2f(20,0); < glEnd(); < glPopMatrix(); < } --------------------------------------------------------------- ogcFSUIPCDataSource.cpp Current idle function --------------------------------------------------------------- < Director_Active = (unsigned int) *(short*)(&m_pData[0x2EE0]); < Director_Bank = -1*( (double) *(double*)(&m_pData[0x2EF0]) ); < Director_Pitch = -1*( (double) *(double*)(&m_pData[0x2EE8]) ); --------------------------------------------------------------- New idle function --------------------------------------------------------------- void ogcFSUIPCDataSource::OnIdle() { DWORD dwResult; // Modified to always try & open the connection if it's down. // This means you can start OpenGC before FS. if(!m_ValidConnection) { // Try to open the FSUIPC connection if (FSUIPC_Open(SIM_ANY, &dwResult)) { m_ValidConnection = true; } else return; } // Temporary variables long _bank; long _pitch; long _tHeading; long _tas; long _ias; long _fracMeters; long _unitMeters; short _dirActive; double _dirPitch; double _dirBank; FSUIPC_Read(0x057c, 4, &_bank, &dwResult); FSUIPC_Read(0x0578, 4, &_pitch, &dwResult); FSUIPC_Read(0x0580, 4, &_tHeading, &dwResult); FSUIPC_Read(0x02b8, 4, &_tas, &dwResult); FSUIPC_Read(0x02bc, 4, &_ias, &dwResult); FSUIPC_Read(0x0570, 4, &_fracMeters, &dwResult); FSUIPC_Read(0x0574, 4, &_unitMeters, &dwResult); FSUIPC_Read(0x2ee0, 2, &_dirActive, &dwResult); FSUIPC_Read(0x2ef0, 8, &_dirBank, &dwResult); FSUIPC_Read(0x2ee8, 8, &_dirPitch, &dwResult); FSUIPC_Process(&dwResult); Bank = -360.0*( (double) _bank )/(65356.0*65356.0); Pitch = -360.0*( (double) _pitch )/(65356.0*65356.0); True_Heading = 360.0*((double)_tHeading)/(65356.0*65356.0); Magnetic_Heading = True_Heading - Magnetic_Variation; TAS = (double)_tas/128; IAS = (double)_ias/128; // Compute altitude // Note that we use the meters and fractional meters data, rather than // the barometric altitude in feet as computed by FSUIPC (which seems // to update rather slowly) //unsigned long fractionalMeters = *(unsigned long*)(&m_pData[0x0570]); unsigned long fractionalMeters = (unsigned long)_fracMeters; long unitMeters = _unitMeters; // 4294967296 is 2^32, because the fractional unit is scaled to maximum // possible magnitude of an unsigned long int Barometric_Alt_Metres = (double) unitMeters + (double) fractionalMeters / 4294967296; Barometric_Alt_Feet = Barometric_Alt_Metres * 3.28084; Director_Active = (unsigned int) _dirActive; Director_Bank = -1*( (double) _dirBank ); Director_Pitch = -1*( (double) _dirPitch ); } ------------------------------------------------------------- **************************************************************************** LOGICSCOPE REALISATIONS LTD, 64 Great Eastern St, London EC2A 3QR The information contained in this document is intended only for the addressee.It may contain confidential and/or legally privileged material.You may not review, retransmit, disseminate, publish or otherwise use or rely on the information in this document unless you are its intended recipient.If you have received this document in error, Please contact the sender and delete all copies of this material. |