From 7a1a0568eaed7b4347835782d26aa0d25a16f199 Mon Sep 17 00:00:00 2001 From: cflw Date: Thu, 23 Apr 2020 20:17:42 +0800 Subject: [PATCH] 20200423 --- .../cflw\345\233\276\345\275\242_d2d.cpp" | 18 +++++------ ...5\275\242_d2d\345\212\251\346\211\213.cpp" | 22 ++++++------- .../cflw\345\233\276\345\275\242_d3d11.cpp" | 2 +- ...d3d\347\235\200\350\211\262\345\231\250.h" | 2 +- ..._dx\347\235\200\350\211\262\345\231\250.h" | 2 +- ...45\275\242_dx\347\272\271\347\220\206.cpp" | 26 ++++++++-------- ...\345\275\242_dx\347\272\271\347\220\206.h" | 20 ++++++------ .../cflw\345\267\245\345\205\267.inl" | 6 ++-- .../cflw\345\274\202\345\270\270.cpp" | 4 +-- .../cflw\345\274\202\345\270\270.h" | 3 +- ...225\344\275\215\350\275\254\346\215\242.h" | 22 ++++++------- ...\345\255\246_\345\233\276\345\275\242.cpp" | 10 +++--- ...3\351\235\242\345\207\240\344\275\225.cpp" | 31 +++++++++++++------ ...263\351\235\242\345\207\240\344\275\225.h" | 6 ++-- ...60\345\255\246_\346\235\202\347\203\251.h" | 1 + ...\345\255\246_\346\235\202\347\203\251.inl" | 9 ++++-- .../cflw\346\226\207\344\273\266_csv.cpp" | 14 ++++----- .../cflw\346\226\207\344\273\266_csv.h" | 4 +-- .../cflw\346\227\266\351\227\264.cpp" | 2 +- .../cflw\350\247\206\347\252\227.cpp" | 2 +- .../cflw\350\247\206\347\252\227.h" | 10 +++--- .../cflw\350\276\223\345\205\245_win.cpp" | 24 +++++++------- .../cflw\350\276\223\345\205\245_xi.cpp" | 4 +-- .../cflw\351\237\263\351\242\221_xa2.cpp" | 2 +- 24 files changed, 134 insertions(+), 112 deletions(-) diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d.cpp" index 2700726..fb99855 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d.cpp" @@ -173,10 +173,10 @@ ComPtr C二维::fc纯色画笔(const 数学::S颜色 &a颜 return v画笔; } ComPtr C二维::fc位图(const dx纹理::I纹理 &a纹理) { - const D2D1_SIZE_U v大小 = {a纹理.fg宽(), a纹理.fg宽()}; + const D2D1_SIZE_U v大小 = {(UINT32)a纹理.fg宽(), (UINT32)a纹理.fg宽()}; const D2D1_BITMAP_PROPERTIES v属性 = {{a纹理.fg格式(), D2D1_ALPHA_MODE_STRAIGHT}, 96, 96}; ComPtr v位图; - HRESULT hr = m渲染目标->CreateBitmap(v大小, a纹理.fg数据(), a纹理.fg行距(), v属性, &v位图); + HRESULT hr = m渲染目标->CreateBitmap(v大小, a纹理.fg数据(), (UINT32)a纹理.fg行距(), v属性, &v位图); return v位图; } ComPtr C二维::fc位图(const ComPtr &a源) { @@ -192,7 +192,7 @@ ComPtr C二维::fc位图画笔(const ComPtr &a位 ComPtr C二维::fc渐变点集(const std::vector &a) const { std::vector va渐变点 = C类型转换::f渐变点(a); ComPtr v渐变点集; - m渲染目标->CreateGradientStopCollection(va渐变点.data(), va渐变点.size(), &v渐变点集); + m渲染目标->CreateGradientStopCollection(va渐变点.data(), (UINT32)va渐变点.size(), &v渐变点集); return v渐变点集; } ComPtr C二维::fc线性渐变画笔(const std::vector &a) const { @@ -444,7 +444,7 @@ void C画文本::fs区域(const 数学::S矩形 &a) { m矩形 = m坐标计算->f矩形_中心半径(a.m坐标, a.m半尺寸); } void C画文本::f绘制文本(const std::wstring_view &a文本) const { - m渲染目标->DrawTextW(a文本.data(), a文本.size(), m格式.Get(), m矩形, m画笔.Get()); + m渲染目标->DrawTextW(a文本.data(), (UINT32)a文本.size(), m格式.Get(), m矩形, m画笔.Get()); } void C画文本::f绘制文本布局(IDWriteTextLayout *a布局) const { m渲染目标->DrawTextLayout({m矩形.left, m矩形.top}, a布局, m画笔.Get()); @@ -471,9 +471,9 @@ D2D1_COLOR_F C类型转换::f颜色(const 数学::S颜色 &a) { return {a.r, a.g, a.b, a.a}; } std::vector C类型转换::f渐变点(const std::vector &a) { - const int n = a.size(); + const size_t n = a.size(); std::vector v数组(n); - for (int i = 0; i != n; ++i) { + for (size_t i = 0; i != n; ++i) { const S渐变点 &v0 = a[i]; D2D1_GRADIENT_STOP &v1 = v数组[i]; v1.position = v0.m位置; @@ -594,8 +594,8 @@ void C修改路径几何::f连续直线(const std::vector<数学::S向量2> &a) } else { m几何槽->AddLine(m坐标计算->f点(a[0])); } - const int n = a.size(); - for (int i = 1; i != n; ++i) { + const size_t n = a.size(); + for (size_t i = 1; i != n; ++i) { m几何槽->AddLine(m坐标计算->f点(a[i])); } } @@ -667,7 +667,7 @@ tp文本布局 C文本工厂::fc文本布局(const std::wstring_view &a文本, I a格式 = C二维::g这->fg默认文本格式().Get(); } ComPtr v布局; - HRESULT hr = m写字工厂->CreateTextLayout(a文本.data(), a文本.size(), a格式, 0, 0, &v布局); + HRESULT hr = m写字工厂->CreateTextLayout(a文本.data(), (UINT32)a文本.size(), a格式, 0, 0, &v布局); return v布局; } tp文本布局 C文本工厂::fc文本布局(const std::wstring_view &a文本, const S文本格式参数 &a格式) const { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d\345\212\251\346\211\213.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d\345\212\251\346\211\213.cpp" index 5c88aa0..c69664b 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d\345\212\251\346\211\213.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d2d\345\212\251\346\211\213.cpp" @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -13,18 +13,18 @@ void GetFirstControlPoints( __in const std::vector& rhs, __out std::vector& x) { assert(rhs.size() == x.size()); - int n = rhs.size(); + size_t n = rhs.size(); std::vector tmp(n); // Temp workspace. FLOAT b = 2.0f; x[0] = rhs[0] / b; - for (int i = 1; i < n; i++) // Decomposition and forward substitution. + for (size_t i = 1; i < n; i++) // Decomposition and forward substitution. { tmp[i] = 1 / b; b = (i < n - 1 ? 4.0f : 3.5f) - tmp[i]; x[i] = (rhs[i] - x[i - 1]) / b; } - for (int i = 1; i < n; i++) { + for (size_t i = 1; i < n; i++) { x[n - i - 1] -= tmp[n - i] * x[n - i]; // Back substitution. } } @@ -43,7 +43,7 @@ void GetCurveControlPoints( assert((firstCtrlPt.size() == secondCtrlPt.size()) && (knots.size() == firstCtrlPt.size() + 1)); - int n = knots.size() - 1; + size_t n = knots.size() - 1; assert(n >= 1); if (n == 1) { @@ -52,7 +52,7 @@ void GetCurveControlPoints( firstCtrlPt[0].x = (2 * knots[0].x + knots[1].x) / 3.0f; firstCtrlPt[0].y = (2 * knots[0].y + knots[1].y) / 3.0f; - // P2 = 2P1 C P0 + // P2 = 2P1 �C P0 secondCtrlPt[0].x = 2 * firstCtrlPt[0].x - knots[0].x; secondCtrlPt[0].y = 2 * firstCtrlPt[0].y - knots[0].y; return; @@ -63,7 +63,7 @@ void GetCurveControlPoints( std::vector rhs(n); // Set right hand side X values - for (int i = 1; i < (n - 1); ++i) { + for (size_t i = 1; i < (n - 1); ++i) { rhs[i] = 4 * knots[i].x + 2 * knots[i + 1].x; } rhs[0] = knots[0].x + 2 * knots[1].x; @@ -73,7 +73,7 @@ void GetCurveControlPoints( GetFirstControlPoints(rhs, x); // Set right hand side Y values - for (int i = 1; i < (n - 1); ++i) { + for (size_t i = 1; i < (n - 1); ++i) { rhs[i] = 4 * knots[i].y + 2 * knots[i + 1].y; } rhs[0] = knots[0].y + 2 * knots[1].y; @@ -83,7 +83,7 @@ void GetCurveControlPoints( GetFirstControlPoints(rhs, y); // Fill output arrays. - for (int i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { // First control point firstCtrlPt[i] = D2D1::Point2F(x[i], y[i]); // Second control point @@ -103,7 +103,7 @@ HRESULT CreateBezierSpline( assert(ppPathGeometry != nullptr); assert(points.size()>1); - int n = points.size(); + size_t n = points.size(); std::vector firstCtrlPt(n - 1); std::vector secondCtrlPt(n - 1); GetCurveControlPoints(points, firstCtrlPt, secondCtrlPt); @@ -119,7 +119,7 @@ HRESULT CreateBezierSpline( if (SUCCEEDED(hr)) { spSink->SetFillMode(D2D1_FILL_MODE_WINDING); spSink->BeginFigure(points[0], D2D1_FIGURE_BEGIN_FILLED); - for (int i = 1; iAddBezier(D2D1::BezierSegment(firstCtrlPt[i - 1], secondCtrlPt[i - 1], points[i])); spSink->EndFigure(D2D1_FIGURE_END_OPEN); spSink->Close(); diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d11.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d11.cpp" index 91e4338..35b062f 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d11.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d11.cpp" @@ -232,7 +232,7 @@ HRESULT C三维::f创建域着色器(tp域着色器 &a, const std::spanCreateDomainShader(a代码.data(), a代码.size(), nullptr, &a); } HRESULT C三维::f创建输入布局(tp输入布局 &a, const std::span &a代码, const C顶点格式 &a顶点格式) { - return m设备->CreateInputLayout(a顶点格式.m数组.data(), a顶点格式.m数组.size(), a代码.data(), a代码.size(), &a); + return m设备->CreateInputLayout(a顶点格式.m数组.data(), (UINT)a顶点格式.m数组.size(), a代码.data(), a代码.size(), &a); } HRESULT C三维::f创建图形管线(tp图形管线 &a, const S图形管线参数 &a参数) { HRESULT hr; diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d\347\235\200\350\211\262\345\231\250.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d\347\235\200\350\211\262\345\231\250.h" index 630e681..fe9f344 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d\347\235\200\350\211\262\345\231\250.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_d3d\347\235\200\350\211\262\345\231\250.h" @@ -28,6 +28,6 @@ class C着色器工厂 { std::string m顶点着色模型, m像素着色模型, m几何着色模型, m外壳着色模型, m域着色模型, m计算着色模型; }; inline std::span fc跨度(const ComPtr &a) { - return {(std::byte*)a->GetBufferPointer(), (std::span::index_type)a->GetBufferSize()}; + return {(std::byte*)a->GetBufferPointer(), (std::span::size_type)a->GetBufferSize()}; } } //namespace cflw::图形::d3d着色器 diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\235\200\350\211\262\345\231\250.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\235\200\350\211\262\345\231\250.h" index 446666f..5e4d2db 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\235\200\350\211\262\345\231\250.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\235\200\350\211\262\345\231\250.h" @@ -28,6 +28,6 @@ class C着色器工厂 { ComPtr m库; }; inline std::span fc跨度(const ComPtr &a) { - return {(std::byte*)a->GetBufferPointer(), (std::span::index_type)a->GetBufferSize()}; + return {(std::byte*)a->GetBufferPointer(), (std::span::size_type)a->GetBufferSize()}; } } //namespace cflw::图形::dx着色器 \ No newline at end of file diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.cpp" index 04b804e..e0a13ec 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.cpp" @@ -25,10 +25,10 @@ HRESULT C图像工厂::f初始化() { } return S_OK; } -HRESULT C图像工厂::f读取图像(const wchar_t *a文件, IWICBitmapFrameDecode **a帧) { +HRESULT C图像工厂::f读取图像(const std::wstring_view &a文件, IWICBitmapFrameDecode **a帧) const { HRESULT hr; ComPtr v解码器; - hr = m工厂->CreateDecoderFromFilename(a文件, 0, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &v解码器); + hr = m工厂->CreateDecoderFromFilename(a文件.data(), 0, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &v解码器); if (FAILED(hr)) { return hr; } @@ -38,13 +38,13 @@ HRESULT C图像工厂::f读取图像(const wchar_t *a文件, IWICBitmapFrameDeco } return S_OK; } -std::unique_ptr C图像工厂::f复制像素数据(IWICBitmapSource *a帧, size_t *ap像素大小, size_t *ap行距, size_t *ap图像大小) { +std::unique_ptr C图像工厂::f复制像素数据(IWICBitmapSource *a帧, size_t *ap像素大小, size_t *ap行距, size_t *ap图像大小) const { const WICBitmapPlaneDescription v描述 = f取图像描述(a帧); const size_t v像素大小 = f像素大小(v描述.Format); const size_t v一排大小 = v描述.Width * v像素大小; const size_t v数据大小 = v一排大小 * v描述.Height; std::unique_ptr v数据 = std::make_unique(v数据大小); - a帧->CopyPixels(0, v一排大小, v数据大小, (BYTE*)v数据.get()); + a帧->CopyPixels(0, (UINT)v一排大小, (UINT)v数据大小, (BYTE*)v数据.get()); if (ap像素大小) { *ap像素大小 = v像素大小; } @@ -56,13 +56,13 @@ std::unique_ptr C图像工厂::f复制像素数据(IWICBitmapSource } return v数据; } -WICBitmapPlaneDescription C图像工厂::f取图像描述(IWICBitmapSource *a帧) { +WICBitmapPlaneDescription C图像工厂::f取图像描述(IWICBitmapSource *a帧) const { WICBitmapPlaneDescription v; a帧->GetPixelFormat(&v.Format); a帧->GetSize(&v.Width, &v.Height); return v; } -size_t C图像工厂::f像素大小(const GUID &guid) { +size_t C图像工厂::f像素大小(const GUID &guid) const { HRESULT hr; ComPtr v组件信息; hr = m工厂->CreateComponentInfo(guid, &v组件信息); @@ -83,7 +83,7 @@ size_t C图像工厂::f像素大小(const GUID &guid) { v格式信息->GetBitsPerPixel(&bpp); return bpp; } -HRESULT C图像工厂::f图像尺寸变换(IWICBitmapSource *a帧, size_t a宽, size_t a高, IWICBitmapScaler **a输出) { +HRESULT C图像工厂::f图像尺寸变换(IWICBitmapSource *a帧, size_t a宽, size_t a高, IWICBitmapScaler **a输出) const { HRESULT hr; ComPtr v缩放; hr = m工厂->CreateBitmapScaler(&v缩放); @@ -97,7 +97,7 @@ HRESULT C图像工厂::f图像尺寸变换(IWICBitmapSource *a帧, size_t a宽, *a输出 = v缩放.Detach(); return S_OK; } -HRESULT C图像工厂::f图像格式变换(IWICBitmapSource *a图像, const GUID &a格式, IWICFormatConverter **a输出) { +HRESULT C图像工厂::f图像格式变换(IWICBitmapSource *a图像, const GUID &a格式, IWICFormatConverter **a输出) const { HRESULT hr; ComPtr v转换; hr = m工厂->CreateFormatConverter(&v转换); @@ -111,7 +111,7 @@ HRESULT C图像工厂::f图像格式变换(IWICBitmapSource *a图像, const GUID *a输出 = v转换.Detach(); return S_OK; } -ComPtr C图像工厂::f高级读取(const wchar_t *a文件名, const std::function &af格式) { +ComPtr C图像工厂::f高级读取(const std::wstring_view &a文件名, const std::function &af格式) const { ComPtr v图像; HRESULT hr = f读取图像(a文件名, &v图像); if (FAILED(hr)) { @@ -130,7 +130,7 @@ ComPtr C图像工厂::f高级读取(const wchar_t *a文件名, } return v格式转换; } -std::unique_ptr C图像工厂::fc纹理(IWICBitmapSource *a源) { +std::unique_ptr C图像工厂::fc纹理(IWICBitmapSource *a源) const { std::unique_ptr v纹理 = std::make_unique(); v纹理->mp数据 = f复制像素数据(a源, &v纹理->m像素大小, &v纹理->m行距, nullptr); if (!v纹理->mp数据) { @@ -142,7 +142,7 @@ std::unique_ptr C图像工厂::fc纹理(IWICBitmapSource *a源) { v纹理->m格式 = 格式::f到dxgi(v描述.Format); return v纹理; } -std::unique_ptr C图像工厂::f一键读取(const wchar_t *a文件名) { +std::unique_ptr C图像工厂::f一键读取(const std::wstring_view &a文件名) const { auto v源 = f高级读取(a文件名, 格式::f到通用格式); return fc纹理(v源.Get()); } @@ -413,8 +413,8 @@ const 数学::S颜色 &C自定义纹理::fg像素(size_t u, size_t v) const { return mp像素[v * m宽 + u]; } 数学::S颜色 C自定义纹理::f线性采样(float u, float v) const { - const float v限制u = 数学::f求余(u, m宽); - const float v限制v = 数学::f求余(v, m高); + const float v限制u = 数学::f求余(u, (float)m宽); + const float v限制v = 数学::f求余(v, (float)m高); const float v地板u = floor(u); const float v地板v = floor(v); const size_t u0 = (size_t)v地板u; diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.h" index b7587c9..44aefe4 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\233\276\345\275\242_dx\347\272\271\347\220\206.h" @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include #include #include @@ -35,20 +36,21 @@ using Microsoft::WRL::ComPtr; class C只读纹理; //============================================================================== // 工厂 +// 注意:图像工厂尽量不要作为局部变量存在。一旦最后一个CoUninitialize被调用,所有创建的对象将被释放 //============================================================================== class C图像工厂 { public: ~C图像工厂(); HRESULT f初始化(); - HRESULT f读取图像(const wchar_t *, IWICBitmapFrameDecode **); - std::unique_ptr f复制像素数据(IWICBitmapSource *, size_t *像素大小 = nullptr, size_t *行距 = nullptr, size_t *图像大小 = nullptr); - size_t f像素大小(const GUID &); - WICBitmapPlaneDescription f取图像描述(IWICBitmapSource *); - HRESULT f图像尺寸变换(IWICBitmapSource *, size_t, size_t, IWICBitmapScaler **); - HRESULT f图像格式变换(IWICBitmapSource *, const GUID &, IWICFormatConverter **); - ComPtr f高级读取(const wchar_t *, const std::function &格式转换 = 格式::f不转换); - std::unique_ptr fc纹理(IWICBitmapSource *); - std::unique_ptr f一键读取(const wchar_t *); + HRESULT f读取图像(const std::wstring_view &, IWICBitmapFrameDecode **) const; + std::unique_ptr f复制像素数据(IWICBitmapSource *, size_t *像素大小 = nullptr, size_t *行距 = nullptr, size_t *图像大小 = nullptr) const; + size_t f像素大小(const GUID &) const; + WICBitmapPlaneDescription f取图像描述(IWICBitmapSource *) const; + HRESULT f图像尺寸变换(IWICBitmapSource *, size_t, size_t, IWICBitmapScaler **) const; + HRESULT f图像格式变换(IWICBitmapSource *, const GUID &, IWICFormatConverter **) const; + ComPtr f高级读取(const std::wstring_view &, const std::function &格式转换 = 格式::f不转换) const; + std::unique_ptr fc纹理(IWICBitmapSource *) const; + std::unique_ptr f一键读取(const std::wstring_view &) const; public: ComPtr m工厂; }; diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\267\245\345\205\267.inl" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\267\245\345\205\267.inl" index 19cc3cd..d4d7d7b 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\267\245\345\205\267.inl" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\267\245\345\205\267.inl" @@ -102,7 +102,7 @@ template t C文本::f文本_整数(const t字符串 &s) { //取负号 if (!辅助::fi无符号(v)) { if (s[v读取位] == L'-') { - v符号 = -1; + v符号 = (t)(-1); ++v读取位; } } @@ -157,10 +157,10 @@ template t C文本::f文本_浮点数(const t字符串 &s) { if (v读取字符 == L'.') { continue; } - v += (v读取字符 - L'0') * pow((t)10, v当前位); + v += (v读取字符 - L'0') * (t)pow((t)10, v当前位); ++v当前位; } - v *= pow((t)10, v小数位置 - v位数); + v *= (t)pow((t)10, v小数位置 - v位数); return v * v符号; } //============================================================================== diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.cpp" index 41395c8..f15bb88 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.cpp" @@ -2,8 +2,8 @@ #include "cflw异常.h" #include "cflw工具.h" namespace cflw::异常 { -X未实现::X未实现(): - std::runtime_error("该函数未实现") { +X未实现::X未实现(const std::string &a文本): + std::runtime_error(a文本) { } X视窗::X视窗(long a): std::runtime_error(std::string("HRESULT:") + std::to_string(a)) { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.h" index 3d58e17..43084a2 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\345\274\202\345\270\270.h" @@ -1,13 +1,14 @@ #pragma once #include #include +#include namespace cflw::异常 { //标准库异常别名 using X参数 = std::invalid_argument; //未实现 class X未实现 : public std::runtime_error { public: - X未实现(); + X未实现(const std::string & = "未实现"); }; //HRESULT class X视窗 : public std::runtime_error { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\215\225\344\275\215\350\275\254\346\215\242.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\215\225\344\275\215\350\275\254\346\215\242.h" index 7f5641a..174157c 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\215\225\344\275\215\350\275\254\346\215\242.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\215\225\344\275\215\350\275\254\346\215\242.h" @@ -5,13 +5,13 @@ namespace cflw::数学 { class C转换因子表 { public: - C转换因子表(const std::initializer_list &p列表) : - v大小{p列表.size()}, - v数据{new double[v大小 * v大小]} { - int i = 0; - for (const double &x : p列表) { - int j = 0; - for (const double &y : p列表) { + C转换因子表(const std::initializer_list &a列表) : + v大小(a列表.size()), + v数据(new double[v大小 * v大小]) { + size_t i = 0; + for (const double &x : a列表) { + size_t j = 0; + for (const double &y : a列表) { v数据[i + j] = y / x; ++j; } @@ -26,15 +26,15 @@ class C转换因子表 { template double operator()(const t &x, const t &y) const { static_assert(std::is_enum::value, "必需是枚举类型"); - const int vx = static_cast(x); + const size_t vx = static_cast(x); assert(vx < v大小); - const int vy = static_cast(y); + const size_t vy = static_cast(y); assert(vy < v大小); return v数据[vx * v大小 + vy]; } template - t数值 operator()(const t单位 &x, const t单位 &y, const t数值 &p数值) const { - return static_cast(operator()(x, y)) * p数值; + t数值 operator()(const t单位 &x, const t单位 &y, const t数值 &a数值) const { + return static_cast(operator()(x, y)) * a数值; } private: size_t v大小 = 0; diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\233\276\345\275\242.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\233\276\345\275\242.cpp" index 36af300..6cdfec1 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\233\276\345\275\242.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\233\276\345\275\242.cpp" @@ -219,11 +219,11 @@ S颜色_亮色浓 S颜色::ft亮色浓() const { // 颜色yuv //============================================================================== S颜色 S颜色_亮色浓::ft红绿蓝() const { - S颜色 v; - v.r = y + 1.14f * v; - v.g = y - 0.39f * u - 0.58f * v; - v.b = y + 2.03f * u; - return v; + S颜色 v返回; + v返回.r = y + 1.14f * v; + v返回.g = y - 0.39f * u - 0.58f * v; + v返回.b = y + 2.03f * u; + return v返回; } //============================================================================== // 世界矩阵2 diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.cpp" index 04e30e3..375551f 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.cpp" @@ -97,9 +97,17 @@ bool f向量线段相交判定(const S向量2 &a点, const S线段2 &a线) { bool f向量圆形相交判定(const S向量2 &a向量, const S圆形 &a圆形) { return (a向量 - a圆形.m坐标).fg大小() <= a圆形.m半径; } +bool f向量矩形相交判定(const S向量2 &a向量, const S矩形 &a矩形) { + const S向量2 v相对坐标 = a向量 - a矩形.m坐标; + const bool x = abs(v相对坐标.x) <= a矩形.m半尺寸.x; + const bool y = abs(v相对坐标.y) <= a矩形.m半尺寸.y; + return x && y; +} bool f向量旋转矩形相交判定(const S向量2 &a向量, const S旋转矩形 &a矩形) { - const S向量2 v = (a向量 - a矩形.m坐标).f旋转r(-a矩形.m方向); - return (abs(v.x) <= a矩形.m半尺寸.x && abs(v.y) <= a矩形.m半尺寸.y); + const S向量2 v相对坐标 = (a向量 - a矩形.m坐标).f旋转r(-a矩形.m方向); + const bool x = abs(v相对坐标.x) <= a矩形.m半尺寸.x; + const bool y = abs(v相对坐标.y) <= a矩形.m半尺寸.y; + return x && y; } bool f圆形相交判定(const S圆形 &a圆形1, const S圆形 &a圆形2) { return f圆形相交判定(a圆形1.m坐标, a圆形1.m半径, a圆形2.m坐标, a圆形2.m半径); @@ -273,25 +281,25 @@ S向量2 S圆形::fg点r(const float &r) const { S向量2 S圆形::fg点d(const float &d) const { return fg点r(d * c度到弧度); } -S向量2 S圆形::f离边最近点(const S圆形 &p圆) const { - const float m方向1 = m坐标.f到点方向r(p圆.m坐标); +S向量2 S圆形::f离边最近点(const S圆形 &a圆) const { + const float m方向1 = m坐标.f到点方向r(a圆.m坐标); const S向量2 m点1 = fg点r(m方向1); - const float m方向2 = p圆.m坐标.f到点方向r(m坐标); - const S向量2 m点2 = p圆.fg点r(m方向2); + const float m方向2 = a圆.m坐标.f到点方向r(m坐标); + const S向量2 m点2 = a圆.fg点r(m方向2); return S向量2((m点1.x + m点2.x) / 2, (m点1.y + m点2.y) / 2); } -bool S圆形::f包含判定(const S向量2 &p) const { +bool S圆形::fi包含点(const S向量2 &p) const { return f向量圆形相交判定(p, *this); } float S圆形::f中线切线夹角r(const S向量2 &a点) const { - if (f包含判定(a点)) { + if (fi包含点(a点)) { return 0; //点不能在圆内 } const float m中线 = m坐标.f到点距离(a点); return asin(m半径 / m中线); } float S圆形::f垂直于中线到切线距离(const S向量2 &a点) const { - if (f包含判定(a点)) { + if (fi包含点(a点)) { return m半径; //点不能在圆内 } const float m中线 = m坐标.f到点距离(a点); @@ -383,6 +391,9 @@ S矩形 S矩形::f下边移(float y) const { const float v半尺寸y = m半尺寸.y - y * 0.5f; return S矩形::fc坐标半尺寸({m坐标.x, v坐标y}, {m半尺寸.x, v半尺寸y}); } +bool S矩形::fi包含点(const S向量2 &a点) const { + return f向量矩形相交判定(a点, *this); +} //============================================================================== // 旋转矩形 //============================================================================== @@ -433,7 +444,7 @@ float S旋转矩形::fg短半轴长() const { S向量2 S旋转矩形::fg全尺寸() const { return m半尺寸 * 2; } -bool S旋转矩形::f包含判定(const S向量2 &p) const { +bool S旋转矩形::fi包含点(const S向量2 &p) const { return f向量旋转矩形相交判定(p, *this); } S向量2 S旋转矩形::fg点(float X, float Y) const { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.h" index 215ba67..70f5bfd 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\345\271\263\351\235\242\345\207\240\344\275\225.h" @@ -27,7 +27,7 @@ struct S圆形 { S向量2 fg点r(const float &方向) const; S向量2 fg点d(const float &方向) const; S向量2 f离边最近点(const S圆形 &) const; - bool f包含判定(const S向量2 &) const; + bool fi包含点(const S向量2 &) const; float f中线切线夹角r(const S向量2 &) const; //中线=过圆心与一点的直线 float f垂直于中线到切线距离(const S向量2 &) const; //切线=过圆外一点切圆的直线 }; @@ -55,6 +55,7 @@ struct S矩形 { S矩形 f右边移(float) const; S矩形 f上边移(float) const; S矩形 f下边移(float) const; + bool fi包含点(const S向量2 &) const; }; struct S旋转矩形 { S向量2 m坐标 = S向量2::c零; @@ -75,7 +76,7 @@ struct S旋转矩形 { float fg短半轴长() const; S向量2 fg全尺寸() const; bool f遍历顶点(std::function) const; - bool f包含判定(const S向量2 &) const; + bool fi包含点(const S向量2 &) const; S窗口矩形 f到窗口矩形(float, float); }; struct S窗口矩形 { @@ -215,6 +216,7 @@ bool f圆形旋转矩形相交判定(const S向量2 &, float, const S向量2 &, bool f向量重叠判定(float *, float *, int); bool f向量线段相交判定(const S向量2 &, const S线段2 &); bool f向量圆形相交判定(const S向量2 &, const S圆形 &); +bool f向量矩形相交判定(const S向量2 &, const S矩形 &); bool f向量旋转矩形相交判定(const S向量2 &, const S旋转矩形 &); bool f圆形相交判定(const S圆形 &, const S圆形 &); bool f圆形旋转矩形相交判定(const S圆形 &, const S旋转矩形 &); diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.h" index 7042242..0b128dc 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.h" @@ -55,6 +55,7 @@ template struct S范围 { S范围 &fs合并(const S范围 &); bool fi范围内(const t &) const; bool fi相交(const S范围 &) const; + bool fi零() const; //小==大,范围为0 S范围 f合并(const S范围 &) const; }; //范围变换计算 diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.inl" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.inl" index 5f8dd7e..a313826 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.inl" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\225\260\345\255\246_\346\235\202\347\203\251.inl" @@ -48,8 +48,9 @@ template t C位置计算::f上到下(const t &a位置, const t &a template S有限值::S有限值() :m当前((t)-1), m最大((t)-1) {} template S有限值::S有限值(const t &_) : m当前(_), m最大(_) {} template void S有限值::f检查() { - if (m当前 > m最大) + if (m当前 > m最大) { m当前 = m最大; + } } template void S有限值::f重置(const t &_) { m当前 = _; @@ -64,7 +65,7 @@ template typename S有限值::t小数 S有限值::fg百分比( //============================================================================== // 范围 //============================================================================== -template S范围::S范围() : m小(), m大() { +template S范围::S范围() : m小(0), m大(1) { } template S范围::S范围(const t &a小, const t &a大) : m小(a小), m大(a大) { } @@ -132,6 +133,9 @@ template bool S范围::fi相交(const S范围 &a范围) const { const t v中心 = a范围.fg中心() - fg中心(); return v中心 <= a范围.fg半径() + fg半径(); } +template bool S范围::fi零() const { + return m小 == m大; +} template S范围 S范围::f合并(const S范围 &a范围) const { return{std::min(m小, a范围.m小), std::max(m大, a范围.m大)}; } @@ -145,6 +149,7 @@ template C范围变换计算::C范围变换计算(const S范围 t C范围变换计算::f变换计算(const S范围 &a前, const S范围 &a后, const t &a值) { + assert(!a前.fi零()); //不能是0,不然会出现除以0异常 return (a值 - a前.m小) / a前.fg直径() * a后.fg直径() + a后.m小; } template t C范围变换计算::operator ()(const t &a) const { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.cpp" index 2ce5d8f..c364028 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.cpp" @@ -6,8 +6,8 @@ namespace csv { //============================================================================= // 行 //============================================================================= -S行::S行(std::vector &p数组) : - m数组{&p数组} { +S行::S行(std::vector &a数组) : + m数组(&a数组) { } const std::wstring &S行::operator[](size_t i) const { return m数组->at(i); @@ -18,8 +18,8 @@ std::vector &S行::fe() const { //============================================================================= // 循环 //============================================================================= -C行循环::C行循环(std::wifstream &p文件) : - m文件{&p文件} { +C行循环::C行循环(std::wifstream &a) : + m文件(&a) { } bool C行循环::f循环控制_i继续() { return !m文件->eof(); @@ -51,13 +51,13 @@ C行循环 C读::fe行() { } return C行循环{m文件}; } -void C读::fs标题行(bool p) { - m标题行 = p; +void C读::fs标题行(bool a) { + m标题行 = a; } //============================================================================= // 写 //============================================================================= -void C写::f打开(const std::wstring &, int p模式) { +void C写::f打开(const std::wstring &, int a模式) { } void C写::fs列数(int) { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.h" index c4b02b7..d9e0d2b 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\226\207\344\273\266_csv.h" @@ -33,7 +33,7 @@ class C读 { void fs标题行(bool); //如果有,fe行()不会出现标题行 private: bool m标题行 = false; - int m第二行开始位置 = 0; + size_t m第二行开始位置 = 0; std::wifstream m文件; }; //============================================================================= @@ -41,7 +41,7 @@ class C读 { //============================================================================= class C写 { public: - void f打开(const std::wstring &, int p模式 = std::ios::out); + void f打开(const std::wstring &, int 模式 = std::ios::out); void fs列数(int); template C写 &operator <<(const t &); private: diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\227\266\351\227\264.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\227\266\351\227\264.cpp" index 555ffa2..7b186c1 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\346\227\266\351\227\264.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\346\227\266\351\227\264.cpp" @@ -82,7 +82,7 @@ double C计帧器::f计算() { const t时间点 v这次时间 = fg现在(); const double v这次间隔 = f间隔(m时间.back(), v这次时间).count(); const int v保留数量 = (int)(c取数范围 / v这次间隔); - const int v删除数量 = m时间.size() - v保留数量 - 1; + const int v删除数量 = (int)m时间.size() - v保留数量 - 1; if (v删除数量 <= 0) { ++m删除计数; if (m删除计数 >= 2) { diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.cpp" index 9241786..4cd753d 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.cpp" @@ -205,7 +205,7 @@ UINT C任务栏按钮::f注册消息() { //============================================================================== // 环境 //============================================================================== -SYSTEM_INFO &C环境::fg系统信息() { +SYSTEM_INFO C环境::fg系统信息() { SYSTEM_INFO si; GetSystemInfo(&si); return si; diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.h" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.h" index a00833a..b682ad4 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.h" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\247\206\347\252\227.h" @@ -48,16 +48,16 @@ enum class E通用权限: unsigned long { //行:6510-6513 // winbase.h //============================================================================== inline void *f内存移动(void *a目标, void *a源, size_t a大小) { - return MoveMemory(a目标, a源, a大小); + return memmove(a目标, a源, a大小); }; //行:103 inline void *f内存复制(void *a目标, void *a源, size_t a大小) { - return CopyMemory(a目标, a源, a大小); + return memcpy(a目标, a源, a大小); }; //行:104 inline void *f内存填充(void *a目标, int a值, size_t a大小) { - return FillMemory(a目标, a值, a大小); + return memset(a目标, a值, a大小); }; //行:105 inline void *f内存清空(void *a目标, size_t a大小) { - return ZeroMemory(a目标, a大小); + return memset(a目标, 0, a大小); }; //行:106 inline DWORD f设置文件指针(HANDLE a文件, LONG a移动距离, PLONG a移动高度距离, DWORD a移动方式) { return SetFilePointer(a文件, a移动距离, a移动高度距离, a移动方式); @@ -251,7 +251,7 @@ class C任务栏按钮 { //============================================================================== class C环境 { public: - static SYSTEM_INFO &fg系统信息(); + static SYSTEM_INFO fg系统信息(); static std::wstring fg计算机名称(); static std::wstring fg用户名称(); static std::wstring fg执行程序目录(); diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_win.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_win.cpp" index cbb9c51..8e11ad6 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_win.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_win.cpp" @@ -100,24 +100,24 @@ void C输入::f窗口消息(UINT a消息, WPARAM w, LPARAM l) { switch (a消息) { case WM_KEYDOWN: case WM_SYSKEYDOWN: - m键盘->m缓冲.f按下(w); + m键盘->m缓冲.f按下((t索引)w); //区分左右键 for (const auto &v : ca对应左右键) { if (std::get<0>(v) == w) { const int &v左 = std::get<1>(v); const int &v右 = std::get<2>(v); if (GetKeyState(v左) & 0x8000) { - m键盘->m缓冲.f按下(v左); + m键盘->m缓冲.f按下((t索引)v左); } if (GetKeyState(v右) & 0x8000) { - m键盘->m缓冲.f按下(v右); + m键盘->m缓冲.f按下((t索引)v右); } } } break; case WM_KEYUP: case WM_SYSKEYUP: - m键盘->m缓冲.f松开(w); + m键盘->m缓冲.f松开((t索引)w); //区分左右键 for (const auto &v : ca对应左右键) { if (std::get<0>(v) == w) { @@ -141,22 +141,22 @@ void C输入::f窗口消息(UINT a消息, WPARAM w, LPARAM l) { if (m鼠标) { switch (a消息) { case WM_LBUTTONDOWN: - m鼠标->m缓冲.f按下((int)E鼠标按键::e左键); + m鼠标->m缓冲.f按下((t索引)E鼠标按键::e左键); break; case WM_RBUTTONDOWN: - m鼠标->m缓冲.f按下((int)E鼠标按键::e右键); + m鼠标->m缓冲.f按下((t索引)E鼠标按键::e右键); break; case WM_MBUTTONDOWN: - m鼠标->m缓冲.f按下((int)E鼠标按键::e中键); + m鼠标->m缓冲.f按下((t索引)E鼠标按键::e中键); break; case WM_LBUTTONUP: - m鼠标->m缓冲.f松开((int)E鼠标按键::e左键); + m鼠标->m缓冲.f松开((t索引)E鼠标按键::e左键); break; case WM_RBUTTONUP: - m鼠标->m缓冲.f松开((int)E鼠标按键::e右键); + m鼠标->m缓冲.f松开((t索引)E鼠标按键::e右键); break; case WM_MBUTTONUP: - m鼠标->m缓冲.f松开((int)E鼠标按键::e中键); + m鼠标->m缓冲.f松开((t索引)E鼠标按键::e中键); break; case WM_MOUSEWHEEL: m鼠标->m滚轮.m这次[0] = GET_WHEEL_DELTA_WPARAM(w) / 120.f; @@ -256,8 +256,8 @@ void C鼠标::f更新() { POINT v点; GetCursorPos(&v点); 视窗::C屏幕坐标到客户区坐标计算 v计算(m窗口); - m坐标.m这次[0] = v计算.f直角坐标xf(v点.x) / m缩放; - m坐标.m这次[1] = v计算.f直角坐标yf(v点.y) / m缩放; + m坐标.m这次[0] = v计算.f直角坐标xf((float)v点.x) / m缩放; + m坐标.m这次[1] = v计算.f直角坐标yf((float)v点.y) / m缩放; //滚轮 m滚轮.f覆盖上次(); m滚轮.f清空这次(); diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_xi.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_xi.cpp" index 9f1259b..1c95cb1 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_xi.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\350\276\223\345\205\245_xi.cpp" @@ -77,10 +77,10 @@ bool IsXInputDevice(const GUID *pGuidProductFromDirectInput) { // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0; WCHAR* strVid = wcsstr(var.bstrVal, L"VID_"); - if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1) + if (strVid && swscanf_s(strVid, L"VID_%4X", &dwVid) != 1) dwVid = 0; WCHAR* strPid = wcsstr(var.bstrVal, L"PID_"); - if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1) + if (strPid && swscanf_s(strPid, L"PID_%4X", &dwPid) != 1) dwPid = 0; // Compare the VID/PID to the DInput device DWORD dwVidPid = MAKELONG(dwVid, dwPid); diff --git "a/cflw\344\273\243\347\240\201\345\272\223/cflw\351\237\263\351\242\221_xa2.cpp" "b/cflw\344\273\243\347\240\201\345\272\223/cflw\351\237\263\351\242\221_xa2.cpp" index 9716f76..37bcefe 100644 --- "a/cflw\344\273\243\347\240\201\345\272\223/cflw\351\237\263\351\242\221_xa2.cpp" +++ "b/cflw\344\273\243\347\240\201\345\272\223/cflw\351\237\263\351\242\221_xa2.cpp" @@ -58,7 +58,7 @@ HRESULT C音频::f创建声音(tp声音 &a声音, const std::wstring_view &a文 v声音->m数据 = std::unique_ptr(v数据); v声音->m大小 = v数据大小; //填充缓冲 - v声音->m缓冲.AudioBytes = v数据大小; + v声音->m缓冲.AudioBytes = (UINT32)v数据大小; v声音->m缓冲.pAudioData = (BYTE*)v数据; v声音->m缓冲.Flags = XAUDIO2_END_OF_STREAM; v声音->m缓冲.LoopBegin = XAUDIO2_NO_LOOP_REGION;