#pragma region CPL License
/*
Nuclex Native Framework
Copyright (C) 2002-2013 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library 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
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#pragma endregion // CPL License
#ifndef NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11POLYGONOPTIONSOBSERVER_H
#define NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11POLYGONOPTIONSOBSERVER_H
#include "Nuclex/Graphics/Config.h"
#include "Nuclex/Graphics/Rasterization/PolygonOptions.h"
#include "../Direct3D11Api.h"
namespace Nuclex { namespace Graphics { namespace Rasterization {
// ------------------------------------------------------------------------------------------- //
class Direct3D11RasterizerResources;
// ------------------------------------------------------------------------------------------- //
}}} // namespace Nuclex::Graphics::Rasterization
namespace Nuclex { namespace Graphics { namespace Rasterization {
// ------------------------------------------------------------------------------------------- //
///Manages an attached Direct3D 11 rasterizer state
class Direct3D11PolygonOptionsObserver : public PolygonOptions::Observer {
/// Initializes a new Direct3D 11 rasterizer state
/// Manager the index buffer belongs to
/// Polygon options the observer is attached to
public: Direct3D11PolygonOptionsObserver(
Direct3D11RasterizerResources &resources, PolygonOptions *polygonOptions
);
/// Frees all resources owned by the polygon options observer
public: virtual ~Direct3D11PolygonOptionsObserver();
/// Called right before the options are destroyed
public: void Destroying();
/// Called when the options have been changed
public: void Changed();
/// Retrieves the agnostic polygon options being observed
/// The agnostic polygon options being observed
public: PolygonOptions *GetResource() const { return this->polygonOptions; }
/// Retrieves the Direct3D rasterizer state the observer is managing
/// The observer's Direct3D rasterizer state
public: const ID3D11RasterizerStateNPtr &GetDirect3DRasterizerState() const {
return this->direct3DRasterizerState;
}
///
/// Creates a Direct3D rasterizer state matching the observed polygon options
///
private: void createDirect3DRasterizerState();
private: Direct3D11PolygonOptionsObserver(const Direct3D11PolygonOptionsObserver &);
private: Direct3D11PolygonOptionsObserver &operator =(
const Direct3D11PolygonOptionsObserver &
);
/// Resource manager the polygon options observer belongs to
private: Direct3D11RasterizerResources &resources;
/// Polygon options this observer is attached to
private: PolygonOptions *polygonOptions;
/// Rasterizer state managed by this observer
private: ID3D11RasterizerStateNPtr direct3DRasterizerState;
};
// ------------------------------------------------------------------------------------------- //
}}} // namespace Nuclex::Graphics::Rasterization
#endif // NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11POLYGONOPTIONSOBSERVER_H