Kaynağa Gözat

In Rev 1.130 of GraphicsOut.cxx by drwr, the query for render-to-texture support is no longer made to the gsg directly at line 368, but is instead routed through an internal GraphicsOut.get_supports_render_texture() which defaults to false. In the wgl path, the derived wglGraphicsBuffer supplies its own get_supports_render_texture() and querys the gsg. The DirectX equivalent classes do not supply a new get_supports_render_texture() and so fails everytime when trying to render_to_texture.

This patches in the requisite get_supports_render_texture() for wdxGraphicsBuffer8 and fixes a few typos between depth and color texture usages.

Thanks to Jonah (11thpenguin) for pointing these mistakes out.
Zhao Huang 13 yıl önce
ebeveyn
işleme
a6993457cc

+ 27 - 0
panda/src/dxgsg8/wdxGraphicsBuffer8.I

@@ -0,0 +1,27 @@
+// Filename: wdxGraphicsBuffer9.I
+// Created by:  zhao (29Sep12)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsBuffer8::get_supports_render_texture
+//       Access: Published, Virtual
+//  Description: Returns true if this particular GraphicsOutput can
+//               render directly into a texture, or false if it must
+//               always copy-to-texture at the end of each frame to
+//               achieve this effect.
+////////////////////////////////////////////////////////////////////
+INLINE bool wdxGraphicsBuffer9::
+get_supports_render_texture() const {
+  // DX8 buffers can always bind-to-texture.
+  return true;
+}

+ 2 - 2
panda/src/dxgsg8/wdxGraphicsBuffer8.cxx

@@ -347,14 +347,14 @@ rebuild_bitplanes() {
     if (depth_ctx) {
       if (!depth_ctx->create_texture(*_dxgsg->_screen)) {
         dxgsg8_cat.error()
-          << "Unable to re-create texture " << *color_ctx->get_texture() << endl;
+          << "Unable to re-create texture " << *depth_ctx->get_texture() << endl;
         return false;
       }
       
       if (depth_tex->get_texture_type() == Texture::TT_2d_texture) {
         depth_d3d_tex = depth_ctx->_d3d_2d_texture;
         nassertr(depth_d3d_tex != 0, false);
-        hr = color_d3d_tex -> GetSurfaceLevel(0, &depth_surf);
+        hr = depth_d3d_tex -> GetSurfaceLevel(0, &depth_surf);
         if (!SUCCEEDED(hr)) {
           dxgsg8_cat.error ( ) << "GetSurfaceLevel " << D3DERRORSTRING(hr) FL;
         }

+ 4 - 0
panda/src/dxgsg8/wdxGraphicsBuffer8.h

@@ -40,6 +40,8 @@ public:
                      GraphicsStateGuardian *gsg,
                      GraphicsOutput *host);
   virtual ~wdxGraphicsBuffer8();
+  
+  virtual INLINE bool get_supports_render_texture() const;
 
   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
   virtual void end_frame(FrameMode mode, Thread *current_thread);
@@ -92,4 +94,6 @@ private:
   friend class DXTextureContext8;
 };
 
+#include "wdxGraphicsBuffer8.I"
+
 #endif