Browse Source

Create a dedicated depth stencil texture in View3D so that temporary depth stencils are not constantly generated when resizing a View3D.
Decrease screen buffer idle time before destruction to 1 second.

Lasse Öörni 12 years ago
parent
commit
36e165596a

+ 15 - 3
Docs/LuaScriptAPI.dox

@@ -6,6 +6,8 @@ namespace Urho3D
 
 \section LuaScriptAPI_GlobalFunctions Global functions
 - Context* GetContext()
+- Object* GetEventSender()
+- EventHandler* GetEventHandler() const
 - Audio* GetAudio()
 - Console* GetConsole()
 - DebugHud* GetDebugHud()
@@ -25,7 +27,7 @@ namespace Urho3D
 - void ErrorExit(const String message = String::EMPTY, int exitCode = EXIT_FAILURE)
 - void OpenConsoleWindow()
 - void PrintLine(const String str, bool error = false)
-- const Vector<String>& GetArguments()
+- string* GetArguments()
 - String GetConsoleInput()
 - String GetPlatform()
 - unsigned GetNumPhysicalCPUs()
@@ -57,7 +59,6 @@ namespace Urho3D
 - String GetInternalPath(const String pathName)
 - String GetNativePath(const String pathName)
 - bool IsAbsolutePath(const String pathName)
-- Object* GetEventSender()
 - void SendEvent(const String eventName, VariantMap& eventData)
 - void SubscribeToEvent(const String eventName, const String functionName)
 - void UnsubscribeFromEvent(const String eventName)
@@ -618,6 +619,17 @@ Properties:
 
 Methods:
 
+- Sound(Context* context)
+- ~Sound()
+- bool LoadRaw(Deserializer& source)
+- bool LoadWav(Deserializer& source)
+- bool LoadOggVorbis(Deserializer& source)
+- void SetSize(unsigned dataSize)
+- void SetData(const void* data, unsigned dataSize)
+- void SetFormat(unsigned frequency, bool sixteenBit, bool stereo)
+- void SetLooped(bool enable)
+- void SetLoop(unsigned repeatOffset, unsigned endOffset)
+- void FixInterpolation()
 - float GetLength() const
 - unsigned GetDataSize() const
 - unsigned GetSampleSize() const
@@ -672,7 +684,6 @@ Methods:
 - void PlayLockless(Sound* sound)
 - void StopLockless()
 - void SetPlayPositionLockless(signed char* position)
-- void Mix(int* dest, unsigned samples, int mixRate, bool stereo, bool interpolation)
 
 Properties:
 
@@ -5104,6 +5115,7 @@ Methods:
 - Scene* GetScene() const
 - Node* GetCameraNode() const
 - Texture2D* GetRenderTexture() const
+- Texture2D* GetDepthTexture() const
 - Viewport* GetViewport() const
 
 Properties:

+ 1 - 0
Docs/ScriptAPI.dox

@@ -6311,6 +6311,7 @@ Properties:
 - uint format
 - bool autoUpdate
 - Texture2D@ renderTexture (readonly)
+- Texture2D@ depthTexture (readonly)
 - Viewport@ viewport (readonly)
 - Scene@ scene (readonly)
 - Node@ cameraNode (readonly)

+ 1 - 1
Source/Engine/Graphics/Renderer.cpp

@@ -251,7 +251,7 @@ static const char* lightPSVariations[] =
 };
 
 static const unsigned INSTANCING_BUFFER_MASK = MASK_INSTANCEMATRIX1 | MASK_INSTANCEMATRIX2 | MASK_INSTANCEMATRIX3;
-static const unsigned MAX_BUFFER_AGE = 2000;
+static const unsigned MAX_BUFFER_AGE = 1000;
 
 Renderer::Renderer(Context* context) :
     Object(context),

+ 1 - 0
Source/Engine/Script/UIAPI.cpp

@@ -477,6 +477,7 @@ static void RegisterView3D(asIScriptEngine* engine)
     engine->RegisterObjectMethod("View3D", "void set_autoUpdate(bool)", asMETHOD(View3D, SetAutoUpdate), asCALL_THISCALL);
     engine->RegisterObjectMethod("View3D", "bool get_autoUpdate() const", asMETHOD(View3D, GetAutoUpdate), asCALL_THISCALL);
     engine->RegisterObjectMethod("View3D", "Texture2D@+ get_renderTexture() const", asMETHOD(View3D, GetRenderTexture), asCALL_THISCALL);
+    engine->RegisterObjectMethod("View3D", "Texture2D@+ get_depthTexture() const", asMETHOD(View3D, GetDepthTexture), asCALL_THISCALL);
     engine->RegisterObjectMethod("View3D", "Viewport@+ get_viewport() const", asMETHOD(View3D, GetViewport), asCALL_THISCALL);
     engine->RegisterObjectMethod("View3D", "Scene@+ get_scene() const", asMETHOD(View3D, GetScene), asCALL_THISCALL);
     engine->RegisterObjectMethod("View3D", "Node@+ get_cameraNode() const", asMETHOD(View3D, GetCameraNode), asCALL_THISCALL);

+ 9 - 1
Source/Engine/UI/View3D.cpp

@@ -44,6 +44,7 @@ View3D::View3D(Context* context) :
     autoUpdate_(true)
 {
     renderTexture_ = new Texture2D(context_);
+    depthTexture_ = new Texture2D(context_);
     viewport_ = new Viewport(context_);
 }
 
@@ -70,10 +71,12 @@ void View3D::OnResize()
     if (width > 0 && height >> 0)
     {
         renderTexture_->SetSize(width, height, rttFormat_, TEXTURE_RENDERTARGET);
+        depthTexture_->SetSize(width, height, Graphics::GetDepthStencilFormat(), TEXTURE_DEPTHSTENCIL);
         RenderSurface* surface = renderTexture_->GetRenderSurface();
         surface->SetViewport(0, viewport_);
         surface->SetUpdateMode(autoUpdate_ ? SURFACE_UPDATEALWAYS : SURFACE_MANUALUPDATE);
-
+        surface->SetLinkedDepthStencil(depthTexture_->GetRenderSurface());
+        
         SetTexture(renderTexture_);
         SetImageRect(IntRect(0, 0, width, height));
 
@@ -137,6 +140,11 @@ Texture2D* View3D::GetRenderTexture() const
     return renderTexture_;
 }
 
+Texture2D* View3D::GetDepthTexture() const
+{
+    return depthTexture_;
+}
+
 Viewport* View3D::GetViewport() const
 {
     return viewport_;

+ 4 - 0
Source/Engine/UI/View3D.h

@@ -68,11 +68,15 @@ public:
     Node* GetCameraNode() const;
     /// Return render texture.
     Texture2D* GetRenderTexture() const;
+    /// Return depth stencil texture.
+    Texture2D* GetDepthTexture() const;
     /// Return viewport.
     Viewport* GetViewport() const;
     
     /// Renderable texture.
     SharedPtr<Texture2D> renderTexture_;
+    /// Depth stencil texture.
+    SharedPtr<Texture2D> depthTexture_;
     /// Viewport.
     SharedPtr<Viewport> viewport_;
     /// Scene.

+ 1 - 0
Source/Extras/LuaScript/pkgs/UI/View3D.pkg

@@ -15,6 +15,7 @@ class View3D : public Window
     Scene* GetScene() const;
     Node* GetCameraNode() const;
     Texture2D* GetRenderTexture() const;
+    Texture2D* GetDepthTexture() const;
     Viewport* GetViewport() const;
     
     tolua_property__get_set unsigned format;