2019-04-11 14:40:54 +08:00
|
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2019-03-31 01:37:06 +08:00
|
|
|
|
//
|
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
|
//
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
|
//
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2019-11-13 14:33:15 +08:00
|
|
|
|
#include <kiwano/core/Component.h>
|
2019-10-11 21:55:29 +08:00
|
|
|
|
#include <kiwano/renderer/win32/FontCollectionLoader.h>
|
|
|
|
|
|
#include <kiwano/renderer/RenderTarget.h>
|
|
|
|
|
|
#include <kiwano/renderer/GifImage.h>
|
2019-12-26 19:25:43 +08:00
|
|
|
|
#include <kiwano/renderer/Font.h>
|
|
|
|
|
|
#include <kiwano/renderer/TextStyle.hpp>
|
2019-07-30 00:41:06 +08:00
|
|
|
|
|
|
|
|
|
|
#if defined(KGE_USE_DIRECTX10)
|
2019-10-14 10:43:11 +08:00
|
|
|
|
# include "win32/D3D10DeviceResources.h"
|
2019-07-30 00:41:06 +08:00
|
|
|
|
#else
|
2019-08-18 10:23:54 +08:00
|
|
|
|
# include "win32/D3D11DeviceResources.h"
|
2019-07-30 00:41:06 +08:00
|
|
|
|
#endif
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
namespace kiwano
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-07-30 00:41:06 +08:00
|
|
|
|
|
|
|
|
|
|
#if defined(KGE_USE_DIRECTX10)
|
|
|
|
|
|
typedef ID3D10DeviceResources ID3DDeviceResources;
|
|
|
|
|
|
#else
|
|
|
|
|
|
typedef ID3D11DeviceResources ID3DDeviceResources;
|
|
|
|
|
|
#endif
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-12-31 16:01:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* \~chinese
|
|
|
|
|
|
* \defgroup Render <EFBFBD><EFBFBD>Ⱦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \addtogroup Render
|
|
|
|
|
|
* @{
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* \~chinese
|
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>Ⱦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*/
|
2019-08-23 13:00:43 +08:00
|
|
|
|
struct RenderConfig
|
|
|
|
|
|
{
|
2019-12-29 18:58:22 +08:00
|
|
|
|
Color clear_color; ///< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
bool vsync; ///< <20><>ֱͬ<D6B1><CDAC>
|
2019-08-23 13:00:43 +08:00
|
|
|
|
|
|
|
|
|
|
RenderConfig(
|
|
|
|
|
|
Color clear_color = Color::Black,
|
|
|
|
|
|
bool vsync = true
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-08-21 16:33:41 +08:00
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* \~chinese
|
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>Ⱦ<EFBFBD><EFBFBD>
|
|
|
|
|
|
*/
|
2019-04-11 14:40:54 +08:00
|
|
|
|
class KGE_API Renderer
|
2019-03-31 01:37:06 +08:00
|
|
|
|
: public Singleton<Renderer>
|
2019-09-10 13:17:47 +08:00
|
|
|
|
, public RenderComponent
|
|
|
|
|
|
, public EventComponent
|
2019-08-16 00:50:54 +08:00
|
|
|
|
, public RenderTarget
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2019-12-20 17:49:16 +08:00
|
|
|
|
friend Singleton<Renderer>;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-08-15 11:22:51 +08:00
|
|
|
|
public:
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
Color const& GetClearColor() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
void SetClearColor(Color const& clear_color);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رմ<D8B1>ֱͬ<D6B1><CDAC>
|
|
|
|
|
|
void SetVSyncEnabled(bool enabled);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>DPI
|
|
|
|
|
|
void SetDpi(float dpi);
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[out] texture <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] file_path ͼƬ·<C6AC><C2B7>
|
2019-08-21 16:33:41 +08:00
|
|
|
|
void CreateTexture(
|
|
|
|
|
|
Texture& texture,
|
2019-08-18 17:49:13 +08:00
|
|
|
|
String const& file_path
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[out] texture <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] resource ͼƬ<CDBC><C6AC>Դ
|
2019-08-21 16:33:41 +08:00
|
|
|
|
void CreateTexture(
|
|
|
|
|
|
Texture& texture,
|
2019-08-23 13:00:43 +08:00
|
|
|
|
Resource const& resource
|
2019-08-16 00:50:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>GIFͼ<46><CDBC>
|
|
|
|
|
|
/// @param[out] gif GIFͼ<46><CDBC>
|
|
|
|
|
|
/// @param[in] file_path ͼƬ·<C6AC><C2B7>
|
2019-08-18 17:49:13 +08:00
|
|
|
|
void CreateGifImage(
|
2019-08-23 13:00:43 +08:00
|
|
|
|
GifImage& gif,
|
2019-08-18 17:49:13 +08:00
|
|
|
|
String const& file_path
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>GIFͼ<46><CDBC>
|
|
|
|
|
|
/// @param[out] gif GIFͼ<46><CDBC>
|
|
|
|
|
|
/// @param[in] resource ͼƬ<CDBC><C6AC>Դ
|
2019-08-16 00:50:54 +08:00
|
|
|
|
void CreateGifImage(
|
2019-08-23 13:00:43 +08:00
|
|
|
|
GifImage& gif,
|
|
|
|
|
|
Resource const& resource
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>GIFͼ<46><CDBC>֡
|
|
|
|
|
|
/// @param[out] frame GIFͼ<46><CDBC>֡
|
|
|
|
|
|
/// @param[in] gif GIFͼ<46><CDBC>
|
|
|
|
|
|
/// @param[in] frame_index ֡<>±<EFBFBD>
|
2019-08-23 13:00:43 +08:00
|
|
|
|
void CreateGifImageFrame(
|
|
|
|
|
|
GifImage::Frame& frame,
|
|
|
|
|
|
GifImage const& gif,
|
2019-10-12 11:26:41 +08:00
|
|
|
|
size_t frame_index
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>弯
|
|
|
|
|
|
/// @param[out] font <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] file_paths <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
2019-08-18 17:49:13 +08:00
|
|
|
|
void CreateFontCollection(
|
2019-12-26 19:25:43 +08:00
|
|
|
|
Font& font,
|
2019-08-18 17:49:13 +08:00
|
|
|
|
Vector<String> const& file_paths
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>弯
|
|
|
|
|
|
/// @param[out] font <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] res_arr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
2019-08-18 17:49:13 +08:00
|
|
|
|
void CreateFontCollection(
|
2019-12-26 19:25:43 +08:00
|
|
|
|
Font& font,
|
2019-08-18 17:49:13 +08:00
|
|
|
|
Vector<Resource> const& res_arr
|
2019-08-18 10:23:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ʽ
|
|
|
|
|
|
/// @param[out] layout <20><><EFBFBD>岼<EFBFBD><E5B2BC>
|
2019-08-15 11:22:51 +08:00
|
|
|
|
void CreateTextFormat(
|
2019-12-26 19:25:43 +08:00
|
|
|
|
TextLayout& layout
|
2019-08-15 11:22:51 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
|
|
|
|
|
|
/// @param[out] layout <20><><EFBFBD>岼<EFBFBD><E5B2BC>
|
2019-08-15 11:22:51 +08:00
|
|
|
|
void CreateTextLayout(
|
2019-12-26 19:25:43 +08:00
|
|
|
|
TextLayout& layout
|
2019-08-15 11:22:51 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>״
|
|
|
|
|
|
/// @param[out] geo <20><>״
|
|
|
|
|
|
/// @param[in] begin_pos <20>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[in] end_pos <20>߶<EFBFBD><DFB6>յ<EFBFBD>
|
2019-08-14 21:38:37 +08:00
|
|
|
|
void CreateLineGeometry(
|
|
|
|
|
|
Geometry& geo,
|
|
|
|
|
|
Point const& begin_pos,
|
|
|
|
|
|
Point const& end_pos
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״
|
|
|
|
|
|
/// @param[out] geo <20><>״
|
|
|
|
|
|
/// @param[in] rect <20><><EFBFBD>δ<EFBFBD>С
|
2019-08-14 21:38:37 +08:00
|
|
|
|
void CreateRectGeometry(
|
|
|
|
|
|
Geometry& geo,
|
|
|
|
|
|
Rect const& rect
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>״
|
|
|
|
|
|
/// @param[out] geo <20><>״
|
|
|
|
|
|
/// @param[in] rect <20><><EFBFBD>δ<EFBFBD>С
|
|
|
|
|
|
/// @param[in] radius Բ<>ǰ뾶
|
2019-08-14 21:38:37 +08:00
|
|
|
|
void CreateRoundedRectGeometry(
|
|
|
|
|
|
Geometry& geo,
|
|
|
|
|
|
Rect const& rect,
|
|
|
|
|
|
Vec2 const& radius
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>״
|
|
|
|
|
|
/// @param[out] geo <20><>״
|
|
|
|
|
|
/// @param[in] center <20><>ԲԲ<D4B2><D4B2>
|
|
|
|
|
|
/// @param[in] radius <20><>Բ<EFBFBD>뾶
|
2019-08-14 21:38:37 +08:00
|
|
|
|
void CreateEllipseGeometry(
|
|
|
|
|
|
Geometry& geo,
|
|
|
|
|
|
Point const& center,
|
|
|
|
|
|
Vec2 const& radius
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param[out] sink <20><>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-12-27 10:51:34 +08:00
|
|
|
|
void CreateGeometrySink(
|
2019-08-14 21:38:37 +08:00
|
|
|
|
GeometrySink& sink
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȾĿ<C8BE><C4BF>
|
|
|
|
|
|
/// @param[out] render_target <20><>ȾĿ<C8BE><C4BF>
|
2019-08-21 16:33:41 +08:00
|
|
|
|
void CreateTextureRenderTarget(
|
2019-12-27 10:51:34 +08:00
|
|
|
|
TextureRenderTargetPtr& render_target
|
2019-03-31 01:37:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>ˢ
|
|
|
|
|
|
/// @param[out] brush <20><>ˢ
|
|
|
|
|
|
/// @param[in] color <20><>ɫ
|
2019-09-09 22:02:53 +08:00
|
|
|
|
void CreateSolidBrush(
|
|
|
|
|
|
Brush& brush,
|
|
|
|
|
|
Color const& color
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>仭ˢ
|
|
|
|
|
|
/// @param[out] brush <20><>ˢ
|
|
|
|
|
|
/// @param[in] begin <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
/// @param[in] end <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>
|
|
|
|
|
|
/// @param[in] stops <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>㼯<EFBFBD><E3BCAF>
|
|
|
|
|
|
/// @param[in] extend_mode <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
2019-09-09 22:02:53 +08:00
|
|
|
|
void CreateLinearGradientBrush(
|
|
|
|
|
|
Brush& brush,
|
|
|
|
|
|
Point const& begin,
|
|
|
|
|
|
Point const& end,
|
|
|
|
|
|
Vector<GradientStop> const& stops,
|
|
|
|
|
|
GradientExtendMode extend_mode
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仭ˢ
|
|
|
|
|
|
/// @param[out] brush <20><>ˢ
|
|
|
|
|
|
/// @param[in] center <20><><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>
|
|
|
|
|
|
/// @param[in] offset <20><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
|
/// @param[in] radius <20><><EFBFBD><EFBFBD><F2BDA5B1>뾶
|
|
|
|
|
|
/// @param[in] stops <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>㼯<EFBFBD><E3BCAF>
|
|
|
|
|
|
/// @param[in] extend_mode <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
2019-09-09 22:02:53 +08:00
|
|
|
|
void CreateRadialGradientBrush(
|
|
|
|
|
|
Brush& brush,
|
|
|
|
|
|
Point const& center,
|
|
|
|
|
|
Vec2 const& offset,
|
|
|
|
|
|
Vec2 const& radius,
|
|
|
|
|
|
Vector<GradientStop> const& stops,
|
|
|
|
|
|
GradientExtendMode extend_mode
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
public:
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡĿ<C8A1>괰<EFBFBD><EAB4B0>
|
|
|
|
|
|
HWND GetTargetWindow() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡ<EFBFBD><C8A1>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
|
Size const& GetOutputSize() const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡDirect2D<32>豸<EFBFBD><E8B1B8>Դ
|
|
|
|
|
|
ID2DDeviceResources* GetD2DDeviceResources();
|
|
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
|
|
|
|
|
/// @brief <20><>ȡDirect3D<33>豸<EFBFBD><E8B1B8>Դ
|
|
|
|
|
|
ID3DDeviceResources* GetD3DDeviceResources();
|
2019-12-28 22:04:08 +08:00
|
|
|
|
|
2019-07-30 13:32:10 +08:00
|
|
|
|
public:
|
2019-08-23 13:00:43 +08:00
|
|
|
|
void Init(RenderConfig const& config);
|
|
|
|
|
|
|
2019-08-12 14:51:54 +08:00
|
|
|
|
void SetupComponent() override;
|
2019-07-30 13:32:10 +08:00
|
|
|
|
|
|
|
|
|
|
void DestroyComponent() override;
|
|
|
|
|
|
|
|
|
|
|
|
void BeforeRender() override;
|
|
|
|
|
|
|
|
|
|
|
|
void AfterRender() override;
|
|
|
|
|
|
|
2019-09-29 22:23:13 +08:00
|
|
|
|
void HandleMessage(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam) override;
|
2019-07-30 13:32:10 +08:00
|
|
|
|
|
2019-03-31 01:37:06 +08:00
|
|
|
|
private:
|
|
|
|
|
|
Renderer();
|
|
|
|
|
|
|
|
|
|
|
|
~Renderer();
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT HandleDeviceLost();
|
|
|
|
|
|
|
2019-10-12 11:26:41 +08:00
|
|
|
|
void ResizeTarget(uint32_t width, uint32_t height);
|
2019-08-20 23:51:12 +08:00
|
|
|
|
|
2019-08-14 08:52:01 +08:00
|
|
|
|
private:
|
2019-09-10 14:10:13 +08:00
|
|
|
|
bool vsync_;
|
|
|
|
|
|
HWND hwnd_;
|
|
|
|
|
|
Color clear_color_;
|
|
|
|
|
|
Size output_size_;
|
|
|
|
|
|
|
|
|
|
|
|
ComPtr<ID2DDeviceResources> d2d_res_;
|
|
|
|
|
|
ComPtr<ID3DDeviceResources> d3d_res_;
|
|
|
|
|
|
ComPtr<ID2D1DrawingStateBlock> drawing_state_block_;
|
2019-08-18 10:23:54 +08:00
|
|
|
|
ComPtr<IFontCollectionLoader> font_collection_loader_;
|
|
|
|
|
|
ComPtr<IResourceFontFileLoader> res_font_file_loader_;
|
|
|
|
|
|
ComPtr<IResourceFontCollectionLoader> res_font_collection_loader_;
|
2019-03-31 01:37:06 +08:00
|
|
|
|
};
|
2019-12-29 18:58:22 +08:00
|
|
|
|
|
2019-12-31 16:01:41 +08:00
|
|
|
|
/** @} */
|
|
|
|
|
|
|
2019-12-29 18:58:22 +08:00
|
|
|
|
inline HWND Renderer::GetTargetWindow() const { return hwnd_; }
|
|
|
|
|
|
|
|
|
|
|
|
inline Size const& Renderer::GetOutputSize() const { return output_size_; }
|
|
|
|
|
|
|
|
|
|
|
|
inline Color const& Renderer::GetClearColor() const { return clear_color_; }
|
|
|
|
|
|
|
|
|
|
|
|
inline ID2DDeviceResources* Renderer::GetD2DDeviceResources() { KGE_ASSERT(d2d_res_); return d2d_res_.get(); }
|
|
|
|
|
|
|
|
|
|
|
|
inline ID3DDeviceResources* Renderer::GetD3DDeviceResources() { KGE_ASSERT(d3d_res_); return d3d_res_.get(); }
|
2019-03-31 01:37:06 +08:00
|
|
|
|
}
|