Utility.h
资源名称:g.rar [点击查看]
上传用户:laitongbao
上传日期:2021-02-20
资源大小:8176k
文件大小:2k
源码类别:
射击游戏
开发平台:
Visual C++
- /***********************************************************************************************
- *工具函数(一般用于内部使用) *
- * *
- * *
- * *
- *************************************************************************************************/
- #include<d3d9.h>
- #include<d3dx9.h>
- #define INITGUID
- #include <dmusici.h>
- #include <dshow.h>
- #include <windows.h>
- #include <stdio.h>
- class Particle_Emit;
- class MeshObject;
- struct VECTOR;
- //UI最多可包含文字数,以字节为单位
- #define MAXTEXT 800
- #pragma once
- typedef struct MEM_FILE_TYP//用于存放内存中的文件及大小
- {
- void* buffer;
- DWORD size;
- } MEM_FILE,*MEM_FILE_PTR;
- //定义宏
- inline DWORD FtoDW( FLOAT f ) { return *((DWORD*)&f); }
- #define S_DELETE(pointer) if(pointer)delete pointer
- #define S_DELETEARRAY(pointer) if(pointer)delete[] pointer
- #define S_RELEASE(pointer) if(pointer)pointer->Release()
- #define S_CLEANUP(pointer) if(pointer)pointer->CleanUp()
- //录入工具函数
- LPDIRECT3DTEXTURE9 LoadTexture(TCHAR* name,DWORD colorKey);//录入贴图到LPDIRECT3DTEXTURE9
- LPDIRECT3DTEXTURE9 LoadTextureFromMemory(void* buffer,DWORD size,DWORD colorKey);
- HRESULT SetVertexBuffer(IDirect3DVertexBuffer9* pVertexBuffer,void*vertex,int size);//设置点缓存
- MEM_FILE LoadFileToMemory(TCHAR* fileName);//把文件录入内存
- //绘图工具函数
- void DrawWire(VECTOR*pt,int numPoints,DWORD color=0xff44ff44);
- //快速碰撞检测
- class SoundPlayer
- {
- public:
- SoundPlayer(TCHAR* filename=NULL);
- void InitSoundDevice();
- void PlaySound(int repeats=0);//播放声音指定次数次,-1次代表无限重复
- void StopSound();
- void ReloadSound(TCHAR* filename);
- void ReleaseSoundDevice();
- private:
- IDirectMusicLoader8* m_pLoader ;
- IDirectMusicPerformance8* m_pPerformance ;
- IDirectMusicSegment8* m_pSegment ;
- };
- class MusicPlayer
- {
- public:
- MusicPlayer(TCHAR* filename=NULL);
- void InitSoundDevice();
- void PlaySound(int repeats=0);//播放声音指定次数次,-1次代表无限重复
- void StopSound();
- void Pause();
- void ReloadSound(TCHAR* filename);
- void ReleaseSoundDevice();
- private:
- HRESULT SwapSourceFilter(WCHAR*wFileName);
- IGraphBuilder *m_pGraph;
- IMediaControl *m_pControl;
- IMediaEvent *m_pEvent;
- IMediaSeeking *m_pMediaSeeking;
- IBaseFilter *m_pSourceCurrent;
- IBaseFilter *m_pSourceNext;
- };
- void ShowMsg(const TCHAR*str,...);