From a2c3d8143f367804481f377506bca283bba16f92 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 3 Jul 2003 20:50:05 +0000 Subject: [PATCH] Jesse's fixes to support building Panda on VC6 --- panda/src/display/graphicsEngine.h | 17 +++++++++-------- panda/src/dxgsg8/d3dfont8.cxx | 10 ++++++---- panda/src/dxgsg8/wdxGraphicsWindow8.cxx | 5 +++-- panda/src/pgraph/geomNode.h | 6 +++++- panda/src/pgraph/pandaNode.h | 6 +++++- panda/src/putil/buttonEventList.h | 4 ++-- panda/src/putil/uniqueIdAllocator.cxx | 3 +++ panda/src/putil/uniqueIdAllocator.h | 9 +++++++-- panda/src/windisplay/winGraphicsWindow.h | 15 +++++++++++++-- 9 files changed, 53 insertions(+), 22 deletions(-) diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index f1a8c7615b..0d37e3066e 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -86,6 +86,15 @@ PUBLISHED: void render_subframe(GraphicsStateGuardian *gsg, DisplayRegion *dr, bool cull_sorting); +public: + enum ThreadState { + TS_wait, + TS_do_frame, + TS_do_flip, + TS_do_release, + TS_terminate + }; + private: typedef pset< PT(GraphicsWindow) > Windows; typedef pset< PT(GraphicsStateGuardian) > GSGs; @@ -139,14 +148,6 @@ private: Mutex _wl_lock; }; - enum ThreadState { - TS_wait, - TS_do_frame, - TS_do_flip, - TS_do_release, - TS_terminate - }; - class RenderThread : public Thread, public WindowRenderer { public: RenderThread(const string &name, GraphicsEngine *engine); diff --git a/panda/src/dxgsg8/d3dfont8.cxx b/panda/src/dxgsg8/d3dfont8.cxx index e64113406a..c1bfbdb637 100644 --- a/panda/src/dxgsg8/d3dfont8.cxx +++ b/panda/src/dxgsg8/d3dfont8.cxx @@ -143,7 +143,8 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) { SIZE size; SIZE sizes [ 127 - 32 ] ; - for(TCHAR c=32; c<127; c++) { + TCHAR c; + for(c=32; c<127; c++) { str[0] = c; // GetTextExtentPoint32 does not care that the font is Italic or not, it will // return the same value. However, if we specify an Italic font, the output @@ -272,7 +273,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) { x = 0 ; y = 0 ; - for(TCHAR c=32; c<127; c++) { + for(c=32; c<127; c++) { str[0] = c; GetTextExtentPoint32( hDC, str, 1, &size ); if((DWORD)(x+size.cx+1) > m_dwTexWidth) { @@ -662,7 +663,8 @@ HRESULT CD3DFont::EndText ( void ) { // User will make another batch if necessary // bool bFiltered = false ; - for(UINT i = 0 ; i < m_nDeferedCalls ; ++ i) { + UINT i; + for(i = 0 ; i < m_nDeferedCalls ; ++ i) { DWORD dwFlags = m_DTArgs [ i ].m_dwFlags ; if(dwFlags & D3DFONT_FILTERED) { bFiltered = true ; @@ -686,7 +688,7 @@ HRESULT CD3DFont::EndText ( void ) { bool bItalic = 0 != ( m_dwFontFlags & D3DFONT_ITALIC ) ; // loop on our batched sets of arguments - for(UINT i = 0 ; i < m_nDeferedCalls ; ++ i) { + for(i = 0 ; i < m_nDeferedCalls ; ++ i) { bool bScaled = m_DTArgs [ i ].m_bScaled ; FLOAT x = m_DTArgs [ i ].m_x ; FLOAT y = m_DTArgs [ i ].m_y ; diff --git a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx index f6b86df1e6..fc257ff2c6 100644 --- a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx @@ -328,6 +328,7 @@ do_fullscreen_resize(int x_size, int y_size) { DCAST_INTO_R(dxpipe, _pipe, false); bool bIsGoodMode=false; + bool bResizeSucceeded=false; if (!dxpipe->special_check_fullscreen_resolution(_wcontext, x_size,y_size)) { // bypass the lowvidmem test below for certain "lowmem" cards we know have valid modes @@ -364,7 +365,7 @@ do_fullscreen_resize(int x_size, int y_size) { _wcontext.PresParams.BackBufferFormat = pixFmt; // make reset_device_resize use presparams or displaymode?? - bool bResizeSucceeded = reset_device_resize_window(x_size, y_size); + bResizeSucceeded = reset_device_resize_window(x_size, y_size); if (!bResizeSucceeded) { wdxdisplay8_cat.error() << "resize() failed with OUT-OF-MEMORY error!\n"; @@ -640,6 +641,7 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer DWORD dwRenderWidth=Display.DisplayMode.Width; DWORD dwRenderHeight=Display.DisplayMode.Height; + DWORD dwBehaviorFlags=0x0; LPDIRECT3D8 pD3D8=Display.pD3D8; D3DCAPS8 *pD3DCaps = &Display.d3dcaps; D3DPRESENT_PARAMETERS* pPresParams = &Display.PresParams; @@ -720,7 +722,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer pPresParams->hDeviceWindow = Display.hWnd; pPresParams->BackBufferWidth = Display.DisplayMode.Width; pPresParams->BackBufferHeight = Display.DisplayMode.Height; - DWORD dwBehaviorFlags=0x0; if (_wcontext.bIsTNLDevice) { dwBehaviorFlags|=D3DCREATE_HARDWARE_VERTEXPROCESSING; diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index 54b3d58e98..ac6660dbdc 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -76,13 +76,17 @@ public: protected: virtual BoundingVolume *recompute_internal_bound(); -private: +public: + // This must be declared public so that VC6 will allow the nested + // CData class to access it. class GeomEntry { public: INLINE GeomEntry(Geom *geom, const RenderState *state); PT(Geom) _geom; CPT(RenderState) _state; }; + +private: typedef pvector Geoms; // This is the data that must be cycled between pipeline stages. diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 12db9995d7..27cc7255d9 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -232,7 +232,9 @@ private: void fix_path_lengths(const CData *cdata); void r_list_descendants(ostream &out, int indent_level) const; -private: +public: + // This must be declared public so that VC6 will allow the nested + // CData class to access it. class EXPCL_PANDA DownConnection { public: INLINE DownConnection(PandaNode *child, int sort); @@ -248,6 +250,8 @@ private: PT(PandaNode) _child; int _sort; }; + +private: typedef ov_multiset Down; class EXPCL_PANDA UpConnection { diff --git a/panda/src/putil/buttonEventList.h b/panda/src/putil/buttonEventList.h index 036b16b9f9..462334f14e 100644 --- a/panda/src/putil/buttonEventList.h +++ b/panda/src/putil/buttonEventList.h @@ -72,8 +72,8 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const ButtonEventList &list) { - list.output(out); +INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) { + buttonlist.output(out); return out; } diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index a335594740..19618e4bb7 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -25,6 +25,9 @@ NotifyCategoryDecl(uniqueIdAllocator, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDef(uniqueIdAllocator, ""); +const U32 UniqueIdAllocator::IndexEnd=(U32)-1; +const U32 UniqueIdAllocator::IndexAllocated=(U32)-2; + #ifndef NDEBUG //[ // Non-release build: #define uniqueIdAllocator_debug(msg) \ diff --git a/panda/src/putil/uniqueIdAllocator.h b/panda/src/putil/uniqueIdAllocator.h index 9d20e8b5d9..c5615c2e84 100644 --- a/panda/src/putil/uniqueIdAllocator.h +++ b/panda/src/putil/uniqueIdAllocator.h @@ -57,10 +57,15 @@ PUBLISHED: void output(ostream& os, bool verbose=false) const; public: - static const U32 IndexEnd=(U32)-1; + // VC6 does not support declaring const values within the class + // definition; we must therefore define the value for this in the + // .cxx file. This does potentially change the way the code is + // generated (since the compiler does not necessarily know the value + // of this constant). + static const U32 IndexEnd; protected: - static const U32 IndexAllocated=(U32)-2; + static const U32 IndexAllocated; U32* _table; U32 _min; U32 _max; diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index b52d9f8967..ed579cdfc2 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -24,6 +24,8 @@ // newer fns #define _WIN32_WINNT 0x0502 +// Jesse thinks that this is supposed to say WIN32_LEAN_AND_MEAN, but he +// doesn't want to fix what isn't broken. #define WINDOWS_LEAN_AND_MEAN #include #undef WINDOWS_LEAN_AND_MEAN @@ -111,7 +113,17 @@ private: // This is used to remember the state of the keyboard when keyboard // focus is lost. - static const int num_virtual_keys = 256; + enum { num_virtual_keys = 256 }; + // You might be wondering why the above is an enum. Originally the line + // read "static const int num_virtual_keys = 256" + // but in trying to support the MSVC6 compiler, we found that you + // were not allowed to define the value of a const within a class like + // that. Defining the value outside the class helps, but then we can't + // use the value to define the length of the _keyboard_state array, and + // also it creates multiply defined symbol errors when you link, because + // other files include this header file. This enum is a clever solution + // to work around the problem. + BYTE _keyboard_state[num_virtual_keys]; protected: @@ -163,7 +175,6 @@ private: static TypeHandle _type_handle; }; - #define PRINT_LAST_ERROR 0 extern EXPCL_PANDAWIN void PrintErrorMessage(DWORD msgID); extern EXPCL_PANDAWIN void ClearToBlack(HWND hWnd, const WindowProperties &props);