Browse Source

Jesse's fixes to support building Panda on VC6

David Rose 22 years ago
parent
commit
a2c3d8143f

+ 9 - 8
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);

+ 6 - 4
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       ; 

+ 3 - 2
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;

+ 5 - 1
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<GeomEntry> Geoms;
 
   // This is the data that must be cycled between pipeline stages.

+ 5 - 1
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<DownConnection> Down;
 
   class EXPCL_PANDA UpConnection {

+ 2 - 2
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;
 }
 

+ 3 - 0
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) \

+ 7 - 2
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;

+ 13 - 2
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 <windows.h>
 #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);