欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

openalsound.h

这是整套横扫千军3D版游戏的源码
H
字号:
#ifndef OPENAL_SOUND_H
#define OPENAL_SOUND_H

// CSound interface definition
#include "Sound.h"

#include <map>
#include <vector>
#include <AL/al.h>
#include <AL/alc.h>
#include "SDL_types.h"

#include "OggStream.h"


using namespace std;

class COpenALSound : public CSound
{
public:
	ALuint GetWaveId(const string& path, bool hardFail);
	void Update();
	void PlaySample(int id, float volume);
	void PlaySample(int id,const float3& p,float volume);
	void PlayStream(const std::string& path, float volume = 1.0f,
					const float3& pos = ZeroVector, bool loop = false);
	void StopStream();
	void SetVolume(float v);

	COpenALSound();
	virtual ~COpenALSound();

private:
	bool ReadWAV(const char *name, Uint8 *buf, int size, ALuint albuffer);

private:
	ALuint LoadALBuffer(const string& path);
	void PlaySample(int id, const float3 &p, float volume, bool relative);

	int maxSounds;
	int cur;
	float globalVolume;
	bool hardFail;

	void UpdateListener();
	void Enqueue(ALuint src);
	
	map<string, ALuint> soundMap; // filename, index into Buffers
	float3 posScale;
	ALuint* Sources;
};


#endif /* SOUND_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -