Browse Source

Fixed erroneous char input suppression in the example scripts.
If only vsync changes on OpenGL, do not recreate the context.
Documentation update.

Lasse Öörni 14 years ago
parent
commit
af01853960

+ 0 - 3
Bin/Data/Scripts/NinjaSnowWar.as

@@ -487,10 +487,7 @@ void HandleKeyDown(StringHash eventType, VariantMap& eventData)
 {
     // Check for toggling the console
     if (eventData["Key"].GetInt() == KEY_F1)
-    {
         console.Toggle();
-        input.SuppressNextChar();
-    }
 }
 
 void HandleScreenMode()

+ 0 - 3
Bin/Data/Scripts/TestScene.as

@@ -303,10 +303,7 @@ void HandleKeyDown(StringHash eventType, VariantMap& eventData)
 {
     // Check for toggling the console
     if (eventData["Key"].GetInt() == KEY_F1)
-    {
         console.Toggle();
-        input.SuppressNextChar();
-    }
 }
 
 void HandleMouseMove(StringHash eventType, VariantMap& eventData)

+ 1 - 1
Docs/GettingStarted.dox

@@ -27,7 +27,7 @@ Although all required third-party libraries are included as source code, there a
 
 \page Running Running Urho3D
 
-For Windows & Direct3D9 mode, Urho3D requires Windows XP or newer, DirectX 9.0c, and a display adapter with SM2.0 support. SM3.0 is highly recommended. For OpenGL mode, an OpenGL 2.0 capable display adapter is required as a minimum; shadows and deferred rendering additionally require the frame buffer object extension.
+For Windows & Direct3D9 mode, Urho3D requires Windows XP or newer, DirectX 9.0c, and a display adapter with SM2.0 support. SM3.0 is highly recommended. For OpenGL mode, an OpenGL 2.0 capable display adapter is required as a minimum; shadows and deferred rendering additionally require the frame buffer object and packed depth stencil extensions.
 
 The main executable Urho3D.exe in the Bin directory contains all the engine runtime functionality. However, it does not contain any inbuilt logic or application, and therefore must be supplied with the name of the application script file it should run:
 

+ 4 - 4
Docs/Reference.dox

@@ -354,8 +354,8 @@ Screen resolution, fullscreen/windowed, vertical sync, forward/deferred mode, an
 
 When setting the initial screen mode, Graphics does a few checks:
 
-- For Direct3D9, it checks which shader model is supported? 2.0 is minimum, but 3.0 will be used if available. Shader model 2.0 can be forced by calling setForceSM2() before calling setMode() for the first time. 
-- For OpenGL, version 2.0 is required as a minimum. Shadows and deferred rendering additionally require the frame buffer object extension.
+- For Direct3D9, it checks which shader model is supported. 2.0 is minimum, but 3.0 will be used if available. %Shader model 2.0 can be forced by calling \ref Graphics::SetForceSM2() "SetForceSM2()" before calling SetMode() for the first time.
+- For OpenGL, version 2.0 is required as a minimum. Shadows and deferred rendering additionally require the frame buffer object and packed depth stencil extensions.
 - Are multiple render targets supported? If not, only forward rendering will be available.
 - Are hardware shadow maps supported? Both ATI & NVIDIA style shadow maps can be used. If neither are available, shadow rendering will be disabled.
 
@@ -373,7 +373,7 @@ The steps for rendering each viewport on each frame are roughly the following:
 - Construct render operations (batches) for the visible objects.
 - Perform these render operations during the rendering step at the end of the frame.
 
-For opaque, non-skinned geometry, batches using the same material and same vertex/index buffers are automatically grouped together for hardware instancing when SM3.0 hardware is available. This reduces the actual draw call count needed.
+For opaque, non-skinned geometry, batches using the same material and same vertex/index buffers are automatically grouped together for hardware instancing when SM3.0 hardware is available. This reduces the actual draw call count needed. Even when instancing is not available, the CPU load is slightly reduced as the rendering state only needs to be checked for each group, not each draw call.
 
 The rendering operations are divided into passes in the following order:
 
@@ -427,7 +427,7 @@ For details on how Direct3D9 and OpenGL rendering differs, see \ref APIDifferenc
 
 - In deferred rendering, OpenGL does not need to allocate a separate render target for linear depth. Instead the hardware depth buffer will be read directly, and linear depth will be reconstructed in the pixel shader. This results in less GPU memory bandwidth needed, but can introduce inaccuracy to depth calculations.
 
-- On OpenGL there is never a "device lost" condition, which would cause dynamic textures or vertex/index buffers to lose their contents.
+- On OpenGL there is never a "device lost" condition, which would cause dynamic textures or vertex/index buffers to lose their contents. However, when the screen mode is changed, the context (along with all GPU resources) will be manually destroyed and recreated. This would be strictly necessary only when changing the multisampling mode, but as bugs may otherwise occur with some GPU drivers, it is best to do for any mode change. 
 
 - At least for now, instancing is not supported for OpenGL. It still benefits from the instance group rendering loop, which only changes the model transform for each object with the same material and light, instead of setting the whole renderstate.
 

+ 1 - 1
Engine/Engine/Engine.cpp

@@ -81,7 +81,7 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
     RenderMode mode = RENDER_FORWARD;
     int width = 0;
     int height = 0;
-    int multiSample = 0;
+    int multiSample = 1;
     bool fullscreen = true;
     bool vsync = false;
     bool forceSM2 = false;

+ 12 - 3
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -170,11 +170,20 @@ bool Graphics::SetMode(RenderMode mode, int width, int height, bool fullscreen,
 {
     PROFILE(SetScreenMode);
     
-    if ((initialized_) && (mode == mode_) && (width == width_) && (height == height_) && (fullscreen == fullscreen_) && (vsync == vsync_)
-        && (multiSample == multiSample_))
+    multiSample = Clamp(multiSample, 1, 16);
+    
+    if ((initialized_) && (mode == mode_) && (width == width_) && (height == height_) && (fullscreen == fullscreen_) &&
+        (vsync == vsync_) && (multiSample == multiSample_))
         return true;
     
-    multiSample = Clamp(multiSample, 1, 16);
+    // If only vsync changes, do not destroy/recreate the context
+    if ((initialized_) && (mode == mode_) && (width == width_) && (height == height_) && (fullscreen == fullscreen_) &&
+        (multiSample == multiSample_) && (vsync != vsync_))
+    {
+        SDL_GL_SetSwapInterval(vsync ? 1 : 0);
+        vsync_ = vsync;
+        return true;
+    }
     
     // If zero dimensions in windowed mode, set default. If zero in fullscreen, use desktop mode
     if ((!width) || (!height))