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 68 69 70 71
| static void RenderAnimation(IN HWND hWnd) {
RECT rw = { 0 };
BLENDFUNCTION bf = { 0 };
POINT lp = { 0 }, ptSrc = { 0 };
SIZEL lpSize = { 0 };
LONG_PTR graphics = 0, imgAttr = 0, lpCallback = 0, callbackdata = 0;
static long imgW, imgH, xDir, yDir;
GetWindowRect(hWnd, &rw);
lpSize.cx = rw.right - rw.left; lpSize.cy = rw.bottom - rw.top;
lp.x = rw.left; lp.y = rw.top;
HDC DesktopDC = GetDC(0);
// Create our memory DC
HDC hMemDC = CreateCompatibleDC(DesktopDC);
HBITMAP hBmp = CreateDIB(DesktopDC, lpSize.cx, lpSize.cy, 32);
if (hBmp) {
SelectObject(hMemDC, hBmp);
if (gP.shadow == 0) {
GdipLoadImageFromFile(Resource(L"amiga.png"), gP.shadow);
if (gP.shadow) { GetImageSize(gP.shadow, imgW, imgH); }
}
// Draw the OpenGL scene
DrawTheScene();
wglMakeCurrent(gP.gldc, gP.glrc);
SwapBuffers(gP.gldc);
DrawAndSetupAlphaChannel(hMemDC, -13, -14);
if (gP.shadow) {
if (GdipCreateFromHDC(hMemDC, graphics) == 0) {
GdipSetInterpolationMode(graphics, 2);
GdipDrawImageRectRectI(graphics, gP.shadow, 1, 14, imgW, imgH, 0, 0, imgW, imgH, 2, imgAttr, lpCallback, callbackdata);
GdipDeleteGraphics(graphics);
}
}
// Update the layered window
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.AlphaFormat = AC_SRC_ALPHA; // Use source alpha
bf.SourceConstantAlpha = 255;
UpdateLayeredWindow (hWnd, DesktopDC, &lp, &lpSize, hMemDC, &ptSrc, 0, &bf, ULW_ALPHA);
DeleteObject(hBmp);
DeleteDC(hMemDC);
// Move the layered window around the screen
long PlayIt = 0;
if (xDir == 0) { xDir = MOVE_STEP; yDir = MOVE_STEP; }
if (xDir > 0) {
if (gP.x + FRAME_SizeX - 21 > GetSystemMetrics(SM_CXSCREEN)) { xDir = -xDir; PlayIt = -1; }
} else {
if (gP.x < 0) { xDir = -xDir; PlayIt = -1; }
}
if (yDir > 0) {
if (gP.y + FRAME_SizeY - 21 > GetSystemMetrics(SM_CYSCREEN)) { yDir = -yDir; PlayIt = -1; }
} else {
if (gP.y < 0) { yDir = -yDir; PlayIt = -1; }
}
if (PlayIt) { PlayWav(); }
gP.x += xDir; gP.y += yDir;
MoveWindow(hWnd, gP.x, gP.y, FRAME_SizeX, FRAME_SizeY + LOGO_SizeY, 0);
}
ReleaseDC(0, DesktopDC);
} |
Partager