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