Incremental Engine  1.0.6
A 2D Game Engine to create Idle Games
IncrementalEngine::Sound Class Reference

#include <Sound.h>

Public Member Functions

 Sound (std::string filename)
 
virtual ~Sound ()
 
HRESULT Init ()
 

Public Attributes

ALuint Buffer
 

Private Attributes

std::string _filename
 

Detailed Description

Definition at line 13 of file Sound.h.

Constructor & Destructor Documentation

◆ Sound()

IncrementalEngine::Sound::Sound ( std::string  filename)

Definition at line 8 of file Sound.cpp.

8  :
9  _filename(filename),
10  Buffer(NULL)
11  {
12  bool formatCheck = IS_WAV(_filename);
13  assert("The sound format you tried to load is incompatible." && formatCheck);
14  }

◆ ~Sound()

IncrementalEngine::Sound::~Sound ( )
virtual

Definition at line 16 of file Sound.cpp.

17  {
18  alDeleteBuffers(1, &Buffer);
19  }

Member Function Documentation

◆ Init()

HRESULT IncrementalEngine::Sound::Init ( )

Definition at line 21 of file Sound.cpp.

22  {
23  FILE* file;
24  ALenum error;
25  ALuint buffer;
26 
27  alGenBuffers(1, &buffer);
28 
29  if ((error = alGetError()) != AL_NO_ERROR)
30  {
31  alDeleteBuffers(1, &buffer);
32  return CO_E_ERRORINAPP;
33  }
34 
35  fopen_s(&file, _filename.c_str(), "r");
36  if (file == NULL)
37  {
38  alDeleteBuffers(1, &buffer);
39  return CO_E_ERRORINAPP;
40  }
41  else
42  {
43  fclose(file);
44  }
45 
46  buffer = alutCreateBufferFromFile(_filename.c_str());
47 
48  if ((error = alGetError()) != AL_NO_ERROR)
49  {
50  alDeleteBuffers(1, &buffer);
51  return CO_E_ERRORINAPP;
52  }
53 
54  Buffer = buffer;
55 
56  return S_OK;
57  }

Member Data Documentation

◆ _filename

std::string IncrementalEngine::Sound::_filename
private

Definition at line 24 of file Sound.h.

◆ Buffer

ALuint IncrementalEngine::Sound::Buffer

Definition at line 16 of file Sound.h.

IncrementalEngine::Sound::_filename
std::string _filename
Definition: Sound.h:24
IncrementalEngine::Sound::Buffer
ALuint Buffer
Definition: Sound.h:16