mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Melhoria em uso de Effect em SpriteBatch.Begin
This commit is contained in:
parent
0ce4255e10
commit
1c432de78f
@ -22,6 +22,7 @@ project ("xna")
|
||||
# Include sub-projects.
|
||||
include_directories(${PROJECT_INCLUDES_DIR})
|
||||
add_subdirectory ("framework")
|
||||
add_subdirectory ("samples")
|
||||
|
||||
#add_subdirectory ("samples")
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@ namespace xna {
|
||||
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
|
||||
_description.StencilReadMask = IntMaxValue;
|
||||
_description.StencilWriteMask = IntMaxValue;
|
||||
_description.StencilReadMask = static_cast<UINT8>(IntMaxValue);
|
||||
_description.StencilWriteMask = static_cast<UINT8>(IntMaxValue);
|
||||
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||
|
||||
return _description;
|
||||
|
@ -150,27 +150,38 @@ namespace xna {
|
||||
t.M21, t.M22, t.M23, t.M24,
|
||||
t.M31, t.M32, t.M33, t.M34,
|
||||
t.M41, t.M42, t.M43, t.M44);
|
||||
|
||||
std::function<void __cdecl()> effectFunc = nullptr;
|
||||
|
||||
if (effect && !impl->dxInputLayout) {
|
||||
void const* shaderByteCode;
|
||||
size_t byteCodeLength;
|
||||
//if Effect is not null set effectBuffer and inputLayout
|
||||
if (effect && effect->impl) {
|
||||
bool effectBufferChanged = false;
|
||||
|
||||
effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
||||
if (!impl->effectBuffer || impl->effectBuffer != effect->impl->dxEffect) {
|
||||
impl->effectBuffer = effect->impl->dxEffect;
|
||||
effectBufferChanged = true;
|
||||
}
|
||||
|
||||
m_device->impl->_device->CreateInputLayout(
|
||||
DirectX::VertexPositionColorTexture::InputElements,
|
||||
DirectX::VertexPositionColorTexture::InputElementCount,
|
||||
shaderByteCode, byteCodeLength,
|
||||
impl->dxInputLayout.GetAddressOf());
|
||||
}
|
||||
if (effectBufferChanged) {
|
||||
void const* shaderByteCode;
|
||||
size_t byteCodeLength;
|
||||
|
||||
auto& context = m_device->impl->_context;
|
||||
effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
||||
|
||||
std::function funcEffect = [=] {
|
||||
effect->impl->dxEffect->Apply(context.Get());
|
||||
context->IASetInputLayout(impl->dxInputLayout.Get());
|
||||
};
|
||||
std::function funcVoid = [=] {};
|
||||
m_device->impl->_device->CreateInputLayout(
|
||||
DirectX::VertexPositionColorTexture::InputElements,
|
||||
DirectX::VertexPositionColorTexture::InputElementCount,
|
||||
shaderByteCode, byteCodeLength,
|
||||
impl->dxInputLayout.GetAddressOf());
|
||||
}
|
||||
|
||||
auto& context = m_device->impl->_context;
|
||||
|
||||
effectFunc = [=] {
|
||||
impl->effectBuffer->Apply(context.Get());
|
||||
context->IASetInputLayout(impl->dxInputLayout.Get());
|
||||
};
|
||||
}
|
||||
|
||||
impl->_dxspriteBatch->Begin(
|
||||
sort,
|
||||
@ -178,7 +189,7 @@ namespace xna {
|
||||
samplerState ? samplerState->impl->_samplerState.Get() : nullptr,
|
||||
depthStencil ? depthStencil->impl->dxDepthStencil.Get() : nullptr,
|
||||
rasterizerState ? rasterizerState->impl->dxRasterizerState.Get() : nullptr,
|
||||
effect ? funcEffect : funcVoid,
|
||||
effectFunc,
|
||||
matrix
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#ifndef XNA_PLATFORMDX_DX_HPP
|
||||
#define XNA_PLATFORMDX_DX_HPP
|
||||
#ifndef XNA_XNA_DX_HPP
|
||||
#define XNA_XNA_DX_HPP
|
||||
|
||||
#define NOMINMAX
|
||||
|
||||
//---------------- DX INCLUDES ----------------//
|
||||
|
||||
@ -12,10 +14,12 @@
|
||||
#include "d3d11.h"
|
||||
#include <d3d11_1.h>
|
||||
#include <d3d11_2.h>
|
||||
//HSLS AND EFFECTS
|
||||
#include <d3dcompiler.h>
|
||||
#include <d3d11_3.h>
|
||||
#include <d3d11_4.h>
|
||||
#include <d3d11shader.h>
|
||||
#include "effects11/d3dx11effect.h"
|
||||
#include <d3d11shadertracing.h>
|
||||
#include <d3dcommon.h>
|
||||
#include <d3dcsx.h>
|
||||
//DirectXTK
|
||||
#include <DirectXMath.h>
|
||||
#include <Audio.h>
|
||||
@ -39,7 +43,6 @@
|
||||
#include <VertexTypes.h>
|
||||
#include <WICTextureLoader.h>
|
||||
//Windows
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <Windows.Foundation.h>
|
||||
@ -62,7 +65,7 @@ namespace xna {
|
||||
|
||||
struct DxHelpers {
|
||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
|
||||
DirectX::XMVECTOR v;
|
||||
DirectX::XMVECTOR v{};
|
||||
|
||||
v.m128_f32[0] = value.X;
|
||||
v.m128_f32[1] = value.Y;
|
||||
@ -72,7 +75,7 @@ namespace xna {
|
||||
|
||||
|
||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector3 const& value) {
|
||||
DirectX::XMVECTOR v;
|
||||
DirectX::XMVECTOR v{};
|
||||
|
||||
v.m128_f32[0] = value.X;
|
||||
v.m128_f32[1] = value.Y;
|
||||
@ -82,7 +85,7 @@ namespace xna {
|
||||
}
|
||||
|
||||
static constexpr DirectX::XMFLOAT3 Vector3ToDx(Vector3 const& value) {
|
||||
DirectX::XMFLOAT3 v;
|
||||
DirectX::XMFLOAT3 v{};
|
||||
|
||||
v.x = value.X;
|
||||
v.y = value.Y;
|
||||
@ -92,7 +95,7 @@ namespace xna {
|
||||
}
|
||||
|
||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector4 const& value) {
|
||||
DirectX::XMVECTOR v;
|
||||
DirectX::XMVECTOR v{};
|
||||
|
||||
v.m128_f32[0] = value.X;
|
||||
v.m128_f32[1] = value.Y;
|
||||
@ -554,7 +557,7 @@ namespace xna {
|
||||
uint64_t m_targetElapsedTicks;
|
||||
};
|
||||
|
||||
//---------------- IMPL ----------------//
|
||||
//---------------- IMPLEMENTATIONS ----------------//
|
||||
|
||||
struct SpriteFont::PlatformImplementation {
|
||||
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };
|
||||
@ -563,6 +566,7 @@ namespace xna {
|
||||
struct SpriteBatch::PlatformImplementation {
|
||||
sptr<DirectX::SpriteBatch> _dxspriteBatch = nullptr;
|
||||
comptr<ID3D11InputLayout> dxInputLayout = nullptr;
|
||||
sptr<DirectX::DX11::IEffect> effectBuffer = nullptr;
|
||||
};
|
||||
|
||||
struct GraphicsAdapter::PlatformImplementation {
|
||||
@ -683,7 +687,7 @@ namespace xna {
|
||||
DXGI_SWAP_CHAIN_DESC1 dxDescription{};
|
||||
DXGI_SWAP_CHAIN_FULLSCREEN_DESC dxFullScreenDescription{};
|
||||
|
||||
bool GetBackBuffer(comptr<ID3D11Texture2D>& texture2D) {
|
||||
bool GetBackBuffer(comptr<ID3D11Texture2D>& texture2D) const {
|
||||
if (!dxSwapChain)
|
||||
return false;
|
||||
|
||||
@ -769,7 +773,7 @@ namespace xna {
|
||||
ShowCursor(visible);
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
inline void Close() const {
|
||||
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
#include "xna/xna.hpp"
|
||||
#include "xna/xna-dx.hpp"
|
Loading…
x
Reference in New Issue
Block a user