mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implemetanções em GraphicsDevice
This commit is contained in:
parent
513292aae7
commit
b983ebcf74
@ -41,7 +41,7 @@ add_library (Xn65 STATIC
|
||||
"platform-dx/displaymode.cpp"
|
||||
"platform-dx/init.cpp"
|
||||
"platform-dx/buffer.cpp"
|
||||
"platform-dx/audioengine.cpp" "graphics/gresource.cpp" "platform-dx/effect.cpp")
|
||||
"platform-dx/audioengine.cpp" "graphics/gresource.cpp" "platform-dx/effect.cpp" "platform-dx/impl.cpp")
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||
set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20)
|
||||
|
@ -57,6 +57,22 @@ namespace xna {
|
||||
}
|
||||
}
|
||||
|
||||
void initAndApplyState(GraphicsDevice::PlatformImplementation& impl, PGraphicsDevice const& device) {
|
||||
impl._blendState->Bind(device);
|
||||
impl._blendState->Initialize();
|
||||
impl._blendState->Apply();
|
||||
|
||||
impl._rasterizerState->Bind(device);
|
||||
impl._rasterizerState->Initialize();
|
||||
impl._rasterizerState->Apply();
|
||||
|
||||
impl._depthStencilState->Bind(device);
|
||||
impl._depthStencilState->Initialize();
|
||||
impl._depthStencilState->Apply();
|
||||
|
||||
impl._samplerStates->Apply(*device);
|
||||
}
|
||||
|
||||
GraphicsDevice::GraphicsDevice() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->_adapter = GraphicsAdapter::DefaultAdapter();
|
||||
@ -131,7 +147,7 @@ namespace xna {
|
||||
|
||||
impl->_context->RSSetViewports(1, &view);
|
||||
|
||||
impl->InitializeAndApplyStates(_this);
|
||||
initAndApplyState(*impl, _this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -143,13 +159,7 @@ namespace xna {
|
||||
impl->_context->OMSetRenderTargets(1, &impl->_renderTarget2D->render_impl->_renderTargetView, nullptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void GraphicsDevice::Clear() {
|
||||
if (!impl) return;
|
||||
|
||||
impl->_context->ClearRenderTargetView(impl->_renderTarget2D->render_impl->_renderTargetView, impl->_backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDevice::Clear(Color const& color) {
|
||||
if (!impl) return;
|
||||
@ -160,12 +170,37 @@ namespace xna {
|
||||
impl->_backgroundColor[1] = v4.Y;
|
||||
impl->_backgroundColor[2] = v4.Z;
|
||||
impl->_backgroundColor[3] = v4.W;
|
||||
|
||||
|
||||
impl->_context->ClearRenderTargetView(
|
||||
impl->_renderTarget2D->render_impl->_renderTargetView,
|
||||
impl->_backgroundColor);
|
||||
}
|
||||
|
||||
void GraphicsDevice::Clear(ClearOptions options, Color const& color, float depth, Int stencil) {
|
||||
if (!impl) return;
|
||||
|
||||
switch (options)
|
||||
{
|
||||
case xna::ClearOptions::DepthBuffer:
|
||||
Exception::Throw(ExMessage::NotImplemented);
|
||||
break;
|
||||
case xna::ClearOptions::Stencil:
|
||||
Exception::Throw(ExMessage::NotImplemented);
|
||||
break;
|
||||
case xna::ClearOptions::Target:
|
||||
Clear(color);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsDevice::Clear(ClearOptions options, Vector4 const& color, float depth, Int stencil) {
|
||||
if (!impl) return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
sptr<GraphicsAdapter> GraphicsDevice::Adapter() const {
|
||||
if (!impl) return nullptr;
|
||||
|
||||
|
5
framework/platform-dx/impl.cpp
Normal file
5
framework/platform-dx/impl.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "xna/platform-dx/dx.hpp"
|
||||
|
||||
namespace xna {
|
||||
|
||||
}
|
@ -114,6 +114,12 @@ namespace xna {
|
||||
Pressed,
|
||||
};
|
||||
|
||||
enum class ClearOptions {
|
||||
DepthBuffer,
|
||||
Stencil,
|
||||
Target,
|
||||
};
|
||||
|
||||
enum class ColorWriteChannels {
|
||||
Red,
|
||||
Green,
|
||||
|
@ -16,6 +16,7 @@ namespace xna {
|
||||
inline static const std::string UnintializedComponent = "Component is not initialized";
|
||||
inline static const std::string MakeWindowAssociation = "Failed to create association with window";
|
||||
inline static const std::string BuildObject = "Unable to build object";
|
||||
inline static const std::string NotImplemented = "Not Implemented";
|
||||
};
|
||||
|
||||
//Structure for throwing exceptions with a message and information from the source file
|
||||
|
@ -32,9 +32,10 @@ namespace xna {
|
||||
Int MultiSampleMask() const;
|
||||
//Gets or sets a bitmask controlling modification of the samples in a multisample render target. The default value is -1 (0xffffffff).
|
||||
void MultiSampleMask(Int value);
|
||||
|
||||
void Clear();
|
||||
|
||||
void Clear(Color const& color);
|
||||
void Clear(ClearOptions options, Color const& color, float depth, Int stencil);
|
||||
void Clear(ClearOptions options, Vector4 const& color, float depth, Int stencil);
|
||||
bool Initialize();
|
||||
bool Present();
|
||||
|
||||
|
@ -91,6 +91,10 @@ namespace xna {
|
||||
return samplers[index];
|
||||
}
|
||||
|
||||
constexpr size_t Count() const {
|
||||
return samplers.size();
|
||||
}
|
||||
|
||||
void Apply(GraphicsDevice const& device);
|
||||
|
||||
public:
|
||||
|
@ -951,24 +951,7 @@ namespace xna {
|
||||
_factory->Release();
|
||||
_factory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeAndApplyStates(PGraphicsDevice const& device) {
|
||||
_blendState->Bind(device);
|
||||
_blendState->Initialize();
|
||||
_blendState->Apply();
|
||||
|
||||
_rasterizerState->Bind(device);
|
||||
_rasterizerState->Initialize();
|
||||
_rasterizerState->Apply();
|
||||
|
||||
_depthStencilState->Bind(device);
|
||||
_depthStencilState->Initialize();
|
||||
_depthStencilState->Apply();
|
||||
|
||||
_samplerStates->Apply(*device);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
ID3D11Device* _device = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user