David Rose 20 rokov pred
rodič
commit
5da0172878
34 zmenil súbory, kde vykonal 1392 pridanie a 4122 odobranie
  1. 1 4
      panda/metalibs/pandadx7/Sources.pp
  2. 13 13
      panda/src/display/graphicsStateGuardian.I
  3. 0 31
      panda/src/display/graphicsStateGuardian.cxx
  4. 1 8
      panda/src/display/graphicsStateGuardian.h
  5. 7 3
      panda/src/display/standardMunger.cxx
  6. 5 12
      panda/src/dxgsg7/Sources.pp
  7. 14 1
      panda/src/dxgsg7/config_dxgsg7.cxx
  8. 2 0
      panda/src/dxgsg7/config_dxgsg7.h
  9. 46 0
      panda/src/dxgsg7/dxGeomMunger7.I
  10. 156 0
      panda/src/dxgsg7/dxGeomMunger7.cxx
  11. 74 0
      panda/src/dxgsg7/dxGeomMunger7.h
  12. 97 331
      panda/src/dxgsg7/dxGraphicsStateGuardian7.I
  13. 699 3238
      panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx
  14. 116 242
      panda/src/dxgsg7/dxGraphicsStateGuardian7.h
  15. 29 0
      panda/src/dxgsg7/dxTextureContext7.I
  16. 27 39
      panda/src/dxgsg7/dxTextureContext7.cxx
  17. 6 8
      panda/src/dxgsg7/dxTextureContext7.h
  18. 1 0
      panda/src/dxgsg7/dxgsg7_composite1.cxx
  19. 8 14
      panda/src/dxgsg7/dxgsg7base.h
  20. 12 103
      panda/src/dxgsg7/wdxGraphicsWindow7.cxx
  21. 0 2
      panda/src/dxgsg7/wdxGraphicsWindow7.h
  22. 26 22
      panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx
  23. 2 2
      panda/src/dxgsg8/dxGraphicsStateGuardian8.h
  24. 2 2
      panda/src/dxgsg8/wdxGraphicsWindow8.h
  25. 1 10
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx
  26. 0 2
      panda/src/glstuff/glGraphicsStateGuardian_src.h
  27. 23 20
      panda/src/gobj/geomEnums.h
  28. 5 1
      panda/src/gobj/geomLinestrips.cxx
  29. 5 2
      panda/src/gobj/geomPrimitive.cxx
  30. 5 1
      panda/src/gobj/geomTrifans.cxx
  31. 5 1
      panda/src/gobj/geomTristrips.cxx
  32. 1 1
      panda/src/gobj/matrixLens.cxx
  33. 2 8
      panda/src/gsgbase/graphicsStateGuardianBase.h
  34. 1 1
      panda/src/mathutil/plane_src.I

+ 1 - 4
panda/metalibs/pandadx7/Sources.pp

@@ -1,7 +1,4 @@
-// DX7 build is temporarily disabled until we bring it up-to-date with
-// the new Geom rewrite.
-#define BUILD_DIRECTORY
-//#define BUILD_DIRECTORY $[HAVE_DX]
+#define BUILD_DIRECTORY $[HAVE_DX]
 
 // DIR_TYPE "metalib" indicates we are building a shared library that
 // consists mostly of references to other shared libraries.  Under

+ 13 - 13
panda/src/display/graphicsStateGuardian.I

@@ -119,6 +119,19 @@ is_active() const {
   return _active && _is_valid;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::is_valid
+//       Access: Published
+//  Description: Returns true if the GSG has been correctly
+//               initialized within a graphics context, false if there
+//               has been some problem or it hasn't been initialized
+//               yet.
+////////////////////////////////////////////////////////////////////
+INLINE bool GraphicsStateGuardian::
+is_valid() const {
+  return _is_valid;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::get_properties
 //       Access: Published
@@ -619,19 +632,6 @@ mark_new() {
   _needs_reset = true;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsStateGuardian::is_valid
-//       Access: Public
-//  Description: Returns true if the GSG has been correctly
-//               initialized within a graphics context, false if there
-//               has been some problem or it hasn't been initialized
-//               yet.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsStateGuardian::
-is_valid() const {
-  return _is_valid;
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::get_transform
 //       Access: Public

+ 0 - 31
panda/src/display/graphicsStateGuardian.cxx

@@ -752,37 +752,6 @@ void GraphicsStateGuardian::
 end_frame() {
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsStateGuardian::wants_normals
-//       Access: Public, Virtual
-//  Description:
-////////////////////////////////////////////////////////////////////
-bool GraphicsStateGuardian::
-wants_normals() const {
-  return (_lighting_enabled || (_force_normals != 0));
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsStateGuardian::wants_texcoords
-//       Access: Public, Virtual
-//  Description:
-////////////////////////////////////////////////////////////////////
-bool GraphicsStateGuardian::
-wants_texcoords() const {
-  return false;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsStateGuardian::wants_colors
-//       Access: Public, Virtual
-//  Description: Returns true if the GSG should issue geometry color
-//               commands, false otherwise.
-////////////////////////////////////////////////////////////////////
-bool GraphicsStateGuardian::
-wants_colors() const {
-  return _vertex_colors_enabled;
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::depth_offset_decals
 //       Access: Public, Virtual

+ 1 - 8
panda/src/display/graphicsStateGuardian.h

@@ -76,6 +76,7 @@ PUBLISHED:
 
   INLINE void set_active(bool active);
   INLINE bool is_active() const;
+  INLINE bool is_valid() const;
 
   INLINE const FrameBufferProperties &get_properties() const;
   INLINE GraphicsPipe *get_pipe() const;
@@ -167,13 +168,6 @@ public:
   virtual void end_scene();
   virtual void end_frame();
 
-  // These functions will be queried by the GeomIssuer to determine if
-  // it should issue normals, texcoords, and/or colors, based on the
-  // GSG's current state.
-  virtual bool wants_normals() const;
-  virtual bool wants_texcoords() const;
-  virtual bool wants_colors() const;
-
   virtual bool depth_offset_decals();
   virtual CPT(RenderState) begin_decal_base_first();
   virtual CPT(RenderState) begin_decal_nested();
@@ -194,7 +188,6 @@ public:
   INLINE bool reset_if_new();
   INLINE void mark_new();
   virtual void reset();
-  INLINE bool is_valid() const;
 
   INLINE CPT(TransformState) get_transform();
   

+ 7 - 3
panda/src/display/standardMunger.cxx

@@ -169,11 +169,9 @@ munge_data_impl(const GeomVertexData *data) {
 ////////////////////////////////////////////////////////////////////
 bool StandardMunger::
 munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) {
-  int geom_rendering = geom->get_geom_rendering();
   int supported_geom_rendering = _gsg->get_supported_geom_rendering();
 
-  int unsupported_bits = geom_rendering & ~supported_geom_rendering;
-
+  int unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering;
   if (unsupported_bits != 0) {
     // Even beyond munging the vertex format, we have to convert the
     // Geom itself into a new primitive type the GSG can render
@@ -188,6 +186,10 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) {
       // any GSG's that can support strips without also supporting
       // fans.
       geom = geom->decompose();
+
+      // Decomposing might produce an indexed Geom, so re-check the
+      // unsupported bits.
+      unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering;
     }
     if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) {
       // Rotate the vertices to account for different shade-model
@@ -198,8 +200,10 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) {
     if ((unsupported_bits & Geom::GR_indexed_bits) != 0) {
       // Convert indexed geometry to nonindexed geometry.
       PT(Geom) new_geom = geom->make_copy();
+      new_geom->set_vertex_data(vertex_data);
       new_geom->make_nonindexed(false);
       geom = new_geom;
+      vertex_data = new_geom->get_vertex_data();
     }
   }
 

+ 5 - 12
panda/src/dxgsg7/Sources.pp

@@ -1,7 +1,4 @@
-// DX7 build is temporarily disabled until we bring it up-to-date with
-// the new Geom rewrite.
-#define BUILD_DIRECTORY
-//#define BUILD_DIRECTORY $[HAVE_DX]
+#define BUILD_DIRECTORY $[HAVE_DX]
 
 #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
                    dtoolutil:c dtoolbase:c dtool:m
@@ -20,23 +17,19 @@
     putil linmath mathutil pnmimage event
     
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
-
-  // need to install these due to external projects that link directly with libpandadx (bartop)  
-  #define INSTALL_HEADERS \
-    config_dxgsg7.h dxGraphicsStateGuardian7.I dxGraphicsStateGuardian7.h \
-    dxTextureContext7.h dxgsg7base.h
-
-  // build dxGraphicsStateGuardian separately since its so big
   
   #define SOURCES \
     dxGraphicsStateGuardian7.cxx \
+    dxGeomMunger7.I dxGeomMunger7.h \
+    dxTextureContext7.I dxTextureContext7.h \
     wdxGraphicsPipe7.I wdxGraphicsPipe7.h \
-    wdxGraphicsWindow7.I wdxGraphicsWindow7.h \
+    wdxGraphicsWindow7.I wdxGraphicsWindow7.h 
     $[INSTALL_HEADERS]
     
   #define INCLUDED_SOURCES \
     config_dxgsg7.cxx \
     dxgsg7base.cxx \
+    dxGeomMunger7.cxx \
     dxTextureContext7.cxx \
     wdxGraphicsPipe7.cxx wdxGraphicsWindow7.cxx
 

+ 14 - 1
panda/src/dxgsg7/config_dxgsg7.cxx

@@ -28,7 +28,7 @@
 
 Configure(config_dxgsg7);
 NotifyCategoryDef(dxgsg7, ":display:gsg");
-NotifyCategoryDef(wdxdisplay7, "windisplay");
+NotifyCategoryDef(wdxdisplay7, "display");
 
 //  Configure this to TRUE if you want DirectX to control the entire screen,
 //  If false, it will just blit into a window.
@@ -76,6 +76,18 @@ ConfigVariableBool dx_do_vidmemsize_check
 ConfigVariableBool dx_preserve_fpu_state
 ("dx-preserve-fpu-state", true);
 
+ConfigVariableBool dx_broken_max_index
+("dx-broken-max-index", false,
+ PRC_DESC("Configure this true if you have a buggy graphics driver that "
+          "doesn't correctly implement the third parameter, NumVertices, "
+          "of DrawIndexedPrimitive().  In particular, the NVIDIA Quadro "
+          "driver version 6.14.10.7184 seems to treat this as a maximum "
+          "vertex index, rather than a delta between the maximum and "
+          "minimum vertex index.  Turn this on if you are seeing stray "
+          "triangles, or you are not seeing all of your triangles.  Enabling "
+          "this should work around this bug, at the cost of some additional "
+          "rendering overhead on the GPU."));
+
 #ifdef _DEBUG
 ConfigVariableDouble dx_global_miplevel_bias
 ("dx-global-miplevel-bias", 0.0);
@@ -112,6 +124,7 @@ init_libdxgsg7() {
 
   DXGraphicsStateGuardian7::init_type();
   DXTextureContext7::init_type();
+  DXGeomMunger7::init_type();
 
   wdxGraphicsPipe7::init_type();
   wdxGraphicsWindow7::init_type();

+ 2 - 0
panda/src/dxgsg7/config_dxgsg7.h

@@ -47,6 +47,8 @@ extern ConfigVariableBool dx_preserve_fpu_state;
 extern ConfigVariableInt dx_force_backface_culling;
 #endif
 
+extern ConfigVariableBool dx_broken_max_index;
+
 #ifdef _DEBUG
 extern ConfigVariableDouble dx_global_miplevel_bias;
 extern ConfigVariableBool dx_debug_view_mipmaps;

+ 46 - 0
panda/src/dxgsg7/dxGeomMunger7.I

@@ -0,0 +1,46 @@
+// Filename: dxGeomMunger7.I
+// Created by:  drose (11Mar05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGeomMunger7::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE DXGeomMunger7::
+DXGeomMunger7(GraphicsStateGuardian *gsg, const RenderState *state) :
+  StandardMunger(gsg, state, 1, NT_packed_dabc, C_color),
+  _texture(state->get_texture()),
+  _tex_gen(state->get_tex_gen())
+{
+  if (_texture != (TextureAttrib *)NULL) {
+    _texture = _texture->filter_to_max(gsg->get_max_texture_stages());
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGeomMunger7::operator new
+//       Access: Public
+//  Description: Calls up to do_operator_new() to implement the
+//               low-overhead allocation/deallocation for this type of
+//               GeomMunger.
+////////////////////////////////////////////////////////////////////
+INLINE void *DXGeomMunger7::
+operator new(size_t size) {
+  return do_operator_new(size, &_deleted_chain);
+}

+ 156 - 0
panda/src/dxgsg7/dxGeomMunger7.cxx

@@ -0,0 +1,156 @@
+// Filename: dxGeomMunger7.cxx
+// Created by:  drose (11Mar05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "dxGeomMunger7.h"
+#include "geomVertexReader.h"
+#include "geomVertexWriter.h"
+#include "config_dxgsg7.h"
+
+GeomMunger *DXGeomMunger7::_deleted_chain = NULL;
+TypeHandle DXGeomMunger7::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGeomMunger7::munge_format_impl
+//       Access: Protected, Virtual
+//  Description: Given a source GeomVertexFormat, converts it if
+//               necessary to the appropriate format for rendering.
+////////////////////////////////////////////////////////////////////
+CPT(GeomVertexFormat) DXGeomMunger7::
+munge_format_impl(const GeomVertexFormat *orig,
+                  const GeomVertexAnimationSpec &animation) {
+  nassertr(animation.get_animation_type() != AT_hardware, NULL);
+
+  // We have to build a completely new format that includes only the
+  // appropriate components, in the appropriate order, in just one
+  // array.
+  PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig);
+  PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat;
+
+  const GeomVertexColumn *vertex_type = orig->get_vertex_column();
+  const GeomVertexColumn *normal_type = orig->get_normal_column(); 
+  const GeomVertexColumn *color_type = orig->get_color_column();
+
+  if (vertex_type != (const GeomVertexColumn *)NULL) {
+    new_array_format->add_column
+      (InternalName::get_vertex(), 3, NT_float32,
+       vertex_type->get_contents());
+    new_format->remove_column(vertex_type->get_name());
+
+  } else {
+    // If we don't have a vertex type, not much we can do.
+    return orig;
+  }
+
+  if (normal_type != (const GeomVertexColumn *)NULL) {
+    new_array_format->add_column
+      (InternalName::get_normal(), 3, NT_float32, C_vector);
+    new_format->remove_column(normal_type->get_name());
+  }
+
+  if (color_type != (const GeomVertexColumn *)NULL) {
+    new_array_format->add_column
+      (InternalName::get_color(), 1, NT_packed_dabc, C_color);
+    new_format->remove_column(color_type->get_name());
+  }
+
+  // To support multitexture, we will need to add all of the relevant
+  // texcoord types, and in the correct order.
+
+  // Now set up each of the active texture coordinate stages--or at
+  // least those for which we're not generating texture coordinates
+  // automatically.
+
+  // Now copy all of the texture coordinates in, in order by stage
+  // index.  But we have to reuse previous columns.
+  if (_texture != (TextureAttrib *)NULL) {
+    typedef pset<const InternalName *> UsedStages;
+    UsedStages used_stages;
+
+    int num_stages = _texture->get_num_on_stages();
+    for (int i = 0; i < num_stages; ++i) {
+      TextureStage *stage = _texture->get_on_stage(i);
+
+      const InternalName *name = stage->get_texcoord_name();
+      if (used_stages.insert(name).second) {
+        // This is the first time we've encountered this texcoord name.
+        const GeomVertexColumn *texcoord_type = orig->get_column(name);
+        
+        if (texcoord_type != (const GeomVertexColumn *)NULL) {
+          new_array_format->add_column
+            (name, texcoord_type->get_num_values(), NT_float32, C_texcoord);
+        } else {
+          // We have to add something as a placeholder, even if the
+          // texture coordinates aren't defined.
+          new_array_format->add_column(name, 2, NT_float32, C_texcoord);
+        }
+        new_format->remove_column(name);
+      }
+    }
+  }
+
+  // Make sure the FVF-style array we just built up is first in the
+  // list.
+  new_format->insert_array(0, new_array_format);
+
+  return GeomVertexFormat::register_format(new_format);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGeomMunger7::compare_to_impl
+//       Access: Protected, Virtual
+//  Description: Called to compare two GeomMungers who are known to be
+//               of the same type, for an apples-to-apples comparison.
+//               This will never be called on two pointers of a
+//               different type.
+////////////////////////////////////////////////////////////////////
+int DXGeomMunger7::
+compare_to_impl(const GeomMunger *other) const {
+  const DXGeomMunger7 *om = DCAST(DXGeomMunger7, other);
+  if (_texture != om->_texture) {
+    return _texture < om->_texture ? -1 : 1;
+  }
+  if (_tex_gen != om->_tex_gen) {
+    return _tex_gen < om->_tex_gen ? -1 : 1;
+  }
+
+  return StandardMunger::compare_to_impl(other);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGeomMunger7::geom_compare_to_impl
+//       Access: Protected, Virtual
+//  Description: Called to compare two GeomMungers who are known to be
+//               of the same type, for an apples-to-apples comparison.
+//               This will never be called on two pointers of a
+//               different type.
+////////////////////////////////////////////////////////////////////
+int DXGeomMunger7::
+geom_compare_to_impl(const GeomMunger *other) const {
+  // Unlike GLGeomMunger, we do consider _texture and _tex_gen
+  // important for this purpose, since they control the number and
+  // order of texture coordinates we might put into the FVF.
+  const DXGeomMunger7 *om = DCAST(DXGeomMunger7, other);
+  if (_texture != om->_texture) {
+    return _texture < om->_texture ? -1 : 1;
+  }
+  if (_tex_gen != om->_tex_gen) {
+    return _tex_gen < om->_tex_gen ? -1 : 1;
+  }
+
+  return StandardMunger::geom_compare_to_impl(other);
+}

+ 74 - 0
panda/src/dxgsg7/dxGeomMunger7.h

@@ -0,0 +1,74 @@
+// Filename: dxGeomMunger7.h
+// Created by:  drose (11Mar05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef DXGEOMMUNGER7_H
+#define DXGEOMMUNGER7_H
+
+#include "pandabase.h"
+#include "standardMunger.h"
+#include "graphicsStateGuardian.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : DXGeomMunger7
+// Description : This specialization on GeomMunger finesses vertices
+//               for DirectX rendering.  In particular, it makes sure
+//               colors are stored in DirectX's packed_argb format,
+//               and that all relevant components are packed into a
+//               single array, in the correct order.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDADX DXGeomMunger7 : public StandardMunger {
+public:
+  INLINE DXGeomMunger7(GraphicsStateGuardian *gsg, const RenderState *state);
+
+protected:
+  virtual CPT(GeomVertexFormat) munge_format_impl(const GeomVertexFormat *orig,
+                                                    const GeomVertexAnimationSpec &animation);
+
+  virtual int compare_to_impl(const GeomMunger *other) const;
+  virtual int geom_compare_to_impl(const GeomMunger *other) const;
+
+public:
+  INLINE void *operator new(size_t size);
+
+private:
+  CPT(TextureAttrib) _texture;
+  CPT(TexGenAttrib) _tex_gen;
+
+  static GeomMunger *_deleted_chain;
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    StandardMunger::init_type();
+    register_type(_type_handle, "DXGeomMunger7",
+                  StandardMunger::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "dxGeomMunger7.I"
+
+#endif

+ 97 - 331
panda/src/dxgsg7/dxGraphicsStateGuardian7.I

@@ -18,347 +18,113 @@
 
 
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_line_smooth
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_line_smooth(bool val) {
-  if(_line_smooth_enabled != val) {
-    _line_smooth_enabled = val;
-  #ifndef NDEBUG
-    {
-        if(val && (_pScrn->D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
-           dxgsg7_cat.error() << "no HW support for line smoothing!!\n";
-    }
-  #endif
-
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_dither
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_dither(bool val) {
-  if (_dither_enabled != val) {
-    _dither_enabled = val;
-
-  #ifndef NDEBUG
-    {
-        if(val && !(_pScrn->D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
-           dxgsg7_cat.error() << "no HW support for color dithering!!\n";
-    }
-  #endif
-
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_stencil_test
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_stencil_test(bool val) {
-  if (_stencil_test_enabled != val) {
-    _stencil_test_enabled = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_color_material
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_color_material(bool val) {
-  if (_color_material_enabled != val) {
-    _color_material_enabled = val;
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_blend
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_blend(bool val) {
-  if (_blend_enabled != val) {
-    _blend_enabled = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_blend
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-set_shademode(D3DSHADEMODE val) {
-  if (_CurShadeMode != val) {
-    _CurShadeMode = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
-  }
-}
-
-INLINE void DXGraphicsStateGuardian7::
-enable_primitive_clipping(bool val) {
-  if (_clipping_enabled != val) {
-    _clipping_enabled = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_fog
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_fog(bool val) {
-  if ((_fog_enabled != val) && (_doFogType!=None)) {
-    _fog_enabled = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_alpha_test
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_alpha_test(bool val )
-{
-  if (_alpha_test_enabled != val) {
-    _alpha_test_enabled = val;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::call_dxLightModelAmbient
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-call_dxLightModelAmbient( const Colorf& color)
-{
-  if (_lmodel_ambient != color) {
-    _lmodel_ambient = color;
-#ifdef GSG_VERBOSE
-    dxgsg7_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
-#endif
-    _pScrn->pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
-                D3DRGBA(color[0], color[1], color[2], color[3]));
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::call_dxAlphaFunc
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
-  if (_alpha_func != func) {
-    _alpha_func = func;
-#ifdef GSG_VERBOSE
-    dxgsg7_cat.debug() << "dxAlphaFunc(";
-    switch (func) {
-    case D3DCMP_NEVER:
-      dxgsg7_cat.debug(false) << "D3DCMP_NEVER";
-      break;
-    case D3DCMP_LESS:
-      dxgsg7_cat.debug(false) << "D3DCMP_LESS";
-      break;
-    case D3DCMP_EQUAL:
-      dxgsg7_cat.debug(false) << "D3DCMP_EQUAL";
-      break;
-#ifdef D3DCMP_LEQUAL
-    case D3DCMP_LEQUAL:
-      dxgsg7_cat.debug(false) << "D3DCMP_LEQUAL";
-      break;
-#endif
-    case D3DCMP_GREATER:
-      dxgsg7_cat.debug(false) << "D3DCMP_GREATER";
-      break;
-    case D3DCMP_NOTEQUAL:
-      dxgsg7_cat.debug(false) << "D3DCMP_NOTEQUAL";
-      break;
-#ifdef D3DCMP_GEQUAL
-    case D3DCMP_GEQUAL:
-      dxgsg7_cat.debug(false) << "D3DCMP_GEQUAL";
-      break;
-#endif
-    case D3DCMP_ALWAYS:
-      dxgsg7_cat.debug(false) << "D3DCMP_ALWAYS";
-      break;
+//     Function: DXGraphicsStateGuardian7::Colorf_to_D3DCOLOR
+//       Access: Public, Static
+//  Description: Converts Panda's floating-point Colorf structure to
+//               DirectX's D3DCOLOR packed structure.
+////////////////////////////////////////////////////////////////////
+INLINE DWORD DXGraphicsStateGuardian7::
+Colorf_to_D3DCOLOR(const Colorf &cColorf) {
+// MS VC defines _M_IX86 for x86.  gcc should define _X86_
+#if defined(_M_IX86) || defined(_X86_)
+    DWORD d3dcolor,tempcolorval=255;
+
+    // note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
+    // dont think this makes much difference
+
+    __asm {
+        push ebx   ; want to save this in case this fn is inlined
+        push ecx
+        mov ecx, cColorf
+        fild tempcolorval
+        fld DWORD PTR [ecx]
+        fmul ST(0),ST(1)
+        fistp tempcolorval  ; no way to store directly to int register
+        mov eax, tempcolorval
+        shl eax, 16
+
+        fld DWORD PTR [ecx+4]  ;grn
+        fmul ST(0),ST(1)
+        fistp tempcolorval
+        mov ebx,tempcolorval
+        shl ebx, 8
+        or eax,ebx
+
+        fld DWORD PTR [ecx+8]  ;blue
+        fmul ST(0),ST(1)
+        fistp tempcolorval
+        or eax,tempcolorval
+
+        fld DWORD PTR [ecx+12] ;alpha
+        fmul ST(0),ST(1)
+        fistp tempcolorval
+        ; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
+        ffree ST(0)
+        fincstp
+        mov ebx,tempcolorval
+        shl ebx, 24
+        or eax,ebx
+        mov d3dcolor,eax
+        pop ecx
+        pop ebx
     }
-    dxgsg7_cat.debug() << " , " << reference_alpha << ")" << endl;
-#endif
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
-  }
 
-  if(_alpha_func_refval != reference_alpha) {
-      _alpha_func_refval = reference_alpha;
-      _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, (UINT) (reference_alpha*255.0f));  //d3d uses 0x0-0xFF, not a float
+   //   dxgsg7_cat.debug() << (void*)d3dcolor << endl;
+   return d3dcolor;
+#else //!_X86_
+   return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
+#endif //!_X86_
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXGraphicsStateGuardian7::get_texture_wrap_mode
+//       Access: Protected, Static
+//  Description: Maps from the Texture's internal wrap mode symbols to
+//               GL's.
+////////////////////////////////////////////////////////////////////
+INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian7::
+get_texture_wrap_mode(Texture::WrapMode wm) {
+  switch (wm) {
+  case Texture::WM_clamp:
+    return D3DTADDRESS_CLAMP;
+  case Texture::WM_repeat:
+    return D3DTADDRESS_WRAP;
+  case Texture::WM_mirror:
+    return D3DTADDRESS_MIRROR;
+  case Texture::WM_mirror_once:
+    return D3DTADDRESS_BORDER;
+  case Texture::WM_border_color:
+    return D3DTADDRESS_BORDER;
   }
-}
-
-INLINE void DXGraphicsStateGuardian7::
-call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
-{
-  if (_blend_source_func != sfunc)
-    {
-    _blend_source_func = sfunc;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
-#ifdef GSG_VERBOSE
-    dxgsg7_cat.debug() << "dxSrcBlendFunc(";
-    switch (sfunc)
-        {
-        case D3DBLEND_ZERO:
-          dxgsg7_cat.debug(false) << "ZERO, ";
-          break;
-        case D3DBLEND_ONE:
-          dxgsg7_cat.debug(false) << "ONE, ";
-          break;
-        case D3DBLEND_DESTCOLOR:
-          dxgsg7_cat.debug(false) << "DESTCOLOR, ";
-          break;
-        case D3DBLEND_INVDESTCOLOR:
-          dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
-          break;
-        case D3DBLEND_SRCALPHA:
-          dxgsg7_cat.debug(false) << "SRCALPHA, ";
-          break;
-        case D3DBLEND_INVSRCALPHA:
-          dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
-          break;
-        case D3DBLEND_DESTALPHA:
-          dxgsg7_cat.debug(false) << "DESTALPHA, ";
-          break;
-        case D3DBLEND_INVDESTALPHA:
-          dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
-          break;
-        case D3DBLEND_SRCALPHASAT:
-          dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
-          break;
-        default:
-          dxgsg7_cat.debug(false) << "unknown, ";
-          break;
-        }
-    dxgsg7_cat.debug(false) << endl;
-#endif
-    }
-  if ( _blend_dest_func != dfunc)
-    {
-    _blend_dest_func = dfunc;
-    _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
-#ifdef GSG_VERBOSE
-    dxgsg7_cat.debug() << "dxDstBlendFunc(";
-    switch (dfunc)
-        {
-        case D3DBLEND_ZERO:
-          dxgsg7_cat.debug(false) << "ZERO, ";
-          break;
-        case D3DBLEND_ONE:
-          dxgsg7_cat.debug(false) << "ONE, ";
-          break;
-        case D3DBLEND_DESTCOLOR:
-          dxgsg7_cat.debug(false) << "DESTCOLOR, ";
-          break;
-        case D3DBLEND_INVDESTCOLOR:
-          dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
-          break;
-        case D3DBLEND_SRCALPHA:
-          dxgsg7_cat.debug(false) << "SRCALPHA, ";
-          break;
-        case D3DBLEND_INVSRCALPHA:
-          dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
-          break;
-        case D3DBLEND_DESTALPHA:
-          dxgsg7_cat.debug(false) << "DESTALPHA, ";
-          break;
-        case D3DBLEND_INVDESTALPHA:
-          dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
-          break;
-        case D3DBLEND_SRCALPHASAT:
-          dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
-          break;
-        }
-    dxgsg7_cat.debug(false) << endl;
-#endif
-    }
-}
-
-INLINE void DXGraphicsStateGuardian7::
-enable_zwritemask(bool val) {
-    if (_depth_write_enabled != val) {
-        _depth_write_enabled = val;
-        _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
-    }
-}
-
-/**  unimplemented
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_multisample
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_multisample(bool val) {
-  _multisample_enabled = val;
-  #ifdef NDEBUG
-    dxgsg7_cat.error() << "dx multisample unimplemented!!\n";
-  #endif
+  dxgsg7_cat.error() << "Invalid Texture::Mode value" << endl;
+  return D3DTADDRESS_WRAP;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_one
-//       Access:
-//  Description:
+//     Function: DXGraphicsStateGuardian7::get_fog_mode_type
+//       Access: Protected, Static
+//  Description: Maps from the fog types to gl version
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_multisample_alpha_one(bool val) {
-  if (_multisample_alpha_one_enabled != val) {
-    _multisample_alpha_one_enabled = val;
+INLINE D3DFOGMODE DXGraphicsStateGuardian7::
+get_fog_mode_type(Fog::Mode m) {
+  switch (m) {
+  case Fog::M_linear:
+    return D3DFOG_LINEAR;
+  case Fog::M_exponential:
+    return D3DFOG_EXP;
+  case Fog::M_exponential_squared:
+    return D3DFOG_EXP2;
   }
+  dxgsg7_cat.error() << "Invalid Fog::Mode value" << endl;
+  return D3DFOG_EXP;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_mask
-//       Access:
-//  Description:
+//     Function: DXGraphicsStateGuardian7::get_tex_mat_sym
+//       Access: Protected, Static
+//  Description: Returns the nth D3DTRANSFORMSTATE_TEXTURE(n) constant.
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_multisample_alpha_mask(bool val) {
-  if (_multisample_alpha_mask_enabled != val) {
-    _multisample_alpha_mask_enabled = val;
-  }
+INLINE D3DTRANSFORMSTATETYPE DXGraphicsStateGuardian7::
+get_tex_mat_sym(int stage_index) {
+  return (D3DTRANSFORMSTATETYPE)(D3DTRANSFORMSTATE_TEXTURE0 + stage_index);
 }
-
-////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian7::enable_point_smooth
-//       Access:
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian7::
-enable_point_smooth(bool val) {
-  // _point_smooth_enabled = val;
-
-  #ifdef NDEBUG
-    dxgsg7_cat.error() << "dx point smoothing unimplemented!!\n";
-  #endif
-}
-*/
-

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 699 - 3238
panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx


+ 116 - 242
panda/src/dxgsg7/dxGraphicsStateGuardian7.h

@@ -19,98 +19,70 @@
 #ifndef DXGRAPHICSSTATEGUARDIAN7_H
 #define DXGRAPHICSSTATEGUARDIAN7_H
 
-//#define GSG_VERBOSE 1
-
 #include "dxgsg7base.h"
 #include "dxTextureContext7.h"
 #include "config_dxgsg7.h"
 
 #include "graphicsStateGuardian.h"
-#include "geomprimitives.h"
 #include "texture.h"
 #include "displayRegion.h"
 #include "material.h"
 #include "depthTestAttrib.h"
+#include "cullFaceAttrib.h"
 #include "renderModeAttrib.h"
 #include "fog.h"
 #include "pointerToArray.h"
-#include "graphicsWindow.h"
 
 class Light;
 
-//#if defined(NOTIFY_DEBUG) || defined(DO_PSTATS)
-#ifdef _DEBUG
-// This function now serves both to print a debug message to the
-// console, as well as to notify PStats about the change in texture
-// memory.  Thus, we compile it in if we are building with support for
-// either notify debug messages or PStats; otherwise, we compile it
-// out.
-extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *pMsg);
-#define PRINTVIDMEM(pDD,pCaps,pMsg) dbgPrintVidMem(pDD,pCaps,pMsg)
-#else
-#define PRINTVIDMEM(pDD,pCaps,pMsg)
-#endif
+class DXVertexBufferContext7;
+class DXIndexBufferContext7;
 
 ////////////////////////////////////////////////////////////////////
-//   Class : DXGraphicsStateGuardian7
-// Description : A GraphicsStateGuardian specialized for rendering
-//               into DX.  There should be no DX calls
-//               outside of this object.
+//       Class : DXGraphicsStateGuardian7
+// Description : A GraphicsStateGuardian for rendering into DirectX7
+//               contexts.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDADX DXGraphicsStateGuardian7 : public GraphicsStateGuardian {
-  friend class wdxGraphicsWindow7;
-  friend class wdxGraphicsPipe7;
-  friend class wdxGraphicsWindow7Group;
-  friend class DXTextureContext7;
-
 public:
   DXGraphicsStateGuardian7(const FrameBufferProperties &properties);
   ~DXGraphicsStateGuardian7();
 
-  virtual void reset();
+  virtual TextureContext *prepare_texture(Texture *tex);
+  void apply_texture(int i, TextureContext *tc);
+  virtual void release_texture(TextureContext *tc);
+
+  virtual PT(GeomMunger) make_geom_munger(const RenderState *state);
+
+  virtual void set_color_clear_value(const Colorf &value);
 
   virtual void do_clear(const RenderBuffer &buffer);
 
   virtual void prepare_display_region();
   virtual bool prepare_lens();
 
-  virtual void draw_point(GeomPoint *geom, GeomContext *gc);
-  virtual void draw_line(GeomLine *geom, GeomContext *gc);
-  virtual void draw_linestrip(GeomLinestrip *geom, GeomContext *gc);
-  void draw_linestrip_base(Geom *geom, GeomContext *gc, bool bConnectEnds);
-  virtual void draw_sprite(GeomSprite *geom, GeomContext *gc);
-  virtual void draw_polygon(GeomPolygon *geom, GeomContext *gc);
-  virtual void draw_quad(GeomQuad *geom, GeomContext *gc);
-  virtual void draw_tri(GeomTri *geom, GeomContext *gc);
-  virtual void draw_tristrip(GeomTristrip *geom, GeomContext *gc);
-  virtual void draw_trifan(GeomTrifan *geom, GeomContext *gc);
-  virtual void draw_sphere(GeomSphere *geom, GeomContext *gc);
+  virtual bool begin_frame();
+  virtual bool begin_scene();
+  virtual void end_scene();
+  virtual void end_frame();
 
-  virtual TextureContext *prepare_texture(Texture *tex);
-  void apply_texture(TextureContext *tc);
-  virtual void release_texture(TextureContext *tc);
+  virtual bool begin_draw_primitives(const Geom *geom, 
+                                     const GeomMunger *munger,
+                                     const GeomVertexData *vertex_data);
+  void determine_fvf();
+  virtual void draw_triangles(const GeomTriangles *primitive);
+  virtual void draw_lines(const GeomLines *primitive);
+  virtual void draw_points(const GeomPoints *primitive);
+  virtual void end_draw_primitives();
 
   virtual void framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
                                            const RenderBuffer &rb);
-
   virtual bool framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
                                        const RenderBuffer &rb);
 
-  virtual void apply_material(const Material *material);
-  virtual void apply_fog(Fog *fog);
+  virtual void reset();
 
-  virtual void issue_transform(const TransformState *transform);
-  virtual void issue_tex_matrix(const TexMatrixAttrib *attrib);
-  virtual void issue_texture(const TextureAttrib *attrib);
-  virtual void issue_material(const MaterialAttrib *attrib);
-  virtual void issue_render_mode(const RenderModeAttrib *attrib);
-  virtual void issue_rescale_normal(const RescaleNormalAttrib *attrib);
-  virtual void issue_alpha_test(const AlphaTestAttrib *attrib);
-  virtual void issue_depth_test(const DepthTestAttrib *attrib);
-  virtual void issue_depth_write(const DepthWriteAttrib *attrib);
-  virtual void issue_cull_face(const CullFaceAttrib *attrib);
-  virtual void issue_fog(const FogAttrib *attrib);
-  virtual void issue_depth_offset(const DepthOffsetAttrib *attrib);
+  virtual void apply_fog(Fog *fog);
 
   virtual void bind_light(PointLight *light_obj, const NodePath &light, 
                           int light_id);
@@ -119,244 +91,146 @@ public:
   virtual void bind_light(Spotlight *light_obj, const NodePath &light, 
                           int light_id);
 
-  //virtual bool begin_frame();
-  virtual bool begin_scene();
-  virtual void end_scene();
-  virtual void end_frame();
-
-  virtual bool wants_texcoords() const;
+  INLINE static DWORD Colorf_to_D3DCOLOR(const Colorf &cColorf);
 
-  virtual void set_color_clear_value(const Colorf& value);
-
-public:
-  // recreate_tex_callback needs pDD,pD3DDevice to be public
-  DXScreenData *_pScrn;
-  LPDIRECT3DDEVICE7 _pD3DDevice;  // cache copy of _pScrn->pD3DDevice, just for speedier access
-
-#ifndef USE_TEXFMTVEC
-  LPDDPIXELFORMAT   _pTexPixFmts;
-  int               _cNumTexPixFmts;
-#endif
+  virtual void set_state_and_transform(const RenderState *state,
+                                       const TransformState *transform);
 
 protected:
+  void do_issue_transform();
+  void do_issue_alpha_test();
+  void do_issue_render_mode();
+  void do_issue_rescale_normal();
+  void do_issue_color_write();
+  void do_issue_depth_test();
+  void do_issue_depth_write();
+  void do_issue_cull_face();
+  void do_issue_fog();
+  void do_issue_depth_offset();
+  void do_issue_tex_gen();
+  void do_issue_shade_model();
+  void do_issue_material();
+  void do_issue_texture();
+  void do_issue_blending();
+  
   virtual void enable_lighting(bool enable);
   virtual void set_ambient_light(const Colorf &color);
   virtual void enable_light(int light_id, bool enable);
 
-  virtual bool slot_new_clip_plane(int plane_id);
   virtual void enable_clip_plane(int plane_id, bool enable);
   virtual void bind_clip_plane(const NodePath &plane, int plane_id);
 
-  virtual void set_blend_mode();
-
-  void free_pointers();            // free local internal buffers
-  void free_dxgsg_objects();   // free the DirectX objects we create
+  void free_nondx_resources();
+  void free_d3d_device();
 
   void set_draw_buffer(const RenderBuffer &rb);
   void set_read_buffer(const RenderBuffer &rb);
 
-  // for storage of the flexible vertex format
-  BYTE *_pCurFvfBufPtr,*_pFvfBufBasePtr;
-  INLINE void add_to_FVFBuf(void *data,  size_t bytes) ;
-  WORD *_index_buf;  // base of malloced array
+  void do_auto_rescale_normal();
 
-  bool                  _dx_ready;
-  HRESULT               _last_testcooplevel_result;
+protected:
+  INLINE static D3DTEXTUREADDRESS get_texture_wrap_mode(Texture::WrapMode wm);
+  INLINE static D3DFOGMODE get_fog_mode_type(Fog::Mode m);
+  const D3DCOLORVALUE &get_light_color(Light *light) const;
+  INLINE static D3DTRANSFORMSTATETYPE get_tex_mat_sym(int stage_index);
 
-  HDC               _front_hdc;
-  DXTextureContext7  *_pCurTexContext;
+  static D3DBLEND get_blend_func(ColorBlendAttrib::Operand operand);
+  void report_texmgr_stats();
 
-  bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
-  D3DMATRIX         _SavedTransform;   
+  void set_context(DXScreenData *new_context);
+  void set_render_target();
 
-  RenderBuffer::Type _cur_read_pixel_buffer;  // source for copy_pixel_buffer operation
-  bool _auto_rescale_normal;
+  void set_texture_blend_mode(int i, const TextureStage *stage);
 
-  void GenerateSphere(void *pVertexSpace,DWORD dwVertSpaceByteSize,
-                    void *pIndexSpace,DWORD dwIndexSpaceByteSize,
-                    D3DVECTOR *pCenter, float fRadius,
-                    DWORD wNumRings, DWORD wNumSections, float sx, float sy, float sz,
-                    DWORD *pNumVertices,DWORD *pNumIndices,DWORD fvfFlags,DWORD dwVertSize);
-  HRESULT RestoreAllVideoSurfaces();
-  HRESULT RecreateAllVideoSurfaces();
-  HRESULT DeleteAllVideoSurfaces();
-
-/*
-  INLINE void enable_multisample_alpha_one(bool val);
-  INLINE void enable_multisample_alpha_mask(bool val);
-  INLINE void enable_multisample(bool val);
-*/  
-
-  INLINE void enable_color_material(bool val);
-  INLINE void enable_fog(bool val);
-  INLINE void enable_zwritemask(bool val);
-  INLINE void set_shademode(D3DSHADEMODE val);
-
-  D3DTEXTUREADDRESS get_texture_wrap_mode(Texture::WrapMode wm) const;
-  D3DFOGMODE get_fog_mode_type(Fog::Mode m) const;
+  void dx_cleanup();
 
-  void do_auto_rescale_normal();
+  bool check_cooperative_level();
 
-  INLINE void enable_primitive_clipping(bool val);
-  INLINE void enable_alpha_test(bool val);
-  INLINE void enable_line_smooth(bool val);
-  INLINE void enable_blend(bool val);
-  INLINE void enable_point_smooth(bool val);
-  INLINE void enable_texturing(bool val);
-  INLINE void call_dxLightModelAmbient(const Colorf& color);
-  INLINE void call_dxAlphaFunc(D3DCMPFUNC func, float ref);
-  INLINE void call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc);
-  static D3DBLEND get_blend_func(ColorBlendAttrib::Operand operand);
-  INLINE void enable_dither(bool val);
-  INLINE void enable_stencil_test(bool val);
-  void report_texmgr_stats();
-  void draw_multitri(Geom *geom, D3DPRIMITIVETYPE tri_id);
-  void set_context(DXScreenData *pNewContextData);
+  void show_frame();
+  void  show_full_screen_frame();
+  void  show_windowed_frame();
 
-  void draw_prim_inner_loop(int nVerts, const Geom *geom, ushort perFlags);
-  void draw_prim_inner_loop_coordtexonly(int nVerts, const Geom *geom);
-  size_t draw_prim_setup(const Geom *geom) ;
+  void copy_pres_reset(DXScreenData *new_context);
 
-  //   for drawing primitives
-  Normalf   p_normal;  // still used to hold G_OVERALL, G_PER_PRIM values
-  TexCoordf p_texcoord;
-  D3DCOLOR  _curD3Dcolor;
-  DWORD     _curFVFflags;
-  DWORD     _perPrim,_perVertex,_perComp;   //  these hold DrawLoopFlags bitmask values
+  static D3DTEXTUREMINFILTER get_d3d_min_type(Texture::FilterType filter_type);
+  static D3DTEXTUREMIPFILTER get_d3d_mip_type(Texture::FilterType filter_type);
+  static D3DTEXTUREOP get_texture_operation(TextureStage::CombineMode mode, int scale);
+  static DWORD get_texture_argument(TextureStage::CombineSource source,
+                                    TextureStage::CombineOperand operand);
+  static DWORD get_texture_argument_modifier(TextureStage::CombineOperand operand);
 
-  D3DCOLOR _scene_graph_color_D3DCOLOR;
-  D3DCOLOR _d3dcolor_clear_value;
-  D3DSHADEMODE _CurShadeMode;
+  static HRESULT CALLBACK enum_tex_formats_callback(LPDDPIXELFORMAT pddpf, void *param);
 
-  bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
+protected:
+  DXScreenData *_screen;
+  LPDIRECT3DDEVICE7 _d3d_device;  // same as _screen->_d3d_device, cached for spd
 
-  // iterators for primitives
-  Geom::VertexIterator vi;
-  Geom::NormalIterator ni;
-  Geom::TexCoordIterator ti;
-  Geom::ColorIterator ci;
+  bool _dx_is_ready;
+  HRESULT _last_testcooplevel_result;
 
-  // these are used for fastpaths that bypass the iterators above
-  // pointers to arrays in current geom, used to traverse indexed and non-indexed arrays
-  Vertexf *_coord_array,*_pCurCoord;
-  ushort *_coordindex_array,*_pCurCoordIndex;
+  bool _vertex_blending_enabled;
 
-  TexCoordf *_texcoord_array,*_pCurTexCoord;
-  ushort *_texcoordindex_array,*_pCurTexCoordIndex;
+  RenderBuffer::Type _cur_read_pixel_buffer;  // source for copy_pixel_buffer operation
+  bool _auto_rescale_normal;
 
-/*
-  PTA_Normalf _norms;
-  PTA_Colorf _colors;
-  PTA_ushort _cindexes,_nindexes;
-*/  
+  D3DCOLOR _d3dcolor_clear_value;
+  UINT _color_writemask;
 
-  Colorf _lmodel_ambient;
   float _material_ambient;
   float _material_diffuse;
   float _material_specular;
   float _material_shininess;
   float _material_emission;
 
-  typedef enum {None,
-                PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
-                PerPixelFog=D3DRENDERSTATE_FOGTABLEMODE
-               } DxgsgFogType;
-  DxgsgFogType _doFogType;
-  bool _fog_enabled;
-/*  
-  TODO: cache fog state
-  float _fog_start,_fog_end,_fog_density,float _fog_color;
-*/    
-  float      _alpha_func_refval;
-  D3DCMPFUNC _alpha_func;
-
-  D3DBLEND _blend_source_func;
-  D3DBLEND _blend_dest_func;
-
-  bool _line_smooth_enabled;
-  bool* _light_enabled;      // bool[_max_lights]
-  bool _color_material_enabled;
-  bool _texturing_enabled;
-  bool _clipping_enabled;
-  bool _dither_enabled;
-  bool _stencil_test_enabled;
-  bool _blend_enabled;
-  bool _depth_test_enabled;
-  bool _depth_write_enabled;
-  bool _alpha_test_enabled;
-  DWORD _clip_plane_bits;
-
-  RenderModeAttrib::Mode _current_fill_mode;  //poinr/wireframe/solid
-  // GraphicsChannel *_panda_gfx_channel;  // cache the 1 channel dx supports
+  enum DxgsgFogType {
+    None,
+    PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
+    PerPixelFog=D3DRENDERSTATE_FOGTABLEMODE
+  };
+  DxgsgFogType _do_fog_type;
 
-  // Cur Texture State
-  TextureStage::Mode _CurTexBlendMode;
-  D3DTEXTUREMAGFILTER _CurTexMagFilter;
-  D3DTEXTUREMINFILTER _CurTexMinFilter;
-  D3DTEXTUREMIPFILTER _CurTexMipFilter;
-  DWORD _CurTexAnisoDegree;
-  Texture::WrapMode _CurTexWrapModeU,_CurTexWrapModeV;
+  DWORD _clip_plane_bits;
+  CullFaceAttrib::Mode _cull_face_mode;
+  RenderModeAttrib::Mode _current_fill_mode;  //point/wireframe/solid
 
-  LMatrix4f _current_projection_mat;
-  int _projection_mat_stack_count;
+  LMatrix4f _projection_mat;
 
   CPT(DisplayRegion) _actual_display_region;
+  const DXVertexBufferContext7 *_active_vbuffer;
+  const DXIndexBufferContext7 *_active_ibuffer;
 
-  // Color/Alpha Matrix Transition stuff
-  INLINE void transform_color(Colorf &InColor,D3DCOLOR &OutColor);
+  bool _tex_stats_retrieval_impossible;
 
-  bool _overlay_windows_supported;
+  int _fvf;
+  LPDDPIXELFORMAT _tex_formats;
+  int _num_tex_formats;
 
-#if 0
-  // This is here just as a temporary hack so this file will still
-  // compile.  However, it is never initialized and will certainly
-  // cause the code to crash when it is referenced.  (This used to be
-  // inherited from the base class, but the new design requires that a
-  // GSG may be used for multiple windows, so it doesn't make sense to
-  // store a window pointer any more.)
-  GraphicsWindow *_win;
-#endif
+  static D3DMATRIX _d3d_ident_mat;
 
 public:
-  static GraphicsStateGuardian*
-  make_DXGraphicsStateGuardian(const FactoryParams &params);
-
-  static TypeHandle get_class_type();
-  static void init_type();
-  virtual TypeHandle get_type() const;
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-//  INLINE void Set_HDC(HDC hdc)  {  _front_hdc = hdc;  }
-  void adjust_view_rect(int x, int y);
-  INLINE void SetDXReady(bool stat)  {  _dx_ready = stat; }
-  INLINE bool GetDXReady()  { return _dx_ready;}
-  void DXGraphicsStateGuardian7::SetTextureBlendMode(TextureStage::Mode TexBlendMode,bool bJustEnable);
-
-  void  dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled);
-
-  #define DO_REACTIVATE_WINDOW true
-  bool  CheckCooperativeLevel(bool bDoReactivateWindow = false);
-
-  void  dx_setup_after_resize(RECT *pViewRect);
-  void  show_frame();
-  void  show_full_screen_frame();
-  void  show_windowed_frame();
 
-  void support_overlay_window(bool flag);
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
 
-
-/*  void  dx_init(  LPDIRECTDRAW7     context,
-          LPDIRECTDRAWSURFACE7  pri,
-          LPDIRECTDRAWSURFACE7  back,
-          LPDIRECTDRAWSURFACE7  zbuf,
-          LPDIRECT3D7          d3d,
-          LPDIRECT3DDEVICE7    d3dDevice,
-          RECT  viewrect); */
-  void dx_init();
-  
-  friend HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param );
+public:
+  static void init_type() {
+    GraphicsStateGuardian::init_type();
+    register_type(_type_handle, "DXGraphicsStateGuardian7",
+                  GraphicsStateGuardian::get_class_type());
+  }
 
 private:
   static TypeHandle _type_handle;
+
+  friend class wdxGraphicsWindow7;
+  friend class wdxGraphicsPipe7;
+  friend class wdxGraphicsWindowGroup7;
+  friend class DXTextureContext7;
 };
 
 #include "dxGraphicsStateGuardian7.I"

+ 29 - 0
panda/src/dxgsg7/dxTextureContext7.I

@@ -0,0 +1,29 @@
+// Filename: dxTextureContext7.I
+// Created by:  drose (26Oct05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: DXTextureContext7::has_mipmaps
+//       Access: Public
+//  Description: Returns true if the texture was created with mipmaps,
+//               false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool DXTextureContext7::
+has_mipmaps() const {
+  return _has_mipmaps;
+}

+ 27 - 39
panda/src/dxgsg7/dxTextureContext7.cxx

@@ -214,7 +214,7 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
     }
 
     if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd,  DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
-        dxgsg7_cat.error() << "CreateTexture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "create_texture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
         return hr;
     }
 
@@ -331,7 +331,7 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
 
                 for(DWORD y=0; y<dwOrigHeight; y++,pDDSurfBytes+=ddsd.lPitch) {
                     pDstWord = (WORD*)pDDSurfBytes;
-
+		    
                     for(DWORD x=0; x<dwOrigWidth; x++,pSrcWord++,pDstWord++) {
                         BYTE r,g,b,a;
                         DWORD dwPixel = *pSrcWord;
@@ -662,7 +662,7 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
             }
 
         default:
-            dxgsg7_cat.error() << "CreateTexture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
+            dxgsg7_cat.error() << "create_texture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
             pDDSurf->Unlock(NULL);
             return E_INVALIDARG;
     }
@@ -1001,12 +1001,8 @@ HRESULT ConvertDDSurftoPixBuf(Texture *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf) {
 //       gets the attributes of the texture from the bitmap, creates the
 //       texture, and then copies the bitmap into the texture.
 //-----------------------------------------------------------------------------
-LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, 
-#ifdef USE_TEXFMTVEC
-                                        DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
-#else
+LPDIRECTDRAWSURFACE7 DXTextureContext7::create_texture(LPDIRECT3DDEVICE7 pd3dDevice, 
                                         int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
-#endif
    {
     HRESULT hr;
     int i,cNumAlphaBits;     //  number of alpha bits in texture pixfmt
@@ -1016,21 +1012,16 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
     ConversionType ConvNeeded;
 
     assert(_texture!=NULL);
+    delete_texture();
+    clear_dirty_flags(Texture::DF_image | Texture::DF_mipmap);
 
-#ifdef USE_TEXFMTVEC
-    int cNumTexPixFmts=TexturePixelFormats.size();
-#endif
     DDPIXELFORMAT *pTexPixFmts = new DDPIXELFORMAT[cNumTexPixFmts];
 
     // make local copy of array so I can muck with it during searches for this texture fmt
     // (such as marking pixfmts that no search will be interested in)
     // probably should do this faster way
 
-#ifdef USE_TEXFMTVEC
-    memcpy(pTexPixFmts,&TexturePixelFormats[0],cNumTexPixFmts*sizeof(DDPIXELFORMAT));
-#else
     memcpy(pTexPixFmts,pTexFmts,cNumTexPixFmts*sizeof(DDPIXELFORMAT));
-#endif
 
     // bpp indicates requested fmt, not pixbuf fmt
     DWORD bpp = get_bits_per_pixel(_texture->get_format(), &cNumAlphaBits);
@@ -1160,10 +1151,10 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
     LPDDPIXELFORMAT pCurPixFmt;
     char *szErrorMsg;
 
-    szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
+    szErrorMsg = "create_texture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
 
     if(dxgsg7_cat.is_spam())
-        dxgsg7_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
+        dxgsg7_cat.spam() << "create_texture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
 
     // Mark formats I dont want to deal with
     for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
@@ -1244,7 +1235,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
 
             // at this point, bail.  dont worry about converting to non-alpha formats yet,
             // I think this will be a very rare case
-                szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT! no available 16 or 32-bit alpha formats!\n";
+                szErrorMsg = "create_texture failed: couldn't find compatible Tex DDPIXELFORMAT! no available 16 or 32-bit alpha formats!\n";
             }
 
             break;
@@ -1466,7 +1457,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
             break;
 
         default:
-            szErrorMsg = "CreateTexture failed: unhandled pixel bitdepth in DX loader";
+            szErrorMsg = "create_texture failed: unhandled pixel bitdepth in DX loader";
     }
 
     // if we've gotten here, haven't found a match
@@ -1509,13 +1500,14 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
         else ft=Texture::FT_linear;
     }
 
-    if((ft==Texture::FT_linear) && !(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
+    if((ft==Texture::FT_linear) && !(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR)) {
         ft=Texture::FT_nearest;
+    }
     _tex->set_magfilter(ft);
 
     // figure out if we are mipmapping this texture
     ft =_tex->get_minfilter();
-    _bHasMipMaps=FALSE;
+    _has_mipmaps=FALSE;
 
     if(!dx_ignore_mipmaps) {  // set if no HW mipmap capable
         switch(ft) {
@@ -1523,11 +1515,11 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
             case Texture::FT_linear_mipmap_nearest:
             case Texture::FT_nearest_mipmap_linear:  // pick nearest in each, interpolate linearly b/w them
             case Texture::FT_linear_mipmap_linear:
-                _bHasMipMaps=TRUE;
+                _has_mipmaps=TRUE;
         }
 
         if(dx_mipmap_everything) {  // debug toggle, ok to leave in since its just a creation cost
-           _bHasMipMaps=TRUE;
+           _has_mipmaps=TRUE;
            if(ft != Texture::FT_linear_mipmap_linear) {
                dxgsg7_cat.spam() << "Forcing mipmap filtering on DX texture [" << _tex->get_name() << "]\n";
            }
@@ -1582,14 +1574,14 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
     }
     _tex->set_anisotropic_degree(aniso_degree);
 #ifdef _DEBUG
-    dxgsg7_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
+    dxgsg7_cat.spam() << "create_texture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
 #endif
 
-    if(_bHasMipMaps) {
+    if(_has_mipmaps) {
        // We dont specify mipmapcount, so CreateSurface will auto-create surfs
        // for all mipmaps down to 1x1 (if driver supports deep-mipmaps, otherwise Nx1)
         ddsd.ddsCaps.dwCaps |= (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX);
-        dxgsg7_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
+        dxgsg7_cat.debug() << "create_texture: generating mipmaps for "<< _tex->get_name() << endl;
     }
 
     if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
@@ -1599,17 +1591,15 @@ LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevi
         ddsd.dwFlags |= DDSD_TEXTURESTAGE;
     }
 
-    PRINTVIDMEM(pDD,&ddsd.ddsCaps,"texture surf (includes AGP mem)");
-
     // Create a new surface for the texture
     if(FAILED( hr = pDD->CreateSurface( &ddsd, &_surface, NULL ) )) {
-        dxgsg7_cat.error() << "CreateTexture failed: pDD->CreateSurface() failed!  hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "create_texture failed: pDD->CreateSurface() failed!  hr = " << ConvD3DErrorToString(hr) << "\n";
         goto error_exit;
     }
 
 
 #ifdef _DEBUG
-    dxgsg7_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
+    dxgsg7_cat.debug() << "create_texture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
 #endif
 
     _PixBufConversionType=ConvNeeded;
@@ -1661,7 +1651,7 @@ FillDDSurfTexturePixels() {
     
     CPTA_uchar orig_image = _texture->get_ram_image();
     if (orig_image.empty()) {
-      dxgsg7_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
+      dxgsg7_cat.fatal() << "create_texture: get_ram_image() failed\n";
       // The texture doesn't have an image to load.
       return E_FAIL;
     }
@@ -1682,7 +1672,7 @@ FillDDSurfTexturePixels() {
 
     _surface->GetSurfaceDesc(&ddsd);
 
-    if(_bHasMipMaps) {
+    if(_has_mipmaps) {
         DWORD i,oldcurxsize,oldcurysize,curxsize,curysize,cMipMapCount=ddsd.dwMipMapCount;
         assert(ddsd.dwMipMapCount<20);
 
@@ -1771,7 +1761,7 @@ FillDDSurfTexturePixels() {
 
             hr = pCurDDSurf->GetAttachedSurface(&ddsCaps, &pMipLevel_DDSurf);
             if(FAILED(hr)) {
-                dxgsg7_cat.error() << "CreateTexture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
+                dxgsg7_cat.error() << "create_texture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
                 delete [] pMipMapPixBufSpace;
                 pCurDDSurf->Release();
                 return hr;
@@ -1799,7 +1789,7 @@ FillDDSurfTexturePixels() {
         if(dx_debug_view_mipmaps) {
 #if 0
             if(!(ddcaps.dwCaps & DDCAPS_BLTSTRETCH)) {
-                dxgsg7_cat.error() << "CreateTexture failed debug-viewing mipmaps, BLT stretching not supported!  ( we need to do SW stretch) \n";
+                dxgsg7_cat.error() << "create_texture failed debug-viewing mipmaps, BLT stretching not supported!  ( we need to do SW stretch) \n";
                 return hr;
             }
 #endif
@@ -1917,13 +1907,11 @@ FillDDSurfTexturePixels() {
 // Desc: Release the surface used to store the texture
 //-----------------------------------------------------------------------------
 void DXTextureContext7::
-DeleteTexture( ) {
+delete_texture( ) {
     if(dxgsg7_cat.is_spam()) {
         dxgsg7_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
     }
 
-    ULONG refcnt;
-
 #ifdef DEBUG_RELEASES
     if(_surface) {
         LPDIRECTDRAW7 pDD;
@@ -1954,13 +1942,13 @@ TextureContext(tex) {
     }
 //#endif
     _surface = NULL;
-    _bHasMipMaps = FALSE;
+    _has_mipmaps = FALSE;
     _tex = tex;
 }
 
 DXTextureContext7::
 ~DXTextureContext7() {
-    DeleteTexture();
+    delete_texture();
     TextureContext::~TextureContext();
     _tex = NULL;
 }

+ 6 - 8
panda/src/dxgsg7/dxTextureContext7.h

@@ -41,17 +41,14 @@ public:
 
 //  static is_unused_texpixelformat(DDPIXELFORMAT *)
 
-#ifdef USE_TEXFMTVEC
-  LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
-#else
-  LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
-#endif
+  LPDIRECTDRAWSURFACE7 create_texture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
+  void delete_texture();
+
+  INLINE bool has_mipmaps() const;
 
-  bool _bHasMipMaps;
+  bool _has_mipmaps;
   DWORD _PixBufConversionType;  // enum ConversionType
 
-  // must be public since called from global callback fns
-  void DeleteTexture();
   HRESULT FillDDSurfTexturePixels();
 
 protected:
@@ -75,6 +72,7 @@ private:
   static TypeHandle _type_handle;
 };
 
+#include "dxTextureContext7.I"
 
 #endif
 

+ 1 - 0
panda/src/dxgsg7/dxgsg7_composite1.cxx

@@ -1,6 +1,7 @@
 #include "dxgsg7base.h"
 #include "dxgsg7base.cxx"
 #include "config_dxgsg7.cxx"
+#include "dxGeomMunger7.cxx"
 #include "dxTextureContext7.cxx"
 #include "wdxGraphicsPipe7.cxx"
 #include "wdxGraphicsWindow7.cxx"

+ 8 - 14
panda/src/dxgsg7/dxgsg7base.h

@@ -38,17 +38,12 @@
 #error DX7 headers not available, you need to install MS Platform SDK or DirectX 8+ SDK!
 #endif
 
+#define D3DERRORSTRING(HRESULT) " at (" << __FILE__  << ":" << __LINE__ << "), hr=" <<  ConvD3DErrorToString(HRESULT) << endl
+
 // disable nameless struct 'warning'
 #pragma warning (disable : 4201)
 
-//#define USE_TEXFMTVEC
-// USE_TEXFMTVEC caused crash on dealloc
-
-#ifdef USE_TEXFMTVEC
-typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
-#else
 #define MAX_DX_TEXPIXFMTS 20    // should be enough for any card
-#endif
 
 #define ISPOW2(X) (((X) & ((X)-1))==0)
 
@@ -69,7 +64,8 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
 #define DEBUG_RELEASES
 
 #ifdef DEBUG_RELEASES
-#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)             \
+#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)  {          \
+   ULONG refcnt;                                                \
    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) {         \
         refcnt = (OBJECT)->Release();                           \
         MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << endl;  \
@@ -82,11 +78,12 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
         (OBJECT) = NULL;                          \
       } else {                                    \
         MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
-      } 
+      } }
 
 #define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg7_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
 #else
-#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
+#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)    { \
+   ULONG refcnt;                                         \
    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
         refcnt=(OBJECT)->Release();                     \
         if((bDoDownToZero) && (refcnt>0)) {             \
@@ -96,7 +93,7 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
               } while(refcnt>0);                  \
         }                                         \
         (OBJECT) = NULL;                          \
-   }
+   } }
 
 #define PRINTREFCNT(OBJECT,STR)  
 #endif    
@@ -127,9 +124,6 @@ typedef struct {
       WORD              CardIDNum;  // its posn in DisplayArray, for dbgprint purposes
       DDDEVICEIDENTIFIER2 DXDeviceID;
       D3DDEVICEDESC7    D3DDevDesc;
-#ifdef USE_TEXFMTVEC
-      DDPixelFormatVec  TexPixFmts;
-#endif
 } DXScreenData;
 #endif
 

+ 12 - 103
panda/src/dxgsg7/wdxGraphicsWindow7.cxx

@@ -174,36 +174,10 @@ open_window() {
   set_coop_levels_and_display_modes();
   create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
 
-  return true;
-}
-
-/*
-////////////////////////////////////////////////////////////////////
-//     Function: wdxGraphicsWindow7::make_gsg
-//       Access: Public, Virtual
-//  Description: Creates a new GSG for the window and stores it in the
-//               _gsg pointer.  This should only be called from within
-//               the draw thread.
-////////////////////////////////////////////////////////////////////
-void wdxGraphicsWindow7::
-make_gsg() {
-  nassertv(_gsg == (GraphicsStateGuardian *)NULL);
-  _dxgsg = new DXGraphicsStateGuardian7(this);
-  _gsg = _dxgsg;
-  // Tell the associated dxGSG about the window handle.
-  _wcontext.hWnd = _hWnd;
-
-  if (!choose_device(0, NULL)) {
-    wdxdisplay7_cat.error()
-      << "Unable to find suitable rendering device.\n";
-    release_gsg();
-    return;
-  }
+  make_current();
 
-  set_coop_levels_and_display_modes();
-  create_screen_buffers_and_device(_dxgsg->scrn, dx_force_16bpp_zbuffer);
+  return true;
 }
-*/
 
 ////////////////////////////////////////////////////////////////////
 //     Function: wdxGraphicsWindow7::end_flip
@@ -284,18 +258,13 @@ handle_reshape() {
       return;
     }
 
-    _dxgsg->RestoreAllVideoSurfaces();
+    _dxgsg->release_all();
 
     set_to_temp_rendertarget();
 
-    // create the new resized rendertargets
-    //RECT view_rect;
-    //get_client_rect_screen(hWnd, &view_rect);
-    //_dxgsg->dx_setup_after_resize(view_rect, &_wcontext);
-
     RECT view_rect;
     get_client_rect_screen(_wcontext.hWnd, &view_rect);
-    _dxgsg->dx_setup_after_resize(&view_rect);
+    //    _dxgsg->dx_setup_after_resize(&view_rect);
   }
 }
 
@@ -307,7 +276,7 @@ handle_reshape() {
 ////////////////////////////////////////////////////////////////////
 bool wdxGraphicsWindow7::
 do_fullscreen_resize(int x_size, int y_size) {
-  _dxgsg->SetDXReady(false);
+  //  _dxgsg->SetDXReady(false);
 
   HRESULT hr;
 
@@ -379,7 +348,7 @@ do_fullscreen_resize(int x_size, int y_size) {
     return false;
   }
 
-  _dxgsg->free_dxgsg_objects();
+  //  _dxgsg->free_dxgsg_objects();
 
    // let driver choose default refresh rate (hopefully its >=60Hz)   
   hr = _wcontext.pDD->SetDisplayMode(x_size, y_size, dwFullScreenBitDepth,
@@ -405,28 +374,11 @@ do_fullscreen_resize(int x_size, int y_size) {
   _wcontext.dwRenderHeight = y_size;
 
   create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer);
-  _dxgsg->RecreateAllVideoSurfaces();
-  _dxgsg->SetDXReady(true);
+  _dxgsg->release_all();
+  //  _dxgsg->SetDXReady(true);
   return true;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: wdxGraphicsWindow7::support_overlay_window
-//       Access: Protected, Virtual
-//  Description: Some windows graphics contexts (e.g. DirectX)
-//               require special support to enable the displaying of
-//               an overlay window (particularly the IME window) over
-//               the fullscreen graphics window.  This is a hook for
-//               the window to enable or disable that mode when
-//               necessary.
-////////////////////////////////////////////////////////////////////
-void wdxGraphicsWindow7::
-support_overlay_window(bool flag) {
-  if (_dxgsg != (DXGraphicsStateGuardian7 *)NULL) {
-    _dxgsg->support_overlay_window(flag);
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: wdxGraphicsWindow7::set_to_temp_rendertarget
 //       Access: Private
@@ -439,8 +391,9 @@ support_overlay_window(bool flag) {
 ////////////////////////////////////////////////////////////////////
 bool wdxGraphicsWindow7::
 set_to_temp_rendertarget() {
+  return true;
+
   LPDIRECTDRAWSURFACE7 pddsDummy = NULL, pddsDummyZ = NULL;
-  ULONG refcnt;
   HRESULT hr;
     
   DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd);
@@ -453,8 +406,6 @@ set_to_temp_rendertarget() {
   ddsd.dwHeight = 1;
   ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER);
   
-  PRINTVIDMEM(pDD, &ddsd.ddsCaps, "dummy backbuf");
-  
   hr = pDD->CreateSurface(&ddsd, &pddsDummy, NULL);    
   if (FAILED(hr)) {
     wdxdisplay7_cat.error()
@@ -470,8 +421,6 @@ set_to_temp_rendertarget() {
     ddsdZ.dwWidth = 1;
     ddsdZ.dwHeight = 1;
     
-    PRINTVIDMEM(pDD,&ddsdZ.ddsCaps,"dummy zbuf");
-    
     hr = pDD->CreateSurface(&ddsdZ, &pddsDummyZ, NULL);
     if (FAILED(hr)) {
       wdxdisplay7_cat.error()
@@ -552,8 +501,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
       ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
     }
 
-    PRINTVIDMEM(pDD, &ddsd.ddsCaps, "initial primary & backbuf");
-
     // Create the primary surface for the fullscreen window
     hr = pDD->CreateSurface(&ddsd, &pPrimaryDDSurf, NULL);
     if (FAILED(hr)) {
@@ -673,8 +620,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
     SurfaceDesc.dwFlags = DDSD_CAPS ;
     SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
-    PRINTVIDMEM(pDD, &SurfaceDesc.ddsCaps, "initial primary surface");
-
     // Create the primary surface for windowed mode.  This includes
     // all of the visible window, so no need to specify height/width.
     hr = pDD->CreateSurface(&SurfaceDesc, &pPrimaryDDSurf, NULL);
@@ -725,8 +670,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
       SurfaceDesc.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
     }
 
-    PRINTVIDMEM(pDD, &SurfaceDesc.ddsCaps, "initial backbuf");
-
     // Create the backbuffer. (might want to handle failure due to
     // running out of video memory)
     hr = pDD->CreateSurface(&SurfaceDesc, &pBackDDSurf, NULL);
@@ -896,8 +839,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
       }
     }
 
-    PRINTVIDMEM(pDD, &ddsd.ddsCaps, "initial zbuf");
-
 #ifdef _DEBUG
     wdxdisplay7_cat.info()
       << "Creating " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp zbuffer\n";
@@ -921,8 +862,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
           << "GetAvailVidMem lied, not enough VidMem for 32bpp, so trying 16bpp on device #"
           << Display.CardIDNum << endl;
         
-        ULONG refcnt;
-
         // free pri and back (maybe should just free pri since created
         // as complex chain?)
         RELEASE(pBackDDSurf, wdxdisplay7, "backbuffer", false);
@@ -993,13 +932,13 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
 
   _dxgsg->set_context(&Display);
   //pDD, pPrimaryDDSurf, pBackDDSurf, pZDDSurf, pD3DI, pD3DDevice, view_rect);
-  _dxgsg->dx_init();
+  //  _dxgsg->dx_init();
 
   // do not SetDXReady() yet since caller may want to do more work
   // before letting rendering proceed
 
   // Oh, go ahead and call it.
-  _dxgsg->SetDXReady(true);
+  //  _dxgsg->SetDXReady(true);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -1389,33 +1328,3 @@ set_coop_levels_and_display_modes() {
     }
   }
 }
-
-#if 0
-
-// probably need this here similar to dx8
-////////////////////////////////////////////////////////////////////
-//     Function: wdxGraphicsWindow8::begin_frame
-//       Access: Public, Virtual
-//  Description: This function will be called within the draw thread
-//               before beginning rendering for a given frame.  It
-//               should do whatever setup is required, and return true
-//               if the frame should be rendered, or false if it
-//               should be skipped.
-////////////////////////////////////////////////////////////////////
-bool wdxGraphicsWindow7::
-begin_frame() {
-  if (_awaiting_restore) {
-    // The fullscreen window was recently restored; we can't continue
-    // until the GSG says we can.
-    if (!_dxgsg->CheckCooperativeLevel()) {
-      // Keep waiting.
-      return false;
-    }
-    _awaiting_restore = false;
-
-    init_resized_window();
-  }
-
-  return WinGraphicsWindow::begin_frame();
-}
-#endif

+ 0 - 2
panda/src/dxgsg7/wdxGraphicsWindow7.h

@@ -46,7 +46,6 @@ public:
                      const string &name);
   virtual ~wdxGraphicsWindow7();
   virtual void end_flip();
-  //virtual bool begin_frame();
   virtual void make_current();
   virtual bool open_window();
 
@@ -54,7 +53,6 @@ protected:
   virtual void fullscreen_restored(WindowProperties &properties);
   virtual void handle_reshape();
   virtual bool do_fullscreen_resize(int x_size, int y_size);
-  virtual void support_overlay_window(bool flag);
 
 private:
   bool set_to_temp_rendertarget();

+ 26 - 22
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -53,7 +53,7 @@
 #include "geomLines.h"
 #include "geomLinestrips.h"
 #include "geomPoints.h"
-#include "GeomVertexReader.h"
+#include "geomVertexReader.h"
 #include "dxGeomMunger8.h"
 #include "config_gobj.h"
 #include "dxVertexBufferContext8.h"
@@ -112,6 +112,7 @@ DXGraphicsStateGuardian8(const FrameBufferProperties &properties) :
   _supported_geom_rendering = 
     Geom::GR_point | Geom::GR_point_uniform_size |
     Geom::GR_point_perspective | Geom::GR_point_sprite |
+    Geom::GR_indexed_other |
     Geom::GR_triangle_strip | Geom::GR_triangle_fan |
     Geom::GR_flat_first_vertex;
 }
@@ -176,27 +177,25 @@ apply_texture(int i, TextureContext *tc) {
 
   int dirty = dtc->get_dirty_flags();
 
-  if (dirty) {
-    // If the texture image has changed, or if its use of mipmaps has
-    // changed, we need to re-create the image.  Ignore other types of
-    // changes, which aren't significant for DX.
-
-    if ((dirty & (Texture::DF_image | Texture::DF_mipmap)) != 0) {
-      // If this is *only* because of a mipmap change, issue a
-      // warning--it is likely that this change is the result of an
-      // error or oversight.
-      if ((dirty & Texture::DF_image) == 0) {
-        dxgsg8_cat.warning()
-          << "Texture " << *dtc->_texture << " has changed mipmap state.\n";
-      }
-
-      if (!dtc->create_texture(*_screen)) {
-        // Oops, we can't re-create the texture for some reason.
-        dxgsg8_cat.error()
-          << "Unable to re-create texture " << *dtc->_texture << endl;
-        _d3d_device->SetTextureStageState(i, D3DTSS_COLOROP, D3DTOP_DISABLE);
-        return;
-      }
+  // If the texture image has changed, or if its use of mipmaps has
+  // changed, we need to re-create the image.  Ignore other types of
+  // changes, which aren't significant for DX.
+  
+  if ((dirty & (Texture::DF_image | Texture::DF_mipmap)) != 0) {
+    // If this is *only* because of a mipmap change, issue a
+    // warning--it is likely that this change is the result of an
+    // error or oversight.
+    if ((dirty & Texture::DF_image) == 0) {
+      dxgsg8_cat.warning()
+	<< "Texture " << *dtc->_texture << " has changed mipmap state.\n";
+    }
+    
+    if (!dtc->create_texture(*_screen)) {
+      // Oops, we can't re-create the texture for some reason.
+      dxgsg8_cat.error()
+	<< "Unable to re-create texture " << *dtc->_texture << endl;
+      _d3d_device->SetTextureStageState(i, D3DTSS_COLOROP, D3DTOP_DISABLE);
+      return;
     }
   }
 
@@ -928,6 +927,11 @@ draw_triangles(const GeomTriangles *primitive) {
       // Nonindexed, client arrays.
       int stride = _vertex_data->get_format()->get_array(0)->get_stride();
       unsigned int first_vertex = primitive->get_first_vertex();
+
+      // Interestingly, my ATI driver seems to fail to draw anything
+      // in this call if the address range of the buffer supplied
+      // crosses over a multiple of 0x10000.  I refuse to hack around
+      // this lame driver bug.
       _d3d_device->DrawPrimitiveUP
         (D3DPT_TRIANGLELIST,
          primitive->get_num_primitives(),

+ 2 - 2
panda/src/dxgsg8/dxGraphicsStateGuardian8.h

@@ -155,7 +155,7 @@ protected:
 
   void dx_cleanup();
   HRESULT reset_d3d_device(D3DPRESENT_PARAMETERS *p_presentation_params, 
-                           DXScreenData **pScrn = NULL);
+                           DXScreenData **screen = NULL);
 
   bool check_cooperative_level();
 
@@ -174,7 +174,7 @@ protected:
 
 protected:
   DXScreenData *_screen;
-  LPDIRECT3DDEVICE8 _d3d_device;  // same as pScrn->_d3d_device, cached for spd
+  LPDIRECT3DDEVICE8 _d3d_device;  // same as _screen->_d3d_device, cached for spd
   IDirect3DSwapChain8 *_swap_chain;
   D3DPRESENT_PARAMETERS _presentation_reset;  // This is built during reset device
 

+ 2 - 2
panda/src/dxgsg8/wdxGraphicsWindow8.h

@@ -16,8 +16,8 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifndef wdxGraphicsWindow8_H
-#define wdxGraphicsWindow8_H
+#ifndef WDXGRAPHICSWINDOW8_H
+#define WDXGRAPHICSWINDOW8_H
 
 #include "pandabase.h"
 #include "winGraphicsWindow.h"

+ 1 - 10
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -295,6 +295,7 @@ reset() {
   _supported_geom_rendering = 
     Geom::GR_indexed_point |
     Geom::GR_point | Geom::GR_point_uniform_size |
+    Geom::GR_indexed_other |
     Geom::GR_triangle_strip | Geom::GR_triangle_fan |
     Geom::GR_flat_last_vertex;
 
@@ -3397,16 +3398,6 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
   report_my_gl_errors();
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: GLGraphicsStateGuardian::wants_texcoords
-//       Access: Public, Virtual
-//  Description:
-////////////////////////////////////////////////////////////////////
-bool CLP(GraphicsStateGuardian)::
-wants_texcoords() const {
-  return true;
-}
-
 #ifdef SUPPORT_IMMEDIATE_MODE
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::draw_immediate_simple_primitives

+ 0 - 2
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -133,8 +133,6 @@ public:
   virtual void bind_light(Spotlight *light_obj, const NodePath &light, 
                           int light_id);
 
-  virtual bool wants_texcoords() const;
-
   void print_gfx_visual();
 
   //For those interested in what the guardian thinks is the current

+ 23 - 20
panda/src/gobj/geomEnums.h

@@ -80,63 +80,66 @@ PUBLISHED:
   // two indicates whether the Geom needs to be munged for the GSG.
   enum GeomRendering {
     // If there are indexed points.
-    GR_indexed_point        = 0x0001,
+    GR_indexed_point        = 0x00001,
+
+    // If there is indexed geometry of any other type.
+    GR_indexed_other        = 0x10000,
 
     // The union of all of the indexed attributes.
-    GR_indexed_bits         = 0x0001,
+    GR_indexed_bits         = 0x10001,
 
     // If there are any points at all.
-    GR_point                = 0x0002,
+    GR_point                = 0x00002,
 
     // If the points are all the same size, other than 1 pixel.
-    GR_point_uniform_size   = 0x0004,
+    GR_point_uniform_size   = 0x00004,
 
     // If the points have a per-vertex size designation.
-    GR_per_point_size       = 0x0008,
+    GR_per_point_size       = 0x00008,
 
     // If the points' size is specified in camera units rather than
     // screen pixels.
-    GR_point_perspective    = 0x0010,
+    GR_point_perspective    = 0x00010,
 
     // If the points have a non-square aspect ratio.
-    GR_point_aspect_ratio   = 0x0020,
+    GR_point_aspect_ratio   = 0x00020,
 
     // If the points are under a scale transform, uniform or non-uniform.
-    GR_point_scale          = 0x0040,
+    GR_point_scale          = 0x00040,
 
     // If the points are rotated off the orthonormal axis.
-    GR_point_rotate         = 0x0080,
+    GR_point_rotate         = 0x00080,
 
     // If the points require texture coordinates interpolated across
     // their face, to render textures as sprites.
-    GR_point_sprite         = 0x0100,
+    GR_point_sprite         = 0x00100,
 
     // If there is a texture matrix applied to the sprite's generated
     // texture coordinates.
-    GR_point_sprite_tex_matrix = 0x0200,
+    GR_point_sprite_tex_matrix = 0x00200,
 
     // The union of all the above point attributes, except GR_indexed_point.
-    GR_point_bits           = 0x03fe,
+    GR_point_bits           = 0x003fe,
 
     // If there are any of these composite types.
-    GR_triangle_strip       = 0x0400,
-    GR_triangle_fan         = 0x0800,
-    GR_line_strip           = 0x1000,
+    GR_triangle_strip       = 0x00400,
+    GR_triangle_fan         = 0x00800,
+    GR_line_strip           = 0x01000,
 
     // The union of all of the above composite types.
-    GR_composite_bits       = 0x1c00,
+    GR_composite_bits       = 0x01c00,
 
     // If the shade model requires a particular vertex for flat shading.
-    GR_flat_first_vertex    = 0x2000,
-    GR_flat_last_vertex     = 0x4000,
+    GR_flat_first_vertex    = 0x02000,
+    GR_flat_last_vertex     = 0x04000,
 
     // The union of the above shade model types.
-    GR_shade_model_bits     = 0x6000,
+    GR_shade_model_bits     = 0x06000,
 
     // If there is a TexGenAttrib in effect with M_light_vector
     // enabled, meaning we need to generate the tangent space light
     // vector as the texture coordinates.
-    GR_texcoord_light_vector = 0x8000,
+    GR_texcoord_light_vector = 0x08000,
   };
 
   // The shade model specifies whether the per-vertex colors and

+ 5 - 1
panda/src/gobj/geomLinestrips.cxx

@@ -91,7 +91,11 @@ get_primitive_type() const {
 ////////////////////////////////////////////////////////////////////
 int GeomLinestrips::
 get_geom_rendering() const {
-  return GR_line_strip;
+  if (is_indexed()) {
+    return GR_line_strip | GR_indexed_other;
+  } else {
+    return GR_line_strip;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 5 - 2
panda/src/gobj/geomPrimitive.cxx

@@ -88,8 +88,11 @@ GeomPrimitive::
 ////////////////////////////////////////////////////////////////////
 int GeomPrimitive::
 get_geom_rendering() const {
-  // The default is nothing fancy.
-  return 0;
+  if (is_indexed()) {
+    return GR_indexed_other;
+  } else {
+    return 0;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 5 - 1
panda/src/gobj/geomTrifans.cxx

@@ -90,7 +90,11 @@ get_primitive_type() const {
 ////////////////////////////////////////////////////////////////////
 int GeomTrifans::
 get_geom_rendering() const {
-  return GR_triangle_fan;
+  if (is_indexed()) {
+    return GR_triangle_fan | GR_indexed_other;
+  } else {
+    return GR_triangle_fan;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 5 - 1
panda/src/gobj/geomTristrips.cxx

@@ -91,7 +91,11 @@ get_primitive_type() const {
 ////////////////////////////////////////////////////////////////////
 int GeomTristrips::
 get_geom_rendering() const {
-  return GR_triangle_strip;
+  if (is_indexed()) {
+    return GR_triangle_strip | GR_indexed_other;
+  } else {
+    return GR_triangle_strip;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
panda/src/gobj/matrixLens.cxx

@@ -53,7 +53,7 @@ is_linear() const {
 void MatrixLens::
 write(ostream &out, int indent_level) const {
   indent(out, indent_level) << get_type() << ":\n";
-  _projection_mat.write(out, indent_level + 2);
+  get_projection_mat().write(out, indent_level + 2);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 2 - 8
panda/src/gsgbase/graphicsStateGuardianBase.h

@@ -115,17 +115,11 @@ class Lens;
 //               TypedReferenceCount for that convenience.
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA GraphicsStateGuardianBase : public TypedWritableReferenceCount {
-public:
+PUBLISHED:
   virtual bool get_supports_multisample() const=0;
   virtual int get_supported_geom_rendering() const=0;
 
-  // These functions will be queried by the GeomIssuer to determine if
-  // it should issue normals, texcoords, and/or colors, based on the
-  // GSG's current state.
-  virtual bool wants_normals() const=0;
-  virtual bool wants_texcoords() const=0;
-  virtual bool wants_colors() const=0;
-
+public:
   // These are some general interface functions; they're defined here
   // mainly to make it easy to call these from code in some directory
   // that display depends on.

+ 1 - 1
panda/src/mathutil/plane_src.I

@@ -131,7 +131,7 @@ operator *= (const FLOATNAME(LMatrix4) &mat) {
 //       Access: Published
 //  Description: Transforms the plane by the indicated matrix.
 ////////////////////////////////////////////////////////////////////
-void FLOATNAME(Plane)::
+INLINE_MATHUTIL void FLOATNAME(Plane)::
 xform(const FLOATNAME(LMatrix4) &mat) {
   (*this) = (*this) * mat;
 }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov