Also fixed presets handling to allow installing add-on out of special://xbmc/addons.
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+float4 main(float4 col : COLOR) : SV_TARGET
+{
+ return col;
+}
\ No newline at end of file
--- /dev/null
+//--------------------------------------------------------------------------------------
+// File: CommonStates.cpp
+//
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// http://go.microsoft.com/fwlink/?LinkId=248929
+//--------------------------------------------------------------------------------------
+
+#include <wrl.h>
+#include "CommonStates.h"
+#include "DirectXHelpers.h"
+#include "DemandCreate.h"
+#include "SharedResourcePool.h"
+#include <mutex>
+
+using namespace DirectX;
+using namespace Microsoft::WRL;
+
+
+// Internal state object implementation class. Only one of these helpers is allocated
+// per D3D device, even if there are multiple public facing CommonStates instances.
+class CommonStates::Impl
+{
+public:
+ Impl(_In_ ID3D11Device* device)
+ : device(device)
+ { }
+
+ HRESULT CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, D3D11_BLEND_OP blendOp, _Out_ ID3D11BlendState** pResult);
+ HRESULT CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult);
+ HRESULT CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult);
+ HRESULT CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult);
+
+ ComPtr<ID3D11Device> device;
+
+ ComPtr<ID3D11BlendState> opaque;
+ ComPtr<ID3D11BlendState> alphaBlend;
+ ComPtr<ID3D11BlendState> additive;
+ ComPtr<ID3D11BlendState> nonPremultiplied;
+
+ ComPtr<ID3D11DepthStencilState> depthNone;
+ ComPtr<ID3D11DepthStencilState> depthDefault;
+ ComPtr<ID3D11DepthStencilState> depthRead;
+
+ ComPtr<ID3D11RasterizerState> cullNone;
+ ComPtr<ID3D11RasterizerState> cullClockwise;
+ ComPtr<ID3D11RasterizerState> cullCounterClockwise;
+ ComPtr<ID3D11RasterizerState> wireframe;
+
+ ComPtr<ID3D11SamplerState> pointWrap;
+ ComPtr<ID3D11SamplerState> pointClamp;
+ ComPtr<ID3D11SamplerState> linearWrap;
+ ComPtr<ID3D11SamplerState> linearClamp;
+ ComPtr<ID3D11SamplerState> anisotropicWrap;
+ ComPtr<ID3D11SamplerState> anisotropicClamp;
+
+ std::mutex mutex;
+
+ static SharedResourcePool<ID3D11Device*, Impl> instancePool;
+};
+
+
+// Global instance pool.
+SharedResourcePool<ID3D11Device*, CommonStates::Impl> CommonStates::Impl::instancePool;
+
+
+// Helper for creating blend state objects.
+HRESULT CommonStates::Impl::CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, D3D11_BLEND_OP blendOp, _Out_ ID3D11BlendState** pResult)
+{
+ D3D11_BLEND_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+
+ desc.RenderTarget[0].BlendEnable = (srcBlend != D3D11_BLEND_ONE) ||
+ (destBlend != D3D11_BLEND_ZERO);
+
+ desc.RenderTarget[0].SrcBlend = desc.RenderTarget[0].SrcBlendAlpha = srcBlend;
+ desc.RenderTarget[0].DestBlend = desc.RenderTarget[0].DestBlendAlpha = destBlend;
+ desc.RenderTarget[0].BlendOp = desc.RenderTarget[0].BlendOpAlpha = blendOp;
+ desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+ desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
+ desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
+
+ HRESULT hr = device->CreateBlendState(&desc, pResult);
+
+ if (SUCCEEDED(hr))
+ SetDebugObjectName(*pResult, "Milkdrop:CommonStates");
+
+ return hr;
+}
+
+
+// Helper for creating depth stencil state objects.
+HRESULT CommonStates::Impl::CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult)
+{
+ D3D11_DEPTH_STENCIL_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+
+ desc.DepthEnable = enable;
+ desc.DepthWriteMask = writeEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
+ desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
+
+ desc.StencilEnable = false;
+ desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
+ desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
+
+ desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+ desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
+ desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
+ desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
+
+ desc.BackFace = desc.FrontFace;
+
+ HRESULT hr = device->CreateDepthStencilState(&desc, pResult);
+
+ if (SUCCEEDED(hr))
+ SetDebugObjectName(*pResult, "Milkdrop:CommonStates");
+
+ return hr;
+}
+
+
+// Helper for creating rasterizer state objects.
+HRESULT CommonStates::Impl::CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult)
+{
+ D3D11_RASTERIZER_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+
+ desc.CullMode = cullMode;
+ desc.FillMode = fillMode;
+ desc.DepthClipEnable = true;
+ desc.MultisampleEnable = true;
+ desc.AntialiasedLineEnable = true;
+
+ HRESULT hr = device->CreateRasterizerState(&desc, pResult);
+
+ if (SUCCEEDED(hr))
+ SetDebugObjectName(*pResult, "Milkdrop:CommonStates");
+
+ return hr;
+}
+
+
+// Helper for creating sampler state objects.
+HRESULT CommonStates::Impl::CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult)
+{
+ D3D11_SAMPLER_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+
+ desc.Filter = filter;
+
+ desc.AddressU = addressMode;
+ desc.AddressV = addressMode;
+ desc.AddressW = addressMode;
+
+ desc.MaxAnisotropy = (device->GetFeatureLevel() > D3D_FEATURE_LEVEL_9_1) ? 16 : 2;
+
+ desc.MaxLOD = FLT_MAX;
+ desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
+
+ HRESULT hr = device->CreateSamplerState(&desc, pResult);
+
+ if (SUCCEEDED(hr))
+ SetDebugObjectName(*pResult, "Milkdrop:CommonStates");
+
+ return hr;
+}
+
+
+//--------------------------------------------------------------------------------------
+// CommonStates
+//--------------------------------------------------------------------------------------
+
+// Public constructor.
+CommonStates::CommonStates(_In_ ID3D11Device* device)
+ : pImpl(Impl::instancePool.DemandCreate(device))
+{
+}
+
+
+// Move constructor.
+CommonStates::CommonStates(CommonStates&& moveFrom)
+ : pImpl(std::move(moveFrom.pImpl))
+{
+}
+
+
+// Move assignment.
+CommonStates& CommonStates::operator= (CommonStates&& moveFrom)
+{
+ pImpl = std::move(moveFrom.pImpl);
+ return *this;
+}
+
+
+// Public destructor.
+CommonStates::~CommonStates()
+{
+}
+
+
+//--------------------------------------------------------------------------------------
+// Blend states
+//--------------------------------------------------------------------------------------
+
+ID3D11BlendState* CommonStates::Opaque() const
+{
+ return DemandCreate(pImpl->opaque, pImpl->mutex, [&](ID3D11BlendState** pResult)
+ {
+ return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, pResult);
+ });
+}
+
+
+ID3D11BlendState* CommonStates::AlphaBlend() const
+{
+ return DemandCreate(pImpl->alphaBlend, pImpl->mutex, [&](ID3D11BlendState** pResult)
+ {
+ return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, pResult);
+ });
+}
+
+
+ID3D11BlendState* CommonStates::Additive() const
+{
+ return DemandCreate(pImpl->additive, pImpl->mutex, [&](ID3D11BlendState** pResult)
+ {
+ return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, pResult);
+ });
+}
+
+
+ID3D11BlendState* CommonStates::NonPremultiplied() const
+{
+ return DemandCreate(pImpl->nonPremultiplied, pImpl->mutex, [&](ID3D11BlendState** pResult)
+ {
+ return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, pResult);
+ });
+}
+
+ID3D11BlendState* CommonStates::Maximize() const
+{
+ return DemandCreate(pImpl->nonPremultiplied, pImpl->mutex, [&](ID3D11BlendState** pResult)
+ {
+ return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_ONE, D3D11_BLEND_OP_MAX, pResult);
+ });
+}
+
+
+//--------------------------------------------------------------------------------------
+// Depth stencil states
+//--------------------------------------------------------------------------------------
+
+ID3D11DepthStencilState* CommonStates::DepthNone() const
+{
+ return DemandCreate(pImpl->depthNone, pImpl->mutex, [&](ID3D11DepthStencilState** pResult)
+ {
+ return pImpl->CreateDepthStencilState(false, false, pResult);
+ });
+}
+
+
+ID3D11DepthStencilState* CommonStates::DepthDefault() const
+{
+ return DemandCreate(pImpl->depthDefault, pImpl->mutex, [&](ID3D11DepthStencilState** pResult)
+ {
+ return pImpl->CreateDepthStencilState(true, true, pResult);
+ });
+}
+
+
+ID3D11DepthStencilState* CommonStates::DepthRead() const
+{
+ return DemandCreate(pImpl->depthRead, pImpl->mutex, [&](ID3D11DepthStencilState** pResult)
+ {
+ return pImpl->CreateDepthStencilState(true, false, pResult);
+ });
+}
+
+
+//--------------------------------------------------------------------------------------
+// Rasterizer states
+//--------------------------------------------------------------------------------------
+
+ID3D11RasterizerState* CommonStates::CullNone() const
+{
+ return DemandCreate(pImpl->cullNone, pImpl->mutex, [&](ID3D11RasterizerState** pResult)
+ {
+ return pImpl->CreateRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID, pResult);
+ });
+}
+
+
+ID3D11RasterizerState* CommonStates::CullClockwise() const
+{
+ return DemandCreate(pImpl->cullClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult)
+ {
+ return pImpl->CreateRasterizerState(D3D11_CULL_FRONT, D3D11_FILL_SOLID, pResult);
+ });
+}
+
+
+ID3D11RasterizerState* CommonStates::CullCounterClockwise() const
+{
+ return DemandCreate(pImpl->cullCounterClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult)
+ {
+ return pImpl->CreateRasterizerState(D3D11_CULL_BACK, D3D11_FILL_SOLID, pResult);
+ });
+}
+
+
+ID3D11RasterizerState* CommonStates::Wireframe() const
+{
+ return DemandCreate(pImpl->wireframe, pImpl->mutex, [&](ID3D11RasterizerState** pResult)
+ {
+ return pImpl->CreateRasterizerState(D3D11_CULL_NONE, D3D11_FILL_WIREFRAME, pResult);
+ });
+}
+
+
+//--------------------------------------------------------------------------------------
+// Sampler states
+//--------------------------------------------------------------------------------------
+
+ID3D11SamplerState* CommonStates::PointWrap() const
+{
+ return DemandCreate(pImpl->pointWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP, pResult);
+ });
+}
+
+
+ID3D11SamplerState* CommonStates::PointClamp() const
+{
+ return DemandCreate(pImpl->pointClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP, pResult);
+ });
+}
+
+
+ID3D11SamplerState* CommonStates::LinearWrap() const
+{
+ return DemandCreate(pImpl->linearWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP, pResult);
+ });
+}
+
+
+ID3D11SamplerState* CommonStates::LinearClamp() const
+{
+ return DemandCreate(pImpl->linearClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, pResult);
+ });
+}
+
+
+ID3D11SamplerState* CommonStates::AnisotropicWrap() const
+{
+ return DemandCreate(pImpl->anisotropicWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_WRAP, pResult);
+ });
+}
+
+
+ID3D11SamplerState* CommonStates::AnisotropicClamp() const
+{
+ return DemandCreate(pImpl->anisotropicClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult)
+ {
+ return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_CLAMP, pResult);
+ });
+}
--- /dev/null
+//--------------------------------------------------------------------------------------
+// File: CommonStates.h
+//
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// http://go.microsoft.com/fwlink/?LinkId=248929
+//--------------------------------------------------------------------------------------
+
+#pragma once
+
+#if defined(_XBOX_ONE) && defined(_TITLE)
+#include <d3d11_x.h>
+#else
+#include <d3d11_1.h>
+#endif
+
+#include <memory>
+#include <wrl.h>
+
+using namespace Microsoft::WRL;
+
+namespace DirectX
+{
+ class CommonStates
+ {
+ public:
+ explicit CommonStates(_In_ ID3D11Device* device);
+ CommonStates(CommonStates&& moveFrom);
+ CommonStates& operator= (CommonStates&& moveFrom);
+ virtual ~CommonStates();
+
+ // Blend states.
+ ID3D11BlendState* __cdecl Opaque() const;
+ ID3D11BlendState* __cdecl AlphaBlend() const;
+ ID3D11BlendState* __cdecl Additive() const;
+ ID3D11BlendState* __cdecl NonPremultiplied() const;
+ ID3D11BlendState* __cdecl Maximize() const;
+
+ // Depth stencil states.
+ ID3D11DepthStencilState* __cdecl DepthNone() const;
+ ID3D11DepthStencilState* __cdecl DepthDefault() const;
+ ID3D11DepthStencilState* __cdecl DepthRead() const;
+
+ // Rasterizer states.
+ ID3D11RasterizerState* __cdecl CullNone() const;
+ ID3D11RasterizerState* __cdecl CullClockwise() const;
+ ID3D11RasterizerState* __cdecl CullCounterClockwise() const;
+ ID3D11RasterizerState* __cdecl Wireframe() const;
+
+ // Sampler states.
+ ID3D11SamplerState* __cdecl PointWrap() const;
+ ID3D11SamplerState* __cdecl PointClamp() const;
+ ID3D11SamplerState* __cdecl LinearWrap() const;
+ ID3D11SamplerState* __cdecl LinearClamp() const;
+ ID3D11SamplerState* __cdecl AnisotropicWrap() const;
+ ID3D11SamplerState* __cdecl AnisotropicClamp() const;
+
+ private:
+ // Private implementation.
+ class Impl;
+
+ std::shared_ptr<Impl> pImpl;
+
+ // Prevent copying.
+ CommonStates(CommonStates const&);
+ CommonStates& operator= (CommonStates const&);
+ };
+}
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include <vector>
+#include <wrl.h>
+#include <d3d9.h>
+#include "CommonStates.h"
+#include "DirectXHelpers.h"
+#include "DX11Context.h"
+#include "vis_milkdrop\support.h"
+
+using namespace DirectX;
+using namespace Microsoft::WRL;
+
+namespace
+{
+ #include "ColorPixelShader.inc"
+ #include "DefaultVertexShader.inc"
+ #include "DiffusePixelShader.inc"
+ #include "TexturePixelShader.inc"
+}
+
+DX11Context::DX11Context(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
+ : m_pDevice(pDevice),
+ m_pContext(pContext),
+ m_pVShader(NULL),
+ m_pInputLayout(NULL),
+ m_pVBuffer(NULL),
+ m_pIBuffer(NULL),
+ m_pCBuffer(NULL),
+ m_bCBufferIsDirty(false),
+ m_uCurrShader(0),
+ m_pState(NULL)
+{
+ for (size_t i = 0; i < MAX_NUM_SHADERS; i++)
+ m_pPShader[i] = NULL;
+}
+
+DX11Context::~DX11Context()
+{
+ if (m_pVShader)
+ m_pVShader->Release();
+ for (size_t i = 0; i < MAX_NUM_SHADERS; i++)
+ if (m_pPShader[i])
+ m_pPShader[i]->Release();
+ if (m_pInputLayout)
+ m_pInputLayout->Release();
+ if (m_pVBuffer)
+ m_pVBuffer->Release();
+ if (m_pIBuffer)
+ m_pIBuffer->Release();
+ if (m_pCBuffer)
+ m_pCBuffer->Release();
+ if (m_pState)
+ m_pState->Release();
+
+ m_states.reset(NULL);
+}
+
+void DX11Context::Initialize()
+{
+ m_states.reset(new CommonStates(m_pDevice));
+
+ D3D11_INPUT_ELEMENT_DESC layout[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+
+ m_pDevice->CreateInputLayout(layout, ARRAYSIZE(layout), DefaultVertexShaderCode, sizeof(DefaultVertexShaderCode), &m_pInputLayout);
+
+ m_pDevice->CreateVertexShader(DefaultVertexShaderCode, sizeof(DefaultVertexShaderCode), NULL, &m_pVShader);
+
+ m_pDevice->CreatePixelShader(DiffusePixelShaderCode, sizeof(DiffusePixelShaderCode), NULL, &m_pPShader[0]);
+ m_pDevice->CreatePixelShader(TexturePixelShaderCode, sizeof(TexturePixelShaderCode), NULL, &m_pPShader[1]);
+ m_pDevice->CreatePixelShader(ColorPixelShaderCode, sizeof(ColorPixelShaderCode), NULL, &m_pPShader[2]);
+
+ CD3D11_BUFFER_DESC bDesc(sizeof(SPRITEVERTEX) * MAX_VERTICES_COUNT,
+ D3D11_BIND_VERTEX_BUFFER,
+ D3D11_USAGE_DYNAMIC,
+ D3D11_CPU_ACCESS_WRITE );
+ m_pDevice->CreateBuffer(&bDesc, NULL, &m_pVBuffer);
+
+ std::vector<uint16_t> indicies;
+ for (size_t i = 1; i < MAX_VERTICES_COUNT / 6 - 2; ++i)
+ {
+ indicies.push_back(0);
+ indicies.push_back(i);
+ indicies.push_back(i + 1);
+ }
+ bDesc.ByteWidth = sizeof(uint16_t) * indicies.size();
+ bDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
+ bDesc.Usage = D3D11_USAGE_IMMUTABLE;
+ bDesc.CPUAccessFlags = 0;
+ D3D11_SUBRESOURCE_DATA bData = { indicies.data() };
+
+ m_pDevice->CreateBuffer(&bDesc, &bData, &m_pIBuffer);
+
+ XMStoreFloat4x4(&m_transforms.world, XMMatrixTranspose(XMMatrixIdentity()));
+ XMStoreFloat4x4(&m_transforms.view, XMMatrixTranspose(XMMatrixIdentity()));
+ XMStoreFloat4x4(&m_transforms.proj, XMMatrixTranspose(XMMatrixIdentity()));
+
+ bDesc.ByteWidth = sizeof(cbTransforms);
+ bDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+ bDesc.Usage = D3D11_USAGE_DYNAMIC;
+ bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ bData.pSysMem = &m_transforms;
+
+ m_pDevice->CreateBuffer(&bDesc, &bData, &m_pCBuffer);
+}
+
+bool DX11Context::CreateTexture(unsigned int uWidth, unsigned int uHeight, unsigned int mipLevels, UINT bindFlags, DXGI_FORMAT format, ID3D11Texture2D** ppTexture)
+{
+ CD3D11_TEXTURE2D_DESC texDesc(format, uWidth, uHeight, 1, mipLevels, bindFlags);
+ return S_OK == m_pDevice->CreateTexture2D(&texDesc, NULL, ppTexture);
+}
+
+void DX11Context::DrawPrimitive(unsigned int primType, unsigned int iPrimCount, const void * pVData, unsigned int vertexStride)
+{
+ if (m_bCBufferIsDirty)
+ {
+ D3D11_MAPPED_SUBRESOURCE res;
+ if (S_OK == m_pContext->Map(m_pCBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res))
+ {
+ memcpy(res.pData, &m_transforms, sizeof(cbTransforms));
+ m_pContext->Unmap(m_pCBuffer, 0);
+ }
+ m_bCBufferIsDirty = false;
+ }
+
+ int numVerts = NumVertsFromType(primType, iPrimCount);
+ UpdateVBuffer(numVerts, pVData, vertexStride);
+
+ unsigned int offsets = 0;
+ m_pContext->IASetVertexBuffers(0, 1, &m_pVBuffer, &vertexStride, &offsets);
+ m_pContext->IASetInputLayout(m_pInputLayout);
+ if (primType == D3DPT_TRIANGLEFAN)
+ {
+ m_pContext->IASetIndexBuffer(m_pIBuffer, DXGI_FORMAT_R16_UINT, 0);
+ m_pContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ m_pContext->DrawIndexed(iPrimCount * 3, 0, 0);
+ }
+ else
+ {
+ m_pContext->IASetPrimitiveTopology((D3D_PRIMITIVE_TOPOLOGY)primType);
+ m_pContext->Draw(numVerts, 0);
+ }
+}
+
+void DX11Context::GetRenderTarget(ID3D11Texture2D** ppTexture, ID3D11Texture2D** ppDepthTexture)
+{
+ ID3D11RenderTargetView* pRTView = NULL;
+ ID3D11DepthStencilView* pDSView = NULL;
+ ID3D11Resource* pResource = NULL;
+
+ m_pContext->OMGetRenderTargets(1, &pRTView, &pDSView);
+ if (pRTView)
+ {
+ pRTView->GetResource(&pResource);
+ pResource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(ppTexture));
+ pResource->Release();
+ pRTView->Release();
+ }
+ if (pDSView)
+ {
+ pDSView->GetResource(&pResource);
+ pResource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(ppDepthTexture));
+ pResource->Release();
+ pDSView->Release();
+ }
+}
+
+void DX11Context::GetViewport(D3D11_VIEWPORT *vp)
+{
+ unsigned int numVP = 1;
+ m_pContext->RSGetViewports(&numVP, vp);
+}
+
+void DX11Context::SetBlendState(bool bEnable, D3D11_BLEND srcBlend, D3D11_BLEND destBlend)
+{
+ if (m_pState)
+ {
+ m_pState->Release();
+ m_pState = NULL;
+ }
+
+ D3D11_BLEND_DESC desc;
+ ZeroMemory(&desc, sizeof(desc));
+
+ //desc.RenderTarget[0].BlendEnable = (srcBlend != D3D11_BLEND_ONE)
+ // || (destBlend != D3D11_BLEND_ZERO);
+
+ desc.RenderTarget[0].BlendEnable = bEnable;
+ desc.RenderTarget[0].SrcBlend = srcBlend;
+ desc.RenderTarget[0].DestBlend = destBlend;
+ desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
+
+ D3D11_BLEND srcAlphaBlend = srcBlend;
+ D3D11_BLEND destBAlhalend = destBlend;
+
+ if (srcBlend == 3 || srcBlend == 4)
+ srcAlphaBlend = (D3D11_BLEND)(srcAlphaBlend + 2);
+ if (srcBlend == 9 || srcBlend == 10)
+ srcAlphaBlend = (D3D11_BLEND)(srcAlphaBlend - 2);
+ if (destBlend == 3 || destBlend == 4)
+ destBAlhalend = (D3D11_BLEND)(destBAlhalend + 2);
+ if (destBlend == 9 || destBlend == 10)
+ destBAlhalend = (D3D11_BLEND)(destBAlhalend - 2);
+
+ desc.RenderTarget[0].SrcBlendAlpha = srcAlphaBlend;
+ desc.RenderTarget[0].DestBlendAlpha = destBAlhalend;
+ desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+ desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+
+ if (SUCCEEDED(m_pDevice->CreateBlendState(&desc, &m_pState)))
+ m_pContext->OMSetBlendState(m_pState, 0, 0xFFFFFFFF);
+}
+
+void DX11Context::SetDepth(bool bEnabled)
+{
+ ID3D11DepthStencilState* pState = bEnabled ? m_states->DepthDefault() : m_states->DepthNone();
+ if (pState)
+ m_pContext->OMSetDepthStencilState(pState, 0);
+}
+
+void DX11Context::SetRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode)
+{
+ ID3D11RasterizerState* pState = NULL;
+
+ if (fillMode == D3D11_FILL_SOLID)
+ {
+ if (cullMode == D3D11_CULL_NONE)
+ pState = m_states->CullNone();
+ if (cullMode == D3D11_CULL_FRONT)
+ pState = m_states->CullClockwise();
+ if (cullMode == D3D11_CULL_BACK)
+ pState = m_states->CullCounterClockwise();
+ }
+ if (fillMode == D3D11_FILL_WIREFRAME)
+ {
+ if (cullMode == D3D11_CULL_NONE)
+ pState = m_states->Wireframe();
+ }
+
+ if (pState)
+ m_pContext->RSSetState(pState);
+}
+
+void DX11Context::SetRenderTarget(ID3D11Texture2D* pTexture, ID3D11Texture2D* pDepthTexture)
+{
+ ID3D11RenderTargetView* pRTView = NULL;
+ ID3D11DepthStencilView* pDSView = NULL;
+ if (pTexture)
+ {
+ CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(pTexture, D3D11_RTV_DIMENSION_TEXTURE2D);
+ m_pDevice->CreateRenderTargetView(pTexture, &rtvDesc, &pRTView);
+
+ CD3D11_VIEWPORT vp(pTexture, pRTView);
+ m_pContext->RSSetViewports(1, &vp);
+ }
+ if (pDepthTexture)
+ {
+ CD3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc(pDepthTexture, D3D11_DSV_DIMENSION_TEXTURE2D);
+ m_pDevice->CreateDepthStencilView(pDepthTexture, &dsvDesc, &pDSView);
+ }
+ m_pContext->OMSetRenderTargets(1, &pRTView, pDSView);
+
+ if (pRTView)
+ pRTView->Release();
+ if (pDSView)
+ pDSView->Release();
+}
+
+void DX11Context::SetSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode)
+{
+ ID3D11SamplerState* pState = NULL;
+ if (addressMode == D3D11_TEXTURE_ADDRESS_WRAP)
+ {
+ if (filter == D3D11_FILTER_MIN_MAG_MIP_POINT)
+ pState = m_states->PointWrap();
+ if (filter == D3D11_FILTER_MIN_MAG_MIP_LINEAR)
+ pState = m_states->LinearWrap();
+ if (filter == D3D11_FILTER_ANISOTROPIC)
+ pState = m_states->AnisotropicWrap();
+ }
+ if (addressMode == D3D11_TEXTURE_ADDRESS_CLAMP)
+ {
+ if (filter == D3D11_FILTER_MIN_MAG_MIP_POINT)
+ pState = m_states->PointClamp();
+ if (filter == D3D11_FILTER_MIN_MAG_MIP_LINEAR)
+ pState = m_states->LinearClamp();
+ if (filter == D3D11_FILTER_ANISOTROPIC)
+ pState = m_states->AnisotropicClamp();
+ }
+
+ if (pState)
+ m_pContext->PSSetSamplers(0, 1, &pState);
+}
+
+void DX11Context::SetShader(unsigned int iIndex)
+{
+ m_pContext->VSSetShader(m_pVShader, NULL, 0);
+ m_pContext->VSSetConstantBuffers(0, 1, &m_pCBuffer);
+
+ if (iIndex >= MAX_NUM_SHADERS - 1)
+ return;
+
+ m_pContext->PSSetShader(m_pPShader[iIndex], NULL, 0);
+ m_uCurrShader = iIndex;
+}
+
+void DX11Context::SetTexture(unsigned int iSlot, ID3D11Texture2D* pTexture)
+{
+ ID3D11ShaderResourceView* views[1] = { NULL };
+ if (pTexture)
+ {
+ CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pTexture, D3D11_SRV_DIMENSION_TEXTURE2D);
+ m_pDevice->CreateShaderResourceView(pTexture, &srvDesc, &views[0]);
+ }
+
+ m_pContext->PSSetShaderResources(iSlot, 1, views);
+
+ if (views[0])
+ views[0]->Release();
+}
+
+void DX11Context::SetTransform(unsigned int transType, DirectX::XMMATRIX* pMatrix)
+{
+ if (transType == 2) // view
+ XMStoreFloat4x4(&m_transforms.view, XMMatrixTranspose(*pMatrix));
+ if (transType == 3) // projection
+ XMStoreFloat4x4(&m_transforms.proj, XMMatrixTranspose(*pMatrix));
+ if (transType == 256) // world
+ XMStoreFloat4x4(&m_transforms.world, XMMatrixTranspose(*pMatrix));
+
+ m_bCBufferIsDirty = true;
+}
+
+void DX11Context::SetVertexColor(bool bUseColor)
+{
+ if (!bUseColor)
+ m_pContext->PSSetShader(m_pPShader[m_uCurrShader], NULL, 0);
+ else
+ m_pContext->PSSetShader(m_pPShader[2], NULL, 0);
+}
+
+int DX11Context::NumVertsFromType(unsigned int primType, int iPrimCount)
+{
+ switch (primType)
+ {
+ case D3DPT_POINTLIST:
+ return iPrimCount;
+ case D3DPT_LINELIST:
+ return iPrimCount * 2;
+ case D3DPT_LINESTRIP:
+ return iPrimCount + 1;
+ case D3DPT_TRIANGLELIST:
+ return iPrimCount * 3;
+ case D3DPT_TRIANGLESTRIP:
+ case D3DPT_TRIANGLEFAN:
+ return iPrimCount + 2;
+ default:
+ return -1;
+ }
+}
+
+void DX11Context::UpdateVBuffer(unsigned int iNumVerts, const void* pVData, unsigned int vertexStride)
+{
+ D3D11_MAPPED_SUBRESOURCE res;
+ if (S_OK == m_pContext->Map(m_pVBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res))
+ {
+ memcpy(res.pData, pVData, iNumVerts * vertexStride);
+ m_pContext->Unmap(m_pVBuffer, 0);
+ }
+}
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#pragma once
+
+#include <d3d11.h>
+#include <DirectXMath.h>
+#include <memory>
+#include "CommonStates.h"
+
+#define MAX_NUM_SHADERS (3)
+#define MAX_VERTICES_COUNT (512*6)
+
+class DX11Context
+{
+public:
+ DX11Context(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
+ ~DX11Context();
+
+ void Initialize();
+ bool CreateTexture(unsigned int uWidth, unsigned int uHeight, unsigned int mipLevels, UINT bindFlags, DXGI_FORMAT format, ID3D11Texture2D** ppTexture);
+ void DrawPrimitive(unsigned int primType, unsigned int iPrimCount, const void * pVData, unsigned int vertexStride);
+ void GetRenderTarget(ID3D11Texture2D** ppTexture, ID3D11Texture2D** ppDepthTexture);
+ void GetViewport(D3D11_VIEWPORT *vp);
+ void SetBlendState(bool bEnable, D3D11_BLEND srcBlend = D3D11_BLEND_ONE, D3D11_BLEND destBlend = D3D11_BLEND_ZERO);
+ void SetDepth(bool bEnabled);
+ void SetRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode);
+ void SetRenderTarget(ID3D11Texture2D* pTexture, ID3D11Texture2D* ppDepthTexture);
+ void SetSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode);
+ void SetShader(unsigned int iIndex);
+ void SetTexture(unsigned int iSlot, ID3D11Texture2D* pTexture);
+ void SetTransform(unsigned int transType, DirectX::XMMATRIX* pMatrix);
+ void SetVertexColor(bool bUseColor);
+
+private:
+ struct cbTransforms
+ {
+ DirectX::XMFLOAT4X4 world;
+ DirectX::XMFLOAT4X4 view;
+ DirectX::XMFLOAT4X4 proj;
+ };
+
+ int NumVertsFromType(unsigned int primType, int iPrimCount);
+ void UpdateVBuffer(unsigned int iNumVerts, const void* pVData, unsigned int vertexStride);
+
+ cbTransforms m_transforms;
+ ID3D11Device* m_pDevice;
+ ID3D11DeviceContext* m_pContext;
+ ID3D11VertexShader* m_pVShader;
+ ID3D11PixelShader* m_pPShader[MAX_NUM_SHADERS];
+ ID3D11InputLayout* m_pInputLayout;
+ ID3D11Buffer* m_pVBuffer;
+ ID3D11Buffer* m_pIBuffer;
+ ID3D11Buffer* m_pCBuffer;
+ bool m_bCBufferIsDirty;
+ unsigned int m_uCurrShader;
+ ID3D11BlendState* m_pState;
+
+ std::unique_ptr<DirectX::CommonStates> m_states;
+};
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+cbuffer cbTransforms : register(b0)
+{
+ float4x4 g_world;
+ float4x4 g_view;
+ float4x4 g_proj;
+};
+
+struct VS_INPUT
+{
+ float4 vPosition : POSITION;
+ float4 Diffuse : COLOR;
+ float2 Tex0 : TEXCOORD0;
+};
+
+struct VS_OUTPUT
+{
+ float4 Diffuse : COLOR;
+ float2 Tex0 : TEXCOORD0;
+ float4 vPosition : SV_POSITION;
+};
+
+VS_OUTPUT main(VS_INPUT In)
+{
+ VS_OUTPUT output = (VS_OUTPUT)0.0;
+
+ float4 worldPos = mul(In.vPosition, g_world);
+ float4 cameraPos = mul(worldPos, g_view);
+ output.vPosition = mul(cameraPos, g_proj);
+ output.Diffuse = saturate(In.Diffuse);
+ output.Tex0 = In.Tex0;
+
+ return output;
+}
\ No newline at end of file
--- /dev/null
+//--------------------------------------------------------------------------------------
+// File: DemandCreate.h
+//
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// http://go.microsoft.com/fwlink/?LinkId=248929
+//--------------------------------------------------------------------------------------
+
+#pragma once
+
+#include <mutex>
+
+namespace DirectX
+{
+ // Helper for lazily creating a D3D resource.
+ template<typename T, typename TCreateFunc>
+ static T* DemandCreate(Microsoft::WRL::ComPtr<T>& comPtr, std::mutex& mutex, TCreateFunc createFunc)
+ {
+ T* result = comPtr.Get();
+
+ // Double-checked lock pattern.
+ MemoryBarrier();
+
+ if (!result)
+ {
+ std::lock_guard<std::mutex> lock(mutex);
+
+ result = comPtr.Get();
+
+ if (!result)
+ {
+ // Create the new object.
+ createFunc(&result);
+
+ MemoryBarrier();
+
+ comPtr.Attach(result);
+ }
+ }
+
+ return result;
+ }
+}
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+Texture2D g_Texture0 : register(t0);
+SamplerState g_Sampler0 : register(s0);
+
+struct PS_INPUT
+{
+ float4 Diffuse : COLOR;
+ float2 Tex0 : TEXCOORD0;
+};
+
+float4 main(PS_INPUT In) : SV_TARGET
+{
+ return saturate(float4((g_Texture0.Sample(g_Sampler0, In.Tex0) * In.Diffuse).rgb, In.Diffuse.a));
+}
\ No newline at end of file
--- /dev/null
+//--------------------------------------------------------------------------------------
+// File: DirectXHelpers.h
+//
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// http://go.microsoft.com/fwlink/?LinkId=248929
+//--------------------------------------------------------------------------------------
+
+#pragma once
+
+#if defined(_XBOX_ONE) && defined(_TITLE)
+#include <d3d11_x.h>
+#define NO_D3D11_DEBUG_NAME
+#else
+#include <d3d11_1.h>
+#endif
+
+#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
+#pragma comment(lib,"dxguid.lib")
+#endif
+
+#include <exception>
+
+#pragma warning(push)
+#pragma warning(disable : 4005)
+#include <stdint.h>
+#pragma warning(pop)
+
+#include <string>
+#include <memory>
+
+namespace DirectX
+{
+ // simliar to std::lock_guard for exception-safe Direct3D 11 resource locking
+ class MapGuard : public D3D11_MAPPED_SUBRESOURCE
+ {
+ public:
+ MapGuard( _In_ ID3D11DeviceContext* context,
+ _In_ ID3D11Resource *resource,
+ _In_ UINT subresource,
+ _In_ D3D11_MAP mapType,
+ _In_ UINT mapFlags )
+ : mContext(context), mResource(resource), mSubresource(subresource)
+ {
+ HRESULT hr = mContext->Map( resource, subresource, mapType, mapFlags, this );
+ if (FAILED(hr))
+ {
+ throw std::exception();
+ }
+ }
+
+ ~MapGuard()
+ {
+ mContext->Unmap( mResource, mSubresource );
+ }
+
+ uint8_t* get() const
+ {
+ return reinterpret_cast<uint8_t*>( pData );
+ }
+ uint8_t* get(size_t slice) const
+ {
+ return reinterpret_cast<uint8_t*>( pData ) + ( slice * DepthPitch );
+ }
+
+ uint8_t* scanline(size_t row) const
+ {
+ return reinterpret_cast<uint8_t*>( pData ) + ( row * RowPitch );
+ }
+ uint8_t* scanline(size_t slice, size_t row) const
+ {
+ return reinterpret_cast<uint8_t*>( pData ) + ( slice * DepthPitch ) + ( row * RowPitch );
+ }
+
+ private:
+ ID3D11DeviceContext* mContext;
+ ID3D11Resource* mResource;
+ UINT mSubresource;
+
+ MapGuard(MapGuard const&);
+ MapGuard& operator= (MapGuard const&);
+ };
+
+
+ // Helper sets a D3D resource name string (used by PIX and debug layer leak reporting).
+ template<UINT TNameLength>
+ inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength])
+ {
+ #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
+ resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
+ #else
+ UNREFERENCED_PARAMETER(resource);
+ UNREFERENCED_PARAMETER(name);
+ #endif
+ }
+
+ inline std::string GetExtension(std::string& filename)
+ {
+ size_t lastDotIndex = filename.rfind('.');
+ if (lastDotIndex != std::string::npos)
+ {
+ std::unique_ptr<char[]> extension(new char[filename.size() - lastDotIndex]);
+ for (unsigned int i = 0; i < filename.size() - lastDotIndex; i++)
+ {
+ extension[i] = tolower(*(filename.c_str() + lastDotIndex + 1 + i));
+ }
+ return std::string(extension.get());
+ }
+ return "";
+ }
+}
\ No newline at end of file
CPlugin* g_plugin=NULL;
char g_visName[512];
-#define PRESETS_DIR "zip://special%3A%2F%2Fxbmc%2Faddons%2Fvisualization.milkdrop%2Fpresets%2F"
-
bool g_UserPackFolder;
-std::string g_configFile;
+std::string g_presetsDir;
int lastPresetIndx =0;
char lastPresetDir[1024] = "";
if (len >= 4 && strcmp(pack + len - 4, ".zip") == 0)
{
// Zip file
- strcpy(g_plugin->m_szPresetDir, PRESETS_DIR);
+ strcpy(g_plugin->m_szPresetDir, g_presetsDir.c_str());
strcat(g_plugin->m_szPresetDir, pack);
strcat(g_plugin->m_szPresetDir, "/");
}
else if (len >= 4 && strcmp(pack + len - 4, ".rar") == 0)
{
// Rar file
- strcpy(g_plugin->m_szPresetDir, PRESETS_DIR);
+ strcpy(g_plugin->m_szPresetDir, g_presetsDir.c_str());
strcat(g_plugin->m_szPresetDir, pack);
strcat(g_plugin->m_szPresetDir, "/");
}
{
// If we have a valid last preset state AND the preset file(dir) is the same as last time
g_plugin->UpdatePresetList();
- g_plugin->m_bHoldPreset = lastLockedStatus;
- g_plugin->m_nCurrentPreset = lastPresetIndx;
- strcpy(g_plugin->m_szCurrentPresetFile, g_plugin->m_szPresetDir);
- strcat(g_plugin->m_szCurrentPresetFile, g_plugin->m_pPresetAddr[g_plugin->m_nCurrentPreset]);
- g_plugin->LoadPreset(g_plugin->m_szCurrentPresetFile, g_plugin->m_fBlendTimeUser);
+ if (g_plugin->m_pPresetAddr)
+ {
+ g_plugin->m_bHoldPreset = lastLockedStatus;
+ g_plugin->m_nCurrentPreset = lastPresetIndx;
+ strcpy(g_plugin->m_szCurrentPresetFile, g_plugin->m_szPresetDir);
+ strcat(g_plugin->m_szCurrentPresetFile, g_plugin->m_pPresetAddr[g_plugin->m_nCurrentPreset]);
+ g_plugin->LoadPreset(g_plugin->m_szCurrentPresetFile, g_plugin->m_fBlendTimeUser);
+ }
}
else
// If it is the first run or a newly chosen preset pack we choose a random preset as first
}
}
+void replaceAll(std::string& str, const std::string& from, const std::string& to)
+{
+ if (from.empty())
+ return;
+ size_t start_pos = 0;
+ while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
+ str.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+}
+
+void urlEscape(std::string& str)
+{
+ if (str.empty())
+ return;
+
+ // 'url encode';
+ replaceAll(str, "%", "%25");
+ replaceAll(str, "\\", "%2F");
+ replaceAll(str, "\"", "%22");
+ replaceAll(str, ":", "%3A");
+ replaceAll(str, "`", "%60");
+ replaceAll(str, "&", "%26");
+ replaceAll(str, "{", "%7B");
+ replaceAll(str, "}", "%7D");
+ replaceAll(str, "]", "%5D");
+ replaceAll(str, "[", "%5B");
+ replaceAll(str, "<", "%3C");
+ replaceAll(str, ">", "%3E");
+ replaceAll(str, "#", "%23");
+}
+
extern "C" ADDON_STATUS ADDON_Create(void* hdl, void* props)
{
if (!props)
VIS_PROPS* visprops = (VIS_PROPS*)props;
_mkdir(visprops->profile);
+ std::string presets = std::string(visprops->presets).append("\\presets\\");
+ urlEscape(presets);
+ g_presetsDir = "zip://" + presets;
+
Preinit();
- if(!g_plugin || !g_plugin->PluginInitialize((LPDIRECT3DDEVICE9)visprops->device, visprops->x, visprops->y, visprops->width, visprops->height, visprops->pixelRatio))
+ if(!g_plugin || !g_plugin->PluginInitialize((ID3D11DeviceContext*)visprops->device, visprops->x, visprops->y, visprops->width, visprops->height, visprops->pixelRatio))
return ADDON_STATUS_UNKNOWN;
return ADDON_STATUS_NEED_SAVEDSETTINGS; // We need some settings to be saved later before we quit this plugin
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)libs\$(TargetName)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)objs\$(TargetName)\$(Configuration)\</IntDir>
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(DXSDK_DIR)Lib\x86;$(LibraryPath)</LibraryPath>
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
- <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(DXSDK_DIR)Lib\x86;$(LibraryPath)</LibraryPath>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
+ <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
+ <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.vis</TargetExt>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MilkDrop_win32dx</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MilkDrop_win32dx</TargetName>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
- <AdditionalDependencies>D3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<ProgramDatabaseFile>$(OutDir)Plugin.pdb</ProgramDatabaseFile>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>D3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="CommonStates.cpp" />
+ <ClCompile Include="DX11Context.cpp" />
<ClCompile Include="MilkdropXBMC.cpp" />
<ClCompile Include="XmlDocument.cpp" />
<ClCompile Include="vis_milkdrop\milkdropfs.cpp" />
<ClCompile Include="vis_milkdrop\evallib\Yylex.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="CommonStates.h" />
+ <ClInclude Include="DemandCreate.h" />
+ <ClInclude Include="DirectXHelpers.h" />
+ <ClInclude Include="DX11Context.h" />
+ <ClInclude Include="SharedResourcePool.h" />
<ClInclude Include="XmlDocument.h" />
<ClInclude Include="vis_milkdrop\plugin.h" />
<ClInclude Include="vis_milkdrop\state.h" />
<ClInclude Include="vis_milkdrop\evallib\eval.h" />
<ClInclude Include="vis_milkdrop\evallib\Lex.h" />
</ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="ColorPixelShader.hlsl">
+ <DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableOptimizations>
+ <EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</EnableDebuggingInformation>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </ObjectFileOutput>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </ObjectFileOutput>
+ </FxCompile>
+ <FxCompile Include="DiffusePixelShader.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableOptimizations>
+ <EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</EnableDebuggingInformation>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </ObjectFileOutput>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </ObjectFileOutput>
+ </FxCompile>
+ <FxCompile Include="DefaultVertexShader.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
+ <DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableOptimizations>
+ <EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</EnableDebuggingInformation>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </ObjectFileOutput>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </ObjectFileOutput>
+ </FxCompile>
+ <FxCompile Include="TexturePixelShader.hlsl">
+ <DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DisableOptimizations>
+ <EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</EnableDebuggingInformation>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </ObjectFileOutput>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename)Code</VariableName>
+ <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).inc</HeaderFileOutput>
+ <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </ObjectFileOutput>
+ </FxCompile>
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Filter Include="Source Files\EvalLib">
<UniqueIdentifier>{786d27fa-7523-42e7-a465-a1fcf9186fc1}</UniqueIdentifier>
</Filter>
+ <Filter Include="Source Files\DX11Stuff">
+ <UniqueIdentifier>{6ea4c808-d88d-4e14-9cd9-9e02efeb7aa8}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MilkdropXBMC.cpp">
<ClCompile Include="vis_milkdrop\evallib\Yylex.c">
<Filter>Source Files\EvalLib</Filter>
</ClCompile>
+ <ClCompile Include="CommonStates.cpp">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClCompile>
+ <ClCompile Include="DX11Context.cpp">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="XmlDocument.h">
<ClInclude Include="vis_milkdrop\evallib\Lex.h">
<Filter>Source Files\EvalLib</Filter>
</ClInclude>
+ <ClInclude Include="CommonStates.h">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClInclude>
+ <ClInclude Include="DemandCreate.h">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClInclude>
+ <ClInclude Include="DirectXHelpers.h">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClInclude>
+ <ClInclude Include="SharedResourcePool.h">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClInclude>
+ <ClInclude Include="DX11Context.h">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="DefaultVertexShader.hlsl">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </FxCompile>
+ <FxCompile Include="TexturePixelShader.hlsl">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </FxCompile>
+ <FxCompile Include="DiffusePixelShader.hlsl">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </FxCompile>
+ <FxCompile Include="ColorPixelShader.hlsl">
+ <Filter>Source Files\DX11Stuff</Filter>
+ </FxCompile>
</ItemGroup>
</Project>
\ No newline at end of file
--- /dev/null
+//--------------------------------------------------------------------------------------
+// File: SharedResourcePool.h
+//
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// http://go.microsoft.com/fwlink/?LinkId=248929
+//--------------------------------------------------------------------------------------
+
+#pragma once
+
+#include <map>
+#include <memory>
+
+namespace DirectX
+{
+ // Pool manager ensures that only a single TData instance is created for each unique TKey.
+ // This is used to avoid duplicate resource creation, so that for instance a caller can
+ // create any number of SpriteBatch instances, but these can internally share shaders and
+ // vertex buffer if more than one SpriteBatch uses the same underlying D3D device.
+ template<typename TKey, typename TData>
+ class SharedResourcePool
+ {
+ public:
+ SharedResourcePool()
+ : mResourceMap(std::make_shared<ResourceMap>())
+ { }
+
+
+ // Allocates or looks up the shared TData instance for the specified key.
+ std::shared_ptr<TData> DemandCreate(TKey key)
+ {
+ std::lock_guard<std::mutex> lock(mResourceMap->mutex);
+
+ // Return an existing instance?
+ auto pos = mResourceMap->find(key);
+
+ if (pos != mResourceMap->end())
+ {
+ auto existingValue = pos->second.lock();
+
+ if (existingValue)
+ return existingValue;
+ else
+ mResourceMap->erase(pos);
+ }
+
+ // Allocate a new instance.
+ auto newValue = std::make_shared<WrappedData>(key, mResourceMap);
+
+ mResourceMap->insert(std::make_pair(key, newValue));
+
+ return newValue;
+ }
+
+
+ private:
+ // Keep track of all allocated TData instances.
+ struct ResourceMap : public std::map<TKey, std::weak_ptr<TData>>
+ {
+ std::mutex mutex;
+ };
+
+ std::shared_ptr<ResourceMap> mResourceMap;
+
+
+ // Wrap TData with our own subclass, so we can hook the destructor
+ // to remove instances from our pool before they are freed.
+ struct WrappedData : public TData
+ {
+ WrappedData(TKey key, std::shared_ptr<ResourceMap> const& resourceMap)
+ : mKey(key),
+ mResourceMap(resourceMap),
+ TData(key)
+ { }
+
+ ~WrappedData()
+ {
+ std::lock_guard<std::mutex> lock(mResourceMap->mutex);
+
+ auto pos = mResourceMap->find(mKey);
+
+ // Check for weak reference expiry before erasing, in case DemandCreate runs on
+ // a different thread at the same time as a previous instance is being destroyed.
+ // We mustn't erase replacement objects that have just been added!
+ if (pos != mResourceMap->end() && pos->second.expired())
+ {
+ mResourceMap->erase(pos);
+ }
+ }
+
+ TKey mKey;
+ std::shared_ptr<ResourceMap> mResourceMap;
+ };
+
+
+ // Prevent copying.
+ SharedResourcePool(SharedResourcePool const&);
+ SharedResourcePool& operator= (SharedResourcePool const&);
+ };
+}
--- /dev/null
+/*
+* Copyright © 2010-2015 Team Kodi
+* http://kodi.tv
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+Texture2D g_Texture0 : register(t0);
+SamplerState g_Sampler0 : register(s0);
+
+struct PS_INPUT
+{
+ float4 Diffuse : COLOR;
+ float2 Tex0 : TEXCOORD0;
+};
+
+float4 main(PS_INPUT In) : SV_TARGET
+{
+ return float4(g_Texture0.Sample(g_Sampler0, In.Tex0).rgb, In.Diffuse.a);
+}
\ No newline at end of file
//#endif
//DXContext::DXContext(HWND hWndWinamp,HINSTANCE hInstance,LPCSTR szClassName,LPCSTR szWindowCaption,WNDPROC pProc,LONG uWindowLong, int minimize_winamp, char* szIniFile)
-DXContext::DXContext(LPDIRECT3DDEVICE9 device, char* szIniFile)
+DXContext::DXContext(ID3D11Device* device, ID3D11DeviceContext* context, char* szIniFile)
{
m_szClassName[0] = 0;
m_szWindowCaption[0] = 0;
m_hwnd = NULL;
//m_lpD3D = NULL;
//HRESULT state = device->GetDirect3D(&m_lpD3D);
- m_lpDevice = device;
+ m_lpDevice = new DX11Context(device, context);
m_hmod_d3d8 = NULL;
m_zFormat = D3DFMT_UNKNOWN;
for (int i=0; i<MAX_DXC_ADAPTERS; i++)
{
// clear active flag
m_ready=FALSE;
+ if (m_lpDevice)
+ delete m_lpDevice;
// release 3D interfaces
// SafeRelease(m_lpDevice);
// 4. some DirectX- / DDraw-specific stuff. Also determine hPluginMonitor.
- m_lpDevice->GetDeviceCaps(&m_caps);
+ //m_lpDevice->GetDeviceCaps(&m_caps);
+ m_lpDevice->Initialize();
#if 0
HMONITOR hPluginMonitor = NULL;
#include "shell_defines.h"
//#include "defines.h"
#include <d3d9.h>
-#include <d3dx9.h>
+#include <d3d11.h>
+#include "../DX11Context.h"
typedef struct
{
{
public:
// PUBLIC FUNCTIONS
- DXContext(LPDIRECT3DDEVICE9 device, char* szIniFile);
+ DXContext(ID3D11Device* device, ID3D11DeviceContext* context, char* szIniFile);
// DXContext(int hWndWinamp,HINSTANCE hInstance,LPCSTR szClassName,LPCSTR szWindowCaption,WNDPROC pProc,LONG uWindowLong, int minimize_winamp, char* szIniFile);
~DXContext();
BOOL StartOrRestartDevice(DXCONTEXT_PARAMS *pParams); // also serves as Init() function
RECT m_monitor_work_rect; // same, but excludes the taskbar area.
RECT m_monitor_work_rect_orig; // original work rect; does not account for pseudo-multimon modes like 2048x768
DXCONTEXT_PARAMS m_current_mode;
- LPDIRECT3DDEVICE9 m_lpDevice;
+ DX11Context* m_lpDevice;
D3DPRESENT_PARAMETERS m_d3dpp;
//LPDIRECT3D9 m_lpD3D;
D3DCAPS9 m_caps;
#include <math.h>
//#include <shellapi.h>
-
+#define COLOR_NORM(x) (((int)(x*255)&0xFF) / 255.0f)
#define D3DCOLOR_RGBA_01(r,g,b,a) D3DCOLOR_RGBA(((int)(r*255)),((int)(g*255)),((int)(b*255)),((int)(a*255)))
#define FRAND ((rand() % 7381)/7380.0f)
// restore any lost surfaces
//m_lpDD->RestoreAllSurfaces();
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
// Remember the original backbuffer and zbuffer
- LPDIRECT3DSURFACE9 pBackBuffer, pZBuffer;
- lpDevice->GetRenderTarget(0, &pBackBuffer );
- lpDevice->GetDepthStencilSurface( &pZBuffer );
+ ID3D11Texture2D *pBackBuffer = NULL, *pZBuffer = NULL;
+ lpDevice->GetRenderTarget(&pBackBuffer, &pZBuffer);
- D3DSURFACE_DESC desc;
- pBackBuffer->GetDesc(&desc);
+ D3D11_TEXTURE2D_DESC desc;
+ pBackBuffer->GetDesc(&desc);
- m_backBufferWidth = desc.Width;
- m_backBufferHeight = desc.Height;
+ m_backBufferWidth = desc.Width;
+ m_backBufferHeight = desc.Height;
// set up render state
{
- DWORD texaddr = (*m_pState->var_pf_wrap) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
- lpDevice->SetRenderState(D3DRS_WRAP0, 0);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, texaddr);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, texaddr);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, texaddr);
+ // Setup DX11 stuff
+ D3D11_TEXTURE_ADDRESS_MODE texAddress = (*m_pState->var_pf_wrap) ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP;
+ lpDevice->SetRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID);
+ lpDevice->SetBlendState(false);
+ lpDevice->SetDepth(false);
+ lpDevice->SetShader(0); // see DX11Contex implementation
+ if (m_bAnisotropicFiltering)
+ lpDevice->SetSamplerState(D3D11_FILTER_ANISOTROPIC, texAddress);
+ else
+ lpDevice->SetSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, texAddress);
+
+ //DWORD texaddr = (*m_pState->var_pf_wrap) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
+ //lpDevice->SetRenderState(D3DRS_WRAP0, 0);
+ //lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, texaddr);
+ //lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, texaddr);
+ //lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, texaddr);
- lpDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
- lpDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
- lpDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
- lpDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- lpDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_AMBIENT, 0xFFFFFFFF ); //?
+ //lpDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
+ //lpDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
+ //lpDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
+ //lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
+ //lpDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
+ //lpDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
+ //lpDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
+ //lpDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
+ //lpDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
+ //lpDevice->SetRenderState( D3DRS_AMBIENT, 0xFFFFFFFF ); //?
// lpDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
// set min/mag/mip filtering modes; use anisotropy if available.
- if (m_bAnisotropicFiltering && (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC))
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
+ //if (m_bAnisotropicFiltering && (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC))
+ // lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
// else if (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR)
- else
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ //else
+ // lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
// else
// SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
- if (m_bAnisotropicFiltering && (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC))
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
- else
+ //if (m_bAnisotropicFiltering && (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC))
+ // lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
+ //else
// else if (GetCaps()->TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+ // lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
// else
// SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
+ //lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
// note: this texture stage state setup works for 0 or 1 texture.
// if you set a texture, it will be modulated with the current diffuse color.
// if you don't set a texture, it will just use the current diffuse color.
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
- if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
- lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
+ //lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ //lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
+ //lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
+ //lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ //lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
+ //lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
+ //lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+ //if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
+ // lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
/* WISO: if (GetCaps()->RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES)
lpDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);*/
// set up to render [from NULL] to VS0 (for motion vectors).
{
lpDevice->SetTexture(0, NULL);
-
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[0]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget);
- pNewTarget->Release();
- lpDevice->SetDepthStencilSurface( NULL );
-
- lpDevice->SetTexture(0, NULL);
+ lpDevice->SetRenderTarget(m_lpVS[0], NULL);
}
// draw motion vectors to VS0
// set up to render [from VS0] to VS1.
{
lpDevice->SetTexture(0, NULL);
-
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[1]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget);
- lpDevice->SetDepthStencilSurface( NULL );
- pNewTarget->Release();
+ lpDevice->SetRenderTarget(m_lpVS[1], NULL);
}
// do the warping for this frame
- if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
- lpDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE);
+ //if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
+ // lpDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE);
/* WISO: if (GetCaps()->RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES)
lpDevice->SetRenderState(D3DRS_EDGEANTIALIAS, FALSE);*/
WarpedBlitFromVS0ToVS1();
- if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
- lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
- /*if (GetCaps()->RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES)
- lpDevice->SetRenderState(D3DRS_EDGEANTIALIAS, TRUE);*/
+ //if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
+ // lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
+ //if (GetCaps()->RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES)
+ // lpDevice->SetRenderState(D3DRS_EDGEANTIALIAS, TRUE);
// draw audio data
- DrawCustomShapes(); // draw these first; better for feedback if the waves draw *over* them.
- DrawCustomWaves();
- DrawWave(mysound.fWave[0], mysound.fWave[1]);
- DrawSprites();
+ DrawCustomShapes(); // draw these first; better for feedback if the waves draw *over* them.
+ DrawCustomWaves();
+ DrawWave(mysound.fWave[0], mysound.fWave[1]);
+ DrawSprites();
// if song title animation just ended, render it into the VS:
if (m_supertext.fStartTime >= 0 &&
// Change the rendertarget back to the original setup
lpDevice->SetTexture(0, NULL);
// WISO: lpDevice->SetRenderTarget( pBackBuffer, pZBuffer );
- lpDevice->SetRenderTarget(0, pBackBuffer);
- lpDevice->SetDepthStencilSurface( pZBuffer );
+ lpDevice->SetRenderTarget(pBackBuffer, pZBuffer);
SafeRelease(pBackBuffer);
SafeRelease(pZBuffer);
DrawUserSprites();
// flip buffers
- IDirect3DTexture9* pTemp = m_lpVS[0];
+ ID3D11Texture2D* pTemp = m_lpVS[0];
m_lpVS[0] = m_lpVS[1];
m_lpVS[1] = pTemp;
/* WISO: if (GetCaps()->RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES)
lpDevice->SetRenderState(D3DRS_EDGEANTIALIAS, FALSE);*/
- if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
- lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
+ //if (GetCaps()->RasterCaps & D3DPRASTERCAPS_DITHER)
+ // lpDevice->SetRenderState(D3DRS_DITHERENABLE, FALSE);
}
if ((float)*m_pState->var_pf_mv_a >= 0.001f)
{
//-------------------------------------------------------
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF(WFVERTEX_FORMAT);
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF(WFVERTEX_FORMAT);
//-------------------------------------------------------
int x,y;
WFVERTEX v[(64+1)*2];
ZeroMemory(v, sizeof(WFVERTEX)*(64+1)*2);
- v[0].Diffuse = D3DCOLOR_RGBA_01((float)*m_pState->var_pf_mv_r,(float)*m_pState->var_pf_mv_g,(float)*m_pState->var_pf_mv_b,(float)*m_pState->var_pf_mv_a);
- for (x=1; x<(nX+1)*2; x++)
- v[x].Diffuse = v[0].Diffuse;
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ for (x = 0; x < (nX + 1) * 2; x++)
+ {
+ v[x].r = COLOR_NORM((float)*m_pState->var_pf_mv_r);
+ v[x].g = COLOR_NORM((float)*m_pState->var_pf_mv_g);
+ v[x].b = COLOR_NORM((float)*m_pState->var_pf_mv_b);
+ v[x].a = COLOR_NORM((float)*m_pState->var_pf_mv_a);
+ }
+
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
for (y=0; y<nY; y++)
{
// draw it
if (n != 0)
- lpDevice->DrawPrimitiveUP(D3DPT_LINELIST, n/2, v, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_LINELIST, n/2, v, sizeof(WFVERTEX));
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
}
}
{
MungeFPCW(NULL); // puts us in single-precision mode & disables exceptions
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
+ lpDevice->SetVertexColor(false);
+ //lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
// warp stuff
float fWarpTime = GetTime() * m_pState->m_fWarpAnimSpeed;
//if (m_pState->m_bBlending)
// fDecay = fDecay*(fCosineBlend) + (1.0f-fCosineBlend)*((float)(*m_pOldState->var_pf_decay));
- if (m_bAutoGamma && GetFrame()==0)
+ /* Comment this because DX11 cannot use the following formats for backbuffer
+ if (m_bAutoGamma && GetFrame()==0)
{
if (strstr(GetDriverDescription(), "nvidia") ||
strstr(GetDriverDescription(), "nVidia") ||
{
fDecay = min(fDecay, (32.0f - m_n16BitGamma)/32.0f);
}
+ */
D3DCOLOR cDecay = D3DCOLOR_RGBA_01(fDecay,fDecay,fDecay,1);
+ fDecay = COLOR_NORM(fDecay);
for (int rep=0; rep<num_reps; rep++)
for (poly=0; poly<m_nGridX+2; poly++)
{
- m_verts_temp[poly].Diffuse = cDecay;
+ m_verts_temp[poly].r = fDecay;
+ m_verts_temp[poly].g = fDecay;
+ m_verts_temp[poly].b = fDecay;
+ m_verts_temp[poly].a = 1.0f;
}
for (int strip=0; strip<m_nGridY*2; strip++)
index++;
}
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, m_nGridX, (void*)m_verts_temp, sizeof(SPRITEVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, m_nGridX, (void*)m_verts_temp, sizeof(SPRITEVERTEX));
}
}
void CPlugin::DrawCustomShapes()
{
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
if (sides<3) sides=3;
if (sides>100) sides=100;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, ((int)(*pState->m_shape[i].var_pf_additive) != 0) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, ((int)(*pState->m_shape[i].var_pf_additive) != 0) ? D3D11_BLEND_ONE : D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ // lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ // lpDevice->SetRenderState(D3DRS_DESTBLEND, ((int)(*pState->m_shape[i].var_pf_additive) != 0) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
SPRITEVERTEX v[512]; // for textured shapes (has texcoords)
WFVERTEX v2[512]; // for untextured shapes + borders
v[0].z = 0;
v[0].tu = 0.5f;
v[0].tv = 0.5f;
- v[0].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_b * 255)) & 0xFF) );
- v[1].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_a2 * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_r2 * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_g2 * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_b2 * 255)) & 0xFF) );
+ v[0].a = COLOR_NORM((float)(*pState->m_shape[i].var_pf_a * alpha_mult));
+ v[0].r = COLOR_NORM((float)(*pState->m_shape[i].var_pf_r));
+ v[0].g = COLOR_NORM((float)(*pState->m_shape[i].var_pf_g));
+ v[0].b = COLOR_NORM((float)(*pState->m_shape[i].var_pf_b));
+ v[1].a = COLOR_NORM((float)(*pState->m_shape[i].var_pf_a2 * alpha_mult));
+ v[1].r = COLOR_NORM((float)(*pState->m_shape[i].var_pf_r2));
+ v[1].g = COLOR_NORM((float)(*pState->m_shape[i].var_pf_g2));
+ v[1].b = COLOR_NORM((float)(*pState->m_shape[i].var_pf_b2));
for (int j=1; j<sides+1; j++)
{
v[j].z = 0;
v[j].tu = 0.5f + 0.5f*cosf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_tex_ang + 3.1415927f*0.25f)/((float)*pState->m_shape[i].var_pf_tex_zoom) * ASPECT; // DON'T TOUCH!
v[j].tv = 0.5f + 0.5f*sinf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_tex_ang + 3.1415927f*0.25f)/((float)*pState->m_shape[i].var_pf_tex_zoom); // DON'T TOUCH!
- v[j].Diffuse = v[1].Diffuse;
+ v[j].a = v[1].a;
+ v[j].r = v[1].r;
+ v[j].g = v[1].g;
+ v[j].b = v[1].b;
+
}
v[sides+1] = v[1];
if ((int)(*pState->m_shape[i].var_pf_textured) != 0)
{
// draw textured version
+ lpDevice->SetVertexColor(false);
lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, sides, (void*)v, sizeof(SPRITEVERTEX));
+ //lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, sides, (void*)v, sizeof(SPRITEVERTEX));
}
else
{
v2[j].x = v[j].x;
v2[j].y = v[j].y;
v2[j].z = v[j].z;
- v2[j].Diffuse = v[j].Diffuse;
+ v2[j].a = v[j].a;
+ v2[j].r = v[j].r;
+ v2[j].g = v[j].g;
+ v2[j].b = v[j].b;
}
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, sides, (void*)v2, sizeof(WFVERTEX));
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF( WFVERTEX_FORMAT );
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, sides, (void*)v2, sizeof(WFVERTEX));
}
if (*pState->m_shape[i].var_pf_border_a > 0)
{
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( WFVERTEX_FORMAT );
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF( WFVERTEX_FORMAT );
- v2[0].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_border_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_border_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_border_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_border_b * 255)) & 0xFF) );
+ v2[0].a = COLOR_NORM(*pState->m_shape[i].var_pf_border_a * alpha_mult);
+ v2[0].r = COLOR_NORM(*pState->m_shape[i].var_pf_border_r);
+ v2[0].g = COLOR_NORM(*pState->m_shape[i].var_pf_border_g);
+ v2[0].b = COLOR_NORM(*pState->m_shape[i].var_pf_border_b);
for (int j=0; j<sides+2; j++)
{
v2[j].x = v[j].x;
v2[j].y = v[j].y;
v2[j].z = v[j].z;
- v2[j].Diffuse = v2[0].Diffuse;
+ v2[j].a = v2[0].a;
+ v2[j].r = v2[0].r;
+ v2[j].g = v2[0].g;
+ v2[j].b = v2[0].b;
}
int its = ((int)(*pState->m_shape[i].var_pf_thick) != 0) ? 4 : 1;
case 2: for (int j=0; j<sides+2; j++) v2[j].y += x_inc; break; // draw fat dots
case 3: for (int j=0; j<sides+2; j++) v2[j].x -= x_inc; break; // draw fat dots
}
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, sides, (void*)&v2[1], sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_LINESTRIP, sides, (void*)&v2[1], sizeof(WFVERTEX));
}
lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
+ lpDevice->SetVertexColor(false);
+ //lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
}
}
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(false, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
void CPlugin::LoadCustomShapePerFrameEvallibVars(CState* pState, int i)
void CPlugin::DrawCustomWaves()
{
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( WFVERTEX_FORMAT );
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF( WFVERTEX_FORMAT );
// note: read in all sound data from CPluginShell's m_sound
int num_reps = (m_pState->m_bBlending) ? 2 : 1;
v[j].x = (float)(*pState->m_wave[i].var_pp_x* 2-1);//*ASPECT;
v[j].y = (float)(*pState->m_wave[i].var_pp_y*-2+1);
v[j].z = 0;
- v[j].Diffuse =
- ((((int)(*pState->m_wave[i].var_pp_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_wave[i].var_pp_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_wave[i].var_pp_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_wave[i].var_pp_b * 255)) & 0xFF) );
+ v[j].a = COLOR_NORM(*pState->m_wave[i].var_pp_a * alpha_mult);
+ v[j].r = COLOR_NORM(*pState->m_wave[i].var_pp_r);
+ v[j].g = COLOR_NORM(*pState->m_wave[i].var_pp_g);
+ v[j].b = COLOR_NORM(*pState->m_wave[i].var_pp_b);
}
#ifndef _NO_EXPR_
*/
// 3. draw it
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, pState->m_wave[i].bAdditive ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, pState->m_wave[i].bAdditive ? D3D11_BLEND_ONE :D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, pState->m_wave[i].bAdditive ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
float ptsize = ((m_nTexSize >= 1024) ? 2.0f : 1.0f) + (pState->m_wave[i].bDrawThick ? 1.0f : 0.0f);
- if (pState->m_wave[i].bUseDots)
- lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
-
- int its = (pState->m_wave[i].bDrawThick && !pState->m_wave[i].bUseDots) ? 4 : 1;
- float x_inc = 2.0f / (float)m_nTexSize;
- for (int it=0; it<its; it++)
+ //if (pState->m_wave[i].bUseDots)
+ // lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
+ // DX11: have not point size, so render quads
+ if (pState->m_wave[i].bUseDots && ptsize > 1.0)
{
- switch(it)
- {
- case 0: break;
- case 1: for (j=0; j<nSamples; j++) v[j].x += x_inc; break; // draw fat dots
- case 2: for (j=0; j<nSamples; j++) v[j].y += x_inc; break; // draw fat dots
- case 3: for (j=0; j<nSamples; j++) v[j].x -= x_inc; break; // draw fat dots
- }
- lpDevice->DrawPrimitiveUP(pState->m_wave[i].bUseDots ? D3DPT_POINTLIST : D3DPT_LINESTRIP, nSamples - (pState->m_wave[i].bUseDots ? 0 : 1), (void*)v, sizeof(WFVERTEX));
+ float dx = ptsize / (float)m_nTexSize;
+ WFVERTEX *v2 = new WFVERTEX[nSamples * 6];
+ int j = 0;
+ for (int k=0; k<nSamples*6; k+=6)
+ {
+ v2[k] = v[j]; v2[ k ].x -= dx; v2[ k ].y -= dx;
+ v2[k+1] = v[j]; v2[k+1].x += dx; v2[k+1].y -= dx;
+ v2[k+2] = v[j]; v2[k+2].x += dx; v2[k+2].y += dx;
+
+ v2[k+3] = v2[k];
+ v2[k+4] = v2[k+2];
+ v2[k+5] = v[j]; v2[k+5].x -= dx; v2[k+5].y += dx;
+ ++j;
+ }
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLELIST, nSamples * 2, (void*)v2, sizeof(WFVERTEX));
+ delete[] v2;
}
-
- ptsize = 1.0f;
- if (pState->m_wave[i].bUseDots)
- lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
+ else
+ {
+ int its = (pState->m_wave[i].bDrawThick && !pState->m_wave[i].bUseDots) ? 4 : 1;
+ float x_inc = 2.0f / (float)m_nTexSize;
+ for (int it = 0; it < its; it++)
+ {
+ switch (it)
+ {
+ case 0: break;
+ case 1: for (j = 0; j < nSamples; j++) v[j].x += x_inc; break; // draw fat dots
+ case 2: for (j = 0; j < nSamples; j++) v[j].y += x_inc; break; // draw fat dots
+ case 3: for (j = 0; j < nSamples; j++) v[j].x -= x_inc; break; // draw fat dots
+ }
+ lpDevice->DrawPrimitive(pState->m_wave[i].bUseDots ? D3DPT_POINTLIST : D3DPT_LINESTRIP, nSamples - (pState->m_wave[i].bUseDots ? 0 : 1), (void*)v, sizeof(WFVERTEX));
+ }
+ }
+ // DX11: do not use point size
+ //if (pState->m_wave[i].bUseDots)
+ // lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
}
}
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(false, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
void CPlugin::DrawWave(float *fL, float *fR)
{
//return;
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( WFVERTEX_FORMAT );
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF( WFVERTEX_FORMAT );
int i;
WFVERTEX v1[576+1], v2[576+1];
}
*/
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, (*m_pState->var_pf_wave_additive) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, (*m_pState->var_pf_wave_additive) ? D3D11_BLEND_ONE : D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, (*m_pState->var_pf_wave_additive) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
//float cr = m_pState->m_waveR.eval(GetTime());
//float cg = m_pState->m_waveG.eval(GetTime());
// apply color & alpha
// ALSO reverse all y values, to stay consistent with the pre-VMS milkdrop,
// which DIDN'T:
- v1[0].Diffuse = D3DCOLOR_RGBA_01(cr, cg, cb, alpha1);
for (i=0; i<nVerts1; i++)
{
- v1[i].Diffuse = v1[0].Diffuse;
- v1[i].y = -v1[i].y;
+ v1[i].r = COLOR_NORM(cr);
+ v1[i].g = COLOR_NORM(cg);
+ v1[i].b = COLOR_NORM(cb);
+ v1[i].a = COLOR_NORM(alpha1);
+ v1[i].y = -v1[i].y;
}
// draw primitives
{
//m_lpD3DDev->DrawPrimitive(primtype, D3DFVF_LVERTEX, (LPVOID)v1, nVerts1, NULL);
if (*m_pState->var_pf_wave_usedots)
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nVerts1, (void*)v1, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_POINTLIST, nVerts1, (void*)v1, sizeof(WFVERTEX));
else
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nVerts1-1, (void*)v1, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_LINESTRIP, nVerts1-1, (void*)v1, sizeof(WFVERTEX));
}
else
{
//m_lpD3DDev->DrawPrimitive(primtype, D3DFVF_LVERTEX, (LPVOID)&v1[nBreak1], nVerts1-nBreak1, NULL);
if (*m_pState->var_pf_wave_usedots)
{
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nBreak1, (void*)v1, sizeof(WFVERTEX));
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nVerts1-nBreak1, (void*)&v1[nBreak1], sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_POINTLIST, nBreak1, (void*)v1, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_POINTLIST, nVerts1-nBreak1, (void*)&v1[nBreak1], sizeof(WFVERTEX));
}
else
{
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nBreak1-1, (void*)v1, sizeof(WFVERTEX));
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nVerts1-nBreak1-1, (void*)&v1[nBreak1], sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_LINESTRIP, nBreak1-1, (void*)v1, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_LINESTRIP, nVerts1-nBreak1-1, (void*)&v1[nBreak1], sizeof(WFVERTEX));
}
}
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
void CPlugin::DrawSprites()
{
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( WFVERTEX_FORMAT );
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetFVF( WFVERTEX_FORMAT );
if (*m_pState->var_pf_darken_center)
{
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);//SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);//SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
WFVERTEX v3[6];
ZeroMemory(v3, sizeof(WFVERTEX)*6);
// colors:
- v3[0].Diffuse = D3DCOLOR_RGBA_01(0, 0, 0, 3.0f/32.0f);
- v3[1].Diffuse = D3DCOLOR_RGBA_01(0, 0, 0, 0.0f/32.0f);
- v3[2].Diffuse = v3[1].Diffuse;
- v3[3].Diffuse = v3[1].Diffuse;
- v3[4].Diffuse = v3[1].Diffuse;
- v3[5].Diffuse = v3[1].Diffuse;
+ v3[0].r = v3[0].g = v3[0].b = 0.0f; v3[0].a = 3.0f / 32.0f;
+ v3[1].r = v3[1].g = v3[1].b = v3[1].a = 0.0f;
+ v3[2].r = v3[2].g = v3[2].b = v3[2].a = 0.0f;
+ v3[3].r = v3[3].g = v3[3].b = v3[3].a = 0.0f;
+ v3[4].r = v3[4].g = v3[4].b = v3[4].a = 0.0f;
+ v3[5].r = v3[5].g = v3[5].b = v3[5].a = 0.0f;
// positioning:
float fHalfSize = 0.05f;
//v3[0].tu = 0; v3[1].tu = 1; v3[2].tu = 0; v3[3].tu = 1;
//v3[0].tv = 1; v3[1].tv = 1; v3[2].tv = 0; v3[3].tv = 0;
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 4, (LPVOID)v3, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 4, (LPVOID)v3, sizeof(WFVERTEX));
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
float fOuterBorderSize = (float)*m_pState->var_pf_ob_size;
float fInnerBorderSize = (float)*m_pState->var_pf_ib_size;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ lpDevice->SetBlendState(true, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
for (int it=0; it<2; it++)
{
float a = (it==0) ? (float)*m_pState->var_pf_ob_a : (float)*m_pState->var_pf_ib_a;
if (a > 0.001f)
{
- v3[0].Diffuse = D3DCOLOR_RGBA_01(r,g,b,a);
- v3[1].Diffuse = v3[0].Diffuse;
- v3[2].Diffuse = v3[0].Diffuse;
- v3[3].Diffuse = v3[0].Diffuse;
+ v3[0].r = v3[1].r = v3[2].r = v3[3].r = COLOR_NORM(r);
+ v3[0].g = v3[1].g = v3[2].g = v3[3].g = COLOR_NORM(g);
+ v3[0].b = v3[1].b = v3[2].b = v3[3].b = COLOR_NORM(b);
+ v3[0].a = v3[1].a = v3[2].a = v3[3].a = COLOR_NORM(a);
// positioning:
float fInnerRad = (it==0) ? 1.0f - fOuterBorderSize : 1.0f - fOuterBorderSize - fInnerBorderSize;
for (int rot=0; rot<4; rot++)
{
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, (LPVOID)v3, sizeof(WFVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 2, (LPVOID)v3, sizeof(WFVERTEX));
// rotate by 90 degrees
for (int v=0; v<4; v++)
}
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
}
void CPlugin::ShowToUser(int bRedraw)
{
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
+ DX11Context* lpDevice = GetDevice();
if (!lpDevice)
return;
lpDevice->SetTexture(0, m_lpVS[1]);
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
+ lpDevice->SetVertexColor(false);
+ //lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
float fZoom = 1.0f;
SPRITEVERTEX v3[4];
float fGammaAdj = (float)*m_pState->var_pf_gamma;//m_pState->m_fGammaAdj.eval(GetTime());
int gamma_passes = (int)(fGammaAdj + 0.999f);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
for (int pass=0; pass<gamma_passes; pass++)
{
}
}
- if (rep==0)
- m_verts_temp[0].Diffuse = D3DCOLOR_RGBA_01(m_cRightEye3DColor[0]*colormult,m_cRightEye3DColor[1]*colormult,m_cRightEye3DColor[2]*colormult,1); // should be the color of right lens (~red)
- else
- m_verts_temp[0].Diffuse = D3DCOLOR_RGBA_01(m_cLeftEye3DColor[0]*colormult,m_cLeftEye3DColor[1]*colormult,m_cLeftEye3DColor[2]*colormult,1); // should be the color of left lens (~blue)
+ if (rep == 0)
+ {
+ m_verts_temp[0].r = COLOR_NORM(m_cRightEye3DColor[0] * colormult);
+ m_verts_temp[0].g = COLOR_NORM(m_cRightEye3DColor[1] * colormult);
+ m_verts_temp[0].b = COLOR_NORM(m_cRightEye3DColor[2] * colormult);
+ m_verts_temp[0].a = 1.0f;
+ }
+ else
+ {
+ m_verts_temp[0].r = COLOR_NORM(m_cLeftEye3DColor[0] * colormult);
+ m_verts_temp[0].g = COLOR_NORM(m_cLeftEye3DColor[1] * colormult);
+ m_verts_temp[0].b = COLOR_NORM(m_cLeftEye3DColor[2] * colormult);
+ m_verts_temp[0].a = 1.0f;
+ }
for (int poly=1; poly<m_nGridX+2; poly++)
- m_verts_temp[poly].Diffuse = m_verts_temp[0].Diffuse;
+ {
+ m_verts_temp[poly].r = m_verts_temp[0].r;
+ m_verts_temp[poly].g = m_verts_temp[0].g;
+ m_verts_temp[poly].b = m_verts_temp[0].b;
+ m_verts_temp[poly].a = m_verts_temp[0].a;
+ }
for (int strip=0; strip<m_nGridY*2; strip++)
{
index++;
}
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, m_nGridX, (void*)m_verts_temp, sizeof(SPRITEVERTEX));
- }
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, m_nGridX, (void*)m_verts_temp, sizeof(SPRITEVERTEX));
+ }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
+ lpDevice->SetBlendState(true, D3D11_BLEND_ONE, D3D11_BLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
}
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false, D3D11_BLEND_ONE, D3D11_BLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
else // regular display (non-stereo)
{
shade[i][k] = shade[i][k]*(fShaderAmount) + 1.0f*(1.0f - fShaderAmount);
}
- v3[i].Diffuse = D3DCOLOR_RGBA_01(shade[i][0],shade[i][1],shade[i][2],1);
+ v3[i].r = COLOR_NORM(shade[i][0]);
+ v3[i].g = COLOR_NORM(shade[i][1]);
+ v3[i].b = COLOR_NORM(shade[i][2]);
+ v3[i].a = 1.0f;
}
}
if (fVideoEchoAlpha > 0.001f)
{
// video echo
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
+ lpDevice->SetBlendState(true, D3D11_BLEND_ONE, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
for (int i=0; i<2; i++)
{
float mix = (i==1) ? fVideoEchoAlpha : 1.0f - fVideoEchoAlpha;
for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(mix*shade[k][0],mix*shade[k][1],mix*shade[k][2],1);
+ {
+ v3[k].r = COLOR_NORM(mix*shade[k][0]);
+ v3[k].g = COLOR_NORM(mix*shade[k][1]);
+ v3[k].b = COLOR_NORM(mix*shade[k][2]);
+ v3[k].a = 1.0f;
+ }
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
if (i==0)
{
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
+ lpDevice->SetBlendState(true, D3D11_BLEND_ONE, D3D11_BLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
if (fGammaAdj > 0.001f)
gamma = 1.0f;
for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(gamma*mix*shade[k][0],gamma*mix*shade[k][1],gamma*mix*shade[k][2],1);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ {
+ v3[k].r = COLOR_NORM(gamma*mix*shade[k][0]);
+ v3[k].g = COLOR_NORM(gamma*mix*shade[k][1]);
+ v3[k].b = COLOR_NORM(gamma*mix*shade[k][2]);
+ v3[k].a = 1.0f;
+ }
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
}
}
}
v3[0].tu = 0.5f / m_nTexSize; v3[1].tu = 1; v3[2].tu = 0.5f / m_nTexSize; v3[3].tu = 1;
v3[0].tv = 1; v3[1].tv = 1; v3[2].tv = 0.5f / m_nTexSize; v3[3].tv = 0.5f / m_nTexSize;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
+ lpDevice->SetBlendState(false, D3D11_BLEND_ONE, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
// draw it iteratively, solid the first time, and additively after that
int nPasses = (int)(fGammaAdj - 0.001f) + 1;
gamma = 1.0f;
for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(gamma*shade[k][0],gamma*shade[k][1],gamma*shade[k][2],1);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ {
+ v3[k].r = COLOR_NORM(gamma*shade[k][0]);
+ v3[k].g = COLOR_NORM(gamma*shade[k][1]);
+ v3[k].b = COLOR_NORM(gamma*shade[k][2]);
+ v3[k].a = 1.0f;
+ }
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
if (nPass==0)
{
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
+ lpDevice->SetBlendState(true, D3D11_BLEND_ONE, D3D11_BLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
}
}
v3[2].y = -fOnePlusInvHeight;
v3[3].y = -fOnePlusInvHeight;
*/
- for (int i=0; i<4; i++) v3[i].Diffuse = D3DCOLOR_RGBA_01(1,1,1,1);
-
- if (*m_pState->var_pf_brighten &&
+ for (int i=0; i<4; i++) v3[i].r = v3[i].g = v3[i].b = v3[i].a = 1.0f;
+
+ if (*m_pState->var_pf_brighten /*&& // DX11 has no caps
(GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR ) &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)
+ (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)*/
)
{
// square root filter
//lpDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); //?
lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
// first, a perfect invert
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ lpDevice->SetBlendState(true, D3D11_BLEND_INV_DEST_COLOR, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
// then modulate by self (square it)
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ lpDevice->SetBlendState(true, D3D11_BLEND_ZERO, D3D11_BLEND_DEST_COLOR);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
// then another perfect invert
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
+ lpDevice->SetBlendState(true, D3D11_BLEND_INV_DEST_COLOR, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ }
- if (*m_pState->var_pf_darken &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)
+ if (*m_pState->var_pf_darken /*&& // DX11 has no caps
+ (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)*/
)
{
// squaring filter
//lpDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); //?
lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ lpDevice->SetBlendState(true, D3D11_BLEND_ZERO, D3D11_BLEND_DEST_COLOR);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
//lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
//lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
- if (*m_pState->var_pf_solarize &&
+ if (*m_pState->var_pf_solarize /*&& // DX11 has no caps
(GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_DESTCOLOR ) &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR)
+ (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR)*/
)
{
//lpDevice->SetRenderState(D3DRS_COLORVERTEX, FALSE); //?
//lpDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); //?
lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ lpDevice->SetVertexColor(true);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ lpDevice->SetBlendState(true, D3D11_BLEND_ZERO, D3D11_BLEND_INV_DEST_COLOR);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVDESTCOLOR);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
+ lpDevice->SetBlendState(true, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_ONE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ }
- if (*m_pState->var_pf_invert &&
- (GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR )
+ if (*m_pState->var_pf_invert /*&& // DX11 has no caps
+ (GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR )*/
)
{
//lpDevice->SetRenderState(D3DRS_COLORVERTEX, FALSE); //?
//lpDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); //?
lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
+ lpDevice->SetVertexColor(true);
+ lpDevice->SetBlendState(true, D3D11_BLEND_INV_DEST_COLOR, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ //lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
+ //lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
+ lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
+ }
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+ lpDevice->SetBlendState(false, D3D11_BLEND_ONE, D3D11_BLEND_ZERO);
+ //lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
}
m_nTexSize = (int)powf(2.0f, (float)nExp);
}
*/
-
- // clip texsize by max. from caps
- if (m_nTexSize > GetCaps()->MaxTextureWidth && GetCaps()->MaxTextureWidth>0)
- m_nTexSize = GetCaps()->MaxTextureWidth;
- if (m_nTexSize > GetCaps()->MaxTextureHeight && GetCaps()->MaxTextureHeight>0)
- m_nTexSize = GetCaps()->MaxTextureHeight;
+ // Commented because in DX11 minimal value of MaxTextureSize is 2048
+ // clip texsize by max. from caps
+ //if (m_nTexSize > GetCaps()->MaxTextureWidth && GetCaps()->MaxTextureWidth>0)
+ // m_nTexSize = GetCaps()->MaxTextureWidth;
+ //if (m_nTexSize > GetCaps()->MaxTextureHeight && GetCaps()->MaxTextureHeight>0)
+ // m_nTexSize = GetCaps()->MaxTextureHeight;
// reallocate
bool bSuccess = false;
SafeRelease(m_lpVS[1]);
SafeRelease(m_pZBuffer);
- LPDIRECT3DSURFACE9 pBackBuffer, tmpSurface;
- D3DSURFACE_DESC tmpDesc;
- D3DVIEWPORT9 pVP;
+ ID3D11Texture2D *pBackBuffer, *tmpSurface;
+ D3D11_TEXTURE2D_DESC tmpDesc;
+ D3D11_VIEWPORT pVP;
- GetDevice()->GetRenderTarget(0, &pBackBuffer );
- GetDevice()->GetDepthStencilSurface(&tmpSurface);
+ GetDevice()->GetRenderTarget(&pBackBuffer, &tmpSurface);
tmpSurface->GetDesc(&tmpDesc);
+ SafeRelease(pBackBuffer);
SafeRelease(tmpSurface);
GetDevice()->GetViewport(&pVP);
- UINT uiwidth=(pVP.Width>m_nTexSize) ? pVP.Width:m_nTexSize;
- UINT uiheight=(pVP.Height>m_nTexSize) ? pVP.Height:m_nTexSize;
-
- printf("CreateDepthStencilSurface with %u x %u", uiwidth, uiheight);
- if(GetDevice()->CreateDepthStencilSurface(uiwidth, uiheight, tmpDesc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, &m_pZBuffer, NULL) != D3D_OK)
+ //UINT uiwidth=(pVP.Width>m_nTexSize) ? pVP.Width : m_nTexSize;
+ //UINT uiheight=(pVP.Height>m_nTexSize) ? pVP.Height:m_nTexSize;
+ // DX11: create depth stencil with same dimension as the backbuffer
+ printf("CreateDepthStencilSurface with %u x %u", tmpDesc.Width, tmpDesc.Height);
+ if (!GetDevice()->CreateTexture(tmpDesc.Width, tmpDesc.Height, 1, D3D11_BIND_DEPTH_STENCIL, DXGI_FORMAT_D24_UNORM_S8_UINT, &m_pZBuffer))
printf("Can't create DepthStencilSurface");
// create VS1 and VS2
- bSuccess = (GetDevice()->CreateTexture(m_nTexSize, m_nTexSize, 1, D3DUSAGE_RENDERTARGET, GetBackBufFormat(), D3DPOOL_DEFAULT, &m_lpVS[0], NULL) == D3D_OK);
+ bSuccess = (GetDevice()->CreateTexture(m_nTexSize, m_nTexSize, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, DXGI_FORMAT_B8G8R8A8_UNORM, &m_lpVS[0]));
if (bSuccess)
{
- IDirect3DSurface9* pNewTarget = NULL;
+ // DX11: no need to clear it
+ /*IDirect3DSurface9* pNewTarget = NULL;
if (m_lpVS[0]->GetSurfaceLevel(0, &pNewTarget) == D3D_OK)
{
GetDevice()->SetRenderTarget(0, pNewTarget);
GetDevice()->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
pNewTarget->Release();
- }
+ }*/
- bSuccess = (GetDevice()->CreateTexture(m_nTexSize, m_nTexSize, 1, D3DUSAGE_RENDERTARGET, GetBackBufFormat(), D3DPOOL_DEFAULT, &m_lpVS[1], NULL) == D3D_OK);
+ bSuccess = (GetDevice()->CreateTexture(m_nTexSize, m_nTexSize, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, DXGI_FORMAT_B8G8R8A8_UNORM, &m_lpVS[1]));
if (bSuccess)
{
- if (m_lpVS[1]->GetSurfaceLevel(0, &pNewTarget) == D3D_OK)
+ // DX11: no need to clear it
+ /*if (m_lpVS[1]->GetSurfaceLevel(0, &pNewTarget) == D3D_OK)
{
GetDevice()->SetRenderTarget(0, pNewTarget);
GetDevice()->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
pNewTarget->Release();
- }
+ }*/
}
else
printf("failed to create texture %d x %d", m_nTexSize, m_nTexSize);
else
printf("failed to create texture %d x %d", m_nTexSize, m_nTexSize);
- GetDevice()->SetRenderTarget(0, pBackBuffer);
- SafeRelease(pBackBuffer);
-
-
if (!bSuccess && m_bTexSizeWasAuto)
m_nTexSize /= 2;
}
void CPlugin::MyRenderFn(int redraw)
{
- LPDIRECT3DSURFACE9 tmpSurface;
- GetDevice()->GetDepthStencilSurface(&tmpSurface);
- GetDevice()->SetDepthStencilSurface(m_pZBuffer);
+ ID3D11Texture2D* rtSurface = NULL, *tmpSurface = NULL;
+ GetDevice()->GetRenderTarget(&rtSurface, &tmpSurface);
+ GetDevice()->SetRenderTarget(rtSurface, m_pZBuffer);
// Render a frame of animation here.
// This function is called each frame just AFTER BeginScene().
m_text.QueueText(GetFont(DECORATIVE_FONT), buf, r, 0, 0xFFFF00FF);
}
/**/
- GetDevice()->SetDepthStencilSurface(tmpSurface);
+ GetDevice()->SetRenderTarget(rtSurface, tmpSurface);
+ SafeRelease(rtSurface);
SafeRelease(tmpSurface);
}
float m_fRandStart[4];
// DIRECTX 8:
- IDirect3DTexture9 *m_lpVS[2];
- IDirect3DSurface9 *m_pZBuffer;
+ ID3D11Texture2D *m_lpVS[2];
+ ID3D11Texture2D *m_pZBuffer;
// IDirect3DTexture8 *m_lpDDSTitle; // CAREFUL: MIGHT BE NULL (if not enough mem)!
int m_nTitleTexSizeX, m_nTitleTexSizeY;
SPRITEVERTEX *m_verts;
char* CPluginShell::GetConfigIniFile() { return m_szConfigIniFile; };
//int CPluginShell::GetFontHeight(eFontIndex idx) { if (idx >= 0 && idx < NUM_BASIC_FONTS + NUM_EXTRA_FONTS) return m_fontinfo[idx].nSize; else return 0; };
int CPluginShell::GetBitDepth() { return m_lpDX->GetBitDepth(); };
-LPDIRECT3DDEVICE9 CPluginShell::GetDevice() { if (m_lpDX) return m_lpDX->m_lpDevice; else return NULL; };
+DX11Context* CPluginShell::GetDevice() { if (m_lpDX) return m_lpDX->m_lpDevice; else return NULL; };
D3DCAPS9* CPluginShell::GetCaps() { if (m_lpDX) return &(m_lpDX->m_caps); else return NULL; };
D3DFORMAT CPluginShell::GetBackBufFormat() { if (m_lpDX) return m_lpDX->m_current_mode.display_mode.Format; else return D3DFMT_UNKNOWN; };
D3DFORMAT CPluginShell::GetBackBufZFormat() { if (m_lpDX) return m_lpDX->GetZFormat(); else return D3DFMT_UNKNOWN; };
#endif
}
-int CPluginShell::AllocateFonts(IDirect3DDevice9* pDevice)
+int CPluginShell::AllocateFonts(DX11Context* pDevice)
{
#if 0
// Create D3DX system font:
{
// m_lpDX = new DXContext(m_hWndWinamp,m_hInstance,CLASSNAME,WINDOWCAPTION,CPluginShell::WindowProc,(LONG)this, m_minimize_winamp, m_szConfigIniFile);
- m_lpDX = new DXContext(m_device, m_szConfigIniFile);
+ m_lpDX = new DXContext(m_device, m_context, m_szConfigIniFile);
if (!m_lpDX)
{
// MessageBox(NULL, "Unable to initialize DXContext;\rprobably out of memory.", "ERROR", MB_OK|MB_SETFOREGROUND|MB_TOPMOST);
void CPluginShell::CleanUpDirectX()
{
SafeDelete(m_lpDX);
+ SafeRelease(m_device);
}
int CPluginShell::PluginPreInitialize(HWND hWinampWnd, HINSTANCE hWinampInstance)
return TRUE;
}
-int CPluginShell::PluginInitialize(LPDIRECT3DDEVICE9 device, int iPosX, int iPosY, int iWidth, int iHeight, float pixelRatio)
+int CPluginShell::PluginInitialize(ID3D11DeviceContext* context, int iPosX, int iPosY, int iWidth, int iHeight, float pixelRatio)
{
// note: initialize GDI before DirectX. Also separate them because
// when we change windowed<->fullscreen, or lose the device and restore it,
// we don't want to mess with any (persistent) GDI stuff.
- m_device = device;
+ m_context = context;
+ context->GetDevice(&m_device);
if (!InitDirectX()) return FALSE; // gives its own error messages
m_lpDX->m_client_width = iWidth;
m_lpDX->m_client_height = iHeight;
}
}
-void CPluginShell::PrepareFor2DDrawing_B(IDirect3DDevice9 *pDevice, int w, int h)
+void CPluginShell::PrepareFor2DDrawing_B(DX11Context *pDevice, int w, int h)
{
// New 2D drawing area will have x,y coords in the range <-1,-1> .. <1,1>
// +--------+ Y=-1
// before rendering primitives!
// Also, be sure your sprites have a z coordinate of 0.
- pDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
- pDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
- pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- pDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
-// pDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
- pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
- pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_LOCALVIEWER, FALSE );
- pDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
-
+ // Setup DX11 stuff
+ pDevice->SetDepth(false);
+ pDevice->SetRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID);
pDevice->SetTexture(0, NULL);
pDevice->SetTexture(1, NULL);
- pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
- pDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
- pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
- pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
- pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );
- pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT );
- pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );
-
- pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
-
- pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
+ pDevice->SetSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP); // or WRAP?! TODO DX11
+ pDevice->SetShader(1); // see DX11Contex implementation
+ pDevice->SetBlendState(false, D3D11_BLEND_ONE, D3D11_BLEND_ZERO);
+
+ //pDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
+ //pDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
+ //pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
+ //pDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
+// pDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
+ //pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
+ //pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_LOCALVIEWER, FALSE );
+ //pDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
+
+ //pDevice->SetTexture(0, NULL);
+ //pDevice->SetTexture(1, NULL);
+ //pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
+ //pDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
+ //pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
+ //pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
+ //pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );
+ //pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+ //pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT );
+ //pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );
+
+ //pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
+ //pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
+ //pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
+
+ //pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
// set up for 2D drawing:
{
- D3DXMATRIX Ortho2D;
- D3DXMATRIX Identity;
-
- D3DXMatrixOrthoLH(&Ortho2D, w, h, 0.0f, 1.0f);
- D3DXMatrixIdentity(&Identity);
+ DirectX::XMMATRIX Ortho2D = DirectX::XMMatrixOrthographicLH(w, h, 0.0f, 1.0f);
+ DirectX::XMMATRIX Identity = DirectX::XMMatrixIdentity();
pDevice->SetTransform(D3DTS_PROJECTION, &Ortho2D);
pDevice->SetTransform(D3DTS_WORLD, &Identity);
int GetWidth(); // returns width of plugin window interior, in pixels.
int GetHeight(); // returns height of plugin window interior, in pixels.
int GetBitDepth(); // returns 8, 16, 24 (rare), or 32
- LPDIRECT3DDEVICE9 GetDevice(); // returns a pointer to the DirectX 8 Device. NOT persistent; can change!
+ DX11Context* GetDevice(); // returns a pointer to the DirectX 8 Device. NOT persistent; can change!
D3DCAPS9* GetCaps(); // returns a pointer to the D3DCAPS8 structer for the device. NOT persistent; can change.
D3DFORMAT GetBackBufFormat(); // returns the pixelformat of the back buffer (probably D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5, D3DFMT_A4R4G4B4, D3DFMT_R3G3B2, D3DFMT_A8R3G3B2, D3DFMT_X4R4G4B4, or D3DFMT_UNKNOWN)
D3DFORMAT GetBackBufZFormat(); // returns the pixelformat of the back buffer's Z buffer (probably D3DFMT_D16_LOCKABLE, D3DFMT_D32, D3DFMT_D15S1, D3DFMT_D24S8, D3DFMT_D16, D3DFMT_D24X8, D3DFMT_D24X4S4, or D3DFMT_UNKNOWN)
DXContext* m_lpDX; // pointer to DXContext object
char m_szPluginsDirPath[MAX_PATH]; // usually 'c:\\program files\\winamp\\plugins\\'
char m_szConfigIniFile[MAX_PATH]; // usually 'c:\\program files\\winamp\\plugins\\something.ini' - filename is determined from identifiers in 'defines.h'
- LPDIRECT3DDEVICE9 m_device;
+ ID3D11Device* m_device;
+ ID3D11DeviceContext* m_context;
// FONTS
IDirect3DTexture9* m_lpDDSText;
// LPD3DXFONT m_d3dx_font[NUM_BASIC_FONTS + NUM_EXTRA_FONTS];
// called by vis.cpp, on behalf of Winamp:
int PluginPreInitialize(HWND hWinampWnd, HINSTANCE hWinampInstance);
- int PluginInitialize(LPDIRECT3DDEVICE9 device, int iPosX, int iPosY, int iWidth, int iHeight, float pixelRatio);
+ int PluginInitialize(ID3D11DeviceContext* context, int iPosX, int iPosY, int iWidth, int iHeight, float pixelRatio);
int PluginRender(unsigned char *pWaveL, unsigned char *pWaveR);
void PluginQuit();
int AllocateDX8Stuff();
void CleanUpNonDx8Stuff();
int InitVJStuff(RECT* pClientRect=NULL);
void CleanUpVJStuff();
- int AllocateFonts(IDirect3DDevice9 *pDevice);
+ int AllocateFonts(DX11Context *pDevice);
void CleanUpFonts();
void AllocateTextSurface();
void ToggleDesktop();
void OnUserResizeWindow();
void OnUserResizeTextWindow();
- void PrepareFor2DDrawing_B(IDirect3DDevice9 *pDevice, int w, int h);
+ void PrepareFor2DDrawing_B(DX11Context *pDevice, int w, int h);
void RenderBuiltInTextMsgs();
public:
void ToggleFullScreen();
int m_nTextWndHeight;
bool m_bTextWindowClassRegistered;
LPDIRECT3D9 m_vjd3d8;
- LPDIRECT3DDEVICE9 m_vjd3d8_device;
+ DX11Context* m_vjd3d8_device;
//HDC m_memDC; // memory device context
//HBITMAP m_memBM, m_oldBM;
//HBRUSH m_hBlackBrush;
void SaveAdapter(int screenmode);
void SaveMaxFps(int screenmode);
void OnTabChanged(int nNewTab);
- LPDIRECT3DDEVICE9 GetTextDevice() { return (m_vjd3d8_device) ? m_vjd3d8_device : m_lpDX->m_lpDevice; }
+ DX11Context* GetTextDevice() { return (m_vjd3d8_device) ? m_vjd3d8_device : m_lpDX->m_lpDevice; }
};
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
+#include <DirectXMath.h>
bool g_bDebugOutput = false;
bool g_bDumpFileCleared = false;
float fov_in_degrees,
float near_clip,
float far_clip,
- D3DXVECTOR3* pvEye,
- D3DXVECTOR3* pvLookat,
- D3DXVECTOR3* pvUp
+ XMFLOAT3* pvEye,
+ XMFLOAT3* pvLookat,
+ XMFLOAT3* pvUp
)
{
#if 0
#endif
}
-void PrepareFor2DDrawing(IDirect3DDevice9 *pDevice)
+void PrepareFor2DDrawing(DX11Context* pDevice)
{
// New 2D drawing area will have x,y coords in the range <-1,-1> .. <1,1>
// +--------+ Y=-1
// 2. SetTexture(), if you need it
// before rendering primitives!
// Also, be sure your sprites have a z coordinate of 0.
- pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
- pDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
- pDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
- pDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
- pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- pDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
-// d3dSetRenderState( D3DRS_CLIPPING, TRUE );
- pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
- pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
- pDevice->SetRenderState( D3DRS_LOCALVIEWER, FALSE );
-
+
+ // Setup DX11 stuff
+ pDevice->SetDepth(true);
+ pDevice->SetRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID);
+ pDevice->SetSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP); // or CLAMP?! TODO DX11
+ pDevice->SetShader(1); // see DX11Context implementation
+ pDevice->SetBlendState(false, D3D11_BLEND_ONE, D3D11_BLEND_ZERO);
pDevice->SetTexture(0, NULL);
pDevice->SetTexture(1, NULL);
+
+ //pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
+ //pDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
+ //pDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
+ //pDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
+ //pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
+ //pDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
+// d3dSetRenderState( D3DRS_CLIPPING, TRUE );
+ //pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
+ //pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
+ //pDevice->SetRenderState( D3DRS_LOCALVIEWER, FALSE );
+
+ //pDevice->SetTexture(0, NULL);
+ //pDevice->SetTexture(1, NULL);
// SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
// SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_POINT);//D3DTEXF_LINEAR);
- pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- pDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
- pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
- pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );
- pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
- pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT );
- pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );
-
- pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
-
- pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
+ //pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ //pDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+ //pDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
+ //pDevice->SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
+ //pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );
+ //pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+ //pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT );
+ //pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE );
+
+ //pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
+ //pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
+ //pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
+ //pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
// set up for 2D drawing:
{
- D3DXMATRIX Ortho2D;
- D3DXMATRIX Identity;
-
- D3DXMatrixOrthoLH(&Ortho2D, 2.0f, -2.0f, 0.0f, 1.0f);
- D3DXMatrixIdentity(&Identity);
+ DirectX::XMMATRIX Ortho2D = DirectX::XMMatrixOrthographicLH(2.0f, -2.0f, 0.0f, 1.0f);
+ DirectX::XMMATRIX Identity = DirectX::XMMatrixIdentity();
pDevice->SetTransform(D3DTS_PROJECTION, &Ortho2D);
pDevice->SetTransform(D3DTS_WORLD, &Identity);
//---------------------------------------------------
-void MakeWorldMatrix( D3DXMATRIX* pOut,
+void MakeWorldMatrix( XMMATRIX* pOut,
float xpos, float ypos, float zpos,
float sx, float sy, float sz,
float pitch, float yaw, float roll)
#endif
}
-void MakeProjectionMatrix( D3DXMATRIX* pOut,
+void MakeProjectionMatrix( XMMATRIX* pOut,
const float near_plane, // Distance to near clipping plane
const float far_plane, // Distance to far clipping plane
const float fov_horiz, // Horizontal field of view angle, in radians
float h = (float)1/tanf(fov_vert*0.5f); // 1/tan(x) == cot(x)
float Q = far_plane/(far_plane - near_plane);
- ZeroMemory(pOut, sizeof(D3DXMATRIX));
- pOut->_11 = w;
- pOut->_22 = h;
- pOut->_33 = Q;
- pOut->_43 = -Q*near_plane;
- pOut->_34 = 1;
+ *pOut = XMMATRIX( w, 0.0f, 0.0f, 0.0f,
+ 0.0f, h, 0.0f, 0.0f,
+ 0.0f, 0.0f, Q, 1.0f,
+ 0.0f, 0.0f, -Q*near_plane, 0.0f);
}
//---------------------------------------------------
#define __NULLSOFT_DX8_EXAMPLE_PLUGIN_SUPPORT_H__ 1
#include <windows.h>
//#include <xtl.h>
-#include <d3dx9.h>
+#include <d3d9.h>
+#include "../DX11Context.h"
//extern "C" void SetTextureStageState( int x, DWORD dwY, DWORD dwZ);
//extern "C" void d3dSetSamplerState( int x, DWORD dwY, DWORD dwZ);
//extern "C" void d3dSetRenderState(DWORD dwY, DWORD dwZ);
-void MakeWorldMatrix( D3DXMATRIX* pOut,
+using namespace DirectX;
+
+void MakeWorldMatrix( XMMATRIX* pOut,
float xpos, float ypos, float zpos,
float sx, float sy, float sz,
float pitch, float yaw, float roll);
-void MakeProjectionMatrix( D3DXMATRIX* pOut,
+void MakeProjectionMatrix( XMMATRIX* pOut,
const float near_plane, // Distance to near clipping plane
const float far_plane, // Distance to far clipping plane
const float fov_horiz, // Horizontal field of view angle, in radians
const float fov_vert); // Vertical field of view angle, in radians
void PrepareFor3DDrawing(
- IDirect3DDevice9 *pDevice,
+ DX11Context* *pDevice,
int viewport_width,
int viewport_height,
float fov_in_degrees,
float near_clip,
float far_clip,
- D3DXVECTOR3* pvEye,
- D3DXVECTOR3* pvLookat,
- D3DXVECTOR3* pvUp
+ XMFLOAT3* pvEye,
+ XMFLOAT3* pvLookat,
+ XMFLOAT3* pvUp
);
-void PrepareFor2DDrawing(IDirect3DDevice9 *pDevice);
+void PrepareFor2DDrawing(DX11Context *pDevice);
// Define vertex formats you'll be using here:
typedef struct _MYVERTEX
{
float x, y; // screen position
float z; // Z-buffer depth
- DWORD Diffuse; // diffuse color
+ float r; float g; float b; float a; // diffuse color
float tu1, tv1; // texture coordinates for texture #0
float tu2, tv2; // texture coordinates for texture #1
// note: even though tu2/tv2 aren't used when multitexturing is off,
typedef struct _WFVERTEX
{
float x, y, z;
- DWORD Diffuse; // diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
-} WFVERTEX, *LPWFVERTEX;
+ float r; float g; float b; float a; // diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
+} WFVERTEX, *LPWFVERTEX;
typedef struct _SPRITEVERTEX
{
float x, y; // screen position
float z; // Z-buffer depth
- DWORD Diffuse; // diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
+ float r; float g; float b; float a;// diffuse color. also acts as filler; aligns struct to 16 bytes (good for random access/indexed prims)
float tu, tv; // texture coordinates for texture #0
} SPRITEVERTEX, *LPSPRITEVERTEX;