Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,786 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: OverlayAnimate.cpp
|
||||
//
|
||||
// Desc: This sample demonstrates how to animate using DirectDraw overlays
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <ddraw.h>
|
||||
#include <mmsystem.h>
|
||||
#include "resource.h"
|
||||
#include "ddutil.h"
|
||||
#include "dxutil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
#define WINDOW_WIDTH 128
|
||||
#define WINDOW_HEIGHT 128
|
||||
#define SPRITE_DIAMETER 48
|
||||
#define NUM_FRAMES 30
|
||||
|
||||
|
||||
LPDIRECTDRAW7 g_pDD = NULL;
|
||||
LPDIRECTDRAWSURFACE7 g_pDDSPrimary = NULL;
|
||||
LPDIRECTDRAWSURFACE7 g_pDDSOverlay = NULL;
|
||||
LPDIRECTDRAWSURFACE7 g_pDDSOverlayBack = NULL;
|
||||
LPDIRECTDRAWSURFACE7 g_pDDSAnimationSheet = NULL;
|
||||
DDOVERLAYFX g_OverlayFX;
|
||||
DWORD g_dwOverlayFlags = 0;
|
||||
DWORD g_dwFrame = 0;
|
||||
DDCAPS g_ddcaps;
|
||||
BOOL g_bActive = FALSE;
|
||||
RECT g_rcSrc = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||
RECT g_rcDst = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||
DWORD g_dwXRatio;
|
||||
DWORD g_dwYRatio;
|
||||
|
||||
// This will be used as the color key, so try to make it something
|
||||
// that doesn't appear in the source image.
|
||||
COLORREF g_dwBackgroundColor = RGB(10, 0, 10);
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function-prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
||||
HRESULT WinInit( HINSTANCE hInst, int nCmdShow, HWND* phWnd, HACCEL* phAccel );
|
||||
HRESULT InitDirectDraw( HWND hWnd );
|
||||
BOOL HasOverlaySupport();
|
||||
VOID FreeDirectDraw();
|
||||
HRESULT CreateDirectDrawSurfaces( HWND hWnd );
|
||||
VOID AdjustSizeForHardwareLimits();
|
||||
HRESULT ProcessNextFrame( HWND hWnd );
|
||||
HRESULT DisplayFrame();
|
||||
HRESULT RestoreSurfaces();
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything and calls
|
||||
// UpdateFrame() when idle from the message pump.
|
||||
//-----------------------------------------------------------------------------
|
||||
int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow )
|
||||
{
|
||||
HRESULT hr;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
HACCEL hAccel;
|
||||
|
||||
if( FAILED( WinInit( hInst, nCmdShow, &hWnd, &hAccel ) ) )
|
||||
return FALSE;
|
||||
|
||||
if( FAILED( InitDirectDraw( hWnd ) ) )
|
||||
{
|
||||
MessageBox( hWnd, TEXT("DirectDraw init failed. ")
|
||||
TEXT("The sample will now exit. "), TEXT("DirectDraw Sample"),
|
||||
MB_ICONERROR | MB_OK );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( HasOverlaySupport() == FALSE )
|
||||
{
|
||||
MessageBox( hWnd, TEXT("This DirectDraw device does not support overlays. ")
|
||||
TEXT("The sample will now exit. "), TEXT("DirectDraw Sample"),
|
||||
MB_ICONERROR | MB_OK );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Create the DirectDraw surfaces needed
|
||||
if( FAILED( hr = CreateDirectDrawSurfaces( hWnd ) ) )
|
||||
{
|
||||
MessageBox( hWnd, TEXT("Failed to create surfaces. This DirectDraw device may not support overlays. ")
|
||||
TEXT("The sample will now exit. "), TEXT("DirectDraw Sample"),
|
||||
MB_ICONERROR | MB_OK );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow( hWnd, SW_SHOW );
|
||||
|
||||
while( TRUE )
|
||||
{
|
||||
// Look for messages, if none are found then
|
||||
// update the state and display it
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
if( 0 == GetMessage(&msg, NULL, 0, 0 ) )
|
||||
{
|
||||
// WM_QUIT was posted, so exit
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
// Translate and dispatch the message
|
||||
if( 0 == TranslateAccelerator( hWnd, hAccel, &msg ) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( g_bActive )
|
||||
{
|
||||
// Move the sprites, blt them to the back buffer, then
|
||||
// flip or blt the back buffer to the primary buffer
|
||||
if( FAILED( ProcessNextFrame( hWnd ) ) )
|
||||
{
|
||||
g_pDD->SetCooperativeLevel( NULL, DDSCL_NORMAL );
|
||||
|
||||
MessageBox( hWnd, TEXT("Displaying the next frame failed. ")
|
||||
TEXT("The sample will now exit. "), TEXT("DirectDraw Sample"),
|
||||
MB_ICONERROR | MB_OK );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure we go to sleep if we have nothing else to do
|
||||
WaitMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinInit()
|
||||
// Desc: Init the window
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT WinInit( HINSTANCE hInst, int nCmdShow, HWND* phWnd, HACCEL* phAccel )
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
HWND hWnd;
|
||||
HACCEL hAccel;
|
||||
|
||||
// If we are in 8 bit mode, then we need to choose a system palette
|
||||
// color because most colors will be dithered expect ones in the palette
|
||||
HDC hDC = GetDC( NULL );
|
||||
if( GetDeviceCaps( hDC, NUMCOLORS ) != -1 )
|
||||
g_dwBackgroundColor = RGB( 255, 0, 255 );
|
||||
ReleaseDC( NULL, hDC );
|
||||
|
||||
// Register the Window Class
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpszClassName = TEXT("OverlayAnimate");
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon( hInst, MAKEINTRESOURCE(IDI_MAIN) );
|
||||
wc.hIconSm = LoadIcon( hInst, MAKEINTRESOURCE(IDI_MAIN) );
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
|
||||
// Let windows paint the colorkey'ed background which our overlay will use
|
||||
wc.hbrBackground = CreateSolidBrush( g_dwBackgroundColor );
|
||||
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
|
||||
if( RegisterClassEx( &wc ) == 0 )
|
||||
return E_FAIL;
|
||||
|
||||
// Load keyboard accelerators
|
||||
hAccel = LoadAccelerators( hInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL) );
|
||||
|
||||
// Calculate the proper size for the window given a client of 640x480
|
||||
DWORD dwFrameWidth = GetSystemMetrics( SM_CXSIZEFRAME );
|
||||
DWORD dwFrameHeight = GetSystemMetrics( SM_CYSIZEFRAME );
|
||||
DWORD dwMenuHeight = GetSystemMetrics( SM_CYMENU );
|
||||
DWORD dwCaptionHeight = GetSystemMetrics( SM_CYCAPTION );
|
||||
DWORD dwWindowWidth = WINDOW_WIDTH + dwFrameWidth * 2;
|
||||
DWORD dwWindowHeight = WINDOW_HEIGHT + dwFrameHeight * 2 +
|
||||
dwMenuHeight + dwCaptionHeight;
|
||||
|
||||
// Create and show the main window
|
||||
hWnd = CreateWindow( TEXT("OverlayAnimate"), TEXT("DirectDraw OverlayAnimate Sample"),
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
dwWindowWidth, dwWindowHeight, NULL, NULL, hInst, NULL );
|
||||
if( hWnd == NULL )
|
||||
return E_FAIL;
|
||||
|
||||
*phWnd = hWnd;
|
||||
*phAccel = hAccel;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDirectDraw()
|
||||
// Desc: Create the DirectDraw object, and init the surfaces
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT InitDirectDraw( HWND hWnd )
|
||||
{
|
||||
DDSURFACEDESC2 ddsd;
|
||||
HRESULT hr;
|
||||
|
||||
// Create the main DirectDraw object
|
||||
if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&g_pDD,
|
||||
IID_IDirectDraw7, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
// Request normal cooperative level to put us in windowed mode
|
||||
if( FAILED( hr = g_pDD->SetCooperativeLevel( hWnd, DDSCL_NORMAL ) ) )
|
||||
return hr;
|
||||
|
||||
// Get driver capabilities to determine Overlay support.
|
||||
ZeroMemory( &g_ddcaps, sizeof(g_ddcaps) );
|
||||
g_ddcaps.dwSize = sizeof(g_ddcaps);
|
||||
|
||||
if( FAILED( hr = g_pDD->GetCaps( &g_ddcaps, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
// Create the primary surface, which in windowed mode is the desktop.
|
||||
ZeroMemory(&ddsd,sizeof(ddsd));
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pDDSPrimary, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CreateDirectDrawSurfaces()
|
||||
// Desc: Creates the DirectDraw surfaces
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CreateDirectDrawSurfaces( HWND hWnd )
|
||||
{
|
||||
DDSURFACEDESC2 ddsd;
|
||||
DDPIXELFORMAT ddpfOverlayFormat;
|
||||
DDSCAPS2 ddscaps;
|
||||
HRESULT hr;
|
||||
|
||||
// Release any previous surfaces
|
||||
SAFE_RELEASE( g_pDDSOverlay );
|
||||
|
||||
// Set the overlay format to 16 bit RGB 5:6:5
|
||||
ZeroMemory( &ddpfOverlayFormat, sizeof(ddpfOverlayFormat) );
|
||||
ddpfOverlayFormat.dwSize = sizeof(ddpfOverlayFormat);
|
||||
ddpfOverlayFormat.dwFlags = DDPF_RGB;
|
||||
ddpfOverlayFormat.dwRGBBitCount = 16;
|
||||
ddpfOverlayFormat.dwRBitMask = 0xF800;
|
||||
ddpfOverlayFormat.dwGBitMask = 0x07E0;
|
||||
ddpfOverlayFormat.dwBBitMask = 0x001F;
|
||||
|
||||
// Setup the overlay surface's attributes in the surface descriptor
|
||||
ZeroMemory( &ddsd, sizeof(ddsd) );
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH |
|
||||
DDSD_BACKBUFFERCOUNT | DDSD_PIXELFORMAT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY | DDSCAPS_FLIP |
|
||||
DDSCAPS_COMPLEX | DDSCAPS_VIDEOMEMORY;
|
||||
ddsd.dwBackBufferCount = 1;
|
||||
ddsd.dwWidth = WINDOW_WIDTH;
|
||||
ddsd.dwHeight = WINDOW_HEIGHT;
|
||||
ddsd.ddpfPixelFormat = ddpfOverlayFormat; // Use 16 bit RGB 5:6:5 pixel format
|
||||
|
||||
// Attempt to create the surface with theses settings
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pDDSOverlay, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
ZeroMemory(&ddscaps, sizeof(ddscaps));
|
||||
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
||||
if( FAILED( hr = g_pDDSOverlay->GetAttachedSurface( &ddscaps, &g_pDDSOverlayBack ) ) )
|
||||
return hr;
|
||||
|
||||
// Setup effects structure
|
||||
ZeroMemory( &g_OverlayFX, sizeof(g_OverlayFX) );
|
||||
g_OverlayFX.dwSize = sizeof(g_OverlayFX);
|
||||
|
||||
// Setup overlay flags.
|
||||
g_dwOverlayFlags = DDOVER_SHOW;
|
||||
|
||||
// Check for destination color keying capability
|
||||
if (g_ddcaps.dwCKeyCaps & DDCKEYCAPS_DESTOVERLAY)
|
||||
{
|
||||
// Using a color key will clip the overlay
|
||||
// when the mouse or other windows go on top of us.
|
||||
DWORD dwDDSColor;
|
||||
|
||||
// The color key can be any color, but a near black (not exactly) allows
|
||||
// the cursor to move around on the window without showing off the
|
||||
// color key, and also clips windows with exactly black text.
|
||||
CSurface frontSurface;
|
||||
frontSurface.Create( g_pDDSPrimary );
|
||||
dwDDSColor = frontSurface.ConvertGDIColor( g_dwBackgroundColor );
|
||||
g_OverlayFX.dckDestColorkey.dwColorSpaceLowValue = dwDDSColor;
|
||||
g_OverlayFX.dckDestColorkey.dwColorSpaceHighValue = dwDDSColor;
|
||||
g_dwOverlayFlags |= DDOVER_DDFX | DDOVER_KEYDESTOVERRIDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPDIRECTDRAWCLIPPER pClipper = NULL;
|
||||
|
||||
// If not, we'll setup a clipper for the window. This will fix the
|
||||
// problem on a few video cards - but the ones that don't shouldn't
|
||||
// care.
|
||||
if( FAILED( hr = g_pDD->CreateClipper(0, &pClipper, NULL) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = pClipper->SetHWnd(0, hWnd ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pDDSPrimary->SetClipper( pClipper ) ) )
|
||||
return hr;
|
||||
|
||||
SAFE_RELEASE( pClipper );
|
||||
}
|
||||
|
||||
|
||||
ZeroMemory( &ddsd, sizeof(ddsd) );
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
ddsd.dwWidth = SPRITE_DIAMETER * 5;
|
||||
ddsd.dwHeight = SPRITE_DIAMETER * 6;
|
||||
ddsd.ddpfPixelFormat = ddpfOverlayFormat; // Use 16 bit RGB 5:6:5 pixel format
|
||||
|
||||
// Attempt to create the surface with theses settings
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pDDSAnimationSheet, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
CSurface animateSurface;
|
||||
animateSurface.Create( g_pDDSAnimationSheet );
|
||||
if( FAILED( hr = animateSurface.DrawBitmap( MAKEINTRESOURCE( IDB_ANIMATE_SHEET ),
|
||||
SPRITE_DIAMETER * 5, SPRITE_DIAMETER * 6 ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: HasOverlaySupport()
|
||||
// Desc: Returns TRUE if the device supports overlays, FALSE otherwise
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL HasOverlaySupport()
|
||||
{
|
||||
// Get driver capabilities to determine overlay support.
|
||||
ZeroMemory( &g_ddcaps, sizeof(g_ddcaps) );
|
||||
g_ddcaps.dwSize = sizeof(g_ddcaps);
|
||||
g_pDD->GetCaps( &g_ddcaps, NULL );
|
||||
|
||||
// Does the driver support overlays in the current mode?
|
||||
// The DirectDraw emulation layer does not support overlays
|
||||
// so overlay related APIs will fail without hardware support.
|
||||
if( g_ddcaps.dwCaps & DDCAPS_OVERLAY )
|
||||
{
|
||||
// Make sure it supports stretching (scaling)
|
||||
if ( g_ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH )
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FreeDirectDraw()
|
||||
// Desc: Release all the DirectDraw objects
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID FreeDirectDraw()
|
||||
{
|
||||
SAFE_RELEASE( g_pDDSOverlay ); // g_pDDSOverlayBack will be automatically released here
|
||||
SAFE_RELEASE( g_pDDSPrimary );
|
||||
SAFE_RELEASE( g_pDDSAnimationSheet );
|
||||
SAFE_RELEASE( g_pDD );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MainWndProc()
|
||||
// Desc: The main window procedure
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case IDM_EXIT:
|
||||
// Received key/menu command to exit app
|
||||
PostMessage( hWnd, WM_CLOSE, 0, 0 );
|
||||
return 0L;
|
||||
}
|
||||
break; // Continue with default processing
|
||||
|
||||
case WM_PAINT:
|
||||
// Update the screen if we need to refresh. This case occurs
|
||||
// when in windowed mode and the window is behind others.
|
||||
// The app will not be active, but it will be visible.
|
||||
if( g_pDDSPrimary )
|
||||
{
|
||||
// UpdateOverlay is how we put the overlay on the screen.
|
||||
if( g_rcDst.top == g_rcDst.bottom )
|
||||
{
|
||||
g_pDDSOverlay->UpdateOverlay( NULL, g_pDDSPrimary, NULL,
|
||||
DDOVER_HIDE, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pDDSOverlay->UpdateOverlay( &g_rcSrc, g_pDDSPrimary,
|
||||
&g_rcDst, g_dwOverlayFlags,
|
||||
&g_OverlayFX);
|
||||
}
|
||||
}
|
||||
break; // Continue with default processing to validate the region
|
||||
|
||||
case WM_QUERYNEWPALETTE:
|
||||
if( g_pDDSPrimary )
|
||||
{
|
||||
// If we are in windowed mode with a desktop resolution in 8 bit
|
||||
// color, then the palette we created during init has changed
|
||||
// since then. So get the palette back from the primary
|
||||
// DirectDraw surface, and set it again so that DirectDraw
|
||||
// realises the palette, then release it again.
|
||||
LPDIRECTDRAWPALETTE pDDPal = NULL;
|
||||
g_pDDSPrimary->GetPalette( &pDDPal );
|
||||
g_pDDSPrimary->SetPalette( pDDPal );
|
||||
SAFE_RELEASE( pDDPal );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
// Make sure we're not moving to be minimized - because otherwise
|
||||
// our ratio varialbes (g_dwXRatio and g_dwYRatio) will end up
|
||||
// being 0, and once we hit CheckBoundries it divides by 0.
|
||||
if (!IsIconic(hWnd))
|
||||
{
|
||||
POINT p = {0, 0}; // Translation point for the window's client region
|
||||
|
||||
g_rcSrc.left = 0;
|
||||
g_rcSrc.right = WINDOW_WIDTH;
|
||||
g_rcSrc.top = 0;
|
||||
g_rcSrc.bottom = WINDOW_HEIGHT;
|
||||
|
||||
GetClientRect(hWnd, &g_rcDst);
|
||||
|
||||
g_dwXRatio = (g_rcDst.right - g_rcDst.left) * 1000 /
|
||||
(g_rcSrc.right - g_rcSrc.left);
|
||||
g_dwYRatio = (g_rcDst.bottom - g_rcDst.top) * 1000 /
|
||||
(g_rcSrc.bottom - g_rcSrc.top);
|
||||
|
||||
ClientToScreen( hWnd, &p );
|
||||
g_rcDst.left = p.x;
|
||||
g_rcDst.top = p.y;
|
||||
g_rcDst.bottom += p.y;
|
||||
g_rcDst.right += p.x;
|
||||
if( g_pDD )
|
||||
AdjustSizeForHardwareLimits();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Else, hide the overlay... just in case we can't do
|
||||
// destination color keying, this will pull the overlay
|
||||
// off of the screen for the user.
|
||||
if (g_pDDSOverlay && g_pDDSPrimary)
|
||||
g_pDDSOverlay->UpdateOverlay( NULL, g_pDDSPrimary, NULL,
|
||||
DDOVER_HIDE, NULL);
|
||||
}
|
||||
|
||||
// Check to make sure our window exists before we tell it to
|
||||
// repaint. This will fail the first time (while the window is
|
||||
// being created).
|
||||
if (hWnd)
|
||||
{
|
||||
InvalidateRect(hWnd, NULL, FALSE);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
return 0L;
|
||||
|
||||
|
||||
case WM_SIZE:
|
||||
// Another check for the minimization action. This check is
|
||||
// quicker though...
|
||||
// Check to see if we are losing our window...
|
||||
if( SIZE_MAXHIDE==wParam || SIZE_MINIMIZED==wParam )
|
||||
g_bActive = FALSE;
|
||||
else
|
||||
g_bActive = TRUE;
|
||||
|
||||
if( g_bActive )
|
||||
{
|
||||
POINT p = {0, 0}; // Translation point for the window's client region
|
||||
|
||||
GetClientRect(hWnd, &g_rcDst);
|
||||
ClientToScreen(hWnd, &p);
|
||||
|
||||
g_rcDst.left = p.x;
|
||||
g_rcDst.top = p.y;
|
||||
g_rcDst.bottom += p.y;
|
||||
g_rcDst.right += p.x;
|
||||
|
||||
g_rcSrc.left = 0;
|
||||
g_rcSrc.right = WINDOW_WIDTH;
|
||||
g_rcSrc.top = 0;
|
||||
g_rcSrc.bottom = WINDOW_HEIGHT;
|
||||
|
||||
// Here we multiply by 1000 to preserve 3 decimal places in the
|
||||
// division opperation (we picked 1000 to be on the same order
|
||||
// of magnitude as the stretch factor for easier comparisons)
|
||||
g_dwXRatio = (g_rcDst.right - g_rcDst.left) * 1000 /
|
||||
(g_rcSrc.right - g_rcSrc.left);
|
||||
|
||||
g_dwYRatio = (g_rcDst.bottom - g_rcDst.top) * 1000 /
|
||||
(g_rcSrc.bottom - g_rcSrc.top);
|
||||
|
||||
AdjustSizeForHardwareLimits();
|
||||
}
|
||||
return 0L;
|
||||
|
||||
|
||||
case WM_DISPLAYCHANGE:
|
||||
// This not only checks for overlay support in the new video mode -
|
||||
// but gets the new caps for the new display settings. That way we
|
||||
// have more accurate info about min/max stretch factors, color
|
||||
// keying
|
||||
if( HasOverlaySupport() == FALSE)
|
||||
{
|
||||
MessageBox( hWnd, "You have changed your adapter settings such "
|
||||
" that you no longer support this overlay.", "Overlay", MB_OK );
|
||||
PostMessage( hWnd, WM_CLOSE, 0, 0 );
|
||||
}
|
||||
return 0L;
|
||||
|
||||
case WM_DESTROY:
|
||||
// Cleanup and close the app
|
||||
FreeDirectDraw();
|
||||
PostQuitMessage( 0 );
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: AdjustSizeForHardwareLimits()
|
||||
// Desc: Checks and corrects all boundries for alignment and stretching
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID AdjustSizeForHardwareLimits()
|
||||
{
|
||||
// Setup effects structure
|
||||
// Make sure the coordinates fulfill the stretching requirements. Often
|
||||
// the hardware will require a certain ammount of stretching to do
|
||||
// overlays. This stretch factor is held in dwMinOverlayStretch as the
|
||||
// stretch factor multiplied by 1000 (to keep an accuracy of 3 decimal
|
||||
// places).
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) &&
|
||||
(g_ddcaps.dwMinOverlayStretch) &&
|
||||
(g_dwXRatio < g_ddcaps.dwMinOverlayStretch) )
|
||||
{
|
||||
// Window is too small
|
||||
g_rcDst.right = 2 * GetSystemMetrics(SM_CXSIZEFRAME) + g_rcDst.left + (WINDOW_WIDTH
|
||||
* (g_ddcaps.dwMinOverlayStretch + 1)) / 1000;
|
||||
}
|
||||
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH) &&
|
||||
(g_ddcaps.dwMaxOverlayStretch) &&
|
||||
(g_dwXRatio > g_ddcaps.dwMaxOverlayStretch) )
|
||||
{
|
||||
// Window is too large
|
||||
g_rcDst.right = 2 * GetSystemMetrics(SM_CXSIZEFRAME) + g_rcDst.left + (WINDOW_HEIGHT
|
||||
* (g_ddcaps.dwMaxOverlayStretch + 999)) / 1000;
|
||||
}
|
||||
|
||||
// Recalculate the ratio's for the upcoming calculations
|
||||
g_dwXRatio = (g_rcDst.right - g_rcDst.left) * 1000 / (g_rcSrc.right - g_rcSrc.left);
|
||||
g_dwYRatio = (g_rcDst.bottom - g_rcDst.top) * 1000 / (g_rcSrc.bottom - g_rcSrc.top);
|
||||
|
||||
// Check to make sure we're within the screen's boundries, if not then fix
|
||||
// the problem by adjusting the source rectangle which we draw from.
|
||||
if (g_rcDst.left < 0)
|
||||
{
|
||||
g_rcSrc.left = -g_rcDst.left * 1000 / g_dwXRatio;
|
||||
g_rcDst.left = 0;
|
||||
}
|
||||
|
||||
if (g_rcDst.right > GetSystemMetrics(SM_CXSCREEN))
|
||||
{
|
||||
g_rcSrc.right = WINDOW_WIDTH - ((g_rcDst.right - GetSystemMetrics(SM_CXSCREEN)) *
|
||||
1000 / g_dwXRatio);
|
||||
g_rcDst.right = GetSystemMetrics(SM_CXSCREEN);
|
||||
}
|
||||
|
||||
if (g_rcDst.bottom > GetSystemMetrics(SM_CYSCREEN))
|
||||
{
|
||||
g_rcSrc.bottom = WINDOW_HEIGHT - ((g_rcDst.bottom - GetSystemMetrics(SM_CYSCREEN))
|
||||
* 1000 / g_dwYRatio);
|
||||
g_rcDst.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
|
||||
if (g_rcDst.top < 0)
|
||||
{
|
||||
g_rcSrc.top = -g_rcDst.top * 1000 / g_dwYRatio;
|
||||
g_rcDst.top = 0;
|
||||
}
|
||||
|
||||
// Make sure the coordinates fulfill the alignment requirements
|
||||
// these expressions (x & -y) just do alignment by dropping low order bits...
|
||||
// so to round up, we add first, then truncate.
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYSRC) &&
|
||||
(g_ddcaps.dwAlignBoundarySrc) )
|
||||
{
|
||||
g_rcSrc.left = (g_rcSrc.left + g_ddcaps.dwAlignBoundarySrc / 2) &
|
||||
-(signed) (g_ddcaps.dwAlignBoundarySrc);
|
||||
}
|
||||
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_ALIGNSIZESRC) &&
|
||||
(g_ddcaps.dwAlignSizeSrc) )
|
||||
{
|
||||
g_rcSrc.right = g_rcSrc.left + (g_rcSrc.right - g_rcSrc.left + g_ddcaps.dwAlignSizeSrc / 2) &
|
||||
-(signed) (g_ddcaps.dwAlignSizeSrc);
|
||||
}
|
||||
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYDEST) &&
|
||||
(g_ddcaps.dwAlignBoundaryDest) )
|
||||
{
|
||||
g_rcDst.left = ( g_rcDst.left + g_ddcaps.dwAlignBoundaryDest / 2 ) &
|
||||
-(signed) (g_ddcaps.dwAlignBoundaryDest);
|
||||
}
|
||||
|
||||
if( (g_ddcaps.dwCaps & DDCAPS_ALIGNSIZEDEST) &&
|
||||
(g_ddcaps.dwAlignSizeDest) )
|
||||
{
|
||||
g_rcDst.right = g_rcDst.left + (g_rcDst.right - g_rcDst.left) &
|
||||
-(signed) (g_ddcaps.dwAlignSizeDest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ProcessNextFrame()
|
||||
// Desc: Move the sprites, blt them to the back buffer, then
|
||||
// flip or blt the back buffer to the primary buffer
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT ProcessNextFrame( HWND hWnd )
|
||||
{
|
||||
static s_dwFrameSkip = 0;
|
||||
HRESULT hr;
|
||||
|
||||
// Only advance the frame animation number every 5th frame
|
||||
s_dwFrameSkip++;
|
||||
s_dwFrameSkip %= 5;
|
||||
|
||||
if( s_dwFrameSkip == 0 )
|
||||
{
|
||||
g_dwFrame++;
|
||||
g_dwFrame %= NUM_FRAMES;
|
||||
}
|
||||
|
||||
// Check the cooperative level before rendering
|
||||
if( FAILED( hr = g_pDD->TestCooperativeLevel() ) )
|
||||
{
|
||||
switch( hr )
|
||||
{
|
||||
case DDERR_EXCLUSIVEMODEALREADYSET:
|
||||
// Do nothing because some other app has exclusive mode
|
||||
Sleep(10);
|
||||
return S_OK;
|
||||
|
||||
case DDERR_WRONGMODE:
|
||||
// The display mode changed on us. Update the
|
||||
// DirectDraw surfaces accordingly
|
||||
return CreateDirectDrawSurfaces( hWnd );
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Display the sprites on the screen
|
||||
if( FAILED( hr = DisplayFrame() ) )
|
||||
{
|
||||
if( hr != DDERR_SURFACELOST )
|
||||
return hr;
|
||||
|
||||
// The surfaces were lost so restore them
|
||||
RestoreSurfaces();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DisplayFrame()
|
||||
// Desc: Blts a the sprites to the back buffer, then flips the
|
||||
// back buffer onto the primary buffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DisplayFrame()
|
||||
{
|
||||
HRESULT hr;
|
||||
RECT rcSrc;
|
||||
|
||||
rcSrc.left = (g_dwFrame % 5) * SPRITE_DIAMETER;
|
||||
rcSrc.top = (g_dwFrame / 5) * SPRITE_DIAMETER;
|
||||
rcSrc.right = rcSrc.left + SPRITE_DIAMETER;
|
||||
rcSrc.bottom = rcSrc.top + SPRITE_DIAMETER;
|
||||
|
||||
g_pDDSOverlayBack->Blt( NULL, g_pDDSAnimationSheet,
|
||||
&rcSrc, DDBLT_WAIT, NULL );
|
||||
|
||||
if( FAILED( hr = g_pDDSOverlay->Flip( NULL, DDFLIP_WAIT ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreSurfaces()
|
||||
// Desc: Restore all the surfaces, and redraw the sprite surfaces.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT RestoreSurfaces()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( FAILED( hr = g_pDD->RestoreAllSurfaces() ) )
|
||||
return hr;
|
||||
|
||||
// No need to re-create the surface, just re-draw it.
|
||||
CSurface animateSurface;
|
||||
animateSurface.Create( g_pDDSAnimationSheet );
|
||||
if( FAILED( hr = animateSurface.DrawBitmap( MAKEINTRESOURCE( IDB_ANIMATE_SHEET ),
|
||||
SPRITE_DIAMETER * 5, SPRITE_DIAMETER * 6 ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
# Microsoft Developer Studio Project File - Name="OverlayAnimate" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=OverlayAnimate - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "overlayanimate.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "overlayanimate.mak" CFG="OverlayAnimate - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "OverlayAnimate - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "OverlayAnimate - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "OverlayAnimate - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 winmm.lib dxguid.lib dxerr8.lib ddraw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "OverlayAnimate - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 winmm.lib dxguid.lib dxerr8.lib ddraw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "OverlayAnimate - Win32 Release"
|
||||
# Name "OverlayAnimate - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverlayAnimate.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OverlayAnimate.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\animate.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\directx.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DirectX.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\ddutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\ddutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "OverlayAnimate"=.\overlayanimate.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on overlayanimate.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=OverlayAnimate - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to OverlayAnimate - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "OverlayAnimate - Win32 Release" && "$(CFG)" != "OverlayAnimate - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "overlayanimate.mak" CFG="OverlayAnimate - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "OverlayAnimate - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "OverlayAnimate - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "OverlayAnimate - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\overlayanimate.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\OverlayAnimate.obj"
|
||||
-@erase "$(INTDIR)\OverlayAnimate.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\overlayanimate.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\overlayanimate.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\OverlayAnimate.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\overlayanimate.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=winmm.lib dxguid.lib dxerr8.lib ddraw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\overlayanimate.pdb" /machine:I386 /out:"$(OUTDIR)\overlayanimate.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\OverlayAnimate.obj" \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\OverlayAnimate.res"
|
||||
|
||||
"$(OUTDIR)\overlayanimate.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "OverlayAnimate - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\overlayanimate.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\OverlayAnimate.obj"
|
||||
-@erase "$(INTDIR)\OverlayAnimate.res"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\overlayanimate.exe"
|
||||
-@erase "$(OUTDIR)\overlayanimate.ilk"
|
||||
-@erase "$(OUTDIR)\overlayanimate.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\overlayanimate.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\OverlayAnimate.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\overlayanimate.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=winmm.lib dxguid.lib dxerr8.lib ddraw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\overlayanimate.pdb" /debug /machine:I386 /out:"$(OUTDIR)\overlayanimate.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\OverlayAnimate.obj" \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\OverlayAnimate.res"
|
||||
|
||||
"$(OUTDIR)\overlayanimate.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("overlayanimate.dep")
|
||||
!INCLUDE "overlayanimate.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "overlayanimate.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "OverlayAnimate - Win32 Release" || "$(CFG)" == "OverlayAnimate - Win32 Debug"
|
||||
SOURCE=.\OverlayAnimate.cpp
|
||||
|
||||
"$(INTDIR)\OverlayAnimate.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\OverlayAnimate.rc
|
||||
|
||||
"$(INTDIR)\OverlayAnimate.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\ddutil.cpp
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <afxres.h>
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN ICON DISCARDABLE "DirectX.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include <windows.h>\r\n"
|
||||
"#include <afxres.h>\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
"X", IDM_EXIT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_ANIMATE_SHEET BITMAP DISCARDABLE "animate.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "E&xit\tAlt+X", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Sample Name: OverlayAnimate Sample
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
OverlayAnimate demonstrates how to use DirectDraw overlays.
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\DDraw\OverlayAnimate
|
||||
|
||||
Executable: DXSDK\Samples\Multimedia\DDraw\Bin
|
||||
|
||||
User's Guide
|
||||
============
|
||||
OverlayAnimate requires no user input. Press the ESC key to quit the program.
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
For details on how to setup a windowed mode DirectDraw app, see the WindowedMode
|
||||
sample.
|
||||
|
||||
To use overlays in general do the following steps in addition to those needed to
|
||||
author a windowed mode DirectDraw app:
|
||||
1. Check to see if hardware supports overlays - check IDirectDraw::GetCaps
|
||||
for DDCAPS_OVERLAY.
|
||||
2. Size the window to meet the hardware overlay size restrictions.
|
||||
3. Create an overlay surface (create it with 1 backbuffer if needed), and
|
||||
set its pixel format to a desired format that is supported by the device.
|
||||
4. Set the dest color key on the overlay to the background color of the window.
|
||||
Be sure to choose a color for the background of the window that Windows typically
|
||||
does not use otherwise, the overlay will be drawn on top of overlapping windows.
|
||||
5. Call UpdateOverlay to display or hide the overlay on the desktop. WM_PAINT is
|
||||
a good place for this.
|
||||
6. When WM_SIZE or WM_MOVE is sent, then update the src and dest rects and
|
||||
check to make sure that they are within the hardware limits.
|
||||
|
||||
To animate the overlay, instead of drawing to the off-screen plain back buffer as
|
||||
in windowed mode case, just draw to the the overlay's backbuffer then flip it.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by OverlayAnimate.rc
|
||||
//
|
||||
#define IDI_MAIN 101
|
||||
#define IDR_MENU 102
|
||||
#define IDR_MAIN_ACCEL 103
|
||||
#define IDB_DIRECTX 107
|
||||
#define IDB_ANIMATE_SHEET 108
|
||||
#define IDM_EXIT 1001
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 110
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||
#define _APS_NEXT_SYMED_VALUE 104
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user