forked from EldarFara/WSE2_Launcher
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEngine_Start.cpp
47 lines (42 loc) · 1.22 KB
/
Engine_Start.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Engine.h"
void Class_Engine::Start()
{
Window_Main = std::make_shared<sf::RenderWindow>();
Window_Main->create({ 637, 477 }, "WSE2 Launcher", sf::Style::None);
Window_Main->setFramerateLimit(50);
SetWindowTransparency();
Initialize();
Runtime();
}
void Class_Engine::SetWindowTransparency()
{
try
{
sf::Image Icon;
Icon.loadFromMemory(Image_Icon, Image_Icon_Length);
Window_Main->setIcon(Icon.getSize().x, Icon.getSize().y, Icon.getPixelsPtr());
sf::Image image;
image.loadFromMemory(Image_MainBackground, Image_MainBackground_Length);
HWND hWnd = Window_Main->getSystemHandle();
const sf::Uint8* pixelData = image.getPixelsPtr();
HRGN hRegion = CreateRectRgn(0, 0, image.getSize().x, image.getSize().y);
for (unsigned int y = 0; y < image.getSize().y; y++)
{
for (unsigned int x = 0; x < image.getSize().x; x++)
{
if (pixelData[y * image.getSize().x * 4 + x * 4 + 3] == 0)
{
HRGN hRegionPixel = CreateRectRgn(x, y, x + 1, y + 1);
CombineRgn(hRegion, hRegion, hRegionPixel, RGN_XOR);
DeleteObject(hRegionPixel);
}
}
}
SetWindowRgn(hWnd, hRegion, true);
DeleteObject(hRegion);
}
catch (const std::exception&)
{
// íó íå ïîëó÷èëîñü è íå ïîëó÷èëîñü, õðåí ñ íèì
}
}