-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhslshader.cpp
67 lines (66 loc) · 1.6 KB
/
hslshader.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <windows.h>
#include <math.h>
typedef union _RGBQUAD {
COLORREF rgb;
struct {
BYTE b;
BYTE g;
BYTE r;
BYTE unused;
};
} *PRGBQUAD;
int red, green, blue;
bool ifcolorblue = false, ifblue = false;
COLORREF Hue(int length) {
if (red != length) {
red < length; red++;
if (ifblue == true) {
return RGB(red, 0, length);
}
else {
return RGB(red, 0, 0);
}
}
else {
if (green != length) {
green < length; green++;
return RGB(length, green, 0);
}
else {
if (blue != length) {
blue < length; blue++;
return RGB(0, length, blue);
}
else {
red = 0; green = 0; blue = 0;
ifblue = true;
}
}
}
}
DWORD WINAPI shader1(LPVOID lpParam) {
int w = GetSystemMetrics(0), h = GetSystemMetrics(1);
_RGBQUAD* data = (_RGBQUAD*)VirtualAlloc(0, (w * h + w) * sizeof(_RGBQUAD), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
for (int i = 0;; i++, i %= 3) {
HDC desk = GetDC(NULL);
HDC hdcdc = CreateCompatibleDC(desk);
HBITMAP hbm = CreateBitmap(w, h, 1, 32, data);
SelectObject(hdcdc, hbm);
BitBlt(hdcdc, 0, 0, w, h, desk, 0, 0, SRCCOPY);
GetBitmapBits(hbm, w * h * 4, data);
for (int i = 0; i < w * h; i++) {
int x = i % w, y = i / h, t = y ^ y | x;
data[i].rgb = RGB(GetRValue(Hue(239)),GetGValue(Hue(239)),GetBValue(Hue(239)));
}
SetBitmapBits(hbm, w * h * 4, data);
BitBlt(desk, 0, 0, w, h, hdcdc, 0, 0, SRCCOPY);
DeleteObject(hbm);
DeleteObject(hdcdc);
DeleteObject(desk);
}
return 0;
}
int main() {
CreateThread(0, 0, shader1, 0, 0, 0);
Sleep(-1);
}