|
@@ -25,37 +25,17 @@
|
|
|
#include "../../Core/Context.h"
|
|
#include "../../Core/Context.h"
|
|
|
#include "../../Core/ProcessUtils.h"
|
|
#include "../../Core/ProcessUtils.h"
|
|
|
#include "../../Core/Profiler.h"
|
|
#include "../../Core/Profiler.h"
|
|
|
-#include "../../Graphics/AnimatedModel.h"
|
|
|
|
|
-#include "../../Graphics/Animation.h"
|
|
|
|
|
-#include "../../Graphics/AnimationController.h"
|
|
|
|
|
-#include "../../Graphics/Camera.h"
|
|
|
|
|
-#include "../../Graphics/CustomGeometry.h"
|
|
|
|
|
-#include "../../Graphics/DebugRenderer.h"
|
|
|
|
|
-#include "../../Graphics/DecalSet.h"
|
|
|
|
|
#include "../../Graphics/Graphics.h"
|
|
#include "../../Graphics/Graphics.h"
|
|
|
#include "../../Graphics/GraphicsEvents.h"
|
|
#include "../../Graphics/GraphicsEvents.h"
|
|
|
#include "../../Graphics/GraphicsImpl.h"
|
|
#include "../../Graphics/GraphicsImpl.h"
|
|
|
#include "../../Graphics/IndexBuffer.h"
|
|
#include "../../Graphics/IndexBuffer.h"
|
|
|
-#include "../../Graphics/Material.h"
|
|
|
|
|
-#include "../../Graphics/Octree.h"
|
|
|
|
|
-#include "../../Graphics/ParticleEffect.h"
|
|
|
|
|
-#include "../../Graphics/ParticleEmitter.h"
|
|
|
|
|
-#include "../../Graphics/RibbonTrail.h"
|
|
|
|
|
#include "../../Graphics/Shader.h"
|
|
#include "../../Graphics/Shader.h"
|
|
|
#include "../../Graphics/ShaderPrecache.h"
|
|
#include "../../Graphics/ShaderPrecache.h"
|
|
|
#include "../../Graphics/ShaderProgram.h"
|
|
#include "../../Graphics/ShaderProgram.h"
|
|
|
-#include "../../Graphics/Skybox.h"
|
|
|
|
|
-#include "../../Graphics/StaticModelGroup.h"
|
|
|
|
|
-#include "../../Graphics/Technique.h"
|
|
|
|
|
-#include "../../Graphics/Terrain.h"
|
|
|
|
|
-#include "../../Graphics/TerrainPatch.h"
|
|
|
|
|
#include "../../Graphics/Texture2D.h"
|
|
#include "../../Graphics/Texture2D.h"
|
|
|
-#include "../../Graphics/Texture2DArray.h"
|
|
|
|
|
-#include "../../Graphics/Texture3D.h"
|
|
|
|
|
#include "../../Graphics/TextureCube.h"
|
|
#include "../../Graphics/TextureCube.h"
|
|
|
#include "../../Graphics/VertexBuffer.h"
|
|
#include "../../Graphics/VertexBuffer.h"
|
|
|
#include "../../Graphics/VertexDeclaration.h"
|
|
#include "../../Graphics/VertexDeclaration.h"
|
|
|
-#include "../../Graphics/Zone.h"
|
|
|
|
|
#include "../../IO/File.h"
|
|
#include "../../IO/File.h"
|
|
|
#include "../../IO/Log.h"
|
|
#include "../../IO/Log.h"
|
|
|
#include "../../Resource/ResourceCache.h"
|
|
#include "../../Resource/ResourceCache.h"
|
|
@@ -257,10 +237,12 @@ static HWND GetWindowHandle(SDL_Window* window)
|
|
|
static unsigned readableDepthFormat = 0;
|
|
static unsigned readableDepthFormat = 0;
|
|
|
|
|
|
|
|
const Vector2 Graphics::pixelUVOffset(0.5f, 0.5f);
|
|
const Vector2 Graphics::pixelUVOffset(0.5f, 0.5f);
|
|
|
|
|
+bool Graphics::gl3Support = false;
|
|
|
|
|
|
|
|
Graphics::Graphics(Context* context) :
|
|
Graphics::Graphics(Context* context) :
|
|
|
Object(context),
|
|
Object(context),
|
|
|
impl_(new GraphicsImpl()),
|
|
impl_(new GraphicsImpl()),
|
|
|
|
|
+ window_(0),
|
|
|
windowIcon_(0),
|
|
windowIcon_(0),
|
|
|
externalWindow_(0),
|
|
externalWindow_(0),
|
|
|
width_(0),
|
|
width_(0),
|
|
@@ -275,8 +257,10 @@ Graphics::Graphics(Context* context) :
|
|
|
tripleBuffer_(false),
|
|
tripleBuffer_(false),
|
|
|
flushGPU_(false),
|
|
flushGPU_(false),
|
|
|
sRGB_(false),
|
|
sRGB_(false),
|
|
|
- deviceLost_(false),
|
|
|
|
|
- queryIssued_(false),
|
|
|
|
|
|
|
+ anisotropySupport_(false),
|
|
|
|
|
+ dxtTextureSupport_(false),
|
|
|
|
|
+ etcTextureSupport_(false),
|
|
|
|
|
+ pvrtcTextureSupport_(false),
|
|
|
lightPrepassSupport_(false),
|
|
lightPrepassSupport_(false),
|
|
|
deferredSupport_(false),
|
|
deferredSupport_(false),
|
|
|
instancingSupport_(false),
|
|
instancingSupport_(false),
|
|
@@ -286,7 +270,6 @@ Graphics::Graphics(Context* context) :
|
|
|
numBatches_(0),
|
|
numBatches_(0),
|
|
|
maxScratchBufferRequest_(0),
|
|
maxScratchBufferRequest_(0),
|
|
|
defaultTextureFilterMode_(FILTER_TRILINEAR),
|
|
defaultTextureFilterMode_(FILTER_TRILINEAR),
|
|
|
- shaderProgram_(0),
|
|
|
|
|
shaderPath_("Shaders/HLSL/"),
|
|
shaderPath_("Shaders/HLSL/"),
|
|
|
shaderExtension_(".hlsl"),
|
|
shaderExtension_(".hlsl"),
|
|
|
orientations_("LandscapeLeft LandscapeRight"),
|
|
orientations_("LandscapeLeft LandscapeRight"),
|
|
@@ -312,7 +295,7 @@ Graphics::~Graphics()
|
|
|
gpuObjects_.Clear();
|
|
gpuObjects_.Clear();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- vertexDeclarations_.Clear();
|
|
|
|
|
|
|
+ impl_->vertexDeclarations_.Clear();
|
|
|
|
|
|
|
|
URHO3D_SAFE_RELEASE(impl_->defaultColorSurface_);
|
|
URHO3D_SAFE_RELEASE(impl_->defaultColorSurface_);
|
|
|
URHO3D_SAFE_RELEASE(impl_->defaultDepthStencilSurface_);
|
|
URHO3D_SAFE_RELEASE(impl_->defaultDepthStencilSurface_);
|
|
@@ -320,11 +303,11 @@ Graphics::~Graphics()
|
|
|
URHO3D_SAFE_RELEASE(impl_->device_);
|
|
URHO3D_SAFE_RELEASE(impl_->device_);
|
|
|
URHO3D_SAFE_RELEASE(impl_->interface_);
|
|
URHO3D_SAFE_RELEASE(impl_->interface_);
|
|
|
|
|
|
|
|
- if (impl_->window_)
|
|
|
|
|
|
|
+ if (window_)
|
|
|
{
|
|
{
|
|
|
SDL_ShowCursor(SDL_TRUE);
|
|
SDL_ShowCursor(SDL_TRUE);
|
|
|
- SDL_DestroyWindow(impl_->window_);
|
|
|
|
|
- impl_->window_ = 0;
|
|
|
|
|
|
|
+ SDL_DestroyWindow(window_);
|
|
|
|
|
+ window_ = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
delete impl_;
|
|
delete impl_;
|
|
@@ -334,41 +317,6 @@ Graphics::~Graphics()
|
|
|
SDL_Quit();
|
|
SDL_Quit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::SetExternalWindow(void* window)
|
|
|
|
|
-{
|
|
|
|
|
- if (!impl_->window_)
|
|
|
|
|
- externalWindow_ = window;
|
|
|
|
|
- else
|
|
|
|
|
- URHO3D_LOGERROR("Window already opened, can not set external window");
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::SetWindowTitle(const String& windowTitle)
|
|
|
|
|
-{
|
|
|
|
|
- windowTitle_ = windowTitle;
|
|
|
|
|
- if (impl_->window_)
|
|
|
|
|
- SDL_SetWindowTitle(impl_->window_, windowTitle_.CString());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::SetWindowIcon(Image* windowIcon)
|
|
|
|
|
-{
|
|
|
|
|
- windowIcon_ = windowIcon;
|
|
|
|
|
- if (impl_->window_)
|
|
|
|
|
- CreateWindowIcon();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::SetWindowPosition(const IntVector2& position)
|
|
|
|
|
-{
|
|
|
|
|
- if (impl_->window_)
|
|
|
|
|
- SDL_SetWindowPosition(impl_->window_, position.x_, position.y_);
|
|
|
|
|
- else
|
|
|
|
|
- position_ = position; // Sets as initial position for OpenWindow()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::SetWindowPosition(int x, int y)
|
|
|
|
|
-{
|
|
|
|
|
- SetWindowPosition(IntVector2(x, y));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync,
|
|
bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync,
|
|
|
bool tripleBuffer, int multiSample)
|
|
bool tripleBuffer, int multiSample)
|
|
|
{
|
|
{
|
|
@@ -416,7 +364,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
|
|
|
|
|
SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
|
|
SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
|
|
|
|
|
|
|
|
- if (!impl_->window_)
|
|
|
|
|
|
|
+ if (!window_)
|
|
|
{
|
|
{
|
|
|
if (!OpenWindow(width, height, resizable, borderless))
|
|
if (!OpenWindow(width, height, resizable, borderless))
|
|
|
return false;
|
|
return false;
|
|
@@ -470,7 +418,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
if (maximize)
|
|
if (maximize)
|
|
|
{
|
|
{
|
|
|
Maximize();
|
|
Maximize();
|
|
|
- SDL_GetWindowSize(impl_->window_, &width, &height);
|
|
|
|
|
|
|
+ SDL_GetWindowSize(window_, &width, &height);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (fullscreen)
|
|
if (fullscreen)
|
|
@@ -490,7 +438,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
impl_->presentParams_.MultiSampleType = multiSample > 1 ? (D3DMULTISAMPLE_TYPE)multiSample : D3DMULTISAMPLE_NONE;
|
|
impl_->presentParams_.MultiSampleType = multiSample > 1 ? (D3DMULTISAMPLE_TYPE)multiSample : D3DMULTISAMPLE_NONE;
|
|
|
impl_->presentParams_.MultiSampleQuality = 0;
|
|
impl_->presentParams_.MultiSampleQuality = 0;
|
|
|
impl_->presentParams_.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
impl_->presentParams_.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
- impl_->presentParams_.hDeviceWindow = GetWindowHandle(impl_->window_);
|
|
|
|
|
|
|
+ impl_->presentParams_.hDeviceWindow = GetWindowHandle(window_);
|
|
|
impl_->presentParams_.EnableAutoDepthStencil = TRUE;
|
|
impl_->presentParams_.EnableAutoDepthStencil = TRUE;
|
|
|
impl_->presentParams_.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
impl_->presentParams_.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
impl_->presentParams_.Flags = D3DPRESENT_LINEAR_CONTENT;
|
|
impl_->presentParams_.Flags = D3DPRESENT_LINEAR_CONTENT;
|
|
@@ -582,24 +530,18 @@ void Graphics::SetFlushGPU(bool enable)
|
|
|
flushGPU_ = enable;
|
|
flushGPU_ = enable;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::SetOrientations(const String& orientations)
|
|
|
|
|
-{
|
|
|
|
|
- orientations_ = orientations.Trimmed();
|
|
|
|
|
- SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-bool Graphics::ToggleFullscreen()
|
|
|
|
|
|
|
+void Graphics::SetForceGL2(bool enable)
|
|
|
{
|
|
{
|
|
|
- return SetMode(width_, height_, !fullscreen_, borderless_, resizable_, highDPI_, vsync_, tripleBuffer_, multiSample_);
|
|
|
|
|
|
|
+ // No effect on Direct3D9
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Graphics::Close()
|
|
void Graphics::Close()
|
|
|
{
|
|
{
|
|
|
- if (impl_->window_)
|
|
|
|
|
|
|
+ if (window_)
|
|
|
{
|
|
{
|
|
|
SDL_ShowCursor(SDL_TRUE);
|
|
SDL_ShowCursor(SDL_TRUE);
|
|
|
- SDL_DestroyWindow(impl_->window_);
|
|
|
|
|
- impl_->window_ = 0;
|
|
|
|
|
|
|
+ SDL_DestroyWindow(window_);
|
|
|
|
|
+ window_ = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -669,7 +611,7 @@ bool Graphics::TakeScreenShot(Image& destImage)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- HWND hwnd = GetWindowHandle(impl_->window_);
|
|
|
|
|
|
|
+ HWND hwnd = GetWindowHandle(window_);
|
|
|
GetClientRect(hwnd, &sourceRect);
|
|
GetClientRect(hwnd, &sourceRect);
|
|
|
ClientToScreen(hwnd, (LPPOINT)&sourceRect);
|
|
ClientToScreen(hwnd, (LPPOINT)&sourceRect);
|
|
|
}
|
|
}
|
|
@@ -742,7 +684,7 @@ bool Graphics::BeginFrame()
|
|
|
{
|
|
{
|
|
|
int width, height;
|
|
int width, height;
|
|
|
|
|
|
|
|
- SDL_GetWindowSize(impl_->window_, &width, &height);
|
|
|
|
|
|
|
+ SDL_GetWindowSize(window_, &width, &height);
|
|
|
if (width != width_ || height != height_)
|
|
if (width != width_ || height != height_)
|
|
|
SetMode(width, height);
|
|
SetMode(width, height);
|
|
|
}
|
|
}
|
|
@@ -750,7 +692,7 @@ bool Graphics::BeginFrame()
|
|
|
{
|
|
{
|
|
|
// To prevent a loop of endless device loss and flicker, do not attempt to render when in fullscreen
|
|
// To prevent a loop of endless device loss and flicker, do not attempt to render when in fullscreen
|
|
|
// and the window is minimized
|
|
// and the window is minimized
|
|
|
- if (fullscreen_ && (SDL_GetWindowFlags(impl_->window_) & SDL_WINDOW_MINIMIZED))
|
|
|
|
|
|
|
+ if (fullscreen_ && (SDL_GetWindowFlags(window_) & SDL_WINDOW_MINIMIZED))
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -760,7 +702,7 @@ bool Graphics::BeginFrame()
|
|
|
{
|
|
{
|
|
|
URHO3D_PROFILE(DeviceLost);
|
|
URHO3D_PROFILE(DeviceLost);
|
|
|
|
|
|
|
|
- deviceLost_ = true;
|
|
|
|
|
|
|
+ impl_->deviceLost_ = true;
|
|
|
|
|
|
|
|
// The device can not be reset yet, sleep and try again eventually
|
|
// The device can not be reset yet, sleep and try again eventually
|
|
|
if (hr == D3DERR_DEVICELOST)
|
|
if (hr == D3DERR_DEVICELOST)
|
|
@@ -811,7 +753,7 @@ void Graphics::EndFrame()
|
|
|
// If a query was issued on the previous frame, first wait for it to finish
|
|
// If a query was issued on the previous frame, first wait for it to finish
|
|
|
if (impl_->frameQuery_)
|
|
if (impl_->frameQuery_)
|
|
|
{
|
|
{
|
|
|
- if (queryIssued_)
|
|
|
|
|
|
|
+ if (impl_->queryIssued_)
|
|
|
{
|
|
{
|
|
|
URHO3D_PROFILE(FlushGPU);
|
|
URHO3D_PROFILE(FlushGPU);
|
|
|
|
|
|
|
@@ -819,13 +761,13 @@ void Graphics::EndFrame()
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- queryIssued_ = false;
|
|
|
|
|
|
|
+ impl_->queryIssued_ = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (flushGPU_)
|
|
if (flushGPU_)
|
|
|
{
|
|
{
|
|
|
impl_->frameQuery_->Issue(D3DISSUE_END);
|
|
impl_->frameQuery_->Issue(D3DISSUE_END);
|
|
|
- queryIssued_ = true;
|
|
|
|
|
|
|
+ impl_->queryIssued_ = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1022,20 +964,21 @@ bool Graphics::SetVertexBuffers(const PODVector<VertexBuffer*>& buffers, unsigne
|
|
|
if (hash)
|
|
if (hash)
|
|
|
{
|
|
{
|
|
|
// If no previous vertex declaration for that hash, create new
|
|
// If no previous vertex declaration for that hash, create new
|
|
|
- if (!vertexDeclarations_.Contains(hash))
|
|
|
|
|
|
|
+ VertexDeclarationMap::Iterator i = impl_->vertexDeclarations_.Find(hash);
|
|
|
|
|
+ if (i == impl_->vertexDeclarations_.End())
|
|
|
{
|
|
{
|
|
|
SharedPtr<VertexDeclaration> newDeclaration(new VertexDeclaration(this, buffers));
|
|
SharedPtr<VertexDeclaration> newDeclaration(new VertexDeclaration(this, buffers));
|
|
|
if (!newDeclaration->GetDeclaration())
|
|
if (!newDeclaration->GetDeclaration())
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
- vertexDeclarations_[hash] = newDeclaration;
|
|
|
|
|
|
|
+ i = impl_->vertexDeclarations_.Insert(MakePair(hash, newDeclaration));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- VertexDeclaration* declaration = vertexDeclarations_[hash];
|
|
|
|
|
- if (declaration != vertexDeclaration_)
|
|
|
|
|
|
|
+ VertexDeclaration* declaration = i->second_;
|
|
|
|
|
+ if (declaration != impl_->vertexDeclaration_)
|
|
|
{
|
|
{
|
|
|
impl_->device_->SetVertexDeclaration(declaration->GetDeclaration());
|
|
impl_->device_->SetVertexDeclaration(declaration->GetDeclaration());
|
|
|
- vertexDeclaration_ = declaration;
|
|
|
|
|
|
|
+ impl_->vertexDeclaration_ = declaration;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1053,7 +996,7 @@ bool Graphics::SetVertexBuffers(const PODVector<VertexBuffer*>& buffers, unsigne
|
|
|
offset = instanceOffset * buffer->GetVertexSize();
|
|
offset = instanceOffset * buffer->GetVertexSize();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (buffer != vertexBuffers_[i] || offset != streamOffsets_[i])
|
|
|
|
|
|
|
+ if (buffer != vertexBuffers_[i] || offset != impl_->streamOffsets_[i])
|
|
|
{
|
|
{
|
|
|
if (buffer)
|
|
if (buffer)
|
|
|
impl_->device_->SetStreamSource(i, (IDirect3DVertexBuffer9*)buffer->GetGPUObject(), offset,
|
|
impl_->device_->SetStreamSource(i, (IDirect3DVertexBuffer9*)buffer->GetGPUObject(), offset,
|
|
@@ -1062,7 +1005,7 @@ bool Graphics::SetVertexBuffers(const PODVector<VertexBuffer*>& buffers, unsigne
|
|
|
impl_->device_->SetStreamSource(i, 0, 0, 0);
|
|
impl_->device_->SetStreamSource(i, 0, 0, 0);
|
|
|
|
|
|
|
|
vertexBuffers_[i] = buffer;
|
|
vertexBuffers_[i] = buffer;
|
|
|
- streamOffsets_[i] = offset;
|
|
|
|
|
|
|
+ impl_->streamOffsets_[i] = offset;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1159,17 +1102,17 @@ void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
|
|
|
if (vertexShader_ && pixelShader_)
|
|
if (vertexShader_ && pixelShader_)
|
|
|
{
|
|
{
|
|
|
Pair<ShaderVariation*, ShaderVariation*> key = MakePair(vertexShader_, pixelShader_);
|
|
Pair<ShaderVariation*, ShaderVariation*> key = MakePair(vertexShader_, pixelShader_);
|
|
|
- ShaderProgramMap::Iterator i = shaderPrograms_.Find(key);
|
|
|
|
|
- if (i != shaderPrograms_.End())
|
|
|
|
|
- shaderProgram_ = i->second_.Get();
|
|
|
|
|
|
|
+ ShaderProgramMap::Iterator i = impl_->shaderPrograms_.Find(key);
|
|
|
|
|
+ if (i != impl_->shaderPrograms_.End())
|
|
|
|
|
+ impl_->shaderProgram_ = i->second_.Get();
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- ShaderProgram* newProgram = shaderPrograms_[key] = new ShaderProgram(vertexShader_, pixelShader_);
|
|
|
|
|
- shaderProgram_ = newProgram;
|
|
|
|
|
|
|
+ ShaderProgram* newProgram = impl_->shaderPrograms_[key] = new ShaderProgram(vertexShader_, pixelShader_);
|
|
|
|
|
+ impl_->shaderProgram_ = newProgram;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
- shaderProgram_ = 0;
|
|
|
|
|
|
|
+ impl_->shaderProgram_ = 0;
|
|
|
|
|
|
|
|
// Store shader combination if shader dumping in progress
|
|
// Store shader combination if shader dumping in progress
|
|
|
if (shaderPrecache_)
|
|
if (shaderPrecache_)
|
|
@@ -1179,7 +1122,7 @@ void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned count)
|
|
void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned count)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (i->second_.type_ == VS)
|
|
if (i->second_.type_ == VS)
|
|
@@ -1191,7 +1134,7 @@ void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned
|
|
|
void Graphics::SetShaderParameter(StringHash param, float value)
|
|
void Graphics::SetShaderParameter(StringHash param, float value)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
static Vector4 data(Vector4::ZERO);
|
|
static Vector4 data(Vector4::ZERO);
|
|
@@ -1207,7 +1150,7 @@ void Graphics::SetShaderParameter(StringHash param, bool value)
|
|
|
{
|
|
{
|
|
|
/// \todo Bool constants possibly have no effect on Direct3D9
|
|
/// \todo Bool constants possibly have no effect on Direct3D9
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
BOOL data = value;
|
|
BOOL data = value;
|
|
@@ -1221,7 +1164,7 @@ void Graphics::SetShaderParameter(StringHash param, bool value)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Color& color)
|
|
void Graphics::SetShaderParameter(StringHash param, const Color& color)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (i->second_.type_ == VS)
|
|
if (i->second_.type_ == VS)
|
|
@@ -1233,7 +1176,7 @@ void Graphics::SetShaderParameter(StringHash param, const Color& color)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector2& vector)
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector2& vector)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
static Vector4 data(Vector4::ZERO);
|
|
static Vector4 data(Vector4::ZERO);
|
|
@@ -1249,7 +1192,7 @@ void Graphics::SetShaderParameter(StringHash param, const Vector2& vector)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
static Matrix3x4 data(Matrix3x4::ZERO);
|
|
static Matrix3x4 data(Matrix3x4::ZERO);
|
|
@@ -1272,7 +1215,7 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
static Vector4 data(Vector4::ZERO);
|
|
static Vector4 data(Vector4::ZERO);
|
|
@@ -1289,7 +1232,7 @@ void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (i->second_.type_ == VS)
|
|
if (i->second_.type_ == VS)
|
|
@@ -1301,7 +1244,7 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
|
|
void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (i->second_.type_ == VS)
|
|
if (i->second_.type_ == VS)
|
|
@@ -1313,7 +1256,7 @@ void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
|
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
|
|
void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
|
|
|
{
|
|
{
|
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
HashMap<StringHash, ShaderParameter>::Iterator i;
|
|
|
- if (!shaderProgram_ || (i = shaderProgram_->parameters_.Find(param)) == shaderProgram_->parameters_.End())
|
|
|
|
|
|
|
+ if (!impl_->shaderProgram_ || (i = impl_->shaderProgram_->parameters_.Find(param)) == impl_->shaderProgram_->parameters_.End())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
if (i->second_.type_ == VS)
|
|
if (i->second_.type_ == VS)
|
|
@@ -1389,7 +1332,7 @@ bool Graphics::NeedParameterUpdate(ShaderParameterGroup group, const void* sourc
|
|
|
|
|
|
|
|
bool Graphics::HasShaderParameter(StringHash param)
|
|
bool Graphics::HasShaderParameter(StringHash param)
|
|
|
{
|
|
{
|
|
|
- return shaderProgram_ && shaderProgram_->parameters_.Find(param) != shaderProgram_->parameters_.End();
|
|
|
|
|
|
|
+ return impl_->shaderProgram_ && impl_->shaderProgram_->parameters_.Find(param) != impl_->shaderProgram_->parameters_.End();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool Graphics::HasTextureUnit(TextureUnit unit)
|
|
bool Graphics::HasTextureUnit(TextureUnit unit)
|
|
@@ -1931,44 +1874,7 @@ void Graphics::PrecacheShaders(Deserializer& source)
|
|
|
|
|
|
|
|
bool Graphics::IsInitialized() const
|
|
bool Graphics::IsInitialized() const
|
|
|
{
|
|
{
|
|
|
- return impl_->window_ != 0 && impl_->GetDevice() != 0;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-IntVector2 Graphics::GetWindowPosition() const
|
|
|
|
|
-{
|
|
|
|
|
- if (impl_->window_)
|
|
|
|
|
- return position_;
|
|
|
|
|
- return IntVector2::ZERO;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-PODVector<IntVector2> Graphics::GetResolutions() const
|
|
|
|
|
-{
|
|
|
|
|
- PODVector<IntVector2> ret;
|
|
|
|
|
- unsigned numModes = (unsigned)SDL_GetNumDisplayModes(0);
|
|
|
|
|
-
|
|
|
|
|
- for (unsigned i = 0; i < numModes; ++i)
|
|
|
|
|
- {
|
|
|
|
|
- SDL_DisplayMode mode;
|
|
|
|
|
- SDL_GetDisplayMode(0, i, &mode);
|
|
|
|
|
- int width = mode.w;
|
|
|
|
|
- int height = mode.h;
|
|
|
|
|
-
|
|
|
|
|
- // Store mode if unique
|
|
|
|
|
- bool unique = true;
|
|
|
|
|
- for (unsigned j = 0; j < ret.Size(); ++j)
|
|
|
|
|
- {
|
|
|
|
|
- if (ret[j].x_ == width && ret[j].y_ == height)
|
|
|
|
|
- {
|
|
|
|
|
- unique = false;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (unique)
|
|
|
|
|
- ret.Push(IntVector2(width, height));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return ret;
|
|
|
|
|
|
|
+ return window_ != 0 && impl_->GetDevice() != 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PODVector<int> Graphics::GetMultiSampleLevels() const
|
|
PODVector<int> Graphics::GetMultiSampleLevels() const
|
|
@@ -1994,13 +1900,6 @@ PODVector<int> Graphics::GetMultiSampleLevels() const
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IntVector2 Graphics::GetDesktopResolution() const
|
|
|
|
|
-{
|
|
|
|
|
- SDL_DisplayMode mode;
|
|
|
|
|
- SDL_GetDesktopDisplayMode(0, &mode);
|
|
|
|
|
- return IntVector2(mode.w, mode.h);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
unsigned Graphics::GetFormat(CompressedFormat format) const
|
|
unsigned Graphics::GetFormat(CompressedFormat format) const
|
|
|
{
|
|
{
|
|
|
switch (format)
|
|
switch (format)
|
|
@@ -2097,14 +1996,19 @@ IntVector2 Graphics::GetRenderTargetDimensions() const
|
|
|
return IntVector2(width, height);
|
|
return IntVector2(width, height);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::WindowResized()
|
|
|
|
|
|
|
+bool Graphics::IsDeviceLost() const
|
|
|
|
|
+{
|
|
|
|
|
+ return impl_->deviceLost_;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void Graphics::OnWindowResized()
|
|
|
{
|
|
{
|
|
|
- if (!impl_->device_ || !impl_->window_)
|
|
|
|
|
|
|
+ if (!impl_->device_ || !window_)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
int newWidth, newHeight;
|
|
int newWidth, newHeight;
|
|
|
|
|
|
|
|
- SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
|
|
|
|
|
|
|
+ SDL_GetWindowSize(window_, &newWidth, &newHeight);
|
|
|
if (newWidth == width_ && newHeight == height_)
|
|
if (newWidth == width_ && newHeight == height_)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
@@ -2131,14 +2035,14 @@ void Graphics::WindowResized()
|
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::WindowMoved()
|
|
|
|
|
|
|
+void Graphics::OnWindowMoved()
|
|
|
{
|
|
{
|
|
|
- if (!impl_->device_ || !impl_->window_ || fullscreen_)
|
|
|
|
|
|
|
+ if (!impl_->device_ || !window_ || fullscreen_)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
int newX, newY;
|
|
int newX, newY;
|
|
|
|
|
|
|
|
- SDL_GetWindowPosition(impl_->window_, &newX, &newY);
|
|
|
|
|
|
|
+ SDL_GetWindowPosition(window_, &newX, &newY);
|
|
|
if (newX == position_.x_ && newY == position_.y_)
|
|
if (newX == position_.x_ && newY == position_.y_)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
@@ -2155,125 +2059,18 @@ void Graphics::WindowMoved()
|
|
|
SendEvent(E_WINDOWPOS, eventData);
|
|
SendEvent(E_WINDOWPOS, eventData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::Maximize()
|
|
|
|
|
-{
|
|
|
|
|
- if (!impl_->window_)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- SDL_MaximizeWindow(impl_->window_);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::Minimize()
|
|
|
|
|
-{
|
|
|
|
|
- if (!impl_->window_)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- SDL_MinimizeWindow(impl_->window_);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::AddGPUObject(GPUObject* object)
|
|
|
|
|
-{
|
|
|
|
|
- MutexLock lock(gpuObjectMutex_);
|
|
|
|
|
-
|
|
|
|
|
- gpuObjects_.Push(object);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::RemoveGPUObject(GPUObject* object)
|
|
|
|
|
-{
|
|
|
|
|
- MutexLock lock(gpuObjectMutex_);
|
|
|
|
|
-
|
|
|
|
|
- gpuObjects_.Remove(object);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void* Graphics::ReserveScratchBuffer(unsigned size)
|
|
|
|
|
-{
|
|
|
|
|
- if (!size)
|
|
|
|
|
- return 0;
|
|
|
|
|
-
|
|
|
|
|
- if (size > maxScratchBufferRequest_)
|
|
|
|
|
- maxScratchBufferRequest_ = size;
|
|
|
|
|
-
|
|
|
|
|
- // First check for a free buffer that is large enough
|
|
|
|
|
- for (Vector<ScratchBuffer>::Iterator i = scratchBuffers_.Begin(); i != scratchBuffers_.End(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- if (!i->reserved_ && i->size_ >= size)
|
|
|
|
|
- {
|
|
|
|
|
- i->reserved_ = true;
|
|
|
|
|
- return i->data_.Get();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Then check if a free buffer can be resized
|
|
|
|
|
- for (Vector<ScratchBuffer>::Iterator i = scratchBuffers_.Begin(); i != scratchBuffers_.End(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- if (!i->reserved_)
|
|
|
|
|
- {
|
|
|
|
|
- i->data_ = new unsigned char[size];
|
|
|
|
|
- i->size_ = size;
|
|
|
|
|
- i->reserved_ = true;
|
|
|
|
|
-
|
|
|
|
|
- URHO3D_LOGDEBUG("Resized scratch buffer to size " + String(size));
|
|
|
|
|
-
|
|
|
|
|
- return i->data_.Get();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Finally allocate a new buffer
|
|
|
|
|
- ScratchBuffer newBuffer;
|
|
|
|
|
- newBuffer.data_ = new unsigned char[size];
|
|
|
|
|
- newBuffer.size_ = size;
|
|
|
|
|
- newBuffer.reserved_ = true;
|
|
|
|
|
- scratchBuffers_.Push(newBuffer);
|
|
|
|
|
- return newBuffer.data_.Get();
|
|
|
|
|
-
|
|
|
|
|
- URHO3D_LOGDEBUG("Allocated scratch buffer with size " + String(size));
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::FreeScratchBuffer(void* buffer)
|
|
|
|
|
-{
|
|
|
|
|
- if (!buffer)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- for (Vector<ScratchBuffer>::Iterator i = scratchBuffers_.Begin(); i != scratchBuffers_.End(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- if (i->reserved_ && i->data_.Get() == buffer)
|
|
|
|
|
- {
|
|
|
|
|
- i->reserved_ = false;
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- URHO3D_LOGWARNING("Reserved scratch buffer " + ToStringHex((unsigned)(size_t)buffer) + " not found");
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Graphics::CleanupScratchBuffers()
|
|
|
|
|
-{
|
|
|
|
|
- for (Vector<ScratchBuffer>::Iterator i = scratchBuffers_.Begin(); i != scratchBuffers_.End(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- if (!i->reserved_ && i->size_ > maxScratchBufferRequest_ * 2 && i->size_ >= 1024 * 1024)
|
|
|
|
|
- {
|
|
|
|
|
- i->data_ = maxScratchBufferRequest_ > 0 ? new unsigned char[maxScratchBufferRequest_] : 0;
|
|
|
|
|
- i->size_ = maxScratchBufferRequest_;
|
|
|
|
|
-
|
|
|
|
|
- URHO3D_LOGDEBUG("Resized scratch buffer to size " + String(maxScratchBufferRequest_));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- maxScratchBufferRequest_ = 0;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void Graphics::CleanupShaderPrograms(ShaderVariation* variation)
|
|
void Graphics::CleanupShaderPrograms(ShaderVariation* variation)
|
|
|
{
|
|
{
|
|
|
- for (ShaderProgramMap::Iterator i = shaderPrograms_.Begin(); i != shaderPrograms_.End();)
|
|
|
|
|
|
|
+ for (ShaderProgramMap::Iterator i = impl_->shaderPrograms_.Begin(); i != impl_->shaderPrograms_.End();)
|
|
|
{
|
|
{
|
|
|
if (i->first_.first_ == variation || i->first_.second_ == variation)
|
|
if (i->first_.first_ == variation || i->first_.second_ == variation)
|
|
|
- i = shaderPrograms_.Erase(i);
|
|
|
|
|
|
|
+ i = impl_->shaderPrograms_.Erase(i);
|
|
|
else
|
|
else
|
|
|
++i;
|
|
++i;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (vertexShader_ == variation || pixelShader_ == variation)
|
|
if (vertexShader_ == variation || pixelShader_ == variation)
|
|
|
- shaderProgram_ = 0;
|
|
|
|
|
|
|
+ impl_->shaderProgram_ = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
unsigned Graphics::GetAlphaFormat()
|
|
unsigned Graphics::GetAlphaFormat()
|
|
@@ -2396,12 +2193,22 @@ unsigned Graphics::GetFormat(const String& formatName)
|
|
|
return GetRGBFormat();
|
|
return GetRGBFormat();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+unsigned Graphics::GetMaxBones()
|
|
|
|
|
+{
|
|
|
|
|
+ return 64;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool Graphics::GetGL3Support()
|
|
|
|
|
+{
|
|
|
|
|
+ return gl3Support;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void Graphics::SetStreamFrequency(unsigned index, unsigned frequency)
|
|
void Graphics::SetStreamFrequency(unsigned index, unsigned frequency)
|
|
|
{
|
|
{
|
|
|
- if (index < MAX_VERTEX_STREAMS && streamFrequencies_[index] != frequency)
|
|
|
|
|
|
|
+ if (index < MAX_VERTEX_STREAMS && impl_->streamFrequencies_[index] != frequency)
|
|
|
{
|
|
{
|
|
|
impl_->device_->SetStreamSourceFreq(index, frequency);
|
|
impl_->device_->SetStreamSourceFreq(index, frequency);
|
|
|
- streamFrequencies_[index] = frequency;
|
|
|
|
|
|
|
+ impl_->streamFrequencies_[index] = frequency;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2409,10 +2216,10 @@ void Graphics::ResetStreamFrequencies()
|
|
|
{
|
|
{
|
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
|
{
|
|
{
|
|
|
- if (streamFrequencies_[i] != 1)
|
|
|
|
|
|
|
+ if (impl_->streamFrequencies_[i] != 1)
|
|
|
{
|
|
{
|
|
|
impl_->device_->SetStreamSourceFreq(i, 1);
|
|
impl_->device_->SetStreamSourceFreq(i, 1);
|
|
|
- streamFrequencies_[i] = 1;
|
|
|
|
|
|
|
+ impl_->streamFrequencies_[i] = 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2427,59 +2234,46 @@ bool Graphics::OpenWindow(int width, int height, bool resizable, bool borderless
|
|
|
if (borderless)
|
|
if (borderless)
|
|
|
flags |= SDL_WINDOW_BORDERLESS;
|
|
flags |= SDL_WINDOW_BORDERLESS;
|
|
|
|
|
|
|
|
- impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), position_.x_, position_.y_, width, height, flags);
|
|
|
|
|
|
|
+ window_ = SDL_CreateWindow(windowTitle_.CString(), position_.x_, position_.y_, width, height, flags);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
- impl_->window_ = SDL_CreateWindowFrom(externalWindow_, 0);
|
|
|
|
|
|
|
+ window_ = SDL_CreateWindowFrom(externalWindow_, 0);
|
|
|
|
|
|
|
|
- if (!impl_->window_)
|
|
|
|
|
|
|
+ if (!window_)
|
|
|
{
|
|
{
|
|
|
URHO3D_LOGERRORF("Could not create window, root cause: '%s'", SDL_GetError());
|
|
URHO3D_LOGERRORF("Could not create window, root cause: '%s'", SDL_GetError());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- SDL_GetWindowPosition(impl_->window_, &position_.x_, &position_.y_);
|
|
|
|
|
|
|
+ SDL_GetWindowPosition(window_, &position_.x_, &position_.y_);
|
|
|
|
|
|
|
|
CreateWindowIcon();
|
|
CreateWindowIcon();
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Graphics::CreateWindowIcon()
|
|
|
|
|
-{
|
|
|
|
|
- if (windowIcon_)
|
|
|
|
|
- {
|
|
|
|
|
- SDL_Surface* surface = windowIcon_->GetSDLSurface();
|
|
|
|
|
- if (surface)
|
|
|
|
|
- {
|
|
|
|
|
- SDL_SetWindowIcon(impl_->window_, surface);
|
|
|
|
|
- SDL_FreeSurface(surface);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen, bool& newBorderless)
|
|
void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen, bool& newBorderless)
|
|
|
{
|
|
{
|
|
|
if (!externalWindow_)
|
|
if (!externalWindow_)
|
|
|
{
|
|
{
|
|
|
if (!newWidth || !newHeight)
|
|
if (!newWidth || !newHeight)
|
|
|
{
|
|
{
|
|
|
- SDL_MaximizeWindow(impl_->window_);
|
|
|
|
|
- SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
|
|
|
|
|
|
|
+ SDL_MaximizeWindow(window_);
|
|
|
|
|
+ SDL_GetWindowSize(window_, &newWidth, &newHeight);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
- SDL_SetWindowSize(impl_->window_, newWidth, newHeight);
|
|
|
|
|
|
|
+ SDL_SetWindowSize(window_, newWidth, newHeight);
|
|
|
|
|
|
|
|
// Hack fix: on SDL 2.0.4 a fullscreen->windowed transition results in a maximized window when the D3D device is reset, so hide before
|
|
// Hack fix: on SDL 2.0.4 a fullscreen->windowed transition results in a maximized window when the D3D device is reset, so hide before
|
|
|
- SDL_HideWindow(impl_->window_);
|
|
|
|
|
- SDL_SetWindowFullscreen(impl_->window_, newFullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
|
|
|
|
- SDL_SetWindowBordered(impl_->window_, newBorderless ? SDL_FALSE : SDL_TRUE);
|
|
|
|
|
- SDL_ShowWindow(impl_->window_);
|
|
|
|
|
|
|
+ SDL_HideWindow(window_);
|
|
|
|
|
+ SDL_SetWindowFullscreen(window_, newFullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
|
|
|
|
+ SDL_SetWindowBordered(window_, newBorderless ? SDL_FALSE : SDL_TRUE);
|
|
|
|
|
+ SDL_ShowWindow(window_);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
// If external window, must ask its dimensions instead of trying to set them
|
|
// If external window, must ask its dimensions instead of trying to set them
|
|
|
- SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
|
|
|
|
|
|
|
+ SDL_GetWindowSize(window_, &newWidth, &newHeight);
|
|
|
newFullscreen = false;
|
|
newFullscreen = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2535,7 +2329,7 @@ bool Graphics::CreateDevice(unsigned adapter, unsigned deviceType)
|
|
|
HRESULT hr = impl_->interface_->CreateDevice(
|
|
HRESULT hr = impl_->interface_->CreateDevice(
|
|
|
adapter,
|
|
adapter,
|
|
|
(D3DDEVTYPE)deviceType,
|
|
(D3DDEVTYPE)deviceType,
|
|
|
- GetWindowHandle(impl_->window_),
|
|
|
|
|
|
|
+ GetWindowHandle(window_),
|
|
|
behaviorFlags,
|
|
behaviorFlags,
|
|
|
&impl_->presentParams_,
|
|
&impl_->presentParams_,
|
|
|
&impl_->device_);
|
|
&impl_->device_);
|
|
@@ -2556,6 +2350,9 @@ bool Graphics::CreateDevice(unsigned adapter, unsigned deviceType)
|
|
|
|
|
|
|
|
void Graphics::CheckFeatureSupport()
|
|
void Graphics::CheckFeatureSupport()
|
|
|
{
|
|
{
|
|
|
|
|
+ anisotropySupport_ = true;
|
|
|
|
|
+ dxtTextureSupport_ = true;
|
|
|
|
|
+
|
|
|
// Reset features first
|
|
// Reset features first
|
|
|
lightPrepassSupport_ = false;
|
|
lightPrepassSupport_ = false;
|
|
|
deferredSupport_ = false;
|
|
deferredSupport_ = false;
|
|
@@ -2643,7 +2440,7 @@ void Graphics::ResetDevice()
|
|
|
|
|
|
|
|
if (SUCCEEDED(impl_->device_->Reset(&impl_->presentParams_)))
|
|
if (SUCCEEDED(impl_->device_->Reset(&impl_->presentParams_)))
|
|
|
{
|
|
{
|
|
|
- deviceLost_ = false;
|
|
|
|
|
|
|
+ impl_->deviceLost_ = false;
|
|
|
OnDeviceReset();
|
|
OnDeviceReset();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2704,7 +2501,7 @@ void Graphics::ResetCachedState()
|
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
|
{
|
|
{
|
|
|
vertexBuffers_[i] = 0;
|
|
vertexBuffers_[i] = 0;
|
|
|
- streamOffsets_[i] = 0;
|
|
|
|
|
|
|
+ impl_->streamOffsets_[i] = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
|
|
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
|
|
@@ -2731,10 +2528,9 @@ void Graphics::ResetCachedState()
|
|
|
impl_->sRGBWrite_ = false;
|
|
impl_->sRGBWrite_ = false;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
|
|
|
- streamFrequencies_[i] = 1;
|
|
|
|
|
|
|
+ impl_->streamFrequencies_[i] = 1;
|
|
|
|
|
|
|
|
indexBuffer_ = 0;
|
|
indexBuffer_ = 0;
|
|
|
- vertexDeclaration_ = 0;
|
|
|
|
|
vertexShader_ = 0;
|
|
vertexShader_ = 0;
|
|
|
pixelShader_ = 0;
|
|
pixelShader_ = 0;
|
|
|
blendMode_ = BLEND_REPLACE;
|
|
blendMode_ = BLEND_REPLACE;
|
|
@@ -2761,8 +2557,8 @@ void Graphics::ResetCachedState()
|
|
|
impl_->srcBlend_ = D3DBLEND_ONE;
|
|
impl_->srcBlend_ = D3DBLEND_ONE;
|
|
|
impl_->destBlend_ = D3DBLEND_ZERO;
|
|
impl_->destBlend_ = D3DBLEND_ZERO;
|
|
|
impl_->blendOp_ = D3DBLENDOP_ADD;
|
|
impl_->blendOp_ = D3DBLENDOP_ADD;
|
|
|
-
|
|
|
|
|
- queryIssued_ = false;
|
|
|
|
|
|
|
+ impl_->vertexDeclaration_ = 0;
|
|
|
|
|
+ impl_->queryIssued_ = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Graphics::SetTextureUnitMappings()
|
|
void Graphics::SetTextureUnitMappings()
|
|
@@ -2785,36 +2581,4 @@ void Graphics::SetTextureUnitMappings()
|
|
|
textureUnits_["ZoneVolumeMap"] = TU_ZONE;
|
|
textureUnits_["ZoneVolumeMap"] = TU_ZONE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void RegisterGraphicsLibrary(Context* context)
|
|
|
|
|
-{
|
|
|
|
|
- Animation::RegisterObject(context);
|
|
|
|
|
- Material::RegisterObject(context);
|
|
|
|
|
- Model::RegisterObject(context);
|
|
|
|
|
- Shader::RegisterObject(context);
|
|
|
|
|
- Technique::RegisterObject(context);
|
|
|
|
|
- Texture2D::RegisterObject(context);
|
|
|
|
|
- Texture2DArray::RegisterObject(context);
|
|
|
|
|
- Texture3D::RegisterObject(context);
|
|
|
|
|
- TextureCube::RegisterObject(context);
|
|
|
|
|
- Camera::RegisterObject(context);
|
|
|
|
|
- Drawable::RegisterObject(context);
|
|
|
|
|
- Light::RegisterObject(context);
|
|
|
|
|
- StaticModel::RegisterObject(context);
|
|
|
|
|
- StaticModelGroup::RegisterObject(context);
|
|
|
|
|
- Skybox::RegisterObject(context);
|
|
|
|
|
- AnimatedModel::RegisterObject(context);
|
|
|
|
|
- AnimationController::RegisterObject(context);
|
|
|
|
|
- BillboardSet::RegisterObject(context);
|
|
|
|
|
- ParticleEffect::RegisterObject(context);
|
|
|
|
|
- ParticleEmitter::RegisterObject(context);
|
|
|
|
|
- RibbonTrail::RegisterObject(context);
|
|
|
|
|
- CustomGeometry::RegisterObject(context);
|
|
|
|
|
- DecalSet::RegisterObject(context);
|
|
|
|
|
- Terrain::RegisterObject(context);
|
|
|
|
|
- TerrainPatch::RegisterObject(context);
|
|
|
|
|
- DebugRenderer::RegisterObject(context);
|
|
|
|
|
- Octree::RegisterObject(context);
|
|
|
|
|
- Zone::RegisterObject(context);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|