add definition of all API symbols declarations for DLL
This commit is contained in:
parent
2c149ff8b1
commit
e88d101855
|
|
@ -28,7 +28,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
class ActionManager;
|
class ActionManager;
|
||||||
|
|
||||||
class Action
|
class E2D_API Action
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, protected IntrusiveListItem<ActionPtr>
|
, protected IntrusiveListItem<ActionPtr>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 循环动作
|
// 循环动作
|
||||||
class Loop
|
class E2D_API Loop
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -61,7 +61,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 顺序动作
|
// 顺序动作
|
||||||
class Sequence
|
class E2D_API Sequence
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -106,7 +106,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 同步动作
|
// 同步动作
|
||||||
class Spawn
|
class E2D_API Spawn
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
struct ActionHelper
|
struct E2D_API ActionHelper
|
||||||
{
|
{
|
||||||
ActionHelper& SetLoopCount(int loop) { this->loop = loop; return (*this); }
|
ActionHelper& SetLoopCount(int loop) { this->loop = loop; return (*this); }
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace easy2d
|
||||||
int loop;
|
int loop;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TweenActionHelper
|
struct E2D_API TweenActionHelper
|
||||||
{
|
{
|
||||||
TweenActionHelper& SetDuration(Duration dur) { this->dur = dur; return (*this); }
|
TweenActionHelper& SetDuration(Duration dur) { this->dur = dur; return (*this); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class ActionManager
|
class E2D_API ActionManager
|
||||||
{
|
{
|
||||||
using Actions = IntrusiveList<ActionPtr>;
|
using Actions = IntrusiveList<ActionPtr>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "ActionTween.h"
|
#include "ActionTween.h"
|
||||||
#include "Geometry.h"
|
|
||||||
#include "include-forwards.h"
|
#include "include-forwards.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Action.hpp"
|
#include "Action.hpp"
|
||||||
#include "logs.h"
|
#include "logs.h"
|
||||||
|
#include "Geometry.h" // PathAction
|
||||||
#include "../math/ease.hpp"
|
#include "../math/ease.hpp"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -32,37 +33,37 @@ namespace easy2d
|
||||||
// See https://easings.net for more information
|
// See https://easings.net for more information
|
||||||
struct Ease
|
struct Ease
|
||||||
{
|
{
|
||||||
static EaseFunc Linear; // 线性
|
static E2D_API EaseFunc Linear; // 线性
|
||||||
static EaseFunc EaseIn; // 由慢变快
|
static E2D_API EaseFunc EaseIn; // 由慢变快
|
||||||
static EaseFunc EaseOut; // 由快变慢
|
static E2D_API EaseFunc EaseOut; // 由快变慢
|
||||||
static EaseFunc EaseInOut; // 由慢变快, 再由快变慢
|
static E2D_API EaseFunc EaseInOut; // 由慢变快, 再由快变慢
|
||||||
static EaseFunc ExpoIn; // 由慢变极快
|
static E2D_API EaseFunc ExpoIn; // 由慢变极快
|
||||||
static EaseFunc ExpoOut; // 由极快变慢
|
static E2D_API EaseFunc ExpoOut; // 由极快变慢
|
||||||
static EaseFunc ExpoInOut; // 由慢至极快, 再由极快边慢
|
static E2D_API EaseFunc ExpoInOut; // 由慢至极快, 再由极快边慢
|
||||||
static EaseFunc ElasticIn; // 自起点赋予弹性
|
static E2D_API EaseFunc ElasticIn; // 自起点赋予弹性
|
||||||
static EaseFunc ElasticOut; // 自终点赋予弹性
|
static E2D_API EaseFunc ElasticOut; // 自终点赋予弹性
|
||||||
static EaseFunc ElasticInOut; // 再起点和终点赋予弹性
|
static E2D_API EaseFunc ElasticInOut; // 再起点和终点赋予弹性
|
||||||
static EaseFunc BounceIn; // 自起点赋予反弹力
|
static E2D_API EaseFunc BounceIn; // 自起点赋予反弹力
|
||||||
static EaseFunc BounceOut; // 自终点赋予反弹力
|
static E2D_API EaseFunc BounceOut; // 自终点赋予反弹力
|
||||||
static EaseFunc BounceInOut; // 在起点和终点赋予反弹力
|
static E2D_API EaseFunc BounceInOut; // 在起点和终点赋予反弹力
|
||||||
static EaseFunc BackIn;
|
static E2D_API EaseFunc BackIn;
|
||||||
static EaseFunc BackOut;
|
static E2D_API EaseFunc BackOut;
|
||||||
static EaseFunc BackInOut;
|
static E2D_API EaseFunc BackInOut;
|
||||||
static EaseFunc QuadIn;
|
static E2D_API EaseFunc QuadIn;
|
||||||
static EaseFunc QuadOut;
|
static E2D_API EaseFunc QuadOut;
|
||||||
static EaseFunc QuadInOut;
|
static E2D_API EaseFunc QuadInOut;
|
||||||
static EaseFunc CubicIn;
|
static E2D_API EaseFunc CubicIn;
|
||||||
static EaseFunc CubicOut;
|
static E2D_API EaseFunc CubicOut;
|
||||||
static EaseFunc CubicInOut;
|
static E2D_API EaseFunc CubicInOut;
|
||||||
static EaseFunc QuartIn;
|
static E2D_API EaseFunc QuartIn;
|
||||||
static EaseFunc QuartOut;
|
static E2D_API EaseFunc QuartOut;
|
||||||
static EaseFunc QuartInOut;
|
static E2D_API EaseFunc QuartInOut;
|
||||||
static EaseFunc QuintIn;
|
static E2D_API EaseFunc QuintIn;
|
||||||
static EaseFunc QuintOut;
|
static E2D_API EaseFunc QuintOut;
|
||||||
static EaseFunc QuintInOut;
|
static E2D_API EaseFunc QuintInOut;
|
||||||
static EaseFunc SineIn;
|
static E2D_API EaseFunc SineIn;
|
||||||
static EaseFunc SineOut;
|
static E2D_API EaseFunc SineOut;
|
||||||
static EaseFunc SineInOut;
|
static E2D_API EaseFunc SineInOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
|
inline EaseFunc MakeEaseIn(float rate) { return std::bind(math::EaseIn, std::placeholders::_1, rate); }
|
||||||
|
|
@ -74,7 +75,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 补间动画
|
// 补间动画
|
||||||
class ActionTween
|
class E2D_API ActionTween
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -113,7 +114,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对位移动作
|
// 相对位移动作
|
||||||
class MoveBy
|
class E2D_API MoveBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -142,7 +143,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 位移动作
|
// 位移动作
|
||||||
class MoveTo
|
class E2D_API MoveTo
|
||||||
: public MoveBy
|
: public MoveBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -171,7 +172,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对跳跃动作
|
// 相对跳跃动作
|
||||||
class JumpBy
|
class E2D_API JumpBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -204,7 +205,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 跳跃动作
|
// 跳跃动作
|
||||||
class JumpTo
|
class E2D_API JumpTo
|
||||||
: public JumpBy
|
: public JumpBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -235,7 +236,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对缩放动作
|
// 相对缩放动作
|
||||||
class ScaleBy
|
class E2D_API ScaleBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -272,7 +273,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 缩放动作
|
// 缩放动作
|
||||||
class ScaleTo
|
class E2D_API ScaleTo
|
||||||
: public ScaleBy
|
: public ScaleBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -309,7 +310,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 透明度相对渐变动作
|
// 透明度相对渐变动作
|
||||||
class OpacityBy
|
class E2D_API OpacityBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -337,7 +338,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 透明度渐变动作
|
// 透明度渐变动作
|
||||||
class OpacityTo
|
class E2D_API OpacityTo
|
||||||
: public OpacityBy
|
: public OpacityBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -366,7 +367,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 淡入动作
|
// 淡入动作
|
||||||
class FadeIn
|
class E2D_API FadeIn
|
||||||
: public OpacityTo
|
: public OpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -379,7 +380,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 淡出动作
|
// 淡出动作
|
||||||
class FadeOut
|
class E2D_API FadeOut
|
||||||
: public OpacityTo
|
: public OpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -392,7 +393,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对旋转动作
|
// 相对旋转动作
|
||||||
class RotateBy
|
class E2D_API RotateBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -420,7 +421,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 旋转动作
|
// 旋转动作
|
||||||
class RotateTo
|
class E2D_API RotateTo
|
||||||
: public RotateBy
|
: public RotateBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -449,7 +450,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 路径动作
|
// 路径动作
|
||||||
class PathAction
|
class E2D_API PathAction
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 帧动画
|
// 帧动画
|
||||||
class Animation
|
class E2D_API Animation
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,20 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
Options::Options()
|
||||||
|
: title(L"Easy2D Game")
|
||||||
|
, width(640)
|
||||||
|
, height(480)
|
||||||
|
, icon(nullptr)
|
||||||
|
, vsync(true)
|
||||||
|
, fullscreen(false)
|
||||||
|
, debug(false)
|
||||||
|
{}
|
||||||
|
|
||||||
Application::Application(String const& app_name)
|
Application::Application(String const& app_name)
|
||||||
: debug_(false)
|
: end_(true)
|
||||||
|
, inited_(false)
|
||||||
|
, debug_(false)
|
||||||
, curr_scene_(nullptr)
|
, curr_scene_(nullptr)
|
||||||
, next_scene_(nullptr)
|
, next_scene_(nullptr)
|
||||||
, transition_(nullptr)
|
, transition_(nullptr)
|
||||||
|
|
@ -47,6 +59,8 @@ namespace easy2d
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
|
Destroy();
|
||||||
|
|
||||||
::CoUninitialize();
|
::CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,6 +144,8 @@ namespace easy2d
|
||||||
|
|
||||||
// use Application instance in message loop
|
// use Application instance in message loop
|
||||||
::SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(this));
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(this));
|
||||||
|
|
||||||
|
inited_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Run()
|
void Application::Run()
|
||||||
|
|
@ -138,10 +154,12 @@ namespace easy2d
|
||||||
|
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
{
|
{
|
||||||
|
end_ = false;
|
||||||
|
|
||||||
Window::Instance()->Prepare();
|
Window::Instance()->Prepare();
|
||||||
|
|
||||||
MSG msg = {};
|
MSG msg = {};
|
||||||
while (::GetMessageW(&msg, nullptr, 0, 0))
|
while (::GetMessageW(&msg, nullptr, 0, 0) && !end_)
|
||||||
{
|
{
|
||||||
::TranslateMessage(&msg);
|
::TranslateMessage(&msg);
|
||||||
::DispatchMessageW(&msg);
|
::DispatchMessageW(&msg);
|
||||||
|
|
@ -151,14 +169,24 @@ namespace easy2d
|
||||||
|
|
||||||
void Application::Quit()
|
void Application::Quit()
|
||||||
{
|
{
|
||||||
Window::Instance()->Destroy();
|
end_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Destroy()
|
void Application::Destroy()
|
||||||
{
|
{
|
||||||
transition_ = nullptr;
|
if (inited_)
|
||||||
next_scene_ = nullptr;
|
{
|
||||||
curr_scene_ = nullptr;
|
inited_ = false;
|
||||||
|
|
||||||
|
transition_.Reset();
|
||||||
|
next_scene_.Reset();
|
||||||
|
curr_scene_.Reset();
|
||||||
|
|
||||||
|
Audio::Instance()->Destroy();
|
||||||
|
RenderSystem::Instance()->Destroy();
|
||||||
|
Window::Instance()->Destroy();
|
||||||
|
Factory::Instance()->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::EnterScene(ScenePtr const & scene)
|
void Application::EnterScene(ScenePtr const & scene)
|
||||||
|
|
|
||||||
|
|
@ -38,19 +38,11 @@ namespace easy2d
|
||||||
bool fullscreen; // 全屏模式
|
bool fullscreen; // 全屏模式
|
||||||
bool debug; // 调试模式
|
bool debug; // 调试模式
|
||||||
|
|
||||||
Options()
|
E2D_API Options();
|
||||||
: title(L"Easy2D Game")
|
|
||||||
, width(640)
|
|
||||||
, height(480)
|
|
||||||
, icon(nullptr)
|
|
||||||
, vsync(true)
|
|
||||||
, fullscreen(false)
|
|
||||||
, debug(false)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Application
|
class E2D_API Application
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -111,6 +103,8 @@ namespace easy2d
|
||||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool end_;
|
||||||
|
bool inited_;
|
||||||
bool debug_;
|
bool debug_;
|
||||||
float time_scale_;
|
float time_scale_;
|
||||||
String app_name_;
|
String app_name_;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// »²¼
|
// »²¼
|
||||||
class Canvas
|
class E2D_API Canvas
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace easy2d
|
||||||
// 使用 RGBA 表示一个带透明度的颜色: Color not_black(1.0f, 1.0f, 1.0f, 0.5f);
|
// 使用 RGBA 表示一个带透明度的颜色: Color not_black(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
// 使用一个 unsigned int 类型的值表示 RGB: Color black(0x000000);
|
// 使用一个 unsigned int 类型的值表示 RGB: Color black(0x000000);
|
||||||
//
|
//
|
||||||
class Color
|
class E2D_API Color
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Color();
|
Color();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class DebugNode
|
class E2D_API DebugNode
|
||||||
: public Node
|
: public Node
|
||||||
, public ISingleton<DebugNode>
|
, public ISingleton<DebugNode>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 延时
|
// 延时动作
|
||||||
class Delay
|
class E2D_API Delay
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
// 事件
|
// 事件
|
||||||
struct Event
|
struct E2D_API Event
|
||||||
{
|
{
|
||||||
EventType type;
|
EventType type;
|
||||||
Node* target;
|
Node* target;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class EventDispatcher
|
class E2D_API EventDispatcher
|
||||||
{
|
{
|
||||||
using Listeners = IntrusiveList<EventListenerPtr>;
|
using Listeners = IntrusiveList<EventListenerPtr>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
||||||
|
|
||||||
class EventDispatcher;
|
class EventDispatcher;
|
||||||
|
|
||||||
class EventListener
|
class E2D_API EventListener
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, protected IntrusiveListItem<EventListenerPtr>
|
, protected IntrusiveListItem<EventListenerPtr>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ namespace easy2d
|
||||||
|
|
||||||
Factory::~Factory()
|
Factory::~Factory()
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Destroying device-independent resources");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Factory::Init(bool debug)
|
HRESULT Factory::Init(bool debug)
|
||||||
|
|
@ -111,6 +110,18 @@ namespace easy2d
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Factory::Destroy()
|
||||||
|
{
|
||||||
|
E2D_LOG(L"Destroying device-independent resources");
|
||||||
|
|
||||||
|
factory_.Reset();
|
||||||
|
imaging_factory_.Reset();
|
||||||
|
write_factory_.Reset();
|
||||||
|
miter_stroke_style_.Reset();
|
||||||
|
bevel_stroke_style_.Reset();
|
||||||
|
round_stroke_style_.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT Factory::CreateHwndRenderTarget(D2DHwndRenderTargetPtr & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const
|
HRESULT Factory::CreateHwndRenderTarget(D2DHwndRenderTargetPtr & hwnd_render_target, D2D1_RENDER_TARGET_PROPERTIES const & properties, D2D1_HWND_RENDER_TARGET_PROPERTIES const & hwnd_rt_properties) const
|
||||||
{
|
{
|
||||||
if (!factory_)
|
if (!factory_)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Factory
|
class E2D_API Factory
|
||||||
: public ISingleton<Factory>
|
: public ISingleton<Factory>
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(Factory);
|
E2D_DECLARE_SINGLETON(Factory);
|
||||||
|
|
@ -36,68 +36,70 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
HRESULT Init(bool debug);
|
HRESULT Init(bool debug);
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
HRESULT CreateHwndRenderTarget(
|
HRESULT CreateHwndRenderTarget(
|
||||||
D2DHwndRenderTargetPtr& hwnd_render_target,
|
_Out_ D2DHwndRenderTargetPtr& hwnd_render_target,
|
||||||
D2D1_RENDER_TARGET_PROPERTIES const& properties,
|
D2D1_RENDER_TARGET_PROPERTIES const& properties,
|
||||||
D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties
|
D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateTextRenderer(
|
HRESULT CreateTextRenderer(
|
||||||
D2DTextRendererPtr& text_renderer,
|
_Out_ D2DTextRendererPtr& text_renderer,
|
||||||
D2DRenderTargetPtr const& render_target,
|
D2DRenderTargetPtr const& render_target,
|
||||||
D2DSolidColorBrushPtr const& brush
|
D2DSolidColorBrushPtr const& brush
|
||||||
);
|
);
|
||||||
|
|
||||||
HRESULT CreateBitmapFromFile(
|
HRESULT CreateBitmapFromFile(
|
||||||
D2DBitmapPtr& bitmap,
|
_Out_ D2DBitmapPtr& bitmap,
|
||||||
D2DRenderTargetPtr const& rt,
|
D2DRenderTargetPtr const& rt,
|
||||||
String const& file_path
|
String const& file_path
|
||||||
);
|
);
|
||||||
|
|
||||||
HRESULT CreateBitmapFromResource(
|
HRESULT CreateBitmapFromResource(
|
||||||
D2DBitmapPtr& bitmap,
|
_Out_ D2DBitmapPtr& bitmap,
|
||||||
D2DRenderTargetPtr const& rt,
|
D2DRenderTargetPtr const& rt,
|
||||||
Resource const& res
|
Resource const& res
|
||||||
);
|
);
|
||||||
|
|
||||||
HRESULT CreateRectangleGeometry(
|
HRESULT CreateRectangleGeometry(
|
||||||
D2DRectangleGeometryPtr& geo,
|
_Out_ D2DRectangleGeometryPtr& geo,
|
||||||
Rect const& rect
|
Rect const& rect
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateRoundedRectangleGeometry(
|
HRESULT CreateRoundedRectangleGeometry(
|
||||||
D2DRoundedRectangleGeometryPtr& geo,
|
_Out_ D2DRoundedRectangleGeometryPtr& geo,
|
||||||
Rect const& rect,
|
Rect const& rect,
|
||||||
float radius_x,
|
float radius_x,
|
||||||
float radius_y
|
float radius_y
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateEllipseGeometry(
|
HRESULT CreateEllipseGeometry(
|
||||||
D2DEllipseGeometryPtr& geo,
|
_Out_ D2DEllipseGeometryPtr& geo,
|
||||||
Point const& center,
|
Point const& center,
|
||||||
float radius_x,
|
float radius_x,
|
||||||
float radius_y
|
float radius_y
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateTransformedGeometry(
|
HRESULT CreateTransformedGeometry(
|
||||||
D2DTransformedGeometryPtr& transformed,
|
_Out_ D2DTransformedGeometryPtr& transformed,
|
||||||
Matrix const& matrix,
|
Matrix const& matrix,
|
||||||
D2DGeometryPtr const& geo
|
D2DGeometryPtr const& geo
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreatePathGeometry(
|
HRESULT CreatePathGeometry(
|
||||||
D2DPathGeometryPtr& geometry
|
_Out_ D2DPathGeometryPtr& geometry
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateTextFormat(
|
HRESULT CreateTextFormat(
|
||||||
D2DTextFormatPtr& text_format,
|
_Out_ D2DTextFormatPtr& text_format,
|
||||||
Font const& font,
|
Font const& font,
|
||||||
TextStyle const& text_style
|
TextStyle const& text_style
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
HRESULT CreateTextLayout(
|
HRESULT CreateTextLayout(
|
||||||
D2DTextLayoutPtr& text_layout,
|
_Out_ D2DTextLayoutPtr& text_layout,
|
||||||
Size& layout_size,
|
_Out_ Size& layout_size,
|
||||||
String const& text,
|
String const& text,
|
||||||
D2DTextFormatPtr const& text_format,
|
D2DTextFormatPtr const& text_format,
|
||||||
TextStyle const& text_style
|
TextStyle const& text_style
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// Ö¡¼¯ºÏ
|
// Ö¡¼¯ºÏ
|
||||||
class Frames
|
class E2D_API Frames
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 섯부녜蹶
|
// 섯부녜蹶
|
||||||
class Geometry
|
class E2D_API Geometry
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
{
|
{
|
||||||
friend class Canvas;
|
friend class Canvas;
|
||||||
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 殮窟
|
// 殮窟
|
||||||
class LineGeometry
|
class E2D_API LineGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -99,7 +99,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 섯부앤近
|
// 섯부앤近
|
||||||
class RectangleGeometry
|
class E2D_API RectangleGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -126,7 +126,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 섯부途近
|
// 섯부途近
|
||||||
class CircleGeometry
|
class E2D_API CircleGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -163,7 +163,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 섯부哭途
|
// 섯부哭途
|
||||||
class EllipseGeometry
|
class E2D_API EllipseGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -206,7 +206,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 섯부쨌쓺
|
// 섯부쨌쓺
|
||||||
class PathGeometry
|
class E2D_API PathGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -260,7 +260,7 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 섯부途실앤近
|
// 섯부途실앤近
|
||||||
class RoundedRectGeometry
|
class E2D_API RoundedRectGeometry
|
||||||
: public Geometry
|
: public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 섯부暠近
|
// 섯부暠近
|
||||||
class GeometryNode
|
class E2D_API GeometryNode
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (!File(res.GetFileName()).Exists())
|
if (!File(res.GetFileName()).Exists())
|
||||||
{
|
{
|
||||||
E2D_WARNING_LOG(L"Image file '%s' not found!", res.GetFileName());
|
E2D_WARNING_LOG(L"Image file '%s' not found!", res.GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hr = RenderSystem::Instance()->CreateBitmapFromFile(bitmap, res.GetFileName());
|
hr = RenderSystem::Instance()->CreateBitmapFromFile(bitmap, res.GetFileName());
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// ͼƬ
|
// ͼƬ
|
||||||
class Image
|
class E2D_API Image
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,12 @@ namespace easy2d
|
||||||
|
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Destroying input device");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Input::Init(HWND hwnd, bool debug)
|
HRESULT Input::Init(HWND hwnd, bool debug)
|
||||||
{
|
{
|
||||||
E2D_NOT_USED(debug);
|
E2D_NOT_USED(debug);
|
||||||
|
|
||||||
E2D_LOG(L"Initing input device");
|
|
||||||
|
|
||||||
hwnd_ = hwnd;
|
hwnd_ = hwnd;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Input
|
class E2D_API Input
|
||||||
: public ISingleton<Input>
|
: public ISingleton<Input>
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(Input);
|
E2D_DECLARE_SINGLETON(Input);
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,10 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#undef DEBUG_CHECK_LIST
|
|
||||||
#ifdef E2D_DEBUG
|
#ifdef E2D_DEBUG
|
||||||
# define DEBUG_CHECK_LIST(list_ptr) list_ptr->Check()
|
# define E2D_DEBUG_CHECK_LIST(list_ptr) list_ptr->Check()
|
||||||
#else
|
#else
|
||||||
# define DEBUG_CHECK_LIST __noop
|
# define E2D_DEBUG_CHECK_LIST __noop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -101,7 +100,7 @@ namespace easy2d
|
||||||
|
|
||||||
last_ = child;
|
last_ = child;
|
||||||
|
|
||||||
DEBUG_CHECK_LIST(this);
|
E2D_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushFront(T const& child)
|
void PushFront(T const& child)
|
||||||
|
|
@ -125,7 +124,7 @@ namespace easy2d
|
||||||
|
|
||||||
first_ = child;
|
first_ = child;
|
||||||
|
|
||||||
DEBUG_CHECK_LIST(this);
|
E2D_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertBefore(T const& child, T const& before)
|
void InsertBefore(T const& child, T const& before)
|
||||||
|
|
@ -144,7 +143,7 @@ namespace easy2d
|
||||||
child->next_ = before;
|
child->next_ = before;
|
||||||
before->prev_ = child;
|
before->prev_ = child;
|
||||||
|
|
||||||
DEBUG_CHECK_LIST(this);
|
E2D_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertAfter(T const& child, T const& after)
|
void InsertAfter(T const& child, T const& after)
|
||||||
|
|
@ -163,7 +162,7 @@ namespace easy2d
|
||||||
child->prev_ = after;
|
child->prev_ = after;
|
||||||
after->next_ = child;
|
after->next_ = child;
|
||||||
|
|
||||||
DEBUG_CHECK_LIST(this);
|
E2D_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(T const& child)
|
void Remove(T const& child)
|
||||||
|
|
@ -198,7 +197,7 @@ namespace easy2d
|
||||||
child->prev_ = nullptr;
|
child->prev_ = nullptr;
|
||||||
child->next_ = nullptr;
|
child->next_ = nullptr;
|
||||||
|
|
||||||
DEBUG_CHECK_LIST(this);
|
E2D_DEBUG_CHECK_LIST(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
|
|
@ -250,4 +249,4 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DEBUG_CHECK_LIST
|
#undef E2D_DEBUG_CHECK_LIST
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (!File(res.GetFileName()).Exists())
|
if (!File(res.GetFileName()).Exists())
|
||||||
{
|
{
|
||||||
E2D_WARNING_LOG(L"Media file '%s' not found", res.GetFileName());
|
E2D_WARNING_LOG(L"Media file '%s' not found", res.GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hr = transcoder.LoadMediaFile(res.GetFileName(), &wave_data_, &size_);
|
hr = transcoder.LoadMediaFile(res.GetFileName(), &wave_data_, &size_);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 稜있
|
// 稜있
|
||||||
class Music
|
class E2D_API Music
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
||||||
class Application;
|
class Application;
|
||||||
|
|
||||||
// 节点
|
// 节点
|
||||||
class Node
|
class E2D_API Node
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, public TaskManager
|
, public TaskManager
|
||||||
, public ActionManager
|
, public ActionManager
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Object
|
class E2D_API Object
|
||||||
: public RefCounter
|
: public RefCounter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class RefCounter
|
class E2D_API RefCounter
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
||||||
//
|
//
|
||||||
// 了解资源的更多信息: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
|
// 了解资源的更多信息: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
|
||||||
//
|
//
|
||||||
class Resource
|
class E2D_API Resource
|
||||||
{
|
{
|
||||||
enum class Type { File, Binary };
|
enum class Type { File, Binary };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// ³¡¾°
|
// ³¡¾°
|
||||||
class Scene
|
class E2D_API Scene
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// ¾«Áé
|
// ¾«Áé
|
||||||
class Sprite
|
class E2D_API Sprite
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
||||||
class TaskManager;
|
class TaskManager;
|
||||||
|
|
||||||
// 定时任务
|
// 定时任务
|
||||||
class Task
|
class E2D_API Task
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
, protected IntrusiveListItem<TaskPtr>
|
, protected IntrusiveListItem<TaskPtr>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class TaskManager
|
class E2D_API TaskManager
|
||||||
{
|
{
|
||||||
using Tasks = IntrusiveList<TaskPtr>;
|
using Tasks = IntrusiveList<TaskPtr>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 文本
|
// 文本
|
||||||
class Text
|
class E2D_API Text
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,113 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
ITextRenderer::ITextRenderer(ID2D1Factory* pD2DFactory, ID2D1RenderTarget* pRT, ID2D1SolidColorBrush* pBrush)
|
class TextRendererImpl
|
||||||
|
: public ITextRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextRendererImpl(
|
||||||
|
ID2D1Factory* pD2DFactory,
|
||||||
|
ID2D1RenderTarget* pRT,
|
||||||
|
ID2D1SolidColorBrush* pBrush
|
||||||
|
);
|
||||||
|
|
||||||
|
~TextRendererImpl();
|
||||||
|
|
||||||
|
STDMETHOD_(void, SetTextStyle)(
|
||||||
|
CONST D2D1_COLOR_F &fillColor,
|
||||||
|
BOOL outline,
|
||||||
|
CONST D2D1_COLOR_F &outlineColor,
|
||||||
|
FLOAT outlineWidth,
|
||||||
|
ID2D1StrokeStyle* outlineJoin
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawGlyphRun)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
DWRITE_MEASURING_MODE measuringMode,
|
||||||
|
__in DWRITE_GLYPH_RUN const* glyphRun,
|
||||||
|
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawUnderline)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
__in DWRITE_UNDERLINE const* underline,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawStrikethrough)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(DrawInlineObject)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
FLOAT originX,
|
||||||
|
FLOAT originY,
|
||||||
|
IDWriteInlineObject* inlineObject,
|
||||||
|
BOOL IsSideways,
|
||||||
|
BOOL IsRightToLeft,
|
||||||
|
IUnknown* clientDrawingEffect
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(IsPixelSnappingDisabled)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out BOOL* isDisabled
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(GetCurrentTransform)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out DWRITE_MATRIX* transform
|
||||||
|
);
|
||||||
|
|
||||||
|
STDMETHOD(GetPixelsPerDip)(
|
||||||
|
__maybenull void* clientDrawingContext,
|
||||||
|
__out FLOAT* pixelsPerDip
|
||||||
|
);
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned long STDMETHODCALLTYPE AddRef();
|
||||||
|
unsigned long STDMETHODCALLTYPE Release();
|
||||||
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||||
|
IID const& riid,
|
||||||
|
void** ppvObject
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned long cRefCount_;
|
||||||
|
D2D1_COLOR_F sFillColor_;
|
||||||
|
D2D1_COLOR_F sOutlineColor_;
|
||||||
|
FLOAT fOutlineWidth;
|
||||||
|
BOOL bShowOutline_;
|
||||||
|
ID2D1Factory* pD2DFactory_;
|
||||||
|
ID2D1RenderTarget* pRT_;
|
||||||
|
ID2D1SolidColorBrush* pBrush_;
|
||||||
|
ID2D1StrokeStyle* pCurrStrokeStyle_;
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT ITextRenderer::Create(
|
||||||
|
ITextRenderer** ppTextRenderer,
|
||||||
|
ID2D1Factory* pD2DFactory,
|
||||||
|
ID2D1RenderTarget* pRT,
|
||||||
|
ID2D1SolidColorBrush* pBrush)
|
||||||
|
{
|
||||||
|
*ppTextRenderer = new (std::nothrow) TextRendererImpl(pD2DFactory, pRT, pBrush);
|
||||||
|
if (*ppTextRenderer)
|
||||||
|
{
|
||||||
|
(*ppTextRenderer)->AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextRendererImpl::TextRendererImpl(ID2D1Factory* pD2DFactory, ID2D1RenderTarget* pRT, ID2D1SolidColorBrush* pBrush)
|
||||||
: cRefCount_(0)
|
: cRefCount_(0)
|
||||||
, pD2DFactory_(pD2DFactory)
|
, pD2DFactory_(pD2DFactory)
|
||||||
, pRT_(pRT)
|
, pRT_(pRT)
|
||||||
|
|
@ -40,29 +146,14 @@ namespace easy2d
|
||||||
pBrush->AddRef();
|
pBrush->AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextRenderer::~ITextRenderer()
|
TextRendererImpl::~TextRendererImpl()
|
||||||
{
|
{
|
||||||
SafeRelease(pD2DFactory_);
|
SafeRelease(pD2DFactory_);
|
||||||
SafeRelease(pRT_);
|
SafeRelease(pRT_);
|
||||||
SafeRelease(pBrush_);
|
SafeRelease(pBrush_);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT ITextRenderer::Create(
|
STDMETHODIMP_(void) TextRendererImpl::SetTextStyle(
|
||||||
ITextRenderer** ppTextRenderer,
|
|
||||||
ID2D1Factory* pD2DFactory,
|
|
||||||
ID2D1RenderTarget* pRT,
|
|
||||||
ID2D1SolidColorBrush* pBrush)
|
|
||||||
{
|
|
||||||
*ppTextRenderer = new (std::nothrow) ITextRenderer(pD2DFactory, pRT, pBrush);
|
|
||||||
if (*ppTextRenderer)
|
|
||||||
{
|
|
||||||
(*ppTextRenderer)->AddRef();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP_(void) ITextRenderer::SetTextStyle(
|
|
||||||
CONST D2D1_COLOR_F &fillColor,
|
CONST D2D1_COLOR_F &fillColor,
|
||||||
BOOL outline,
|
BOOL outline,
|
||||||
CONST D2D1_COLOR_F &outlineColor,
|
CONST D2D1_COLOR_F &outlineColor,
|
||||||
|
|
@ -76,7 +167,7 @@ namespace easy2d
|
||||||
pCurrStrokeStyle_ = outlineJoin;
|
pCurrStrokeStyle_ = outlineJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::DrawGlyphRun(
|
STDMETHODIMP TextRendererImpl::DrawGlyphRun(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -169,7 +260,7 @@ namespace easy2d
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::DrawUnderline(
|
STDMETHODIMP TextRendererImpl::DrawUnderline(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -238,7 +329,7 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::DrawStrikethrough(
|
STDMETHODIMP TextRendererImpl::DrawStrikethrough(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -307,7 +398,7 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::DrawInlineObject(
|
STDMETHODIMP TextRendererImpl::DrawInlineObject(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT originX,
|
FLOAT originX,
|
||||||
FLOAT originY,
|
FLOAT originY,
|
||||||
|
|
@ -326,12 +417,12 @@ namespace easy2d
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(unsigned long) ITextRenderer::AddRef()
|
STDMETHODIMP_(unsigned long) TextRendererImpl::AddRef()
|
||||||
{
|
{
|
||||||
return InterlockedIncrement(&cRefCount_);
|
return InterlockedIncrement(&cRefCount_);
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(unsigned long) ITextRenderer::Release()
|
STDMETHODIMP_(unsigned long) TextRendererImpl::Release()
|
||||||
{
|
{
|
||||||
unsigned long newCount = InterlockedDecrement(&cRefCount_);
|
unsigned long newCount = InterlockedDecrement(&cRefCount_);
|
||||||
|
|
||||||
|
|
@ -344,7 +435,7 @@ namespace easy2d
|
||||||
return newCount;
|
return newCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::IsPixelSnappingDisabled(
|
STDMETHODIMP TextRendererImpl::IsPixelSnappingDisabled(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out BOOL* isDisabled)
|
__out BOOL* isDisabled)
|
||||||
{
|
{
|
||||||
|
|
@ -354,7 +445,7 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::GetCurrentTransform(
|
STDMETHODIMP TextRendererImpl::GetCurrentTransform(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out DWRITE_MATRIX* transform)
|
__out DWRITE_MATRIX* transform)
|
||||||
{
|
{
|
||||||
|
|
@ -364,7 +455,7 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::GetPixelsPerDip(
|
STDMETHODIMP TextRendererImpl::GetPixelsPerDip(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out FLOAT* pixelsPerDip)
|
__out FLOAT* pixelsPerDip)
|
||||||
{
|
{
|
||||||
|
|
@ -378,7 +469,7 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP ITextRenderer::QueryInterface(
|
STDMETHODIMP TextRendererImpl::QueryInterface(
|
||||||
IID const& riid,
|
IID const& riid,
|
||||||
void** ppvObject)
|
void** ppvObject)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,15 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class ITextRenderer
|
interface ITextRenderer
|
||||||
: public IDWriteTextRenderer
|
: public IDWriteTextRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static HRESULT Create(
|
static E2D_API HRESULT Create(
|
||||||
ITextRenderer** ppTextRenderer,
|
_Out_ ITextRenderer** ppTextRenderer,
|
||||||
ID2D1Factory* pD2DFactory,
|
_In_ ID2D1Factory* pD2DFactory,
|
||||||
ID2D1RenderTarget* pRT,
|
_In_ ID2D1RenderTarget* pRT,
|
||||||
ID2D1SolidColorBrush* pBrush
|
_In_ ID2D1SolidColorBrush* pBrush
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD_(void, SetTextStyle)(
|
STDMETHOD_(void, SetTextStyle)(
|
||||||
|
|
@ -39,87 +39,8 @@ namespace easy2d
|
||||||
BOOL outline,
|
BOOL outline,
|
||||||
CONST D2D1_COLOR_F &outlineColor,
|
CONST D2D1_COLOR_F &outlineColor,
|
||||||
FLOAT outlineWidth,
|
FLOAT outlineWidth,
|
||||||
ID2D1StrokeStyle* outlineJoin
|
_In_ ID2D1StrokeStyle* outlineJoin
|
||||||
);
|
) PURE;
|
||||||
|
|
||||||
STDMETHOD(DrawGlyphRun)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
DWRITE_MEASURING_MODE measuringMode,
|
|
||||||
__in DWRITE_GLYPH_RUN const* glyphRun,
|
|
||||||
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawUnderline)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_UNDERLINE const* underline,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawStrikethrough)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT baselineOriginX,
|
|
||||||
FLOAT baselineOriginY,
|
|
||||||
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(DrawInlineObject)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
FLOAT originX,
|
|
||||||
FLOAT originY,
|
|
||||||
IDWriteInlineObject* inlineObject,
|
|
||||||
BOOL IsSideways,
|
|
||||||
BOOL IsRightToLeft,
|
|
||||||
IUnknown* clientDrawingEffect
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(IsPixelSnappingDisabled)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out BOOL* isDisabled
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(GetCurrentTransform)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out DWRITE_MATRIX* transform
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(GetPixelsPerDip)(
|
|
||||||
__maybenull void* clientDrawingContext,
|
|
||||||
__out FLOAT* pixelsPerDip
|
|
||||||
);
|
|
||||||
|
|
||||||
public:
|
|
||||||
unsigned long STDMETHODCALLTYPE AddRef();
|
|
||||||
unsigned long STDMETHODCALLTYPE Release();
|
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
|
||||||
IID const& riid,
|
|
||||||
void** ppvObject
|
|
||||||
);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ITextRenderer(
|
|
||||||
ID2D1Factory* pD2DFactory,
|
|
||||||
ID2D1RenderTarget* pRT,
|
|
||||||
ID2D1SolidColorBrush* pBrush
|
|
||||||
);
|
|
||||||
|
|
||||||
~ITextRenderer();
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned long cRefCount_;
|
|
||||||
D2D1_COLOR_F sFillColor_;
|
|
||||||
D2D1_COLOR_F sOutlineColor_;
|
|
||||||
FLOAT fOutlineWidth;
|
|
||||||
BOOL bShowOutline_;
|
|
||||||
ID2D1Factory* pD2DFactory_;
|
|
||||||
ID2D1RenderTarget* pRT_;
|
|
||||||
ID2D1SolidColorBrush* pBrush_;
|
|
||||||
ID2D1StrokeStyle* pCurrStrokeStyle_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文本样式
|
// 文本样式
|
||||||
class TextStyle
|
class E2D_API TextStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Color color; // 颜色
|
Color color; // 颜色
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Transform
|
class E2D_API Transform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float rotation; // Ðýת
|
float rotation; // Ðýת
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace easy2d
|
||||||
class Scene;
|
class Scene;
|
||||||
|
|
||||||
// 场景过渡
|
// 场景过渡
|
||||||
class Transition
|
class E2D_API Transition
|
||||||
: public virtual Object
|
: public virtual Object
|
||||||
{
|
{
|
||||||
friend class Application;
|
friend class Application;
|
||||||
|
|
|
||||||
|
|
@ -167,26 +167,13 @@ namespace easy2d
|
||||||
|
|
||||||
Audio::~Audio()
|
Audio::~Audio()
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Destroying audio device");
|
|
||||||
|
|
||||||
ClearVoiceCache();
|
|
||||||
|
|
||||||
if (mastering_voice_)
|
|
||||||
{
|
|
||||||
mastering_voice_->DestroyVoice();
|
|
||||||
mastering_voice_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SafeRelease(x_audio2_);
|
|
||||||
|
|
||||||
modules::MediaFoundation::Get().MFShutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Audio::Init(bool debug)
|
HRESULT Audio::Init(bool debug)
|
||||||
{
|
{
|
||||||
E2D_NOT_USED(debug);
|
E2D_NOT_USED(debug);
|
||||||
|
|
||||||
E2D_LOG(L"Initing audio device");
|
E2D_LOG(L"Initing audio resources");
|
||||||
|
|
||||||
HRESULT hr = modules::MediaFoundation::Get().MFStartup(MF_VERSION, MFSTARTUP_FULL);
|
HRESULT hr = modules::MediaFoundation::Get().MFStartup(MF_VERSION, MFSTARTUP_FULL);
|
||||||
|
|
||||||
|
|
@ -203,6 +190,23 @@ namespace easy2d
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::Destroy()
|
||||||
|
{
|
||||||
|
E2D_LOG(L"Destroying audio resources");
|
||||||
|
|
||||||
|
ClearVoiceCache();
|
||||||
|
|
||||||
|
if (mastering_voice_)
|
||||||
|
{
|
||||||
|
mastering_voice_->DestroyVoice();
|
||||||
|
mastering_voice_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SafeRelease(x_audio2_);
|
||||||
|
|
||||||
|
modules::MediaFoundation::Get().MFShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT Audio::CreateVoice(Voice& voice, const WAVEFORMATEX* wfx)
|
HRESULT Audio::CreateVoice(Voice& voice, const WAVEFORMATEX* wfx)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Voice
|
class E2D_API Voice
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -74,7 +74,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Audio
|
class E2D_API Audio
|
||||||
: public ISingleton<Audio>
|
: public ISingleton<Audio>
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(Audio);
|
E2D_DECLARE_SINGLETON(Audio);
|
||||||
|
|
@ -84,6 +84,8 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
HRESULT Init(bool debug);
|
HRESULT Init(bool debug);
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
// 开启设备
|
// 开启设备
|
||||||
void Open();
|
void Open();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,7 @@
|
||||||
//#define E2D_ERROR_LOG(FORMAT, ...) wprintf(FORMAT L"\n", __VA_ARGS__)
|
//#define E2D_ERROR_LOG(FORMAT, ...) wprintf(FORMAT L"\n", __VA_ARGS__)
|
||||||
//#define E2D_ERROR_HR_LOG(HR, FORMAT, ...) E2D_ERROR_LOG(L"Failure with HRESULT of %08X " FORMAT L"\n", HR, __VA_ARGS__)
|
//#define E2D_ERROR_HR_LOG(HR, FORMAT, ...) E2D_ERROR_LOG(L"Failure with HRESULT of %08X " FORMAT L"\n", HR, __VA_ARGS__)
|
||||||
|
|
||||||
|
//---- Define attributes of all API symbols declarations for DLL
|
||||||
|
//#define E2D_API __declspec( dllexport )
|
||||||
|
//#define E2D_API __declspec( dllimport )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,25 +65,25 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
namespace logs
|
namespace logs
|
||||||
{
|
{
|
||||||
void Enable();
|
E2D_API void Enable();
|
||||||
|
|
||||||
void Disable();
|
E2D_API void Disable();
|
||||||
|
|
||||||
void Print(const wchar_t* format, ...);
|
E2D_API void Print(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Println(const wchar_t* format, ...);
|
E2D_API void Println(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Message(const wchar_t* format, ...);
|
E2D_API void Message(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Messageln(const wchar_t* format, ...);
|
E2D_API void Messageln(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Warning(const wchar_t* format, ...);
|
E2D_API void Warning(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Warningln(const wchar_t* format, ...);
|
E2D_API void Warningln(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Error(const wchar_t* format, ...);
|
E2D_API void Error(const wchar_t* format, ...);
|
||||||
|
|
||||||
void Errorln(const wchar_t* format, ...);
|
E2D_API void Errorln(const wchar_t* format, ...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,4 +101,16 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef E2D_API
|
||||||
|
/* Building or calling Easy2D as a static library */
|
||||||
|
# define E2D_API
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* C4251 can be ignored if you are deriving from a type in the
|
||||||
|
* C++ Standard Library, compiling a debug release (/MTd) and
|
||||||
|
* where the compiler error message refers to _Container_base.
|
||||||
|
*/
|
||||||
|
# pragma warning (disable: 4251)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define E2D_NOT_USED(VAR) ((void)VAR)
|
#define E2D_NOT_USED(VAR) ((void)VAR)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
namespace modules
|
namespace modules
|
||||||
{
|
{
|
||||||
class Shlwapi
|
class E2D_API Shlwapi
|
||||||
{
|
{
|
||||||
Shlwapi();
|
Shlwapi();
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DirectX
|
class E2D_API DirectX
|
||||||
{
|
{
|
||||||
DirectX();
|
DirectX();
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class XAudio2
|
class E2D_API XAudio2
|
||||||
{
|
{
|
||||||
XAudio2();
|
XAudio2();
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MediaFoundation
|
class E2D_API MediaFoundation
|
||||||
{
|
{
|
||||||
MediaFoundation();
|
MediaFoundation();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,11 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Noncopyable
|
class E2D_API Noncopyable
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Noncopyable() = default;
|
Noncopyable() = default;
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,11 @@ namespace easy2d
|
||||||
|
|
||||||
RenderSystem::~RenderSystem()
|
RenderSystem::~RenderSystem()
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Destroying graphics device");
|
|
||||||
|
|
||||||
ClearImageCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT RenderSystem::Init(HWND hwnd, bool vsync, bool debug)
|
HRESULT RenderSystem::Init(HWND hwnd, bool vsync, bool debug)
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Initing graphics device");
|
E2D_LOG(L"Initing graphics resources");
|
||||||
|
|
||||||
vsync_enabled_ = vsync;
|
vsync_enabled_ = vsync;
|
||||||
debug_ = debug;
|
debug_ = debug;
|
||||||
|
|
@ -56,6 +53,19 @@ namespace easy2d
|
||||||
return CreateResources(hwnd);
|
return CreateResources(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderSystem::Destroy()
|
||||||
|
{
|
||||||
|
E2D_LOG(L"Destroying graphics resources");
|
||||||
|
|
||||||
|
ClearImageCache();
|
||||||
|
|
||||||
|
text_renderer_.Reset();
|
||||||
|
solid_brush_.Reset();
|
||||||
|
render_target_.Reset();
|
||||||
|
fps_text_format_.Reset();
|
||||||
|
fps_text_layout_.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT RenderSystem::BeginDraw(HWND hwnd)
|
HRESULT RenderSystem::BeginDraw(HWND hwnd)
|
||||||
{
|
{
|
||||||
HRESULT hr = CreateResources(hwnd);
|
HRESULT hr = CreateResources(hwnd);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class RenderSystem
|
class E2D_API RenderSystem
|
||||||
: public ISingleton<RenderSystem>
|
: public ISingleton<RenderSystem>
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(RenderSystem);
|
E2D_DECLARE_SINGLETON(RenderSystem);
|
||||||
|
|
@ -48,6 +48,8 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
HRESULT Init(HWND hwnd, bool vsync, bool debug);
|
HRESULT Init(HWND hwnd, bool vsync, bool debug);
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
// ¿ªÊ¼äÖȾ
|
// ¿ªÊ¼äÖȾ
|
||||||
HRESULT BeginDraw(HWND hwnd);
|
HRESULT BeginDraw(HWND hwnd);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace easy2d
|
||||||
// 1.5 小时: 1.5_h
|
// 1.5 小时: 1.5_h
|
||||||
// 3 小时 45 分 15 秒: 3_h + 45_m + 15_s
|
// 3 小时 45 分 15 秒: 3_h + 45_m + 15_s
|
||||||
//
|
//
|
||||||
struct Duration
|
struct E2D_API Duration
|
||||||
{
|
{
|
||||||
Duration();
|
Duration();
|
||||||
|
|
||||||
|
|
@ -110,10 +110,10 @@ namespace easy2d
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 预定义的时间段 */
|
/* 预定义的时间段 */
|
||||||
extern const Duration Millisecond; // 毫秒
|
E2D_API extern const Duration Millisecond; // 毫秒
|
||||||
extern const Duration Second; // 秒
|
E2D_API extern const Duration Second; // 秒
|
||||||
extern const Duration Minute; // 分钟
|
E2D_API extern const Duration Minute; // 分钟
|
||||||
extern const Duration Hour; // 小时
|
E2D_API extern const Duration Hour; // 小时
|
||||||
|
|
||||||
|
|
||||||
// 时间
|
// 时间
|
||||||
|
|
@ -123,7 +123,7 @@ namespace easy2d
|
||||||
// TimePoint t1, t2;
|
// TimePoint t1, t2;
|
||||||
// int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
|
// int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
|
||||||
//
|
//
|
||||||
struct TimePoint
|
struct E2D_API TimePoint
|
||||||
{
|
{
|
||||||
TimePoint();
|
TimePoint();
|
||||||
|
|
||||||
|
|
@ -148,14 +148,14 @@ namespace easy2d
|
||||||
//
|
//
|
||||||
// 由于该时间点基于系统启动时间开始计算, 所以无法格式化该时间,
|
// 由于该时间点基于系统启动时间开始计算, 所以无法格式化该时间,
|
||||||
// 也无法获得该时间的 Unix 时间戳
|
// 也无法获得该时间的 Unix 时间戳
|
||||||
TimePoint Now() E2D_NOEXCEPT;
|
E2D_API TimePoint Now() E2D_NOEXCEPT;
|
||||||
|
|
||||||
// 时间段格式化
|
// 时间段格式化
|
||||||
//
|
//
|
||||||
// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
|
// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
|
||||||
// 例如: "300ms", "-1.5h", "2h45m"
|
// 例如: "300ms", "-1.5h", "2h45m"
|
||||||
// 允许的时间单位有 "ms", "s", "m", "h"
|
// 允许的时间单位有 "ms", "s", "m", "h"
|
||||||
Duration ParseDuration(const std::wstring& parse_str);
|
E2D_API Duration ParseDuration(const std::wstring& parse_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,16 +51,6 @@ namespace easy2d
|
||||||
|
|
||||||
Window::~Window()
|
Window::~Window()
|
||||||
{
|
{
|
||||||
E2D_LOG(L"Destroying window");
|
|
||||||
|
|
||||||
if (is_fullscreen_)
|
|
||||||
RestoreResolution(device_name_);
|
|
||||||
|
|
||||||
if (device_name_)
|
|
||||||
{
|
|
||||||
delete[] device_name_;
|
|
||||||
device_name_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Window::Init(String title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc, bool debug)
|
HRESULT Window::Init(String title, int width, int height, LPCWSTR icon, bool fullscreen, WNDPROC proc, bool debug)
|
||||||
|
|
@ -168,6 +158,26 @@ namespace easy2d
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::Destroy()
|
||||||
|
{
|
||||||
|
E2D_LOG(L"Destroying window");
|
||||||
|
|
||||||
|
if (is_fullscreen_)
|
||||||
|
RestoreResolution(device_name_);
|
||||||
|
|
||||||
|
if (device_name_)
|
||||||
|
{
|
||||||
|
delete[] device_name_;
|
||||||
|
device_name_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle_)
|
||||||
|
{
|
||||||
|
::DestroyWindow(handle_);
|
||||||
|
handle_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Window::Prepare()
|
void Window::Prepare()
|
||||||
{
|
{
|
||||||
::ShowWindow(handle_, SW_SHOWNORMAL);
|
::ShowWindow(handle_, SW_SHOWNORMAL);
|
||||||
|
|
@ -338,15 +348,6 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::Destroy()
|
|
||||||
{
|
|
||||||
if (handle_)
|
|
||||||
{
|
|
||||||
::DestroyWindow(handle_);
|
|
||||||
handle_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
MONITORINFOEX GetMoniterInfoEx(HWND hwnd)
|
MONITORINFOEX GetMoniterInfoEx(HWND hwnd)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Window
|
class E2D_API Window
|
||||||
: public ISingleton<Window>
|
: public ISingleton<Window>
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(Window);
|
E2D_DECLARE_SINGLETON(Window);
|
||||||
|
|
@ -64,6 +64,8 @@ namespace easy2d
|
||||||
bool debug
|
bool debug
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
void Prepare();
|
void Prepare();
|
||||||
|
|
||||||
HWND GetHandle() const;
|
HWND GetHandle() const;
|
||||||
|
|
@ -74,8 +76,6 @@ namespace easy2d
|
||||||
|
|
||||||
void SetActive(bool actived);
|
void SetActive(bool actived);
|
||||||
|
|
||||||
void Destroy();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Window();
|
Window();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,10 @@ namespace easy2d
|
||||||
Vec2 bottom_left = Transform(rect.GetLeftBottom());
|
Vec2 bottom_left = Transform(rect.GetLeftBottom());
|
||||||
Vec2 bottom_right = Transform(rect.GetRightBottom());
|
Vec2 bottom_right = Transform(rect.GetRightBottom());
|
||||||
|
|
||||||
float left = min(min(top_left.x, top_right.x), min(bottom_left.x, bottom_right.x));
|
float left = std::min(std::min(top_left.x, top_right.x), std::min(bottom_left.x, bottom_right.x));
|
||||||
float right = max(max(top_left.x, top_right.x), max(bottom_left.x, bottom_right.x));
|
float right = std::max(std::max(top_left.x, top_right.x), std::max(bottom_left.x, bottom_right.x));
|
||||||
float top = min(min(top_left.y, top_right.y), min(bottom_left.y, bottom_right.y));
|
float top = std::min(std::min(top_left.y, top_right.y), std::min(bottom_left.y, bottom_right.y));
|
||||||
float bottom = max(max(top_left.y, top_right.y), max(bottom_left.y, bottom_right.y));
|
float bottom = std::max(std::max(top_left.y, top_right.y), std::max(bottom_left.y, bottom_right.y));
|
||||||
|
|
||||||
return Rect{ left, top, (right - left), (bottom - top) };
|
return Rect{ left, top, (right - left), (bottom - top) };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "vector.hpp"
|
#include "vector.hpp"
|
||||||
#include "Rect.hpp"
|
#include "Rect.hpp"
|
||||||
#include <d2d1.h>
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
namespace math
|
namespace math
|
||||||
{
|
{
|
||||||
struct Matrix
|
struct E2D_API Matrix
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace easy2d
|
||||||
namespace math
|
namespace math
|
||||||
{
|
{
|
||||||
// 矩形
|
// 矩形
|
||||||
struct Rect
|
struct E2D_API Rect
|
||||||
{
|
{
|
||||||
Vec2 origin; // 左上角坐标
|
Vec2 origin; // 左上角坐标
|
||||||
Vec2 size; // 宽度和高度
|
Vec2 size; // 宽度和高度
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../core/macros.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -34,7 +35,7 @@ namespace easy2d
|
||||||
// double d = math::Rand(1.2, 1.5);
|
// double d = math::Rand(1.2, 1.5);
|
||||||
//
|
//
|
||||||
|
|
||||||
std::default_random_engine& GetRandomEngine();
|
E2D_API std::default_random_engine& GetRandomEngine();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T RandomInt(T min, T max)
|
static T RandomInt(T min, T max)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../core/macros.h"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
namespace math
|
namespace math
|
||||||
{
|
{
|
||||||
struct Vec2
|
struct E2D_API Vec2
|
||||||
{
|
{
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
class Button
|
class E2D_API Button
|
||||||
: public Sprite
|
: public Sprite
|
||||||
{
|
{
|
||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace easy2d
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
// 꽉데
|
// 꽉데
|
||||||
class Menu
|
class E2D_API Menu
|
||||||
: public Node
|
: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 数据管理工具
|
// 数据管理工具
|
||||||
class Data
|
class E2D_API Data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Data(
|
Data(
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 文件
|
// 文件
|
||||||
class File
|
class E2D_API File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
File();
|
File();
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 路径
|
// 路径
|
||||||
class Path
|
class E2D_API Path
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 获取数据的默认保存路径
|
// 获取数据的默认保存路径
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 音乐播放器
|
// 音乐播放器
|
||||||
class Player
|
class E2D_API Player
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
using MusicMap = Map<size_t, MusicPtr>;
|
using MusicMap = Map<size_t, MusicPtr>;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class ResLoader
|
class E2D_API ResLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Ìí¼ÓͼƬ
|
// Ìí¼ÓͼƬ
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class Transcoder
|
class E2D_API Transcoder
|
||||||
{
|
{
|
||||||
WAVEFORMATEX* wave_format_;
|
WAVEFORMATEX* wave_format_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,12 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../core/macros.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
std::wstring StringMultiByteToWideChar(const std::string& str);
|
E2D_API std::wstring StringMultiByteToWideChar(const std::string& str);
|
||||||
|
|
||||||
std::string StringWideCharToMultiByte(const std::wstring& wstr);
|
E2D_API std::string StringWideCharToMultiByte(const std::wstring& wstr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue