소스 검색

feat: 添加画板类

nicetry12138 1 년 전
부모
커밋
d8a2678760

+ 2 - 0
OpenGL/README.md

@@ -256,6 +256,8 @@ buffer(Pointer to the Bitmap’s Pixel Data) |  buffer 是一个指针,它
 
 **位图**,也称为栅格图像或点阵图像,是由像素(图片元素)的单个点组成的图像。每个像素都有自己的颜色信息,位图通常用于存储数字照片和其他类型的图像。位图的特点是可以精确地控制每个像素,但缺点是放大后会出现像素化,且文件大小通常比矢量图像
 
+### 点的绘制
+
 
 
 ## 图形处理及纹理系统

+ 1 - 0
OpenGL/src/WindowsProjectTest/WindowsProjectTest/Canvas.cpp

@@ -0,0 +1 @@
+#include "Canvas.h"

+ 16 - 0
OpenGL/src/WindowsProjectTest/WindowsProjectTest/Canvas.h

@@ -0,0 +1,16 @@
+#pragma once
+#include "GTMATH.hpp"
+
+namespace GT {
+	// ²Ù×÷»­²¼µÄÀà
+	class Canvas
+	{
+	private:
+		int m_Width;
+		int m_Height;
+		RGBA* m_Buffer;
+	};
+}
+
+
+

+ 79 - 0
OpenGL/src/WindowsProjectTest/WindowsProjectTest/GTMATH.hpp

@@ -0,0 +1,79 @@
+#pragma once
+namespace GT
+{
+
+#define	PI									3.14159265358979323
+#define	DEG2RAD(theta)						(0.01745329251994329 * (theta))
+#define MIN(a,b)							((a)<(b)?(a):(b))
+#define MAX(a,b)							((a)>(b)?(a):(b))
+
+	template<typename T>
+	void	swapT(T& a, T& b)
+	{
+		T tmp = a;
+		a = b;
+		b = tmp;
+	}
+
+#define		SWAP_INT(a , b)   swapT<int>(a , b);
+	template<typename T>
+	struct tVec2
+	{
+		T	x;
+		T	y;
+
+		tVec2(T	_x, T	_y)
+		{
+			x = _x;
+			y = _y;
+		}
+		tVec2()
+		{
+			x = -1;
+			y = -1;
+		}
+	};
+
+	typedef tVec2<int>		intV2;
+	typedef tVec2<float>	floatV2;
+
+	typedef unsigned int	uint;
+	typedef unsigned char	byte;
+
+	struct GT_RECT
+	{
+		int m_left;
+		int m_right;
+		int m_top;
+		int m_bottom;
+		GT_RECT(int _left = 0,
+			int _right = 0,
+			int _top = 0,
+			int _bottom = 0)
+		{
+			m_left = _left;
+			m_right = _right;
+			m_top = _top;
+			m_bottom = _bottom;
+		}
+	};
+
+	struct RGBA
+	{
+		byte m_b;
+		byte m_g;
+		byte m_r;
+		byte m_a;
+
+		RGBA(byte _r = 255,
+			byte _g = 255,
+			byte _b = 255,
+			byte _a = 255)
+		{
+			m_r = _r;
+			m_g = _g;
+			m_b = _b;
+			m_a = _a;
+		}
+	};
+}

+ 10 - 2
OpenGL/src/WindowsProjectTest/WindowsProjectTest/WindowsProjectTest.cpp

@@ -24,6 +24,14 @@ BOOL                InitInstance(HINSTANCE, int);
 LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
 INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
 
+void Render() {
+    
+
+
+	// 将 hMem 的数据一次写入到 hDC 中
+	BitBlt(hDC, 0, 0, wWidth, wHeight, hMem, 0, 0, SRCCOPY);
+}
+
 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                      _In_opt_ HINSTANCE hPrevInstance,
                      _In_ LPWSTR    lpCmdLine,
@@ -82,8 +90,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
             DispatchMessage(&msg);
         }
 
-        // 将 hMem 的数据一次写入到 hDC 中
-        BitBlt(hDC, 0, 0, wWidth, wHeight, hMem, 0, 0, SRCCOPY);
+        Render();
     }
 
     return (int) msg.wParam;
@@ -211,3 +218,4 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     }
     return (INT_PTR)FALSE;
 }
+

+ 3 - 0
OpenGL/src/WindowsProjectTest/WindowsProjectTest/WindowsProjectTest.vcxproj

@@ -127,12 +127,15 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="Canvas.h" />
     <ClInclude Include="framework.h" />
+    <ClInclude Include="GTMATH.hpp" />
     <ClInclude Include="Resource.h" />
     <ClInclude Include="targetver.h" />
     <ClInclude Include="WindowsProjectTest.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="Canvas.cpp" />
     <ClCompile Include="WindowsProjectTest.cpp" />
   </ItemGroup>
   <ItemGroup>

+ 9 - 0
OpenGL/src/WindowsProjectTest/WindowsProjectTest/WindowsProjectTest.vcxproj.filters

@@ -27,11 +27,20 @@
     <ClInclude Include="WindowsProjectTest.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="GTMATH.hpp">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="Canvas.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="WindowsProjectTest.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="Canvas.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="WindowsProjectTest.rc">