Kaynağa Gözat

Fixed comments.
Added -logdebug command line option.

Lasse Öörni 14 yıl önce
ebeveyn
işleme
fbdd44c3b8

+ 1 - 1
Engine/Core/ProcessUtils.cpp

@@ -1,6 +1,6 @@
 //
 // Urho3D Engine
-// Copyright (c) 2008-2011 Lasse Öörni
+// Copyright (c) 2008-2011 Lasse Öörni
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal

+ 1 - 1
Engine/Engine/CoreAPI.cpp

@@ -1,6 +1,6 @@
 //
 // Urho3D Engine
-// Copyright (c) 2008-2011 Lasse Öörni
+// Copyright (c) 2008-2011 Lasse Öörni
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal

+ 5 - 0
Engine/Engine/Engine.cpp

@@ -89,6 +89,7 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
     bool interpolate = true;
     bool flush = true;
     bool threads = true;
+    bool logDebug = false;
     
     for (unsigned i = 0; i < arguments.Size(); ++i)
     {
@@ -98,6 +99,8 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
             
             if (argument == "headless")
                 headless_ = true;
+            else if (argument == "logdebug")
+                logDebug = true;
             else if (argument == "nolimit")
                 SetMaxFps(0);
             else if (argument == "nosound")
@@ -174,6 +177,8 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
     // Start logging
     Log* log = GetSubsystem<Log>();
     log->Open(logName);
+    if (logDebug)
+        log->SetLevel(LOG_DEBUG);
     
     // Set amount of worker threads according to the available physical CPU cores. Using also hyperthreaded cores results in
     // unpredictable extra synchronization overhead. Also reserve one core for the main thread

+ 1 - 1
Engine/Graphics/DebugRenderer.h

@@ -97,7 +97,7 @@ public:
     void AddSkeleton(const Skeleton& skeleton, const Color& color, bool depthTest = true);
     /// Add a triangle mesh.
     void AddTriangleMesh(const void* vertexData, unsigned vertexSize, const void* indexData, unsigned indexSize, unsigned indexStart, unsigned indexCount, const Matrix3x4& transform, const Color& color, bool depthTest = true);
-    /// Update vertex buffer and render all debug lines. The viewport and rendertarget should be set before.
+    /// Update vertex buffer and render all debug lines. The viewport and render target should be set before.
     void Render();
     
     /// Return the view transform.

+ 2 - 2
Engine/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -543,7 +543,7 @@ bool Graphics::BeginFrame()
     
     impl_->device_->BeginScene();
     
-    // Set default rendertarget and depth buffer
+    // Set default render target and depth buffer
     ResetRenderTargets();
     
     // Cleanup textures from previous frame
@@ -1312,7 +1312,7 @@ void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
         impl_->colorSurfaces_[index] = newColorSurface;
     }
     
-    // If the rendertarget is also bound as a texture, replace with backup texture or null
+    // If the render target is also bound as a texture, replace with backup texture or null
     if (renderTarget)
     {
         Texture* parentTexture = renderTarget->GetParentTexture();

+ 2 - 2
Engine/Graphics/Direct3D9/D3D9Graphics.h

@@ -130,11 +130,11 @@ public:
     void SetDefaultTextureFilterMode(TextureFilterMode mode);
     /// %Set texture anisotropy.
     void SetTextureAnisotropy(unsigned level);
-    /// Reset all render targets and depth buffer (render to back buffer and back buffer depth stencil.)
+    /// Reset all render targets and depth stencil buffer (render to back buffer.)
     void ResetRenderTargets();
     /// Reset specific render target.
     void ResetRenderTarget(unsigned index);
-    /// Reset depth stencil.
+    /// Reset depth stencil buffer.
     void ResetDepthStencil();
     /// %Set render target.
     void SetRenderTarget(unsigned index, RenderSurface* renderTarget);

+ 24 - 18
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -279,7 +279,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool vsync, bool
     tripleBuffer_ = tripleBuffer;
     multiSample_ = multiSample;
     
-    // Reset rendertargets and viewport for the new screen mode
+    // Reset render targets and viewport for the new screen mode
     ResetRenderTargets();
     
     // Clear the window to black now, because GPU object restore may take time
@@ -358,7 +358,7 @@ bool Graphics::BeginFrame()
     if (fullscreen_ && (!glfwGetWindowParam(impl_->window_, GLFW_ACTIVE) || glfwGetWindowParam(impl_->window_, GLFW_ICONIFIED)))
         return false;
     
-    // Set default rendertarget and depth buffer
+    // Set default render target and depth buffer
     ResetRenderTargets();
     
     // Cleanup textures from previous frame
@@ -1129,7 +1129,7 @@ void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
     {
         renderTargets_[index] = renderTarget;
         
-        // If the rendertarget is also bound as a texture, replace with backup texture or null
+        // If the render target is also bound as a texture, replace with backup texture or null
         if (renderTarget)
         {
             Texture* parentTexture = renderTarget->GetParentTexture();
@@ -1169,7 +1169,7 @@ void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
         // otherwise it is an OpenGL error (incomplete framebuffer)
         SetDrawBuffers();
         
-        // If all rendertargets and the depth buffer are not textures, revert to backbuffer rendering
+        // If all render targets and the depth buffer are not textures, revert to backbuffer rendering
         bool noFBO = (depthStencil_ == 0);
         for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
         {
@@ -1201,22 +1201,28 @@ void Graphics::SetDepthStencil(RenderSurface* depthStencil)
 {
     if (depthStencil != depthStencil_)
     {
-        // If we are using a rendertarget texture, it is required in OpenGL to also have an own depth stencil
-        // Create a new depth stencil texture as necessary to be able to provide similar behaviour.
+        // If we are using a render target texture, it is required in OpenGL to also have an own depth stencil
+        // Create a new depth stencil texture as necessary to be able to provide similar behaviour as Direct3D9
         if (renderTargets_[0] && !depthStencil)
         {
             int width = renderTargets_[0]->GetWidth();
             int height = renderTargets_[0]->GetHeight();
-            int searchKey = (width << 16) | height;
-            HashMap<int, SharedPtr<Texture2D> >::Iterator i = depthTextures_.Find(searchKey);
-            if (i != depthTextures_.End())
-                depthStencil = i->second_->GetRenderSurface();
-            else
+            
+            // Direct3D9 default depth stencil can not be used when render target is larger than the window.
+            // Check size similarly
+            if (width <= width_ && height <= height_)
             {
-                SharedPtr<Texture2D> newDepthTexture(new Texture2D(context_));
-                newDepthTexture->SetSize(width, height, GetDepthStencilFormat(), TEXTURE_DEPTHSTENCIL);
-                depthTextures_[searchKey] = newDepthTexture;
-                depthStencil = newDepthTexture->GetRenderSurface();
+                int searchKey = (width << 16) | height;
+                HashMap<int, SharedPtr<Texture2D> >::Iterator i = depthTextures_.Find(searchKey);
+                if (i != depthTextures_.End())
+                    depthStencil = i->second_->GetRenderSurface();
+                else
+                {
+                    SharedPtr<Texture2D> newDepthTexture(new Texture2D(context_));
+                    newDepthTexture->SetSize(width, height, GetDepthStencilFormat(), TEXTURE_DEPTHSTENCIL);
+                    depthTextures_[searchKey] = newDepthTexture;
+                    depthStencil = newDepthTexture->GetRenderSurface();
+                }
             }
         }
         
@@ -1268,7 +1274,7 @@ void Graphics::SetDepthStencil(RenderSurface* depthStencil)
         // otherwise it is an OpenGL error (incomplete framebuffer)
         SetDrawBuffers();
         
-        // If all rendertargets and the depth buffer are not textures, revert to backbuffer rendering
+        // If all render targets and the depth buffer are not textures, revert to backbuffer rendering
         bool noFBO = (depthStencil_ == 0);
         for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
         {
@@ -1847,7 +1853,7 @@ void Graphics::ResetCachedState()
 
 void Graphics::SetDrawBuffers()
 {
-    // Calculate the bit combination of non-zero color rendertargets to first check if the combination changed
+    // Calculate the bit combination of non-zero color render targets to first check if the combination changed
     unsigned newDrawBuffers = 0;
     for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
     {
@@ -1858,7 +1864,7 @@ void Graphics::SetDrawBuffers()
     if (newDrawBuffers == impl_->drawBuffers_)
         return;
     
-    // Check for no color rendertargets (depth rendering only)
+    // Check for no color render targets (depth rendering only)
     if (!newDrawBuffers)
         glDrawBuffer(GL_NONE);
     else

+ 3 - 3
Engine/Graphics/OpenGL/OGLGraphics.h

@@ -152,11 +152,11 @@ public:
     void SetTextureAnisotropy(unsigned level);
     /// Dirty texture parameters of all textures (when global settings change.)
     void SetTextureParametersDirty();
-    /// Reset all render targets and depth buffer (render to back buffer and back buffer depth stencil.)
+    /// Reset all render targets and depth stencil buffer (render to back buffer.)
     void ResetRenderTargets();
     /// Reset specific render target.
     void ResetRenderTarget(unsigned index);
-    /// Reset depth stencil.
+    /// Reset depth stencil buffer.
     void ResetDepthStencil();
     /// Set render target.
     void SetRenderTarget(unsigned index, RenderSurface* renderTarget);
@@ -458,7 +458,7 @@ private:
     unsigned stencilMask_;
     /// Default texture filtering mode.
     TextureFilterMode defaultTextureFilterMode_;
-    /// Map for additional depth textures, to emulate Direct3D9 ability to mix rendertarget and backbuffer rendering.
+    /// Map for additional depth textures, to emulate Direct3D9 ability to mix render texture and backbuffer rendering.
     HashMap<int, SharedPtr<Texture2D> > depthTextures_;
 };
 

+ 1 - 2
Engine/Graphics/OpenGL/OGLTexture.cpp

@@ -200,8 +200,7 @@ int Texture::GetLevelHeight(unsigned level) const
 
 TextureUsage Texture::GetUsage() const
 {
-    /// \todo Check for rendertarget / depthstencil mode
-    
+    /// \todo Check for render target / depth stencil mode
     if (dynamic_)
         return TEXTURE_DYNAMIC;
     

+ 4 - 4
Engine/Graphics/Renderer.cpp

@@ -766,7 +766,7 @@ Texture2D* Renderer::GetShadowMap(Light* light, Camera* camera, unsigned viewWid
     int retries = 3;
     
     #ifdef USE_OPENGL
-    // Create shadow map only. Color rendertarget is not needed
+    // Create shadow map only. Color render target is not needed
     while (retries)
     {
         if (!newShadowMap->SetSize(width, height, shadowMapFormat, TEXTURE_DEPTHSTENCIL))
@@ -783,7 +783,7 @@ Texture2D* Renderer::GetShadowMap(Light* light, Camera* camera, unsigned viewWid
         }
     }
     #else
-    // Create shadow map and dummy color rendertarget
+    // Create shadow map and dummy color render target
     bool fallback = graphics_->GetFallback();
     while (retries)
     {
@@ -798,13 +798,13 @@ Texture2D* Renderer::GetShadowMap(Light* light, Camera* camera, unsigned viewWid
             newShadowMap->SetFilterMode(FILTER_BILINEAR);
             if (!fallback)
             {
-                // If no dummy color rendertarget for this size exists yet, create one now
+                // If no dummy color render target for this size exists yet, create one now
                 if (!colorShadowMaps_.Contains(searchKey))
                 {
                     colorShadowMaps_[searchKey] = new Texture2D(context_);
                     colorShadowMaps_[searchKey]->SetSize(width, height, dummyColorFormat, TEXTURE_RENDERTARGET);
                 }
-                // Link the color rendertarget to the shadow map
+                // Link the color render target to the shadow map
                 newShadowMap->GetRenderSurface()->SetLinkedRenderTarget(colorShadowMaps_[searchKey]->GetRenderSurface());
             }
             else

+ 1 - 1
Engine/Graphics/View.cpp

@@ -662,7 +662,7 @@ void View::GetBatches()
                     continue;
                 
                 // Check here if the material technique refers to a render target texture with camera(s) attached
-                // Only check this for the main view (null rendertarget)
+                // Only check this for the main view (null render target)
                 if (!renderTarget_ && baseBatch.material_ && baseBatch.material_->GetAuxViewFrameNumber() != frame_.frameNumber_)
                     CheckMaterialForAuxView(baseBatch.material_);
                 

+ 1 - 1
Engine/Graphics/View.h

@@ -90,7 +90,7 @@ public:
     /// Destruct.
     virtual ~View();
     
-    /// Define with rendertarget and viewport. Return true if successful.
+    /// Define with render target and viewport. Return true if successful.
     bool Define(RenderSurface* renderTarget, const Viewport& viewport);
     /// Update and cull objects and construct rendering batches.
     void Update(const FrameInfo& frame);