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:
271
Library/dxx8/samples/Multimedia/Common/include/asyncio.h
Normal file
271
Library/dxx8/samples/Multimedia/Common/include/asyncio.h
Normal file
@@ -0,0 +1,271 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: AsyncIo.h
|
||||
//
|
||||
// Desc: DirectShow sample code - base library for I/O functionality.
|
||||
//
|
||||
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __ASYNCIO_H__
|
||||
#define __ASYNCIO_H__
|
||||
//
|
||||
// definition of CAsyncFile object that performs file access. It provides
|
||||
// asynchronous, unbuffered, aligned reads from a file, using a worker thread
|
||||
// on win95 and potentially overlapped i/o if available.
|
||||
|
||||
// !!! Need to use real overlapped i/o if available
|
||||
// currently only uses worker thread, not overlapped i/o
|
||||
|
||||
|
||||
class CAsyncIo;
|
||||
class CAsyncStream;
|
||||
|
||||
//
|
||||
// Model the stream we read from based on a file-like interface
|
||||
//
|
||||
class CAsyncStream
|
||||
{
|
||||
public:
|
||||
virtual ~CAsyncStream() {};
|
||||
virtual HRESULT SetPointer(LONGLONG llPos) = 0;
|
||||
virtual HRESULT Read(PBYTE pbBuffer,
|
||||
DWORD dwBytesToRead,
|
||||
BOOL bAlign,
|
||||
LPDWORD pdwBytesRead) = 0;
|
||||
virtual LONGLONG Size(LONGLONG *pSizeAvailable = NULL) = 0;
|
||||
virtual DWORD Alignment() = 0;
|
||||
virtual void Lock() = 0;
|
||||
virtual void Unlock() = 0;
|
||||
//virtual void SetStopHandle(HANDLE hevStop) {}
|
||||
};
|
||||
|
||||
// represents a single request and performs the i/o. Can be called on either
|
||||
// worker thread or app thread, but must hold pcsFile across file accesses.
|
||||
// (ie across SetFilePointer/ReadFile pairs)
|
||||
class CAsyncRequest
|
||||
{
|
||||
CAsyncIo *m_pIo;
|
||||
CAsyncStream *m_pStream;
|
||||
LONGLONG m_llPos;
|
||||
BOOL m_bAligned;
|
||||
LONG m_lLength;
|
||||
BYTE* m_pBuffer;
|
||||
LPVOID m_pContext;
|
||||
DWORD m_dwUser;
|
||||
HRESULT m_hr;
|
||||
|
||||
public:
|
||||
// init the params for this request. Issue the i/o
|
||||
// if overlapped i/o is possible.
|
||||
HRESULT Request(
|
||||
CAsyncIo *pIo,
|
||||
CAsyncStream *pStream,
|
||||
LONGLONG llPos,
|
||||
LONG lLength,
|
||||
BOOL bAligned,
|
||||
BYTE* pBuffer,
|
||||
LPVOID pContext, // filter's context
|
||||
DWORD dwUser); // downstream filter's context
|
||||
|
||||
// issue the i/o if not overlapped, and block until i/o complete.
|
||||
// returns error code of file i/o
|
||||
HRESULT Complete();
|
||||
|
||||
// cancels the i/o. blocks until i/o is no longer pending
|
||||
HRESULT Cancel()
|
||||
{
|
||||
return S_OK;
|
||||
};
|
||||
|
||||
// accessor functions
|
||||
LPVOID GetContext()
|
||||
{
|
||||
return m_pContext;
|
||||
};
|
||||
|
||||
DWORD GetUser()
|
||||
{
|
||||
return m_dwUser;
|
||||
};
|
||||
|
||||
HRESULT GetHResult() {
|
||||
return m_hr;
|
||||
};
|
||||
|
||||
// we set m_lLength to the actual length
|
||||
LONG GetActualLength() {
|
||||
return m_lLength;
|
||||
};
|
||||
|
||||
LONGLONG GetStart() {
|
||||
return m_llPos;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
typedef CGenericList<CAsyncRequest> CRequestList;
|
||||
|
||||
// this class needs a worker thread, but the ones defined in classes\base
|
||||
// are not suitable (they assume you have one message sent or posted per
|
||||
// request, whereas here for efficiency we want just to set an event when
|
||||
// there is work on the queue).
|
||||
//
|
||||
// we create CAsyncRequest objects and queue them on m_listWork. The worker
|
||||
// thread pulls them off, completes them and puts them on m_listDone.
|
||||
// The events m_evWork and m_evDone are set when the corresponding lists are
|
||||
// not empty.
|
||||
//
|
||||
// Synchronous requests are done on the caller thread. These should be
|
||||
// synchronised by the caller, but to make sure we hold m_csFile across
|
||||
// the SetFilePointer/ReadFile code.
|
||||
//
|
||||
// Flush by calling BeginFlush. This rejects all further requests (by
|
||||
// setting m_bFlushing within m_csLists), cancels all requests and moves them
|
||||
// to the done list, and sets m_evDone to ensure that no WaitForNext operations
|
||||
// will block. Call EndFlush to cancel this state.
|
||||
//
|
||||
// we support unaligned calls to SyncRead. This is done by opening the file
|
||||
// twice if we are using unbuffered i/o (m_dwAlign > 1).
|
||||
// !!!fix this to buffer on top of existing file handle?
|
||||
class CAsyncIo
|
||||
{
|
||||
|
||||
CCritSec m_csReader;
|
||||
CAsyncStream *m_pStream;
|
||||
|
||||
CCritSec m_csLists; // locks access to the list and events
|
||||
BOOL m_bFlushing; // true if between BeginFlush/EndFlush
|
||||
CRequestList m_listWork;
|
||||
CRequestList m_listDone;
|
||||
CAMEvent m_evWork; // set when list is not empty
|
||||
CAMEvent m_evDone;
|
||||
|
||||
// for correct flush behaviour: all protected by m_csLists
|
||||
LONG m_cItemsOut; // nr of items not on listDone or listWork
|
||||
BOOL m_bWaiting; // TRUE if someone waiting for m_evAllDone
|
||||
CAMEvent m_evAllDone; // signal when m_cItemsOut goes to 0 if m_cWaiting
|
||||
|
||||
|
||||
CAMEvent m_evStop; // set when thread should exit
|
||||
HANDLE m_hThread;
|
||||
|
||||
LONGLONG Size() {
|
||||
ASSERT(m_pStream != NULL);
|
||||
return m_pStream->Size();
|
||||
};
|
||||
|
||||
// start the thread
|
||||
HRESULT StartThread(void);
|
||||
|
||||
// stop the thread and close the handle
|
||||
HRESULT CloseThread(void);
|
||||
|
||||
// manage the list of requests. hold m_csLists and ensure
|
||||
// that the (manual reset) event hevList is set when things on
|
||||
// the list but reset when the list is empty.
|
||||
// returns null if list empty
|
||||
CAsyncRequest* GetWorkItem();
|
||||
|
||||
// get an item from the done list
|
||||
CAsyncRequest* GetDoneItem();
|
||||
|
||||
// put an item on the work list
|
||||
HRESULT PutWorkItem(CAsyncRequest* pRequest);
|
||||
|
||||
// put an item on the done list
|
||||
HRESULT PutDoneItem(CAsyncRequest* pRequest);
|
||||
|
||||
// called on thread to process any active requests
|
||||
void ProcessRequests(void);
|
||||
|
||||
// initial static thread proc calls ThreadProc with DWORD
|
||||
// param as this
|
||||
static DWORD WINAPI InitialThreadProc(LPVOID pv) {
|
||||
CAsyncIo * pThis = (CAsyncIo*) pv;
|
||||
return pThis->ThreadProc();
|
||||
};
|
||||
|
||||
DWORD ThreadProc(void);
|
||||
|
||||
public:
|
||||
|
||||
CAsyncIo(CAsyncStream *pStream);
|
||||
~CAsyncIo();
|
||||
|
||||
// open the file
|
||||
HRESULT Open(LPCTSTR pName);
|
||||
|
||||
// ready for async activity - call this before
|
||||
// calling Request
|
||||
HRESULT AsyncActive(void);
|
||||
|
||||
// call this when no more async activity will happen before
|
||||
// the next AsyncActive call
|
||||
HRESULT AsyncInactive(void);
|
||||
|
||||
// queue a requested read. must be aligned.
|
||||
HRESULT Request(
|
||||
LONGLONG llPos,
|
||||
LONG lLength,
|
||||
BOOL bAligned,
|
||||
BYTE* pBuffer,
|
||||
LPVOID pContext,
|
||||
DWORD dwUser);
|
||||
|
||||
// wait for the next read to complete
|
||||
HRESULT WaitForNext(
|
||||
DWORD dwTimeout,
|
||||
LPVOID *ppContext,
|
||||
DWORD * pdwUser,
|
||||
LONG * pcbActual
|
||||
);
|
||||
|
||||
// perform a read of an already aligned buffer
|
||||
HRESULT SyncReadAligned(
|
||||
LONGLONG llPos,
|
||||
LONG lLength,
|
||||
BYTE* pBuffer,
|
||||
LONG* pcbActual,
|
||||
PVOID pvContext
|
||||
);
|
||||
|
||||
// perform a synchronous read. will be buffered
|
||||
// if not aligned.
|
||||
HRESULT SyncRead(
|
||||
LONGLONG llPos,
|
||||
LONG lLength,
|
||||
BYTE* pBuffer);
|
||||
|
||||
// return length
|
||||
HRESULT Length(LONGLONG *pllTotal, LONGLONG* pllAvailable);
|
||||
|
||||
// all Reader positions, read lengths and memory locations must
|
||||
// be aligned to this.
|
||||
HRESULT Alignment(LONG* pl);
|
||||
|
||||
HRESULT BeginFlush();
|
||||
HRESULT EndFlush();
|
||||
|
||||
LONG Alignment()
|
||||
{
|
||||
return m_pStream->Alignment();
|
||||
};
|
||||
|
||||
BOOL IsAligned(LONG l) {
|
||||
if ((l & (Alignment() -1)) == 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
BOOL IsAligned(LONGLONG ll) {
|
||||
return IsAligned( (LONG) (ll & 0xffffffff));
|
||||
};
|
||||
|
||||
// Accessor
|
||||
HANDLE StopEvent() const { return m_evDone; }
|
||||
};
|
||||
|
||||
#endif // __ASYNCIO_H__
|
||||
226
Library/dxx8/samples/Multimedia/Common/include/asyncrdr.h
Normal file
226
Library/dxx8/samples/Multimedia/Common/include/asyncrdr.h
Normal file
@@ -0,0 +1,226 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: AsyncRdr.h
|
||||
//
|
||||
// Desc: DirectShow sample code - base library for I/O functionality.
|
||||
//
|
||||
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __ASYNCRDR_H__
|
||||
#define __ASYNCRDR_H__
|
||||
|
||||
|
||||
//
|
||||
// AsyncRdr
|
||||
//
|
||||
// Defines an IO source filter.
|
||||
//
|
||||
// This filter (CAsyncReader) supports IBaseFilter and IFileSourceFilter interfaces from the
|
||||
// filter object itself. It has a single output pin (CAsyncOutputPin)
|
||||
// which supports IPin and IAsyncReader.
|
||||
//
|
||||
// This filter is essentially a wrapper for the CAsyncFile class that does
|
||||
// all the work.
|
||||
//
|
||||
|
||||
|
||||
// the filter class (defined below)
|
||||
class CAsyncReader;
|
||||
|
||||
|
||||
// the output pin class
|
||||
class CAsyncOutputPin
|
||||
: public IAsyncReader,
|
||||
public CBasePin
|
||||
{
|
||||
protected:
|
||||
CAsyncReader* m_pReader;
|
||||
CAsyncIo * m_pIo;
|
||||
|
||||
// This is set every time we're asked to return an IAsyncReader
|
||||
// interface
|
||||
// This allows us to know if the downstream pin can use
|
||||
// this transport, otherwise we can hook up to thinks like the
|
||||
// dump filter and nothing happens
|
||||
BOOL m_bQueriedForAsyncReader;
|
||||
|
||||
HRESULT InitAllocator(IMemAllocator **ppAlloc);
|
||||
|
||||
public:
|
||||
// constructor and destructor
|
||||
CAsyncOutputPin(
|
||||
HRESULT * phr,
|
||||
CAsyncReader *pReader,
|
||||
CAsyncIo *pIo,
|
||||
CCritSec * pLock);
|
||||
|
||||
~CAsyncOutputPin();
|
||||
|
||||
// --- CUnknown ---
|
||||
|
||||
// need to expose IAsyncReader
|
||||
DECLARE_IUNKNOWN
|
||||
STDMETHODIMP NonDelegatingQueryInterface(REFIID, void**);
|
||||
|
||||
// --- IPin methods ---
|
||||
STDMETHODIMP Connect(
|
||||
IPin * pReceivePin,
|
||||
const AM_MEDIA_TYPE *pmt // optional media type
|
||||
);
|
||||
|
||||
// --- CBasePin methods ---
|
||||
|
||||
// return the types we prefer - this will return the known
|
||||
// file type
|
||||
HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
|
||||
|
||||
// can we support this type?
|
||||
HRESULT CheckMediaType(const CMediaType* pType);
|
||||
|
||||
// Clear the flag so we see if IAsyncReader is queried for
|
||||
HRESULT CheckConnect(IPin *pPin)
|
||||
{
|
||||
m_bQueriedForAsyncReader = FALSE;
|
||||
return CBasePin::CheckConnect(pPin);
|
||||
}
|
||||
|
||||
// See if it was asked for
|
||||
HRESULT CompleteConnect(IPin *pReceivePin)
|
||||
{
|
||||
if (m_bQueriedForAsyncReader) {
|
||||
return CBasePin::CompleteConnect(pReceivePin);
|
||||
} else {
|
||||
#ifdef VFW_E_NO_TRANSPORT
|
||||
return VFW_E_NO_TRANSPORT;
|
||||
#else
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Remove our connection status
|
||||
HRESULT BreakConnect()
|
||||
{
|
||||
m_bQueriedForAsyncReader = FALSE;
|
||||
return CBasePin::BreakConnect();
|
||||
}
|
||||
|
||||
// --- IAsyncReader methods ---
|
||||
// pass in your preferred allocator and your preferred properties.
|
||||
// method returns the actual allocator to be used. Call GetProperties
|
||||
// on returned allocator to learn alignment and prefix etc chosen.
|
||||
// this allocator will be not be committed and decommitted by
|
||||
// the async reader, only by the consumer.
|
||||
STDMETHODIMP RequestAllocator(
|
||||
IMemAllocator* pPreferred,
|
||||
ALLOCATOR_PROPERTIES* pProps,
|
||||
IMemAllocator ** ppActual);
|
||||
|
||||
// queue a request for data.
|
||||
// media sample start and stop times contain the requested absolute
|
||||
// byte position (start inclusive, stop exclusive).
|
||||
// may fail if sample not obtained from agreed allocator.
|
||||
// may fail if start/stop position does not match agreed alignment.
|
||||
// samples allocated from source pin's allocator may fail
|
||||
// GetPointer until after returning from WaitForNext.
|
||||
STDMETHODIMP Request(
|
||||
IMediaSample* pSample,
|
||||
DWORD dwUser); // user context
|
||||
|
||||
// block until the next sample is completed or the timeout occurs.
|
||||
// timeout (millisecs) may be 0 or INFINITE. Samples may not
|
||||
// be delivered in order. If there is a read error of any sort, a
|
||||
// notification will already have been sent by the source filter,
|
||||
// and STDMETHODIMP will be an error.
|
||||
STDMETHODIMP WaitForNext(
|
||||
DWORD dwTimeout,
|
||||
IMediaSample** ppSample, // completed sample
|
||||
DWORD * pdwUser); // user context
|
||||
|
||||
// sync read of data. Sample passed in must have been acquired from
|
||||
// the agreed allocator. Start and stop position must be aligned.
|
||||
// equivalent to a Request/WaitForNext pair, but may avoid the
|
||||
// need for a thread on the source filter.
|
||||
STDMETHODIMP SyncReadAligned(
|
||||
IMediaSample* pSample);
|
||||
|
||||
|
||||
// sync read. works in stopped state as well as run state.
|
||||
// need not be aligned. Will fail if read is beyond actual total
|
||||
// length.
|
||||
STDMETHODIMP SyncRead(
|
||||
LONGLONG llPosition, // absolute file position
|
||||
LONG lLength, // nr bytes required
|
||||
BYTE* pBuffer); // write data here
|
||||
|
||||
// return total length of stream, and currently available length.
|
||||
// reads for beyond the available length but within the total length will
|
||||
// normally succeed but may block for a long period.
|
||||
STDMETHODIMP Length(
|
||||
LONGLONG* pTotal,
|
||||
LONGLONG* pAvailable);
|
||||
|
||||
// cause all outstanding reads to return, possibly with a failure code
|
||||
// (VFW_E_TIMEOUT) indicating they were cancelled.
|
||||
// these are defined on IAsyncReader and IPin
|
||||
STDMETHODIMP BeginFlush(void);
|
||||
STDMETHODIMP EndFlush(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// The filter object itself. Supports IBaseFilter through
|
||||
// CBaseFilter and also IFileSourceFilter directly in this object
|
||||
|
||||
class CAsyncReader : public CBaseFilter
|
||||
{
|
||||
|
||||
protected:
|
||||
// filter-wide lock
|
||||
CCritSec m_csFilter;
|
||||
|
||||
// all i/o done here
|
||||
CAsyncIo m_Io;
|
||||
|
||||
// our output pin
|
||||
CAsyncOutputPin m_OutputPin;
|
||||
|
||||
// Type we think our data is
|
||||
CMediaType m_mt;
|
||||
|
||||
public:
|
||||
|
||||
// construction / destruction
|
||||
|
||||
CAsyncReader(
|
||||
TCHAR *pName,
|
||||
LPUNKNOWN pUnk,
|
||||
CAsyncStream *pStream,
|
||||
HRESULT *phr);
|
||||
~CAsyncReader();
|
||||
|
||||
|
||||
// --- CBaseFilter methods ---
|
||||
int GetPinCount();
|
||||
CBasePin *GetPin(int n);
|
||||
|
||||
// --- Access our media type
|
||||
const CMediaType *LoadType() const
|
||||
{
|
||||
return &m_mt;
|
||||
}
|
||||
|
||||
virtual HRESULT Connect(
|
||||
IPin * pReceivePin,
|
||||
const AM_MEDIA_TYPE *pmt // optional media type
|
||||
)
|
||||
{
|
||||
return m_OutputPin.CBasePin::Connect(pReceivePin, pmt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //__ASYNCRDR_H__
|
||||
211
Library/dxx8/samples/Multimedia/Common/include/d3dapp.h
Normal file
211
Library/dxx8/samples/Multimedia/Common/include/d3dapp.h
Normal file
@@ -0,0 +1,211 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DApp.h
|
||||
//
|
||||
// Desc: Application class for the Direct3D samples framework library.
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef D3DAPP_H
|
||||
#define D3DAPP_H
|
||||
|
||||
// basetsd.h defines INT_PTR (used below). It is not included by default
|
||||
// under VC 5.0. If you are using VC6 or later, it is included via Windows.h.
|
||||
#include <basetsd.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Error codes
|
||||
//-----------------------------------------------------------------------------
|
||||
enum APPMSGTYPE { MSG_NONE, MSGERR_APPMUSTEXIT, MSGWARN_SWITCHEDTOREF };
|
||||
|
||||
#define D3DAPPERR_NODIRECT3D 0x82000001
|
||||
#define D3DAPPERR_NOWINDOW 0x82000002
|
||||
#define D3DAPPERR_NOCOMPATIBLEDEVICES 0x82000003
|
||||
#define D3DAPPERR_NOWINDOWABLEDEVICES 0x82000004
|
||||
#define D3DAPPERR_NOHARDWAREDEVICE 0x82000005
|
||||
#define D3DAPPERR_HALNOTCOMPATIBLE 0x82000006
|
||||
#define D3DAPPERR_NOWINDOWEDHAL 0x82000007
|
||||
#define D3DAPPERR_NODESKTOPHAL 0x82000008
|
||||
#define D3DAPPERR_NOHALTHISMODE 0x82000009
|
||||
#define D3DAPPERR_NONZEROREFCOUNT 0x8200000a
|
||||
#define D3DAPPERR_MEDIANOTFOUND 0x8200000b
|
||||
#define D3DAPPERR_RESIZEFAILED 0x8200000c
|
||||
#define D3DAPPERR_NULLREFDEVICE 0x8200000d
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DModeInfo
|
||||
// Desc: Structure for holding information about a display mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DModeInfo
|
||||
{
|
||||
DWORD Width; // Screen width in this mode
|
||||
DWORD Height; // Screen height in this mode
|
||||
D3DFORMAT Format; // Pixel format in this mode
|
||||
DWORD dwBehavior; // Hardware / Software / Mixed vertex processing
|
||||
D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DDeviceInfo
|
||||
// Desc: Structure for holding information about a Direct3D device, including
|
||||
// a list of modes compatible with this device
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DDeviceInfo
|
||||
{
|
||||
// Device data
|
||||
D3DDEVTYPE DeviceType; // Reference, HAL, etc.
|
||||
D3DCAPS8 d3dCaps; // Capabilities of this device
|
||||
const TCHAR* strDesc; // Name of this device
|
||||
BOOL bCanDoWindowed; // Whether this device can work in windowed mode
|
||||
|
||||
// Modes for this device
|
||||
DWORD dwNumModes;
|
||||
D3DModeInfo modes[150];
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentMode;
|
||||
BOOL bWindowed;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleTypeWindowed;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleTypeFullscreen;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DAdapterInfo
|
||||
// Desc: Structure for holding information about an adapter, including a list
|
||||
// of devices available on this adapter
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DAdapterInfo
|
||||
{
|
||||
// Adapter data
|
||||
D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier;
|
||||
D3DDISPLAYMODE d3ddmDesktop; // Desktop display mode for this adapter
|
||||
|
||||
// Devices for this adapter
|
||||
DWORD dwNumDevices;
|
||||
D3DDeviceInfo devices[5];
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentDevice;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DApplication
|
||||
// Desc: A base class for creating sample D3D8 applications. To create a simple
|
||||
// Direct3D application, simply derive this class into a class (such as
|
||||
// class CMyD3DApplication) and override the following functions, as
|
||||
// needed:
|
||||
// OneTimeSceneInit() - To initialize app data (alloc mem, etc.)
|
||||
// InitDeviceObjects() - To initialize the 3D scene objects
|
||||
// FrameMove() - To animate the scene
|
||||
// Render() - To render the scene
|
||||
// DeleteDeviceObjects() - To cleanup the 3D scene objects
|
||||
// FinalCleanup() - To cleanup app data (for exitting the app)
|
||||
// MsgProc() - To handle Windows messages
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DApplication
|
||||
{
|
||||
protected:
|
||||
// Internal variables for the state of the app
|
||||
D3DAdapterInfo m_Adapters[10];
|
||||
DWORD m_dwNumAdapters;
|
||||
DWORD m_dwAdapter;
|
||||
BOOL m_bWindowed;
|
||||
BOOL m_bActive;
|
||||
BOOL m_bReady;
|
||||
BOOL m_bHasFocus;
|
||||
|
||||
// Internal variables used for timing
|
||||
BOOL m_bFrameMoving;
|
||||
BOOL m_bSingleStep;
|
||||
|
||||
// Internal error handling function
|
||||
HRESULT DisplayErrorMsg( HRESULT hr, DWORD dwType );
|
||||
|
||||
// Internal functions to manage and render the 3D scene
|
||||
HRESULT BuildDeviceList();
|
||||
BOOL FindDepthStencilFormat( UINT iAdapter, D3DDEVTYPE DeviceType,
|
||||
D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat );
|
||||
HRESULT Initialize3DEnvironment();
|
||||
HRESULT Resize3DEnvironment();
|
||||
HRESULT ToggleFullscreen();
|
||||
HRESULT ForceWindowed();
|
||||
HRESULT UserSelectNewDevice();
|
||||
VOID Cleanup3DEnvironment();
|
||||
HRESULT Render3DEnvironment();
|
||||
virtual HRESULT AdjustWindowForChange();
|
||||
static INT_PTR CALLBACK SelectDeviceProc( HWND hDlg, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
protected:
|
||||
// Main objects used for creating and rendering the 3D scene
|
||||
D3DPRESENT_PARAMETERS m_d3dpp; // Parameters for CreateDevice/Reset
|
||||
HWND m_hWnd; // The main app window
|
||||
HWND m_hWndFocus; // The D3D focus window (usually same as m_hWnd)
|
||||
HMENU m_hMenu; // App menu bar (stored here when fullscreen)
|
||||
LPDIRECT3D8 m_pD3D; // The main D3D object
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice; // The D3D rendering device
|
||||
D3DCAPS8 m_d3dCaps; // Caps for the device
|
||||
D3DSURFACE_DESC m_d3dsdBackBuffer; // Surface desc of the backbuffer
|
||||
DWORD m_dwCreateFlags; // Indicate sw or hw vertex processing
|
||||
DWORD m_dwWindowStyle; // Saved window style for mode switches
|
||||
RECT m_rcWindowBounds; // Saved window bounds for mode switches
|
||||
RECT m_rcWindowClient; // Saved client area size for mode switches
|
||||
|
||||
// Variables for timing
|
||||
FLOAT m_fTime; // Current time in seconds
|
||||
FLOAT m_fElapsedTime; // Time elapsed since last frame
|
||||
FLOAT m_fFPS; // Instanteous frame rate
|
||||
TCHAR m_strDeviceStats[90];// String to hold D3D device stats
|
||||
TCHAR m_strFrameStats[90]; // String to hold frame stats
|
||||
|
||||
// Overridable variables for the app
|
||||
TCHAR* m_strWindowTitle; // Title for the app's window
|
||||
BOOL m_bUseDepthBuffer; // Whether to autocreate depthbuffer
|
||||
DWORD m_dwMinDepthBits; // Minimum number of bits needed in depth buffer
|
||||
DWORD m_dwMinStencilBits; // Minimum number of bits needed in stencil buffer
|
||||
DWORD m_dwCreationWidth; // Width used to create window
|
||||
DWORD m_dwCreationHeight; // Height used to create window
|
||||
BOOL m_bShowCursorWhenFullscreen; // Whether to show cursor when fullscreen
|
||||
BOOL m_bClipCursorWhenFullscreen; // Whether to limit cursor pos when fullscreen
|
||||
|
||||
// Overridable functions for the 3D scene created by the app
|
||||
virtual HRESULT ConfirmDevice(D3DCAPS8*,DWORD,D3DFORMAT) { return S_OK; }
|
||||
virtual HRESULT OneTimeSceneInit() { return S_OK; }
|
||||
virtual HRESULT InitDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT RestoreDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT FrameMove() { return S_OK; }
|
||||
virtual HRESULT Render() { return S_OK; }
|
||||
virtual HRESULT InvalidateDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT DeleteDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT FinalCleanup() { return S_OK; }
|
||||
|
||||
public:
|
||||
// Functions to create, run, pause, and clean up the application
|
||||
virtual HRESULT Create( HINSTANCE hInstance );
|
||||
virtual INT Run();
|
||||
virtual LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual VOID Pause( BOOL bPause );
|
||||
|
||||
// Internal constructor
|
||||
CD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
130
Library/dxx8/samples/Multimedia/Common/include/d3dfile.h
Normal file
130
Library/dxx8/samples/Multimedia/Common/include/d3dfile.h
Normal file
@@ -0,0 +1,130 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DFile.h
|
||||
//
|
||||
// Desc: Support code for loading DirectX .X files.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef D3DFILE_H
|
||||
#define D3DFILE_H
|
||||
#include <tchar.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DMesh
|
||||
// Desc: Class for loading and rendering file-based meshes
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DMesh
|
||||
{
|
||||
public:
|
||||
TCHAR m_strName[512];
|
||||
|
||||
LPD3DXMESH m_pSysMemMesh; // SysMem mesh, lives through resize
|
||||
LPD3DXMESH m_pLocalMesh; // Local mesh, rebuilt on resize
|
||||
|
||||
DWORD m_dwNumMaterials; // Materials for the mesh
|
||||
D3DMATERIAL8* m_pMaterials;
|
||||
LPDIRECT3DTEXTURE8* m_pTextures;
|
||||
BOOL m_bUseMaterials;
|
||||
|
||||
public:
|
||||
// Rendering
|
||||
HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice,
|
||||
BOOL bDrawOpaqueSubsets = TRUE,
|
||||
BOOL bDrawAlphaSubsets = TRUE );
|
||||
|
||||
// Mesh access
|
||||
LPD3DXMESH GetSysMemMesh() { return m_pSysMemMesh; }
|
||||
LPD3DXMESH GetLocalMesh() { return m_pLocalMesh; }
|
||||
|
||||
// Rendering options
|
||||
VOID UseMeshMaterials( BOOL bFlag ) { m_bUseMaterials = bFlag; }
|
||||
HRESULT SetFVF( LPDIRECT3DDEVICE8 pd3dDevice, DWORD dwFVF );
|
||||
|
||||
// Initializing
|
||||
HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
|
||||
// Creation/destruction
|
||||
HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strFilename );
|
||||
HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData );
|
||||
HRESULT Destroy();
|
||||
|
||||
CD3DMesh( TCHAR* strName = _T("CD3DFile_Mesh") );
|
||||
virtual ~CD3DMesh();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DFrame
|
||||
// Desc: Class for loading and rendering file-based meshes
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DFrame
|
||||
{
|
||||
public:
|
||||
TCHAR m_strName[512];
|
||||
D3DXMATRIX m_mat;
|
||||
CD3DMesh* m_pMesh;
|
||||
TCHAR m_strMeshName[512];
|
||||
|
||||
CD3DFrame* m_pNext;
|
||||
CD3DFrame* m_pChild;
|
||||
|
||||
public:
|
||||
// Matrix access
|
||||
VOID SetMatrix( D3DXMATRIX* pmat ) { m_mat = *pmat; }
|
||||
D3DXMATRIX* GetMatrix() { return &m_mat; }
|
||||
|
||||
CD3DMesh* FindMesh( TCHAR* strMeshName );
|
||||
CD3DFrame* FindFrame( TCHAR* strFrameName );
|
||||
BOOL EnumMeshes( BOOL (*EnumMeshCB)(CD3DMesh*,VOID*),
|
||||
VOID* pContext );
|
||||
|
||||
HRESULT Destroy();
|
||||
HRESULT RestoreDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice,
|
||||
BOOL bDrawOpaqueSubsets = TRUE,
|
||||
BOOL bDrawAlphaSubsets = TRUE,
|
||||
D3DXMATRIX* pmatWorldMartix = NULL);
|
||||
|
||||
CD3DFrame( TCHAR* strName = _T("CD3DFile_Frame") );
|
||||
virtual ~CD3DFrame();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DFile
|
||||
// Desc: Class for loading and rendering file-based meshes
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DFile : public CD3DFrame
|
||||
{
|
||||
HRESULT LoadMesh( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData,
|
||||
CD3DFrame* pParentFrame );
|
||||
HRESULT LoadFrame( LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECTXFILEDATA pFileData,
|
||||
CD3DFrame* pParentFrame );
|
||||
public:
|
||||
HRESULT Create( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strFilename );
|
||||
HRESULT CreateFromResource( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strResource, TCHAR* strType );
|
||||
// For pure devices, specify the world transform. If the world transform is not
|
||||
// specified on pure devices, this function will fail.
|
||||
HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice, D3DXMATRIX* pmatWorldMatrix = NULL );
|
||||
|
||||
CD3DFile() : CD3DFrame( _T("CD3DFile_Root") ) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
77
Library/dxx8/samples/Multimedia/Common/include/d3dfont.h
Normal file
77
Library/dxx8/samples/Multimedia/Common/include/d3dfont.h
Normal file
@@ -0,0 +1,77 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DFont.h
|
||||
//
|
||||
// Desc: Texture-based font class
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef D3DFONT_H
|
||||
#define D3DFONT_H
|
||||
#include <tchar.h>
|
||||
#include <D3D8.h>
|
||||
|
||||
|
||||
// Font creation flags
|
||||
#define D3DFONT_BOLD 0x0001
|
||||
#define D3DFONT_ITALIC 0x0002
|
||||
#define D3DFONT_ZENABLE 0x0004
|
||||
|
||||
// Font rendering flags
|
||||
#define D3DFONT_CENTERED 0x0001
|
||||
#define D3DFONT_TWOSIDED 0x0002
|
||||
#define D3DFONT_FILTERED 0x0004
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DFont
|
||||
// Desc: Texture-based font class for doing text in a 3D scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DFont
|
||||
{
|
||||
TCHAR m_strFontName[80]; // Font properties
|
||||
DWORD m_dwFontHeight;
|
||||
DWORD m_dwFontFlags;
|
||||
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice; // A D3DDevice used for rendering
|
||||
LPDIRECT3DTEXTURE8 m_pTexture; // The d3d texture for this font
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pVB; // VertexBuffer for rendering text
|
||||
DWORD m_dwTexWidth; // Texture dimensions
|
||||
DWORD m_dwTexHeight;
|
||||
FLOAT m_fTextScale;
|
||||
FLOAT m_fTexCoords[128-32][4];
|
||||
|
||||
// Stateblocks for setting and restoring render states
|
||||
DWORD m_dwSavedStateBlock;
|
||||
DWORD m_dwDrawTextStateBlock;
|
||||
|
||||
public:
|
||||
// 2D and 3D text drawing functions
|
||||
HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
|
||||
TCHAR* strText, DWORD dwFlags=0L );
|
||||
HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
|
||||
FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
|
||||
TCHAR* strText, DWORD dwFlags=0L );
|
||||
HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
|
||||
|
||||
// Function to get extent of text
|
||||
HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );
|
||||
|
||||
// Initializing and destroying device-dependent objects
|
||||
HRESULT InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
|
||||
// Constructor / destructor
|
||||
CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
|
||||
~CD3DFont();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
34
Library/dxx8/samples/Multimedia/Common/include/d3dres.h
Normal file
34
Library/dxx8/samples/Multimedia/Common/include/d3dres.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DRes.h
|
||||
//
|
||||
// Desc: Resource definitions required by the CD3DApplication class.
|
||||
// Any application using the CD3DApplication class must include resources
|
||||
// with the following identifiers.
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef D3DRES_H
|
||||
#define D3DRES_H
|
||||
|
||||
|
||||
#define IDI_MAIN_ICON 101 // Application icon
|
||||
#define IDR_MAIN_ACCEL 113 // Keyboard accelerator
|
||||
#define IDR_MENU 141 // Application menu
|
||||
#define IDR_POPUP 142 // Popup menu
|
||||
#define IDD_SELECTDEVICE 144 // "Change Device" dialog box
|
||||
|
||||
#define IDC_ADAPTER_COMBO 1002 // Adapter combobox for "SelectDevice" dlg
|
||||
#define IDC_DEVICE_COMBO 1000 // Device combobox for "SelectDevice" dlg
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003 // Mode combobox for "SelectDevice" dlg
|
||||
#define IDC_MULTISAMPLE_COMBO 1005 // MultiSample combobox for "SelectDevice" dlg
|
||||
#define IDC_WINDOW 1016 // Radio button for windowed-mode
|
||||
#define IDC_FULLSCREEN 1018 // Radio button for fullscreen-mode
|
||||
|
||||
#define IDM_CHANGEDEVICE 40002 // Command to invoke "Change Device" dlg
|
||||
#define IDM_TOGGLEFULLSCREEN 40003 // Command to toggle fullscreen mode
|
||||
#define IDM_TOGGLESTART 40004 // Command to toggle frame animation
|
||||
#define IDM_SINGLESTEP 40005 // Command to single step frame animation
|
||||
#define IDM_EXIT 40006 // Command to exit the application
|
||||
|
||||
|
||||
#endif // D3DRES_H
|
||||
314
Library/dxx8/samples/Multimedia/Common/include/d3dsaver.h
Normal file
314
Library/dxx8/samples/Multimedia/Common/include/d3dsaver.h
Normal file
@@ -0,0 +1,314 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DSaver.h
|
||||
//
|
||||
// Desc: Framework for screensavers that use Direct3D 8.0.
|
||||
//
|
||||
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _D3DSAVER_H
|
||||
#define _D3DSAVER_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Error codes
|
||||
//-----------------------------------------------------------------------------
|
||||
enum APPMSGTYPE { MSG_NONE, MSGERR_APPMUSTEXIT, MSGWARN_SWITCHEDTOREF };
|
||||
|
||||
#define D3DAPPERR_NODIRECT3D 0x82000001
|
||||
#define D3DAPPERR_NOWINDOW 0x82000002
|
||||
#define D3DAPPERR_NOCOMPATIBLEDEVICES 0x82000003
|
||||
#define D3DAPPERR_NOWINDOWABLEDEVICES 0x82000004
|
||||
#define D3DAPPERR_NOHARDWAREDEVICE 0x82000005
|
||||
#define D3DAPPERR_HALNOTCOMPATIBLE 0x82000006
|
||||
#define D3DAPPERR_NOWINDOWEDHAL 0x82000007
|
||||
#define D3DAPPERR_NODESKTOPHAL 0x82000008
|
||||
#define D3DAPPERR_NOHALTHISMODE 0x82000009
|
||||
#define D3DAPPERR_NONZEROREFCOUNT 0x8200000a
|
||||
#define D3DAPPERR_MEDIANOTFOUND 0x8200000b
|
||||
#define D3DAPPERR_RESIZEFAILED 0x8200000c
|
||||
#define D3DAPPERR_INITDEVICEOBJECTSFAILED 0x8200000d
|
||||
#define D3DAPPERR_CREATEDEVICEFAILED 0x8200000e
|
||||
#define D3DAPPERR_NOPREVIEW 0x8200000f
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constants
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MAX_DISPLAYS 9
|
||||
#define NO_ADAPTER 0xffffffff
|
||||
#define NO_MONITOR 0xffffffff
|
||||
|
||||
|
||||
//***************************************************************************************
|
||||
// Modes of operation for screensaver
|
||||
enum SaverMode
|
||||
{
|
||||
sm_config, // Config dialog box
|
||||
sm_preview, // Mini preview window in Display Properties dialog
|
||||
sm_full, // Full-on screensaver mode
|
||||
sm_test, // Test mode
|
||||
sm_passwordchange // Change password
|
||||
};
|
||||
|
||||
|
||||
// Prototype for VerifyScreenSavePwd() in password.cpl, used on Win9x
|
||||
typedef BOOL (PASCAL * VERIFYPWDPROC) (HWND);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DModeInfo
|
||||
// Desc: Structure for holding information about a display mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DModeInfo
|
||||
{
|
||||
DWORD Width; // Screen width in this mode
|
||||
DWORD Height; // Screen height in this mode
|
||||
D3DFORMAT Format; // Pixel format in this mode
|
||||
DWORD dwBehavior; // Hardware / Software / Mixed vertex processing
|
||||
D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DWindowedModeInfo
|
||||
// Desc: Structure for holding information about a display mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DWindowedModeInfo
|
||||
{
|
||||
D3DFORMAT DisplayFormat;
|
||||
D3DFORMAT BackBufferFormat;
|
||||
DWORD dwBehavior; // Hardware / Software / Mixed vertex processing
|
||||
D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DDeviceInfo
|
||||
// Desc: Structure for holding information about a Direct3D device, including
|
||||
// a list of modes compatible with this device
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DDeviceInfo
|
||||
{
|
||||
// Device data
|
||||
D3DDEVTYPE DeviceType; // Reference, HAL, etc.
|
||||
D3DCAPS8 d3dCaps; // Capabilities of this device
|
||||
const TCHAR* strDesc; // Name of this device
|
||||
BOOL bCanDoWindowed; // Whether this device can work in windowed mode
|
||||
|
||||
// Modes for this device
|
||||
DWORD dwNumModes;
|
||||
D3DModeInfo modes[150];
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentMode;
|
||||
BOOL bWindowed;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleType;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DAdapterInfo
|
||||
// Desc: Structure for holding information about an adapter, including a list
|
||||
// of devices available on this adapter
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DAdapterInfo
|
||||
{
|
||||
// Adapter data
|
||||
DWORD iMonitor; // Which MonitorInfo corresponds to this adapter
|
||||
D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier;
|
||||
D3DDISPLAYMODE d3ddmDesktop; // Desktop display mode for this adapter
|
||||
|
||||
// Devices for this adapter
|
||||
DWORD dwNumDevices;
|
||||
D3DDeviceInfo devices[3];
|
||||
BOOL bHasHAL;
|
||||
BOOL bHasAppCompatHAL;
|
||||
BOOL bHasSW;
|
||||
BOOL bHasAppCompatSW;
|
||||
|
||||
// User's preferred mode settings for this adapter
|
||||
DWORD dwUserPrefWidth;
|
||||
DWORD dwUserPrefHeight;
|
||||
D3DFORMAT d3dfmtUserPrefFormat;
|
||||
BOOL bLeaveBlack; // If TRUE, don't render to this display
|
||||
BOOL bDisableHW; // If TRUE, don't use HAL on this display
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentDevice;
|
||||
HWND hWndDevice;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct MonitorInfo
|
||||
// Desc: Structure for holding information about a monitor
|
||||
//-----------------------------------------------------------------------------
|
||||
struct MonitorInfo
|
||||
{
|
||||
TCHAR strDeviceName[128];
|
||||
TCHAR strMonitorName[128];
|
||||
HMONITOR hMonitor;
|
||||
RECT rcScreen;
|
||||
DWORD iAdapter; // Which D3DAdapterInfo corresponds to this monitor
|
||||
HWND hWnd;
|
||||
|
||||
// Error message state
|
||||
FLOAT xError;
|
||||
FLOAT yError;
|
||||
FLOAT widthError;
|
||||
FLOAT heightError;
|
||||
FLOAT xVelError;
|
||||
FLOAT yVelError;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct RenderUnit
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct RenderUnit
|
||||
{
|
||||
UINT iAdapter;
|
||||
UINT iMonitor;
|
||||
D3DDEVTYPE DeviceType; // Reference, HAL, etc.
|
||||
DWORD dwBehavior;
|
||||
IDirect3DDevice8* pd3dDevice;
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
BOOL bDeviceObjectsInited; // InitDeviceObjects was called
|
||||
BOOL bDeviceObjectsRestored; // RestoreDeviceObjects was called
|
||||
TCHAR strDeviceStats[90];// String to hold D3D device stats
|
||||
TCHAR strFrameStats[40]; // String to hold frame stats
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DScreensaver
|
||||
// Desc: D3D screensaver class
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DScreensaver
|
||||
{
|
||||
public:
|
||||
CD3DScreensaver();
|
||||
|
||||
virtual HRESULT Create( HINSTANCE hInstance );
|
||||
virtual INT Run();
|
||||
HRESULT DisplayErrorMsg( HRESULT hr, DWORD dwType = 0 );
|
||||
|
||||
protected:
|
||||
SaverMode ParseCommandLine( TCHAR* pstrCommandLine );
|
||||
VOID ChangePassword();
|
||||
HRESULT DoSaver();
|
||||
|
||||
virtual VOID DoConfig() { }
|
||||
virtual VOID ReadSettings() {};
|
||||
VOID ReadScreenSettings( HKEY hkeyParent );
|
||||
VOID WriteScreenSettings( HKEY hkeyParent );
|
||||
|
||||
virtual VOID DoPaint( HWND hwnd, HDC hdc );
|
||||
HRESULT Initialize3DEnvironment();
|
||||
VOID Cleanup3DEnvironment();
|
||||
HRESULT Render3DEnvironment();
|
||||
static LRESULT CALLBACK SaverProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual LRESULT SaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
VOID InterruptSaver();
|
||||
VOID ShutdownSaver();
|
||||
VOID DoScreenSettingsDialog( HWND hwndParent );
|
||||
static INT_PTR CALLBACK ScreenSettingsDlgProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
INT_PTR ScreenSettingsDlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
VOID SetupAdapterPage(HWND hWnd);
|
||||
|
||||
HRESULT CreateSaverWindow();
|
||||
HRESULT BuildDeviceList();
|
||||
BOOL FindDepthStencilFormat( UINT iAdapter, D3DDEVTYPE DeviceType,
|
||||
D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat );
|
||||
HRESULT CheckWindowedFormat( UINT iAdapter, D3DWindowedModeInfo* pD3DWindowedModeInfo );
|
||||
HRESULT CreateFullscreenRenderUnit( RenderUnit* pRenderUnit );
|
||||
HRESULT CreateWindowedRenderUnit( RenderUnit* pRenderUnit );
|
||||
BOOL FindNextLowerMode( D3DDeviceInfo* pD3DDeviceInfo );
|
||||
VOID SwitchToRenderUnit( UINT iRenderUnit );
|
||||
VOID BuildProjectionMatrix( FLOAT fNear, FLOAT fFar, D3DXMATRIX* pMatrix );
|
||||
HRESULT SetProjectionMatrix( FLOAT fNear, FLOAT fFar );
|
||||
virtual VOID UpdateDeviceStats();
|
||||
virtual VOID UpdateFrameStats();
|
||||
virtual BOOL GetTextForError( HRESULT hr, TCHAR* pszError, DWORD dwNumChars );
|
||||
VOID UpdateErrorBox();
|
||||
VOID EnumMonitors( VOID );
|
||||
BOOL GetBestAdapter( DWORD* piAdapter );
|
||||
|
||||
virtual VOID SetDevice( UINT iDevice ) { }
|
||||
virtual HRESULT RegisterSoftwareDevice() { return S_OK; }
|
||||
virtual HRESULT ConfirmDevice(D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT fmtBackBuffer) { return S_OK; }
|
||||
virtual HRESULT ConfirmMode( LPDIRECT3DDEVICE8 pd3dDev ) { return S_OK; }
|
||||
virtual HRESULT OneTimeSceneInit() { return S_OK; }
|
||||
virtual HRESULT InitDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT RestoreDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT FrameMove() { return S_OK; }
|
||||
virtual HRESULT Render() { return S_OK; }
|
||||
virtual HRESULT InvalidateDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT DeleteDeviceObjects() { return S_OK; }
|
||||
virtual HRESULT FinalCleanup() { return S_OK; }
|
||||
|
||||
protected:
|
||||
SaverMode m_SaverMode; // sm_config, sm_full, sm_preview, etc.
|
||||
BOOL m_bAllScreensSame; // If TRUE, show same image on all screens
|
||||
HWND m_hWnd; // Focus window and device window on primary
|
||||
HWND m_hWndParent;
|
||||
HINSTANCE m_hInstance;
|
||||
BOOL m_bWaitForInputIdle; // Used to pause when preview starts
|
||||
DWORD m_dwSaverMouseMoveCount;
|
||||
BOOL m_bIs9x;
|
||||
HINSTANCE m_hPasswordDLL;
|
||||
VERIFYPWDPROC m_VerifySaverPassword;
|
||||
BOOL m_bCheckingSaverPassword;
|
||||
BOOL m_bWindowed;
|
||||
|
||||
// Variables for non-fatal error management
|
||||
BOOL m_bErrorMode; // Whether to display an error
|
||||
HRESULT m_hrError; // Error code to display
|
||||
TCHAR m_szError[400]; // Error message text
|
||||
|
||||
MonitorInfo m_Monitors[MAX_DISPLAYS];
|
||||
DWORD m_dwNumMonitors;
|
||||
RenderUnit m_RenderUnits[MAX_DISPLAYS];
|
||||
DWORD m_dwNumRenderUnits;
|
||||
D3DAdapterInfo* m_Adapters[MAX_DISPLAYS];
|
||||
DWORD m_dwNumAdapters;
|
||||
IDirect3D8* m_pD3D;
|
||||
IDirect3DDevice8* m_pd3dDevice; // Current D3D device
|
||||
RECT m_rcRenderTotal; // Rect of entire area to be rendered
|
||||
RECT m_rcRenderCurDevice; // Rect of render area of current device
|
||||
D3DSURFACE_DESC m_d3dsdBackBuffer; // Info on back buffer for current device
|
||||
|
||||
TCHAR m_strWindowTitle[200]; // Title for the app's window
|
||||
BOOL m_bAllowRef; // Whether to allow REF D3D device
|
||||
BOOL m_bUseDepthBuffer; // Whether to autocreate depthbuffer
|
||||
BOOL m_bMultithreaded; // Whether to make D3D thread-safe
|
||||
BOOL m_bOneScreenOnly; // Only ever show screensaver on one screen
|
||||
TCHAR m_strRegPath[200]; // Where to store registry info
|
||||
DWORD m_dwMinDepthBits; // Minimum number of bits needed in depth buffer
|
||||
DWORD m_dwMinStencilBits; // Minimum number of bits needed in stencil buffer
|
||||
D3DSWAPEFFECT m_SwapEffectFullscreen; // SwapEffect to use in fullscreen Present()
|
||||
D3DSWAPEFFECT m_SwapEffectWindowed; // SwapEffect to use in windowed Present()
|
||||
|
||||
// Variables for timing
|
||||
FLOAT m_fTime; // Current time in seconds
|
||||
FLOAT m_fElapsedTime; // Time elapsed since last frame
|
||||
FLOAT m_fFPS; // Instanteous frame rate
|
||||
TCHAR m_strDeviceStats[90];// D3D device stats for current device
|
||||
TCHAR m_strFrameStats[40]; // Frame stats for current device
|
||||
};
|
||||
|
||||
#endif
|
||||
256
Library/dxx8/samples/Multimedia/Common/include/d3dutil.h
Normal file
256
Library/dxx8/samples/Multimedia/Common/include/d3dutil.h
Normal file
@@ -0,0 +1,256 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: D3DUtil.h
|
||||
//
|
||||
// Desc: Helper functions and typing shortcuts for Direct3D programming.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef D3DUTIL_H
|
||||
#define D3DUTIL_H
|
||||
#include <D3D8.h>
|
||||
#include <D3DX8Math.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_InitMaterial()
|
||||
// Desc: Initializes a D3DMATERIAL8 structure, setting the diffuse and ambient
|
||||
// colors. It does not set emissive or specular colors.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID D3DUtil_InitMaterial( D3DMATERIAL8& mtrl, FLOAT r=0.0f, FLOAT g=0.0f,
|
||||
FLOAT b=0.0f, FLOAT a=1.0f );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_InitLight()
|
||||
// Desc: Initializes a D3DLIGHT structure, setting the light position. The
|
||||
// diffuse color is set to white, specular and ambient left as black.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID D3DUtil_InitLight( D3DLIGHT8& light, D3DLIGHTTYPE ltType,
|
||||
FLOAT x=0.0f, FLOAT y=0.0f, FLOAT z=0.0f );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_CreateTexture()
|
||||
// Desc: Helper function to create a texture. It checks the root path first,
|
||||
// then tries the DXSDK media path (as specified in the system registry).
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT D3DUtil_CreateTexture( LPDIRECT3DDEVICE8 pd3dDevice, TCHAR* strTexture,
|
||||
LPDIRECT3DTEXTURE8* ppTexture,
|
||||
D3DFORMAT d3dFormat = D3DFMT_UNKNOWN );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_SetColorKey()
|
||||
// Desc: Changes all texels matching the colorkey to transparent, black.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT D3DUtil_SetColorKey( LPDIRECT3DTEXTURE8 pTexture, DWORD dwColorKey );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_CreateVertexShader()
|
||||
// Desc: Assembles and creates a file-based vertex shader
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT D3DUtil_CreateVertexShader( LPDIRECT3DDEVICE8 pd3dDevice,
|
||||
TCHAR* strFilename, DWORD* pdwVertexDecl,
|
||||
DWORD* pdwVertexShader );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_GetCubeMapViewMatrix()
|
||||
// Desc: Returns a view matrix for rendering to a face of a cubemap.
|
||||
//-----------------------------------------------------------------------------
|
||||
D3DXMATRIX D3DUtil_GetCubeMapViewMatrix( DWORD dwFace );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_GetRotationFromCursor()
|
||||
// Desc: Returns a quaternion for the rotation implied by the window's cursor
|
||||
// position.
|
||||
//-----------------------------------------------------------------------------
|
||||
D3DXQUATERNION D3DUtil_GetRotationFromCursor( HWND hWnd,
|
||||
FLOAT fTrackBallRadius=1.0f );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: D3DUtil_SetDeviceCursor
|
||||
// Desc: Builds and sets a cursor for the D3D device based on hCursor.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT D3DUtil_SetDeviceCursor( LPDIRECT3DDEVICE8 pd3dDevice, HCURSOR hCursor,
|
||||
BOOL bAddWatermark );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DArcBall
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DArcBall
|
||||
{
|
||||
INT m_iWidth; // ArcBall's window width
|
||||
INT m_iHeight; // ArcBall's window height
|
||||
FLOAT m_fRadius; // ArcBall's radius in screen coords
|
||||
FLOAT m_fRadiusTranslation; // ArcBall's radius for translating the target
|
||||
|
||||
D3DXQUATERNION m_qDown; // Quaternion before button down
|
||||
D3DXQUATERNION m_qNow; // Composite quaternion for current drag
|
||||
D3DXMATRIX m_matRotation; // Matrix for arcball's orientation
|
||||
D3DXMATRIX m_matRotationDelta; // Matrix for arcball's orientation
|
||||
D3DXMATRIX m_matTranslation; // Matrix for arcball's position
|
||||
D3DXMATRIX m_matTranslationDelta; // Matrix for arcball's position
|
||||
BOOL m_bDrag; // Whether user is dragging arcball
|
||||
BOOL m_bRightHanded; // Whether to use RH coordinate system
|
||||
|
||||
D3DXVECTOR3 ScreenToVector( int sx, int sy );
|
||||
|
||||
public:
|
||||
LRESULT HandleMouseMessages( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
D3DXMATRIX* GetRotationMatrix() { return &m_matRotation; }
|
||||
D3DXMATRIX* GetRotationDeltaMatrix() { return &m_matRotationDelta; }
|
||||
D3DXMATRIX* GetTranslationMatrix() { return &m_matTranslation; }
|
||||
D3DXMATRIX* GetTranslationDeltaMatrix() { return &m_matTranslationDelta; }
|
||||
BOOL IsBeingDragged() { return m_bDrag; }
|
||||
|
||||
VOID SetRadius( FLOAT fRadius );
|
||||
VOID SetWindow( INT w, INT h, FLOAT r=0.9 );
|
||||
VOID SetRightHanded( BOOL bRightHanded ) { m_bRightHanded = bRightHanded; }
|
||||
|
||||
CD3DArcBall();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CD3DCamera
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CD3DCamera
|
||||
{
|
||||
D3DXVECTOR3 m_vEyePt; // Attributes for view matrix
|
||||
D3DXVECTOR3 m_vLookatPt;
|
||||
D3DXVECTOR3 m_vUpVec;
|
||||
|
||||
D3DXVECTOR3 m_vView;
|
||||
D3DXVECTOR3 m_vCross;
|
||||
|
||||
D3DXMATRIX m_matView;
|
||||
D3DXMATRIX m_matBillboard; // Special matrix for billboarding effects
|
||||
|
||||
FLOAT m_fFOV; // Attributes for projection matrix
|
||||
FLOAT m_fAspect;
|
||||
FLOAT m_fNearPlane;
|
||||
FLOAT m_fFarPlane;
|
||||
D3DXMATRIX m_matProj;
|
||||
|
||||
public:
|
||||
// Access functions
|
||||
D3DXVECTOR3 GetEyePt() { return m_vEyePt; }
|
||||
D3DXVECTOR3 GetLookatPt() { return m_vLookatPt; }
|
||||
D3DXVECTOR3 GetUpVec() { return m_vUpVec; }
|
||||
D3DXVECTOR3 GetViewDir() { return m_vView; }
|
||||
D3DXVECTOR3 GetCross() { return m_vCross; }
|
||||
|
||||
D3DXMATRIX GetViewMatrix() { return m_matView; }
|
||||
D3DXMATRIX GetBillboardMatrix() { return m_matBillboard; }
|
||||
D3DXMATRIX GetProjMatrix() { return m_matProj; }
|
||||
|
||||
VOID SetViewParams( D3DXVECTOR3 &vEyePt, D3DXVECTOR3& vLookatPt,
|
||||
D3DXVECTOR3& vUpVec );
|
||||
VOID SetProjParams( FLOAT fFOV, FLOAT fAspect, FLOAT fNearPlane,
|
||||
FLOAT fFarPlane );
|
||||
|
||||
CD3DCamera();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper macros for pixel shader instructions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Parameter writemasks
|
||||
#define D3DPSP_WRITEMASK_B D3DSP_WRITEMASK_0
|
||||
#define D3DPSP_WRITEMASK_G D3DSP_WRITEMASK_1
|
||||
#define D3DPSP_WRITEMASK_R D3DSP_WRITEMASK_2
|
||||
#define D3DPSP_WRITEMASK_A D3DSP_WRITEMASK_3
|
||||
#define D3DPSP_WRITEMASK_C (D3DPSP_WRITEMASK_B|D3DPSP_WRITEMASK_G|D3DPSP_WRITEMASK_R)
|
||||
#define D3DPSP_WRITEMASK_ALL (D3DSP_WRITEMASK_0|D3DSP_WRITEMASK_1|D3DSP_WRITEMASK_2|D3DSP_WRITEMASK_3)
|
||||
#define D3DPSP_WRITEMASK_10 (D3DSP_WRITEMASK_0|D3DSP_WRITEMASK_1)
|
||||
#define D3DPSP_WRITEMASK_32 (D3DSP_WRITEMASK_2|D3DSP_WRITEMASK_3)
|
||||
|
||||
// Source and destination parameter token
|
||||
#define D3DPS_REGNUM_MASK(_Num) ( (1L<<31) | ((_Num)&D3DSP_REGNUM_MASK) )
|
||||
#define D3DPS_DST(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSPR_TEMP | D3DPSP_WRITEMASK_ALL )
|
||||
#define D3DPS_SRC_TEMP(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_TEMP )
|
||||
#define D3DPS_SRC_INPUT(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_INPUT )
|
||||
#define D3DPS_SRC_CONST(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_CONST )
|
||||
#define D3DPS_SRC_TEXTURE(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_TEXTURE )
|
||||
#define D3DVS_SRC_ADDR(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_ADDR )
|
||||
#define D3DVS_SRC_RASTOUT(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_RASTOUT )
|
||||
#define D3DVS_SRC_ATTROUT(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_ATTROUT )
|
||||
#define D3DVS_SRC_TEXCRDOUT(_Num) ( D3DPS_REGNUM_MASK(_Num) | D3DSP_NOSWIZZLE | D3DSPR_TEXCRDOUT )
|
||||
|
||||
// Temp destination registers
|
||||
#define D3DS_DR0 D3DPS_DST(0)
|
||||
#define D3DS_DR1 D3DPS_DST(1)
|
||||
#define D3DS_DR2 D3DPS_DST(2)
|
||||
#define D3DS_DR3 D3DPS_DST(3)
|
||||
#define D3DS_DR4 D3DPS_DST(4)
|
||||
#define D3DS_DR5 D3DPS_DST(5)
|
||||
#define D3DS_DR6 D3DPS_DST(6)
|
||||
#define D3DS_DR7 D3DPS_DST(7)
|
||||
|
||||
// Temp source registers
|
||||
#define D3DS_SR0 D3DPS_SRC_TEMP(0)
|
||||
#define D3DS_SR1 D3DPS_SRC_TEMP(1)
|
||||
#define D3DS_SR2 D3DPS_SRC_TEMP(2)
|
||||
#define D3DS_SR3 D3DPS_SRC_TEMP(3)
|
||||
#define D3DS_SR4 D3DPS_SRC_TEMP(4)
|
||||
#define D3DS_SR5 D3DPS_SRC_TEMP(5)
|
||||
#define D3DS_SR6 D3DPS_SRC_TEMP(6)
|
||||
#define D3DS_SR7 D3DPS_SRC_TEMP(7)
|
||||
|
||||
// Texture parameters
|
||||
#define D3DS_T0 D3DPS_SRC_TEXTURE(0)
|
||||
#define D3DS_T1 D3DPS_SRC_TEXTURE(1)
|
||||
#define D3DS_T2 D3DPS_SRC_TEXTURE(2)
|
||||
#define D3DS_T3 D3DPS_SRC_TEXTURE(3)
|
||||
#define D3DS_T4 D3DPS_SRC_TEXTURE(4)
|
||||
#define D3DS_T5 D3DPS_SRC_TEXTURE(5)
|
||||
#define D3DS_T6 D3DPS_SRC_TEXTURE(6)
|
||||
#define D3DS_T7 D3DPS_SRC_TEXTURE(7)
|
||||
|
||||
// Constant (factor) source parameters
|
||||
#define D3DS_C0 D3DPS_SRC_CONST(0)
|
||||
#define D3DS_C1 D3DPS_SRC_CONST(1)
|
||||
#define D3DS_C2 D3DPS_SRC_CONST(2)
|
||||
#define D3DS_C3 D3DPS_SRC_CONST(3)
|
||||
#define D3DS_C4 D3DPS_SRC_CONST(4)
|
||||
#define D3DS_C5 D3DPS_SRC_CONST(5)
|
||||
#define D3DS_C6 D3DPS_SRC_CONST(6)
|
||||
#define D3DS_C7 D3DPS_SRC_CONST(7)
|
||||
|
||||
// Iterated source parameters (0==Diffuse, 1==specular)
|
||||
#define D3DS_V0 D3DPS_SRC_INPUT(0)
|
||||
#define D3DS_V1 D3DPS_SRC_INPUT(1)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // D3DUTIL_H
|
||||
140
Library/dxx8/samples/Multimedia/Common/include/ddutil.h
Normal file
140
Library/dxx8/samples/Multimedia/Common/include/ddutil.h
Normal file
@@ -0,0 +1,140 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: ddutil.cpp
|
||||
//
|
||||
// Desc: Routines for loading bitmap and palettes from resources
|
||||
//
|
||||
// Copyright (C) 1998-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DDUTIL_H
|
||||
#define DDUTIL_H
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <d3d.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Classes defined in this header file
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDisplay;
|
||||
class CSurface;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Flags for the CDisplay and CSurface methods
|
||||
//-----------------------------------------------------------------------------
|
||||
#define DSURFACELOCK_READ
|
||||
#define DSURFACELOCK_WRITE
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CDisplay
|
||||
// Desc: Class to handle all DDraw aspects of a display, including creation of
|
||||
// front and back buffers, creating offscreen surfaces and palettes,
|
||||
// and blitting surface and displaying bitmaps.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDisplay
|
||||
{
|
||||
protected:
|
||||
LPDIRECTDRAW7 m_pDD;
|
||||
LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
|
||||
LPDIRECTDRAWSURFACE7 m_pddsBackBuffer;
|
||||
LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes
|
||||
|
||||
HWND m_hWnd;
|
||||
RECT m_rcWindow;
|
||||
BOOL m_bWindowed;
|
||||
BOOL m_bStereo;
|
||||
|
||||
public:
|
||||
CDisplay();
|
||||
~CDisplay();
|
||||
|
||||
// Access functions
|
||||
HWND GetHWnd() { return m_hWnd; }
|
||||
LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
|
||||
LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
|
||||
LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
|
||||
LPDIRECTDRAWSURFACE7 GetBackBufferLeft() { return m_pddsBackBufferLeft; }
|
||||
|
||||
// Status functions
|
||||
BOOL IsWindowed() { return m_bWindowed; }
|
||||
BOOL IsStereo() { return m_bStereo; }
|
||||
|
||||
// Creation/destruction methods
|
||||
HRESULT CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight,
|
||||
DWORD dwBPP );
|
||||
HRESULT CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight );
|
||||
HRESULT InitClipper();
|
||||
HRESULT UpdateBounds();
|
||||
virtual HRESULT DestroyObjects();
|
||||
|
||||
// Methods to create child objects
|
||||
HRESULT CreateSurface( CSurface** ppSurface, DWORD dwWidth,
|
||||
DWORD dwHeight );
|
||||
HRESULT CreateSurfaceFromBitmap( CSurface** ppSurface, TCHAR* strBMP,
|
||||
DWORD dwDesiredWidth,
|
||||
DWORD dwDesiredHeight );
|
||||
HRESULT CreateSurfaceFromText( CSurface** ppSurface, HFONT hFont,
|
||||
TCHAR* strText,
|
||||
COLORREF crBackground,
|
||||
COLORREF crForeground );
|
||||
HRESULT CreatePaletteFromBitmap( LPDIRECTDRAWPALETTE* ppPalette, const TCHAR* strBMP );
|
||||
|
||||
// Display methods
|
||||
HRESULT Clear( DWORD dwColor = 0L );
|
||||
HRESULT ColorKeyBlt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
|
||||
RECT* prc = NULL );
|
||||
HRESULT Blt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
|
||||
RECT* prc=NULL, DWORD dwFlags=0 );
|
||||
HRESULT Blt( DWORD x, DWORD y, CSurface* pSurface, RECT* prc = NULL );
|
||||
HRESULT ShowBitmap( HBITMAP hbm, LPDIRECTDRAWPALETTE pPalette=NULL );
|
||||
HRESULT SetPalette( LPDIRECTDRAWPALETTE pPalette );
|
||||
HRESULT Present();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CSurface
|
||||
// Desc: Class to handle aspects of a DirectDrawSurface.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSurface
|
||||
{
|
||||
LPDIRECTDRAWSURFACE7 m_pdds;
|
||||
DDSURFACEDESC2 m_ddsd;
|
||||
BOOL m_bColorKeyed;
|
||||
|
||||
public:
|
||||
LPDIRECTDRAWSURFACE7 GetDDrawSurface() { return m_pdds; }
|
||||
BOOL IsColorKeyed() { return m_bColorKeyed; }
|
||||
|
||||
HRESULT DrawBitmap( HBITMAP hBMP, DWORD dwBMPOriginX = 0, DWORD dwBMPOriginY = 0,
|
||||
DWORD dwBMPWidth = 0, DWORD dwBMPHeight = 0 );
|
||||
HRESULT DrawBitmap( TCHAR* strBMP, DWORD dwDesiredWidth, DWORD dwDesiredHeight );
|
||||
HRESULT DrawText( HFONT hFont, TCHAR* strText, DWORD dwOriginX, DWORD dwOriginY,
|
||||
COLORREF crBackground, COLORREF crForeground );
|
||||
|
||||
HRESULT SetColorKey( DWORD dwColorKey );
|
||||
DWORD ConvertGDIColor( COLORREF dwGDIColor );
|
||||
static HRESULT GetBitMaskInfo( DWORD dwBitMask, DWORD* pdwShift, DWORD* pdwBits );
|
||||
|
||||
HRESULT Create( LPDIRECTDRAW7 pDD, DDSURFACEDESC2* pddsd );
|
||||
HRESULT Create( LPDIRECTDRAWSURFACE7 pdds );
|
||||
HRESULT Destroy();
|
||||
|
||||
CSurface();
|
||||
~CSurface();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DDUTIL_H
|
||||
|
||||
866
Library/dxx8/samples/Multimedia/Common/include/didcfgview.h
Normal file
866
Library/dxx8/samples/Multimedia/Common/include/didcfgview.h
Normal file
@@ -0,0 +1,866 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: didcfgview.h
|
||||
//
|
||||
// Desc: Header file for DIDCfgView, a class that encapsulates a view of a
|
||||
// DirectInput device. The DIDCfgView class exists to make it easier
|
||||
// to make custom interfaces to view or configure action mappings for
|
||||
// input devices(instead of using IDirectInput8::ConfigureDevices).
|
||||
//
|
||||
// To use the DIDCfgView class, you initialize it for a particular
|
||||
// DirectInput device. You then set up state information for how the
|
||||
// image should be drawn: colors, fonts, and details for callouts(the
|
||||
// lines drawn from each axis/button to a label). Finally, you can
|
||||
// call RenderView, passing in a bitmap or HDC for DIDCfgView to draw
|
||||
// the image to.
|
||||
//
|
||||
// DIDCfgView is the only class in this file that you need to understand
|
||||
// or interface to. The other classes shown here are only used to
|
||||
// implement the DIDCfgView class.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __DIDCV_H__
|
||||
#define __DIDCV_H__
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
|
||||
|
||||
// invalid id, used for unique, signed identifiers
|
||||
#define DIDCV_INVALID_ID -1
|
||||
|
||||
// flags for callout states
|
||||
#define DIDCV_DRAWCALLOUT 0x1
|
||||
#define DIDCV_DRAWOVERLAY 0x2
|
||||
#define DIDCV_DRAWHIGHLIGHT 0x4
|
||||
#define DIDCV_DRAWEMPTYCALLOUT 0x8
|
||||
#define DIDCV_DRAWFULLNAME 0x10
|
||||
|
||||
// all flags set
|
||||
#define DIDCV_ALL_CALLOUT_STATE_SET 0xFFFFFFFF
|
||||
|
||||
// default dimensions
|
||||
#define DIDCV_MAX_IMAGE_WIDTH 512
|
||||
#define DIDCV_MAX_IMAGE_HEIGHT 512
|
||||
#define DIDCV_CUSTOM_VIEW_WIDTH 400
|
||||
#define DIDCV_CUSTOM_VIEW_HEIGHT 300
|
||||
|
||||
// DidcvCreateFont attribute flags
|
||||
#define DIDCV_FONT_BOLD 0x1
|
||||
#define DIDCV_FONT_ITALIC 0x2
|
||||
#define DIDCV_FONT_UNDERLINE 0x4
|
||||
#define DIDCV_FONT_STRIKEOUT 0x8
|
||||
|
||||
// default font point width
|
||||
#define DIDCV_DEFAULT_FONT_SIZE 90
|
||||
|
||||
// default size of callout array in DidcvCalloutManager
|
||||
#define DIDCV_DEFAULT_CALLOUT_MANAGER_ARRAY_SIZE 0
|
||||
|
||||
// default size of callout array in DidcvCalloutSet
|
||||
#define DIDCV_DEFAULT_CALLOUT_SET_ARRAY_SIZE 8
|
||||
|
||||
|
||||
|
||||
|
||||
// forward declarations
|
||||
class DidcvViewManager;
|
||||
class DidcvCalloutManager;
|
||||
class DidcvBitmap;
|
||||
class DidcvCallout;
|
||||
class DidcvCalloutSet;
|
||||
struct DIDCfgViewInfo;
|
||||
struct DidcvCalloutData;
|
||||
struct DidcvCalloutState;
|
||||
struct DidcvActionMap;
|
||||
struct DidcvCustomViewInfo;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DIDCfgView
|
||||
// Desc: main interface for retrieving and rendering device configuration views
|
||||
//
|
||||
// Init() - initializes the object for a particular DirectInputDevice
|
||||
// SetActionFormat() - sets the action mapping for the device
|
||||
// SetCalloutState() - specifies state for a given callout
|
||||
// SetAllCalloutState() - sets the state for all callouts
|
||||
// GetObjectIDByLocation() - gets object id at location of current view
|
||||
// SetCurrentView() - sets the current view to be rendered
|
||||
// RebuildViews() - collapses or expand the views for this device
|
||||
// RenderView() - renders device configuration view with image,
|
||||
// callout information, action mapping.
|
||||
//-----------------------------------------------------------------------------
|
||||
class DIDCfgView
|
||||
{
|
||||
public:
|
||||
DIDCfgView();
|
||||
~DIDCfgView();
|
||||
|
||||
public:
|
||||
// main device configuration view interface
|
||||
HRESULT Init( LPDIRECTINPUTDEVICE8 pDevice );
|
||||
HRESULT SetActionFormat( LPDIACTIONFORMAT pDiaf );
|
||||
HRESULT SetCalloutState( DWORD dwFlags, DWORD dwObjID );
|
||||
HRESULT SetAllCalloutState( DWORD dwFlags );
|
||||
HRESULT GetObjectIDByLocation( LPDWORD pdwObjID, LPPOINT pPt );
|
||||
HRESULT SetCurrentView( INT nView );
|
||||
HRESULT RebuildViews( BOOL bCompact );
|
||||
HRESULT RenderView( HBITMAP hBitmap, BOOL bIsDib );
|
||||
HRESULT RenderView( HDC hdc );
|
||||
|
||||
// rendering options
|
||||
HRESULT SetViewOrigin( const POINT* pPtOrg, POINT* pPtOldOrg );
|
||||
HRESULT CalcCenterOrgForCurrentView( const SIZE* pImgSize, POINT* pPtOrg, BOOL bSetOrigin = FALSE );
|
||||
VOID SetDefaultText( const TCHAR* pctszDefaultText, DWORD length );
|
||||
VOID SetColors( COLORREF crFore, COLORREF crBack, COLORREF crHighlight, COLORREF crHighlightLine );
|
||||
VOID GetColors( COLORREF* pCrFore, COLORREF* pCrBack, COLORREF* pCrHighlight, COLORREF* pCrHighlightLine );
|
||||
HRESULT SetFont( const TCHAR* pctszFontName, DWORD dwAttributes );
|
||||
HFONT GetFont();
|
||||
|
||||
// information access functios
|
||||
HRESULT GetInfo( DIDCfgViewInfo* pCfgViewInfo );
|
||||
HRESULT GetCurrentView( LPINT lpnView );
|
||||
HRESULT GetCalloutState( LPDWORD lpdwFlags, DWORD dwObjID );
|
||||
|
||||
protected:
|
||||
// protected helper functions
|
||||
VOID CleanUp();
|
||||
HRESULT InitAlloc();
|
||||
HRESULT InitImageInfoRetrieve( LPDIRECTINPUTDEVICE8 pDevice );
|
||||
HRESULT InitImageInfoProcess();
|
||||
VOID CalcSizes( const DIDEVICEIMAGEINFO* prgImageInfoArray, DWORD dwNumElements, const LPDWORD pNumViews, LPDWORD pNumCallouts, LPDWORD pNumDistinctObjID );
|
||||
HRESULT RenderView( HDC hdc, VOID* pBits, INT width, INT height );
|
||||
|
||||
HRESULT InitCustomViews( LPDIRECTINPUTDEVICE8 pDevice, BOOL bUseInternal = FALSE );
|
||||
HRESULT BuildCustomViews();
|
||||
VOID RenderFullname( HDC hdc, const TCHAR* pctszFullname, const RECT* pRect );
|
||||
BOOL CopyActionMap( LPDIACTIONFORMAT pDiaf );
|
||||
|
||||
protected:
|
||||
// data structures for managing views and callouts
|
||||
DidcvViewManager* m_lpViewManager;
|
||||
DidcvCalloutManager* m_lpCalloutManager;
|
||||
|
||||
// keeps track of whether this has been initialized
|
||||
BOOL m_bIsInit;
|
||||
// the index of the next view to render
|
||||
INT m_nView;
|
||||
// pointer to the DIDEVICEIMAGEINFOHEADER
|
||||
LPDIDEVICEIMAGEINFOHEADER m_lpDidImgHeader;
|
||||
// custom device view data
|
||||
DidcvCustomViewInfo* m_lpCustomViewInfo;
|
||||
|
||||
// device reference
|
||||
LPDIRECTINPUTDEVICE8 m_lpDIDevice;
|
||||
// action mapping copy
|
||||
LPDIACTIONFORMAT m_lpDiaf;
|
||||
// can this view be collapsed
|
||||
BOOL m_bCanBeCollapsed;
|
||||
// is this view compacted
|
||||
BOOL m_bIsCollapsed;
|
||||
|
||||
// rendering options
|
||||
COLORREF m_crFore;
|
||||
COLORREF m_crBack;
|
||||
COLORREF m_crHighlight;
|
||||
COLORREF m_crHighlightLine;
|
||||
POINT m_ptOrigin;
|
||||
HFONT m_hFont;
|
||||
TCHAR m_tszDefaultText [MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DIDCfgViewInfo
|
||||
// Desc: struct containing current information about DIDCfgView states
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DIDCfgViewInfo
|
||||
{
|
||||
BOOL bIsInit; // is the CfgView object initialized
|
||||
INT iCurrentViewID; // the ID of the current view
|
||||
INT iNumTotalViews; // total number of views
|
||||
DWORD dwNumUniqueCallouts; // number of unique
|
||||
BOOL bCanBeCollapsed; // can views for this CfgView object be compacted
|
||||
BOOL bIsCollapsed; // is the CfgView currently using collapsed views
|
||||
|
||||
|
||||
DIDCfgViewInfo()
|
||||
: bIsInit( FALSE ),
|
||||
iCurrentViewID( DIDCV_INVALID_ID ),
|
||||
iNumTotalViews( 0 ),
|
||||
dwNumUniqueCallouts( 0 ),
|
||||
bCanBeCollapsed( FALSE ),
|
||||
bIsCollapsed( FALSE )
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DidcvCustomViewInfo
|
||||
// Desc: object containing information about custom views
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DidcvCustomViewInfo
|
||||
{
|
||||
DWORD dwType; // type of the operation(count or save)
|
||||
DWORD dwCount; // the total count of items
|
||||
DWORD dwSize; // number of items actually in array
|
||||
LPDIDEVICEOBJECTINSTANCE* rgObjData; // array of control info
|
||||
|
||||
DidcvCustomViewInfo()
|
||||
: dwType( 0 ),
|
||||
dwCount( 0 ),
|
||||
dwSize( 0 ),
|
||||
rgObjData( NULL )
|
||||
{ }
|
||||
|
||||
~DidcvCustomViewInfo() { CleanUp(); }
|
||||
|
||||
VOID CleanUp();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvView
|
||||
// Desc: data structure for representing one view of a device
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvView
|
||||
{
|
||||
public:
|
||||
virtual ~DidcvView() { };
|
||||
|
||||
// DidcvView interface
|
||||
void SetOffset( INT nOffset );
|
||||
void SetID( INT nID );
|
||||
INT GetOffset() const;
|
||||
INT GetID() const;
|
||||
|
||||
// rendering
|
||||
virtual BOOL GetViewSize( SIZE* pSize ) const = 0;
|
||||
virtual void Render( HDC hdc, VOID* pBits, INT width, INT height, const POINT* pPtOrigin ) = 0;
|
||||
|
||||
protected:
|
||||
// constructor
|
||||
DidcvView();
|
||||
// the original offset in the array returned by DirectInputDevice8::GetImage
|
||||
INT m_nOffset;
|
||||
// the internally assigned unique identifier
|
||||
INT m_nID;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvBitmapView
|
||||
// Desc: subclass of DidcvView that renders a bitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvBitmapView : public DidcvView
|
||||
{
|
||||
public:
|
||||
~DidcvBitmapView();
|
||||
|
||||
// interface
|
||||
virtual BOOL GetViewSize( SIZE* pSize ) const;
|
||||
virtual void Render( HDC hdc, VOID* pBits, INT width, INT height, const POINT* pPtOrigin );
|
||||
|
||||
public:
|
||||
// function to instantiate a DidcvBitmapView
|
||||
static DidcvBitmapView* Create( LPCTSTR ptszImagePath, DWORD dwFlags );
|
||||
|
||||
private:
|
||||
// constructor
|
||||
DidcvBitmapView();
|
||||
|
||||
protected:
|
||||
// bitmap of the view
|
||||
DidcvBitmap* m_lpBitmap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvCustomView
|
||||
// Desc: subclass of DidcvView that renders a view from custom data
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvCustomView : public DidcvView
|
||||
{
|
||||
public:
|
||||
~DidcvCustomView() { }
|
||||
|
||||
// interface
|
||||
virtual BOOL GetViewSize( SIZE* pSize ) const;
|
||||
virtual void Render( HDC hdc, VOID* pBits, INT width, INT height, const POINT* pPtOrigin );
|
||||
|
||||
public:
|
||||
// static function to instantiate a DidcvCustomView
|
||||
static DidcvCustomView* Create( const DidcvCustomViewInfo* pInfo, DWORD dwStartIndex, DWORD* pFinishIndex );
|
||||
static BOOL CalcImageInfo( DWORD index, LPRECT rcOverlay, LPDWORD pNumPoints, LPPOINT rgptCalloutLine, LPRECT rcCalloutRect );
|
||||
static DWORD CalcNumViews( DWORD dwCount );
|
||||
|
||||
private:
|
||||
// constructor
|
||||
DidcvCustomView( const DidcvCustomViewInfo* pInfo, DWORD dwStartIndex, DWORD dwEndIndex );
|
||||
|
||||
protected:
|
||||
// returns coordinates for a given index
|
||||
void CalcCoordinates( DWORD dwIndex, LPRECT lpRect );
|
||||
|
||||
// custom data from which to render the view
|
||||
const DidcvCustomViewInfo* m_lpCustomViewInfoRef;
|
||||
DWORD m_dwStartIndex;
|
||||
DWORD m_dwEndIndex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvViewManager
|
||||
// Desc: stores and manages all the views for particular device
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvViewManager
|
||||
{
|
||||
public:
|
||||
DidcvViewManager();
|
||||
~DidcvViewManager();
|
||||
|
||||
// interface
|
||||
BOOL SetCapacity( UINT uCapacity, BOOL bDeleteContent = TRUE );
|
||||
BOOL AddImage( DidcvView* pView, INT nOffset = DIDCV_INVALID_ID );
|
||||
DidcvView* GetImage( INT nID );
|
||||
DidcvView* GetImageByOffset( INT nOffset );
|
||||
UINT GetNumViews() const;
|
||||
void CleanUp();
|
||||
|
||||
protected:
|
||||
// table holding references to views, indexed by the internal unique identifier
|
||||
DidcvView ** m_ppViewTable;
|
||||
UINT m_capacity;
|
||||
UINT m_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvCallout
|
||||
// Desc: data structure for representing one callout on a particular view
|
||||
// A callout is the line drawn from each axis/button to a label
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvCallout
|
||||
{
|
||||
public:
|
||||
~DidcvCallout();
|
||||
|
||||
// accessor functions to information retrieved from DirectInput
|
||||
DWORD GetObjID() const;
|
||||
const RECT & GetOverlayRect() const;
|
||||
const RECT & GetCalloutRect() const;
|
||||
const POINT* GetCalloutLine( DWORD* lpNumPts ) const;
|
||||
DWORD GetTextAlign() const;
|
||||
DWORD GetOverlayOffset() const;
|
||||
|
||||
// accessor functions to internal data
|
||||
void SetAssociatedViewID( INT nViewRef );
|
||||
INT GetAssociatedViewID() const;
|
||||
void SetDataRef( const DidcvCalloutData* lpData );
|
||||
const DidcvCalloutData* GetDataRef() const;
|
||||
|
||||
// hit test for a given point
|
||||
DWORD HitTest( LPPOINT lpPt ) const;
|
||||
|
||||
// draw the overlay
|
||||
DWORD DrawOverlay( HDC hDC, VOID* lpBits, INT width, INT height, const POINT* pptOrigin );
|
||||
|
||||
public:
|
||||
// static functions to instantiate a callout object
|
||||
static DidcvCallout* Create( LPDIDEVICEIMAGEINFO devImgInfo );
|
||||
|
||||
private:
|
||||
// private constructor
|
||||
DidcvCallout();
|
||||
|
||||
protected:
|
||||
// copy of device information
|
||||
DIDEVICEIMAGEINFO m_devImgInfo;
|
||||
// the view that this particular callout is associated with
|
||||
INT m_nViewRef;
|
||||
// pointer to callout state/data
|
||||
const DidcvCalloutData* m_lpDataRef;
|
||||
// the bitmap of the overlay
|
||||
DidcvBitmap* m_lpOverlayBitmap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// default array size
|
||||
#define GW_ARRAY_DEFAULT_SIZE 4
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class GwArray
|
||||
// Desc: templated c-style array class for PRIMITIVE data types only
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class Item>
|
||||
class GwArray
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
GwArray() { this->Alloc( GW_ARRAY_DEFAULT_SIZE ); m_size = 0; }
|
||||
GwArray( UINT initCap ) { this->Alloc( initCap ); m_size = 0; }
|
||||
~GwArray() { this->DeAlloc(); m_size = 0; }
|
||||
|
||||
public:
|
||||
void SetSize( UINT newCap )
|
||||
{
|
||||
if( newCap == m_capacity )
|
||||
return;
|
||||
|
||||
m_size =( newCap < m_size ? newCap : m_size );
|
||||
|
||||
UINT old_cap = m_capacity;
|
||||
UINT numoverlap =( newCap > m_capacity ? m_capacity : newCap );
|
||||
|
||||
Item* oldList = m_list;
|
||||
this->Alloc( newCap );
|
||||
|
||||
if( oldList )
|
||||
{
|
||||
memcpy( m_list, oldList, sizeof( Item )* numoverlap );
|
||||
|
||||
// free( oldList );
|
||||
delete [] oldList;
|
||||
}
|
||||
}
|
||||
|
||||
Item & operator[]( UINT index )
|
||||
{
|
||||
if( index >= m_capacity )
|
||||
assert( index >= 0 && index < m_capacity );
|
||||
|
||||
return m_list[index];
|
||||
}
|
||||
|
||||
const Item & operator[]( UINT index ) const
|
||||
{
|
||||
if( index >= m_capacity )
|
||||
assert( index >= 0 && index < m_capacity );
|
||||
|
||||
return m_list[index];
|
||||
}
|
||||
|
||||
void PushBack( const Item & item )
|
||||
{
|
||||
if( m_capacity == 0 )
|
||||
SetSize( 2 );
|
||||
else if( m_size >= m_capacity )
|
||||
SetSize( m_capacity* 2 );
|
||||
|
||||
m_list[m_size] = item;
|
||||
m_size++;
|
||||
}
|
||||
|
||||
void Resize( UINT newCap ) { SetSize( newCap ); }
|
||||
void PopBack() { if( m_size ) m_size--; }
|
||||
void Clear() { m_size = 0; }
|
||||
void Trim() { Resize( m_size ); }
|
||||
UINT Capacity() const { return m_capacity; }
|
||||
UINT Size() const { return m_size; }
|
||||
|
||||
protected:
|
||||
inline void Alloc( UINT cap )
|
||||
{
|
||||
if( cap == 0 )
|
||||
m_list = NULL;
|
||||
else
|
||||
{
|
||||
m_list = new Item[cap];
|
||||
assert( m_list );
|
||||
memset( m_list, 0, sizeof( Item )* cap );
|
||||
}
|
||||
|
||||
m_capacity = cap;
|
||||
}
|
||||
|
||||
inline void DeAlloc()
|
||||
{
|
||||
if( m_list != NULL )
|
||||
{
|
||||
//free( m_list );
|
||||
delete [] m_list;
|
||||
m_list = NULL;
|
||||
}
|
||||
|
||||
m_capacity = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
// array
|
||||
Item* m_list;
|
||||
// number of entries the array can hold
|
||||
UINT m_capacity;
|
||||
// number of entries added using PushBack() minus # removed using PopBack()
|
||||
UINT m_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvCalloutApplicant
|
||||
// Desc: abstract base class for processing DidcvCallout
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvCalloutApplicant
|
||||
{
|
||||
public:
|
||||
virtual ~DidcvCalloutApplicant() { }
|
||||
virtual BOOL Apply( DidcvCallout* pCallout ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvCalloutSet
|
||||
// Desc: a group of DidcvCallout references
|
||||
// A callout is the line drawn from each axis/button to a label
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvCalloutSet
|
||||
{
|
||||
public:
|
||||
DidcvCalloutSet();
|
||||
~DidcvCalloutSet();
|
||||
|
||||
public:
|
||||
BOOL AddCallout( DidcvCallout* pCallout );
|
||||
void Apply( DidcvCalloutApplicant* pCalloutApp );
|
||||
void SetIdentifier( DWORD dwID );
|
||||
DWORD GetIdentifier() const;
|
||||
void SetData( void* pData );
|
||||
void* GetData() const;
|
||||
|
||||
const GwArray <DidcvCallout*> & GetInternalArrayRef() const;
|
||||
void TrimArrays();
|
||||
|
||||
protected:
|
||||
void CleanUp();
|
||||
|
||||
protected:
|
||||
GwArray <DidcvCallout*> m_calloutList;
|
||||
DWORD m_dwSetID;
|
||||
void* m_lpData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvCalloutManager
|
||||
// Desc: data structure for storing and managing callouts
|
||||
// A callout is the line drawn from each axis/button to a label
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvCalloutManager
|
||||
{
|
||||
public:
|
||||
DidcvCalloutManager();
|
||||
~DidcvCalloutManager();
|
||||
|
||||
// main interface
|
||||
BOOL AddCallout( DidcvCallout* pCallout, INT nView );
|
||||
BOOL SetCalloutState( const DidcvCalloutState* pCalloutState, DWORD dwObjID );
|
||||
BOOL SetAllCalloutState( const DidcvCalloutState* pCalloutState );
|
||||
BOOL SetActionMap( const LPDIACTION pAction, DWORD dwObjID );
|
||||
void ClearAllActionMaps();
|
||||
|
||||
// information
|
||||
DWORD GetObjectIDByLocation( const LPPOINT pPt, INT nView );
|
||||
BOOL GetCalloutState( DidcvCalloutState* pCalloutState, DWORD dwObjID );
|
||||
BOOL GetActionMap( DidcvActionMap* pActionMap, DWORD dwObjID );
|
||||
const DidcvCalloutSet* GetCalloutSetByView( INT nView ) const;
|
||||
const DidcvCalloutSet* GetCalloutSetByObjID( DWORD dwObjID ) const;
|
||||
const DidcvCalloutData* GetCalloutDataRef( DWORD dwObjID ) const;
|
||||
UINT GetNumUniqueCallouts() const;
|
||||
|
||||
BOOL EnumObjects( LPDIRECTINPUTDEVICE8 pDevice, LPDIENUMDEVICEOBJECTSCALLBACK pCallback, LPVOID pvRef, DWORD dwMapOnly );
|
||||
BOOL CalcCanBeCollapsed();
|
||||
|
||||
// allocation
|
||||
BOOL SetCapacity( DWORD dwNumCallouts, DWORD dwNumUniqueObjID, DWORD dwNumViews, BOOL bDeleteContent = TRUE );
|
||||
void TrimArrays();
|
||||
void CleanUp();
|
||||
|
||||
protected:
|
||||
// helper functions
|
||||
DidcvCalloutSet* Find( const GwArray <DidcvCalloutSet*> & array, DWORD dwIdentifier ) const;
|
||||
DidcvCalloutData* GetCalloutData( DWORD dwObjID ) const;
|
||||
|
||||
protected:
|
||||
// list of all callouts added
|
||||
GwArray <DidcvCallout*> m_calloutList;
|
||||
// list of callout sets, one for each unique callout id
|
||||
GwArray <DidcvCalloutSet*> m_calloutSetListByObjID;
|
||||
// list of callout sets, one for each view
|
||||
GwArray <DidcvCalloutSet*> m_calloutSetListByView;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DidcvCalloutData
|
||||
// Desc: data structure holding references to callout data components
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DidcvCalloutData
|
||||
{
|
||||
DidcvCalloutState* lpState; // callout state info
|
||||
DidcvActionMap* lpActionMap; // action mapped this callout
|
||||
|
||||
DidcvCalloutData( DidcvCalloutState* s, DidcvActionMap* a )
|
||||
: lpState( s ), lpActionMap( a )
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DidcvCalloutState
|
||||
// Desc: state information for a callout
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DidcvCalloutState
|
||||
{
|
||||
// whether to draw
|
||||
BOOL bDrawCallout;
|
||||
BOOL bDrawOverlay;
|
||||
BOOL bDrawHighlight;
|
||||
BOOL bDrawEmptyCallout;
|
||||
BOOL bDrawFullname;
|
||||
|
||||
// specifies which state is valid
|
||||
DWORD dwFlags;
|
||||
|
||||
// --- member functions ---
|
||||
DidcvCalloutState( DWORD f = 0, BOOL c = FALSE, BOOL o = FALSE,
|
||||
BOOL h = FALSE, BOOL e = FALSE, BOOL d = FALSE )
|
||||
: dwFlags( f ), bDrawCallout( c ), bDrawOverlay( o ), bDrawHighlight( h ),
|
||||
bDrawEmptyCallout( e ), bDrawFullname( d )
|
||||
{ }
|
||||
|
||||
void SmartSet( const DidcvCalloutState* other );
|
||||
void Copy( const DidcvCalloutState* other ) { *this = *other; }
|
||||
DWORD MakeFlag() const;
|
||||
void SetFlag( DWORD dwExtFlags );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DidcvActionMap
|
||||
// Desc: action mapping information for a callout
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DidcvActionMap
|
||||
{
|
||||
DIACTION dia;
|
||||
|
||||
DidcvActionMap() { ZeroMemory( &dia, sizeof( DIACTION ) ); }
|
||||
void Copy( const DidcvActionMap* other ) { this->dia = other->dia; }
|
||||
|
||||
LPCSTR GetActionName() const { return dia.lptszActionName; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// utility functions
|
||||
void DidcvPolyLineArrow( HDC hDC, const POINT* rgpt, INT nPoints, BOOL bDoShadow = FALSE );
|
||||
HFONT DidcvCreateFont( HDC hdc, const TCHAR* szFaceName, int iDeciPtHeight, int iDeciPtWidth, int iAttributes, BOOL fLogRes);
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct rgref
|
||||
// Desc: templated lightweight c-style array
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T>
|
||||
struct rgref {
|
||||
rgref( T* p ) : pt( p ) {}
|
||||
|
||||
T & operator []( int i ) { return pt[i]; }
|
||||
const T & operator []( int i ) const { return pt[i]; }
|
||||
|
||||
private:
|
||||
T *pt;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct SPOINT
|
||||
// Desc: used by line drawing routine
|
||||
//-----------------------------------------------------------------------------
|
||||
struct SPOINT {
|
||||
SPOINT()
|
||||
#define SPOINT_INITIALIZERS \
|
||||
p( u.p ), \
|
||||
s( u.s ), \
|
||||
a((( int* )( void* ) u.a ) ), \
|
||||
x( u.p.x ), \
|
||||
y( u.p.y ), \
|
||||
cx( u.s.cx ), \
|
||||
cy( u.s.cy )
|
||||
: SPOINT_INITIALIZERS
|
||||
{ x = y = 0; }
|
||||
|
||||
SPOINT( int, POINT *r )
|
||||
: p( *r ),
|
||||
s( *(( SIZE* )( void* ) r ) ),
|
||||
a((( int* )( void* ) r ) ),
|
||||
x( r->x ),
|
||||
y( r->y ),
|
||||
cx( r->x ),
|
||||
cy( r->y )
|
||||
{ }
|
||||
|
||||
SPOINT( const SPOINT & sp )
|
||||
: SPOINT_INITIALIZERS
|
||||
{ p = sp.p; }
|
||||
|
||||
SPOINT( int b, int c )
|
||||
: SPOINT_INITIALIZERS
|
||||
{ x = b; y = c; }
|
||||
|
||||
SPOINT( const POINT &point )
|
||||
: SPOINT_INITIALIZERS
|
||||
{ p = point; }
|
||||
|
||||
SPOINT( const SIZE &size )
|
||||
: SPOINT_INITIALIZERS
|
||||
{ s = size; }
|
||||
|
||||
#undef SPOINT_INITIALIZERS
|
||||
|
||||
SPOINT operator =( const SPOINT &sp ) { p = sp.p; return *this; }
|
||||
SPOINT operator =( const POINT &_p ) { p = _p; return *this; }
|
||||
SPOINT operator =( const SIZE &_s ) { s = _s; return *this; }
|
||||
|
||||
operator POINT() const { return p; }
|
||||
operator SIZE() const { return s; }
|
||||
|
||||
long &x, &y, &cx, &cy;
|
||||
POINT &p;
|
||||
SIZE &s;
|
||||
rgref<int> a;
|
||||
|
||||
private:
|
||||
union {
|
||||
POINT p;
|
||||
SIZE s;
|
||||
int a[2];
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvBitmap
|
||||
// Desc: object containing a bitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvBitmap
|
||||
{
|
||||
public:
|
||||
~DidcvBitmap();
|
||||
|
||||
// drawing interface
|
||||
BOOL Draw( HDC hDC, INT xStart, INT yStart);
|
||||
BOOL Blend( HDC hDC, INT xStart, INT yStart );
|
||||
BOOL Blend( VOID* lpBits, INT xStart, INT yStart, INT width, INT height );
|
||||
|
||||
// information
|
||||
BOOL GetSize( SIZE* lpSize ) const;
|
||||
HBITMAP GetHandle();
|
||||
LPVOID GetBits();
|
||||
|
||||
public:
|
||||
// static function for instantiating a DidcvBitmap
|
||||
static DidcvBitmap* Create( LPCTSTR tszFilename );
|
||||
static DidcvBitmap* Create( INT width, INT height );
|
||||
|
||||
private:
|
||||
// private constructor
|
||||
DidcvBitmap();
|
||||
|
||||
protected:
|
||||
// helper functions
|
||||
void CleanUp();
|
||||
void FigureSize();
|
||||
|
||||
static DidcvBitmap* CreateViaD3dx( LPCTSTR tszFilename );
|
||||
static DidcvBitmap* CreateViaLoadImage( HINSTANCE hinst, LPCTSTR tszName,
|
||||
UINT uType, int cx, int cy, UINT fuLoad );
|
||||
|
||||
protected:
|
||||
// GDI handle to bitmap
|
||||
HBITMAP m_hbitmap;
|
||||
VOID* m_lpBits;
|
||||
SIZE m_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// alpha blending information
|
||||
#define DIDCV_ALPHABLEND_DLL_NAME TEXT( "MSIMG32.DLL" )
|
||||
#define DIDCV_ALPHABLEND_PROC_NAME TEXT( "AlphaBlend" )
|
||||
|
||||
#if( WINVER >= 0x400 )
|
||||
typedef WINGDIAPI BOOL( WINAPI* DIDCV_ALPHABLEND )( HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION );
|
||||
#else
|
||||
typedef DIDCV_ALPHABLEND DWORD
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class DidcvAlphaBlend
|
||||
// Desc: utility class for alpha blending
|
||||
//-----------------------------------------------------------------------------
|
||||
class DidcvAlphaBlend
|
||||
{
|
||||
public:
|
||||
// reference counting interface
|
||||
static BOOL AddClient();
|
||||
static BOOL ReleaseClient();
|
||||
|
||||
// functions to perform blending
|
||||
static BOOL Blend( HDC hDC, INT xStart, INT yStart, INT width, INT height, HBITMAP hbitmap, const SIZE* lpSize );
|
||||
static BOOL Blend( VOID* lpDestBits, INT xStart, INT yStart, INT destWidth, INT destHeight, VOID* lpSrcBits, INT srcWidth, INT srcHeight );
|
||||
|
||||
protected:
|
||||
static DIDCV_ALPHABLEND s_alphaBlendProc;
|
||||
static HMODULE s_hDll;
|
||||
static DWORD s_dwNumClients;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // #ifndef __DIDCV_H__
|
||||
62
Library/dxx8/samples/Multimedia/Common/include/diutil.h
Normal file
62
Library/dxx8/samples/Multimedia/Common/include/diutil.h
Normal file
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DIUtil.h
|
||||
//
|
||||
// Desc: DirectInput support using action mapping
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DIUTIL_H
|
||||
#define DIUTIL_H
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CInputDeviceManager
|
||||
// Desc: Input device manager using DX8 action mapping
|
||||
//-----------------------------------------------------------------------------
|
||||
class CInputDeviceManager
|
||||
{
|
||||
public:
|
||||
struct DeviceInfo
|
||||
{
|
||||
LPDIRECTINPUTDEVICE8 pdidDevice;
|
||||
LPVOID pParam;
|
||||
};
|
||||
|
||||
typedef HRESULT (CALLBACK *LPDIMANAGERCALLBACK)(CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID);
|
||||
|
||||
private:
|
||||
BOOL m_bCleanupCOM;
|
||||
HWND m_hWnd;
|
||||
TCHAR* m_strUserName;
|
||||
|
||||
LPDIRECTINPUT8 m_pDI;
|
||||
DeviceInfo* m_pDevices;
|
||||
DWORD m_dwMaxDevices;
|
||||
DWORD m_dwNumDevices;
|
||||
DIACTIONFORMAT m_diaf;
|
||||
|
||||
LPDIMANAGERCALLBACK m_AddDeviceCallback;
|
||||
LPVOID m_AddDeviceCallbackParam;
|
||||
|
||||
public:
|
||||
// Device control
|
||||
HRESULT AddDevice( const DIDEVICEINSTANCE* pdidi, LPDIRECTINPUTDEVICE8 pdidDevice );
|
||||
HRESULT GetDevices( DeviceInfo** ppDeviceInfo, DWORD* pdwNumDevices );
|
||||
HRESULT ConfigureDevices( HWND hWnd, IUnknown* pSurface, VOID* pCallback, DWORD dwFlags, LPVOID pvCBParam );
|
||||
VOID UnacquireDevices();
|
||||
VOID SetFocus( HWND hWnd );
|
||||
|
||||
// Construction
|
||||
HRESULT SetActionFormat( DIACTIONFORMAT& diaf, BOOL bReenumerate );
|
||||
HRESULT Create( HWND hWnd, TCHAR* strUserName, DIACTIONFORMAT& diaf, LPDIMANAGERCALLBACK AddDeviceCallback, LPVOID pCallbackParam );
|
||||
|
||||
CInputDeviceManager();
|
||||
~CInputDeviceManager();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
126
Library/dxx8/samples/Multimedia/Common/include/dmutil.h
Normal file
126
Library/dxx8/samples/Multimedia/Common/include/dmutil.h
Normal file
@@ -0,0 +1,126 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DMUtil.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DMUTIL_H
|
||||
#define DMUTIL_H
|
||||
|
||||
#include <dmusicc.h>
|
||||
#include <dmusici.h>
|
||||
#include <dsound.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Classes used by this header
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMusicManager;
|
||||
class CMusicSegment;
|
||||
class CMusicScript;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMusicManager
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMusicManager
|
||||
{
|
||||
protected:
|
||||
BOOL m_bCleanupCOM;
|
||||
IDirectMusicLoader8* m_pLoader;
|
||||
IDirectMusicPerformance8* m_pPerformance;
|
||||
|
||||
public:
|
||||
CMusicManager();
|
||||
~CMusicManager();
|
||||
|
||||
inline IDirectMusicLoader8* GetLoader() { return m_pLoader; }
|
||||
inline IDirectMusicPerformance8* GetPerformance() { return m_pPerformance; }
|
||||
IDirectMusicAudioPath8* GetDefaultAudioPath();
|
||||
|
||||
HRESULT Initialize( HWND hWnd, DWORD dwPChannels = 128, DWORD dwDefaultPathType = DMUS_APATH_DYNAMIC_STEREO );
|
||||
|
||||
HRESULT SetSearchDirectory( const TCHAR* strMediaPath );
|
||||
VOID CollectGarbage();
|
||||
|
||||
HRESULT CreateSegmentFromFile( CMusicSegment** ppSegment, TCHAR* strFileName,
|
||||
BOOL bDownloadNow = TRUE, BOOL bIsMidiFile = FALSE );
|
||||
HRESULT CreateScriptFromFile( CMusicScript** ppScript, TCHAR* strFileName );
|
||||
|
||||
HRESULT CreateChordMapFromFile( IDirectMusicChordMap8** ppChordMap, TCHAR* strFileName );
|
||||
HRESULT CreateStyleFromFile( IDirectMusicStyle8** ppStyle, TCHAR* strFileName );
|
||||
HRESULT GetMotifFromStyle( IDirectMusicSegment8** ppMotif, TCHAR* strStyle, TCHAR* wstrMotif );
|
||||
|
||||
HRESULT CreateSegmentFromResource( CMusicSegment** ppSegment, TCHAR* strResource, TCHAR* strResourceType,
|
||||
BOOL bDownloadNow = TRUE, BOOL bIsMidiFile = FALSE );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMusicSegment
|
||||
// Desc: Encapsulates functionality of an IDirectMusicSegment
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMusicSegment
|
||||
{
|
||||
protected:
|
||||
IDirectMusicSegment8* m_pSegment;
|
||||
IDirectMusicLoader8* m_pLoader;
|
||||
IDirectMusicPerformance8* m_pPerformance;
|
||||
IDirectMusicAudioPath8* m_pEmbeddedAudioPath;
|
||||
BOOL m_bDownloaded;
|
||||
|
||||
public:
|
||||
CMusicSegment( IDirectMusicPerformance8* pPerformance,
|
||||
IDirectMusicLoader8* pLoader,
|
||||
IDirectMusicSegment8* pSegment );
|
||||
virtual ~CMusicSegment();
|
||||
|
||||
inline IDirectMusicSegment8* GetSegment() { return m_pSegment; }
|
||||
HRESULT GetStyle( IDirectMusicStyle8** ppStyle, DWORD dwStyleIndex = 0 );
|
||||
|
||||
HRESULT SetRepeats( DWORD dwRepeats );
|
||||
HRESULT Play( DWORD dwFlags = DMUS_SEGF_SECONDARY, IDirectMusicAudioPath8* pAudioPath = NULL );
|
||||
HRESULT Stop( DWORD dwFlags = 0 );
|
||||
HRESULT Download( IDirectMusicAudioPath8* pAudioPath = NULL );
|
||||
HRESULT Unload( IDirectMusicAudioPath8* pAudioPath = NULL );
|
||||
|
||||
BOOL IsPlaying();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMusicScript
|
||||
// Desc: Encapsulates functionality of an IDirectMusicScript
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMusicScript
|
||||
{
|
||||
protected:
|
||||
IDirectMusicScript8* m_pScript;
|
||||
IDirectMusicLoader8* m_pLoader;
|
||||
IDirectMusicPerformance8* m_pPerformance;
|
||||
|
||||
public:
|
||||
CMusicScript( IDirectMusicPerformance8* pPerformance,
|
||||
IDirectMusicLoader8* pLoader,
|
||||
IDirectMusicScript8* pScript );
|
||||
virtual ~CMusicScript();
|
||||
|
||||
inline IDirectMusicScript8* GetScript() { return m_pScript; }
|
||||
|
||||
HRESULT CallRoutine( TCHAR* strRoutine );
|
||||
HRESULT SetVariableNumber( TCHAR* strVariable, LONG lValue );
|
||||
HRESULT GetVariableNumber( TCHAR* strVariable, LONG* plValue );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DMUTIL_H
|
||||
171
Library/dxx8/samples/Multimedia/Common/include/dsutil.h
Normal file
171
Library/dxx8/samples/Multimedia/Common/include/dsutil.h
Normal file
@@ -0,0 +1,171 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DSUtil.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DSUTIL_H
|
||||
#define DSUTIL_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <mmreg.h>
|
||||
#include <dsound.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Classes used by this header
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSoundManager;
|
||||
class CSound;
|
||||
class CStreamingSound;
|
||||
class CWaveFile;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Typing macros
|
||||
//-----------------------------------------------------------------------------
|
||||
#define WAVEFILE_READ 1
|
||||
#define WAVEFILE_WRITE 2
|
||||
|
||||
#define DSUtil_StopSound(s) { if(s) s->Stop(); }
|
||||
#define DSUtil_PlaySound(s) { if(s) s->Play( 0, 0 ); }
|
||||
#define DSUtil_PlaySoundLooping(s) { if(s) s->Play( 0, DSBPLAY_LOOPING ); }
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CSoundManager
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSoundManager
|
||||
{
|
||||
protected:
|
||||
LPDIRECTSOUND8 m_pDS;
|
||||
|
||||
public:
|
||||
CSoundManager();
|
||||
~CSoundManager();
|
||||
|
||||
HRESULT Initialize( HWND hWnd, DWORD dwCoopLevel, DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate );
|
||||
inline LPDIRECTSOUND8 GetDirectSound() { return m_pDS; }
|
||||
HRESULT SetPrimaryBufferFormat( DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate );
|
||||
HRESULT Get3DListenerInterface( LPDIRECTSOUND3DLISTENER* ppDSListener );
|
||||
|
||||
HRESULT Create( CSound** ppSound, LPTSTR strWaveFileName, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 );
|
||||
HRESULT CreateFromMemory( CSound** ppSound, BYTE* pbData, ULONG ulDataSize, LPWAVEFORMATEX pwfx, DWORD dwCreationFlags = 0, GUID guid3DAlgorithm = GUID_NULL, DWORD dwNumBuffers = 1 );
|
||||
HRESULT CreateStreaming( CStreamingSound** ppStreamingSound, LPTSTR strWaveFileName, DWORD dwCreationFlags, GUID guid3DAlgorithm, DWORD dwNotifyCount, DWORD dwNotifySize, HANDLE hNotifyEvent );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CSound
|
||||
// Desc: Encapsulates functionality of a DirectSound buffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSound
|
||||
{
|
||||
protected:
|
||||
LPDIRECTSOUNDBUFFER* m_apDSBuffer;
|
||||
DWORD m_dwDSBufferSize;
|
||||
CWaveFile* m_pWaveFile;
|
||||
DWORD m_dwNumBuffers;
|
||||
|
||||
HRESULT RestoreBuffer( LPDIRECTSOUNDBUFFER pDSB, BOOL* pbWasRestored );
|
||||
|
||||
public:
|
||||
CSound( LPDIRECTSOUNDBUFFER* apDSBuffer, DWORD dwDSBufferSize, DWORD dwNumBuffers, CWaveFile* pWaveFile );
|
||||
virtual ~CSound();
|
||||
|
||||
HRESULT Get3DBufferInterface( DWORD dwIndex, LPDIRECTSOUND3DBUFFER* ppDS3DBuffer );
|
||||
HRESULT FillBufferWithSound( LPDIRECTSOUNDBUFFER pDSB, BOOL bRepeatWavIfBufferLarger );
|
||||
LPDIRECTSOUNDBUFFER GetFreeBuffer();
|
||||
LPDIRECTSOUNDBUFFER GetBuffer( DWORD dwIndex );
|
||||
|
||||
HRESULT Play( DWORD dwPriority = 0, DWORD dwFlags = 0 );
|
||||
HRESULT Stop();
|
||||
HRESULT Reset();
|
||||
BOOL IsSoundPlaying();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CStreamingSound
|
||||
// Desc: Encapsulates functionality to play a wave file with DirectSound.
|
||||
// The Create() method loads a chunk of wave file into the buffer,
|
||||
// and as sound plays more is written to the buffer by calling
|
||||
// HandleWaveStreamNotification() whenever hNotifyEvent is signaled.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CStreamingSound : public CSound
|
||||
{
|
||||
protected:
|
||||
DWORD m_dwLastPlayPos;
|
||||
DWORD m_dwPlayProgress;
|
||||
DWORD m_dwNotifySize;
|
||||
DWORD m_dwNextWriteOffset;
|
||||
BOOL m_bFillNextNotificationWithSilence;
|
||||
|
||||
public:
|
||||
CStreamingSound( LPDIRECTSOUNDBUFFER pDSBuffer, DWORD dwDSBufferSize, CWaveFile* pWaveFile, DWORD dwNotifySize );
|
||||
~CStreamingSound();
|
||||
|
||||
HRESULT HandleWaveStreamNotification( BOOL bLoopedPlay );
|
||||
HRESULT Reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CWaveFile
|
||||
// Desc: Encapsulates reading or writing sound data to or from a wave file
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWaveFile
|
||||
{
|
||||
public:
|
||||
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
|
||||
HMMIO m_hmmio; // MM I/O handle for the WAVE
|
||||
MMCKINFO m_ck; // Multimedia RIFF chunk
|
||||
MMCKINFO m_ckRiff; // Use in opening a WAVE file
|
||||
DWORD m_dwSize; // The size of the wave file
|
||||
MMIOINFO m_mmioinfoOut;
|
||||
DWORD m_dwFlags;
|
||||
BOOL m_bIsReadingFromMemory;
|
||||
BYTE* m_pbData;
|
||||
BYTE* m_pbDataCur;
|
||||
ULONG m_ulDataSize;
|
||||
CHAR* m_pResourceBuffer;
|
||||
|
||||
protected:
|
||||
HRESULT ReadMMIO();
|
||||
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );
|
||||
|
||||
public:
|
||||
CWaveFile();
|
||||
~CWaveFile();
|
||||
|
||||
HRESULT Open( LPTSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
HRESULT Close();
|
||||
|
||||
HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
|
||||
HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );
|
||||
|
||||
DWORD GetSize();
|
||||
HRESULT ResetFile();
|
||||
WAVEFORMATEX* GetFormat() { return m_pwfx; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DSUTIL_H
|
||||
112
Library/dxx8/samples/Multimedia/Common/include/dxutil.h
Normal file
112
Library/dxx8/samples/Multimedia/Common/include/dxutil.h
Normal file
@@ -0,0 +1,112 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DXUtil.h
|
||||
//
|
||||
// Desc: Helper functions and typing shortcuts for DirectX programming.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DXUTIL_H
|
||||
#define DXUTIL_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Miscellaneous helper functions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DXUtil_GetDXSDKMediaPath() and DXUtil_FindMediaFile()
|
||||
// Desc: Returns the DirectX SDK path, as stored in the system registry
|
||||
// during the SDK install.
|
||||
//-----------------------------------------------------------------------------
|
||||
const TCHAR* DXUtil_GetDXSDKMediaPath();
|
||||
HRESULT DXUtil_FindMediaFile( TCHAR* strPath, TCHAR* strFilename );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
|
||||
// Desc: Helper functions to read/write a string registry key
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
|
||||
HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
|
||||
HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
|
||||
HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
|
||||
|
||||
HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
|
||||
HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
|
||||
HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
|
||||
HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DXUtil_Timer()
|
||||
// Desc: Performs timer opertations. Use the following commands:
|
||||
// TIMER_RESET - to reset the timer
|
||||
// TIMER_START - to start the timer
|
||||
// TIMER_STOP - to stop (or pause) the timer
|
||||
// TIMER_ADVANCE - to advance the timer by 0.1 seconds
|
||||
// TIMER_GETABSOLUTETIME - to get the absolute system time
|
||||
// TIMER_GETAPPTIME - to get the current time
|
||||
// TIMER_GETELAPSEDTIME - to get the time that elapsed between
|
||||
// TIMER_GETELAPSEDTIME calls
|
||||
//-----------------------------------------------------------------------------
|
||||
enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
|
||||
TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
|
||||
FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
|
||||
VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
|
||||
VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
|
||||
VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
|
||||
VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
|
||||
VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GUID to String converting
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DXUtil_ConvertGUIDToString( const GUID* pGuidIn, TCHAR* strOut );
|
||||
BOOL DXUtil_ConvertStringToGUID( const TCHAR* strIn, GUID* pGuidOut );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Debug printing support
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DXUtil_Trace( TCHAR* strMsg, ... );
|
||||
HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
|
||||
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#define DXTRACE DXUtil_Trace
|
||||
#else
|
||||
#define DXTRACE sizeof
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) | defined(_DEBUG)
|
||||
#define DEBUG_MSG(str) _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
|
||||
#else
|
||||
#define DEBUG_MSG(str) (0L)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DXUTIL_H
|
||||
102
Library/dxx8/samples/Multimedia/Common/include/netclient.h
Normal file
102
Library/dxx8/samples/Multimedia/Common/include/netclient.h
Normal file
@@ -0,0 +1,102 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: NetConnect.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef NETCLIENT_H
|
||||
#define NETCLIENT_H
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <dplay8.h>
|
||||
#include <dpaddr.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, structures, and error codes
|
||||
//-----------------------------------------------------------------------------
|
||||
#define DISPLAY_REFRESH_RATE 250
|
||||
#define TIMERID_DISPLAY_HOSTS 1
|
||||
#define TIMERID_CONNECT_COMPLETE 2
|
||||
|
||||
|
||||
#define NCW_S_FORWARD 0x01000001 // Dialog success, so go forward
|
||||
#define NCW_S_BACKUP 0x01000002 // Dialog canceled, show previous dialog
|
||||
#define NCW_S_QUIT 0x01000003 // Dialog quit, close app
|
||||
#define NCW_S_LOBBYCONNECT 0x01000004 // Dialog connected from lobby, connect success
|
||||
|
||||
|
||||
class CNetClientWizard
|
||||
{
|
||||
public:
|
||||
CNetClientWizard( HINSTANCE hInst, TCHAR* strAppName, GUID* pGuidApp );
|
||||
virtual ~CNetClientWizard();
|
||||
|
||||
HRESULT WINAPI MessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
|
||||
HRESULT WINAPI LobbyMessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
|
||||
|
||||
VOID Init( IDirectPlay8Client* pDPClient, IDirectPlay8LobbiedApplication* pLobbiedApp );
|
||||
HRESULT DoConnectWizard();
|
||||
HRESULT ConnectUsingLobbySettings();
|
||||
|
||||
void SetPlayerName( TCHAR* strPlayerName ) { _tcscpy( m_strLocalPlayerName, strPlayerName ); }
|
||||
TCHAR* GetPlayerName() { return m_strLocalPlayerName; }
|
||||
BOOL HaveConnectionSettingsFromLobby() { return m_bHaveConnectionSettingsFromLobby; }
|
||||
|
||||
protected:
|
||||
struct DPHostEnumInfo
|
||||
{
|
||||
DWORD dwRef;
|
||||
DPN_APPLICATION_DESC* pAppDesc;
|
||||
IDirectPlay8Address* pHostAddr;
|
||||
IDirectPlay8Address* pDeviceAddr;
|
||||
TCHAR szSession[MAX_PATH];
|
||||
DWORD dwLastPollTime;
|
||||
BOOL bValid;
|
||||
DPHostEnumInfo* pNext;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK StaticSessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
static INT_PTR CALLBACK StaticLobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK SessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK LobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
VOID SessionsDlgInitListbox( HWND hDlg );
|
||||
HRESULT SessionsDlgEnumHosts( HWND hDlg );
|
||||
HRESULT SessionsDlgNoteEnumResponse( PDPNMSG_ENUM_HOSTS_RESPONSE pEnumHostsResponse );
|
||||
VOID SessionsDlgExpireOldHostEnums();
|
||||
HRESULT SessionsDlgDisplayEnumList( HWND hDlg );
|
||||
HRESULT SessionsDlgJoinGame( HWND hDlg );
|
||||
HRESULT SessionsDlgCreateGame( HWND hDlg );
|
||||
VOID SessionsDlgEnumListCleanup();
|
||||
|
||||
IDirectPlay8Client* m_pDPClient;
|
||||
IDirectPlay8LobbiedApplication* m_pLobbiedApp;
|
||||
CRITICAL_SECTION m_csHostEnum;
|
||||
GUID m_guidApp;
|
||||
HRESULT m_hrDialog;
|
||||
HWND m_hDlg;
|
||||
HINSTANCE m_hInst;
|
||||
DPHostEnumInfo m_DPHostEnumHead;
|
||||
TCHAR m_strAppName[MAX_PATH];
|
||||
TCHAR m_strLocalPlayerName[MAX_PATH];
|
||||
BOOL m_bSearchingForSessions;
|
||||
BOOL m_bEnumListChanged;
|
||||
DPNHANDLE m_hEnumAsyncOp;
|
||||
DWORD m_dwEnumHostExpireInterval;
|
||||
BOOL m_bConnecting;
|
||||
DPNHANDLE m_hConnectAsyncOp;
|
||||
HANDLE m_hConnectCompleteEvent;
|
||||
HANDLE m_hLobbyConnectionEvent;
|
||||
HRESULT m_hrConnectComplete;
|
||||
BOOL m_bHaveConnectionSettingsFromLobby;
|
||||
DPNHANDLE m_hLobbyClient;
|
||||
};
|
||||
|
||||
|
||||
#endif // NETCLIENT_H
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#define IDD_CLIENT_CONNECT 12001
|
||||
#define IDC_PLAYER_NAME_EDIT 12100
|
||||
#define IDC_GAMES_LIST 12101
|
||||
#define IDC_JOIN 12102
|
||||
#define IDC_IP_ADDRESS 12103
|
||||
#define IDC_SEARCH_CHECK 12104
|
||||
#define IDC_WAIT_TEXT 12105
|
||||
#define IDI_MAIN 12200
|
||||
125
Library/dxx8/samples/Multimedia/Common/include/netconnect.h
Normal file
125
Library/dxx8/samples/Multimedia/Common/include/netconnect.h
Normal file
@@ -0,0 +1,125 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: NetConnect.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef NETCONNECT_H
|
||||
#define NETCONNECT_H
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <dplay8.h>
|
||||
#include <dpaddr.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, structures, and error codes
|
||||
//-----------------------------------------------------------------------------
|
||||
#define DISPLAY_REFRESH_RATE 250
|
||||
#define TIMERID_DISPLAY_HOSTS 1
|
||||
#define TIMERID_CONNECT_COMPLETE 2
|
||||
|
||||
#define NCW_S_FORWARD 0x01000001 // Dialog success, so go forward
|
||||
#define NCW_S_BACKUP 0x01000002 // Dialog canceled, show previous dialog
|
||||
#define NCW_S_QUIT 0x01000003 // Dialog quit, close app
|
||||
#define NCW_S_LOBBYCONNECT 0x01000004 // Dialog connected from lobby, connect success
|
||||
|
||||
|
||||
class CNetConnectWizard
|
||||
{
|
||||
public:
|
||||
CNetConnectWizard( HINSTANCE hInst, HWND hWndParent, TCHAR* strAppName, GUID* pGuidApp );
|
||||
virtual ~CNetConnectWizard();
|
||||
|
||||
HRESULT WINAPI MessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
|
||||
HRESULT WINAPI LobbyMessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
|
||||
|
||||
VOID Init( IDirectPlay8Peer* pDP, IDirectPlay8LobbiedApplication* pLobbiedApp );
|
||||
VOID Shutdown();
|
||||
HRESULT DoConnectWizard( BOOL bBackTrack );
|
||||
HRESULT ConnectUsingLobbySettings();
|
||||
|
||||
void SetMaxPlayers( DWORD dwMaxPlayers ) { m_dwMaxPlayers = dwMaxPlayers; }
|
||||
void SetPlayerName( TCHAR* strPlayerName ) { _tcscpy( m_strLocalPlayerName, strPlayerName ); }
|
||||
void SetSessionName( TCHAR* strSessionName ) { _tcscpy( m_strSessionName, strSessionName ); }
|
||||
void SetPreferredProvider( TCHAR* strPreferredProvider ) { _tcscpy( m_strPreferredProvider, strPreferredProvider ); }
|
||||
|
||||
TCHAR* GetPlayerName() { return m_strLocalPlayerName; }
|
||||
TCHAR* GetSessionName() { return m_strSessionName; }
|
||||
TCHAR* GetPreferredProvider() { return m_strPreferredProvider; }
|
||||
BOOL IsHostPlayer() { return m_bHostPlayer; }
|
||||
BOOL IsMigrateHost() { return m_bMigrateHost; }
|
||||
BOOL HaveConnectionSettingsFromLobby() { return m_bHaveConnectionSettingsFromLobby; }
|
||||
|
||||
protected:
|
||||
struct DPHostEnumInfo
|
||||
{
|
||||
DWORD dwRef;
|
||||
DPN_APPLICATION_DESC* pAppDesc;
|
||||
IDirectPlay8Address* pHostAddr;
|
||||
IDirectPlay8Address* pDeviceAddr;
|
||||
TCHAR szSession[MAX_PATH];
|
||||
DWORD dwLastPollTime;
|
||||
BOOL bValid;
|
||||
DPHostEnumInfo* pNext;
|
||||
};
|
||||
|
||||
static INT_PTR CALLBACK StaticConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
static INT_PTR CALLBACK StaticSessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
static INT_PTR CALLBACK StaticCreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
static INT_PTR CALLBACK StaticLobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK ConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK SessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK CreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
INT_PTR CALLBACK LobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
HRESULT ConnectionsDlgFillListBox( HWND hDlg );
|
||||
HRESULT ConnectionsDlgOnOK( HWND hDlg );
|
||||
VOID ConnectionsDlgCleanup( HWND hDlg );
|
||||
|
||||
VOID SessionsDlgInitListbox( HWND hDlg );
|
||||
HRESULT SessionsDlgEnumHosts( HWND hDlg );
|
||||
HRESULT SessionsDlgNoteEnumResponse( PDPNMSG_ENUM_HOSTS_RESPONSE pEnumHostsResponse );
|
||||
VOID SessionsDlgExpireOldHostEnums();
|
||||
HRESULT SessionsDlgDisplayEnumList( HWND hDlg );
|
||||
HRESULT SessionsDlgJoinGame( HWND hDlg );
|
||||
HRESULT SessionsDlgCreateGame( HWND hDlg );
|
||||
VOID SessionsDlgEnumListCleanup();
|
||||
|
||||
IDirectPlay8Peer* m_pDP;
|
||||
IDirectPlay8LobbiedApplication* m_pLobbiedApp;
|
||||
CRITICAL_SECTION m_csHostEnum;
|
||||
GUID m_guidApp;
|
||||
HRESULT m_hrDialog;
|
||||
HWND m_hDlg;
|
||||
HINSTANCE m_hInst;
|
||||
HWND m_hWndParent;
|
||||
DWORD m_dwMaxPlayers;
|
||||
TCHAR m_strAppName[MAX_PATH];
|
||||
TCHAR m_strPreferredProvider[MAX_PATH];
|
||||
TCHAR m_strSessionName[MAX_PATH];
|
||||
TCHAR m_strLocalPlayerName[MAX_PATH];
|
||||
BOOL m_bSearchingForSessions;
|
||||
BOOL m_bMigrateHost;
|
||||
IDirectPlay8Address* m_pDeviceAddress;
|
||||
IDirectPlay8Address* m_pHostAddress;
|
||||
DPHostEnumInfo m_DPHostEnumHead;
|
||||
BOOL m_bEnumListChanged;
|
||||
DPNHANDLE m_hEnumAsyncOp;
|
||||
BOOL m_bHostPlayer;
|
||||
DWORD m_dwEnumHostExpireInterval;
|
||||
BOOL m_bConnecting;
|
||||
DPNHANDLE m_hConnectAsyncOp;
|
||||
HANDLE m_hConnectCompleteEvent;
|
||||
HANDLE m_hLobbyConnectionEvent;
|
||||
HRESULT m_hrConnectComplete;
|
||||
BOOL m_bHaveConnectionSettingsFromLobby;
|
||||
DPNHANDLE m_hLobbyClient;
|
||||
};
|
||||
|
||||
|
||||
#endif // NETCONNECT_H
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
#define IDD_MULTIPLAYER_CONNECT 10001
|
||||
#define IDD_MULTIPLAYER_GAMES 10002
|
||||
#define IDD_MULTIPLAYER_CREATE 10003
|
||||
#define IDD_LOBBY_WAIT_STATUS 10004
|
||||
#define IDC_RETURN 11001
|
||||
#define IDC_PLAYER_NAME_EDIT 11002
|
||||
#define IDC_GAMES_LIST 11003
|
||||
#define IDC_JOIN 11004
|
||||
#define IDC_CREATE 11005
|
||||
#define IDC_CONNECTION_LIST 11006
|
||||
#define IDC_BACK 11007
|
||||
#define IDC_EDIT_SESSION_NAME 11009
|
||||
#define IDC_SEARCH_CHECK 11010
|
||||
#define IDC_LOBBYCONNECTCANCEL 11011
|
||||
#define IDC_WAIT_TEXT 11012
|
||||
#define IDC_MIGRATE_HOST 11013
|
||||
#define IDI_MAIN 11014
|
||||
53
Library/dxx8/samples/Multimedia/Common/include/netvoice.h
Normal file
53
Library/dxx8/samples/Multimedia/Common/include/netvoice.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: NetVoice.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef NETVOICE_H
|
||||
#define NETVOICE_H
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <dvoice.h>
|
||||
|
||||
|
||||
class CNetVoice
|
||||
{
|
||||
public:
|
||||
CNetVoice( LPDVMESSAGEHANDLER pfnDirectPlayClientVoiceMessageHandler,
|
||||
LPDVMESSAGEHANDLER pfnDirectPlayServerVoiceMessageHandler );
|
||||
virtual ~CNetVoice();
|
||||
|
||||
HRESULT Init( HWND hDlg, BOOL bCreateSession, BOOL bConnectToSession,
|
||||
LPUNKNOWN pDirectPlay, DWORD dwSessionType, GUID* pGuidCT,
|
||||
DVCLIENTCONFIG* pdvClientConfig, LPDIRECTSOUND lpds = NULL );
|
||||
HRESULT Free();
|
||||
|
||||
HRESULT HostMigrate( LPDIRECTPLAYVOICESERVER pdvServerInterface );
|
||||
HRESULT IsHalfDuplex() { return m_bHalfDuplex; }
|
||||
HRESULT ChangeVoiceClientSettings( DVCLIENTCONFIG* pdvClientConfig );
|
||||
|
||||
LPDIRECTPLAYVOICECLIENT GetVoiceClient() { return m_pVoiceClient; }
|
||||
LPDIRECTPLAYVOICESERVER GetVoiceServer() { return m_pVoiceServer; }
|
||||
|
||||
protected:
|
||||
LPDIRECTPLAYVOICECLIENT m_pVoiceClient;
|
||||
LPDIRECTPLAYVOICESERVER m_pVoiceServer;
|
||||
LPDVMESSAGEHANDLER m_pfnDirectPlayClientVoiceMessageHandler;
|
||||
LPDVMESSAGEHANDLER m_pfnDirectPlayServerVoiceMessageHandler;
|
||||
|
||||
HRESULT VoiceSessionCreate( LPUNKNOWN pDirectPlay, DWORD dwSessionType, GUID* pGuidCT );
|
||||
HRESULT VoiceSessionTestAudioSetup( HWND hDlg );
|
||||
HRESULT VoiceSessionConnect( HWND hDlg, LPUNKNOWN pDirectPlay,
|
||||
DVCLIENTCONFIG* pdvClientConfig, LPDIRECTSOUND lpds = NULL );
|
||||
HRESULT VoiceSessionDisconnect();
|
||||
HRESULT VoiceSessionDestroy();
|
||||
|
||||
HRESULT m_bHalfDuplex;
|
||||
};
|
||||
|
||||
|
||||
#endif // NETVOICE_H
|
||||
|
||||
Reference in New Issue
Block a user