summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-09-22 13:21:30 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-09-22 13:21:30 -0400
commit8d9c74bc4f9652739143163f6861682999fbfbe5 (patch)
treefade1044a4fef66e67c6ca8cf9f1c0e13b4b6a53 /engine
parentadd alut (diff)
downloadminecraftvulkan-8d9c74bc4f9652739143163f6861682999fbfbe5.tar.gz
minecraftvulkan-8d9c74bc4f9652739143163f6861682999fbfbe5.tar.bz2
minecraftvulkan-8d9c74bc4f9652739143163f6861682999fbfbe5.zip
finish openal and ALUT
Diffstat (limited to 'engine')
-rw-r--r--engine/xe_engine.cpp7
-rw-r--r--engine/xe_engine.hpp4
-rw-r--r--engine/xe_sound.cpp14
-rw-r--r--engine/xe_sound_device.cpp64
-rw-r--r--engine/xe_sound_device.hpp25
5 files changed, 9 insertions, 105 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp
index 9384094..af2c470 100644
--- a/engine/xe_engine.cpp
+++ b/engine/xe_engine.cpp
@@ -1,6 +1,8 @@
#include "xe_engine.hpp"
#include "xe_image.hpp"
+
#include <chrono>
+#include <AL/alut.h>
namespace xe {
@@ -9,6 +11,11 @@ XeEngine::XeEngine(int width, int height, std::string name) : xeWindow{width, he
xeRenderer{xeWindow, xeDevice},
xeCamera{} {
loadDescriptorPool();
+ alutInit(0, NULL);
+};
+
+XeEngine::~XeEngine() {
+ alutExit();
};
void XeEngine::loadDescriptorPool() {
diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp
index 285edf3..d86c6a9 100644
--- a/engine/xe_engine.hpp
+++ b/engine/xe_engine.hpp
@@ -6,7 +6,6 @@
#include "xe_camera.hpp"
#include "xe_descriptors.hpp"
#include "xe_image.hpp"
-#include "xe_sound_device.hpp"
#include <chrono>
#include <string>
@@ -18,7 +17,7 @@ class XeEngine {
XeEngine(int width, int height, std::string name);
- ~XeEngine() {};
+ ~XeEngine();
XeEngine(const XeEngine&) = delete;
XeEngine operator=(const XeEngine&) = delete;
@@ -45,7 +44,6 @@ class XeEngine {
XeDevice xeDevice;
XeRenderer xeRenderer;
XeCamera xeCamera;
- XeSoundDevice xeSoundDevice;
std::chrono::_V2::system_clock::time_point currentTime;
float frameTime;
diff --git a/engine/xe_sound.cpp b/engine/xe_sound.cpp
index d315179..09589fa 100644
--- a/engine/xe_sound.cpp
+++ b/engine/xe_sound.cpp
@@ -8,20 +8,8 @@ namespace xe {
XeSound::XeSound(const std::string& filename) {
- // ALvoid *data;
- // ALsizei size, freq;
- // ALenum format;
- // ALboolean loop;
- // char *bufferData;
-
- alutInit(0, NULL);
-
- std::cout << std::hex << alutGetError() << "\n";
-
buffer = alutCreateBufferFromFile(filename.c_str());
- std::cout << std::hex << alutGetError() << "\n";
-
alGenSources(1, &source);
alSourcef(source, AL_GAIN, 1.f);
@@ -30,13 +18,13 @@ XeSound::XeSound(const std::string& filename) {
alSource3f(source, AL_VELOCITY, 0, 0, 0);
alSourcei(source, AL_LOOPING, AL_FALSE);
alSourcei(source, AL_BUFFER, buffer);
+ alSourcef(source, AL_GAIN, 3.f);
}
XeSound::~XeSound() {
alDeleteSources(1, &source);
alDeleteBuffers(1, &buffer);
- alutExit();
}
void XeSound::play() {
diff --git a/engine/xe_sound_device.cpp b/engine/xe_sound_device.cpp
deleted file mode 100644
index 3bc931d..0000000
--- a/engine/xe_sound_device.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "xe_sound_device.hpp"
-
-#include <stdexcept>
-#include <iostream>
-#include <cstring>
-
-namespace xe {
-
-XeSoundDevice::XeSoundDevice() {
-
-// ALboolean enumeration;
-// enumeration = alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT");
-// if (enumeration == AL_FALSE) {
-// fprintf(stderr, "enumeration extension not available\n");
-// listAudioDevices(alcGetString(NULL, ALC_DEVICE_SPECIFIER));
-// }
-
-// listAudioDevices(alcGetString(NULL, ALC_DEVICE_SPECIFIER));
-
-// const ALCchar* name = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
-
-// device = alcOpenDevice(name);
-// if (!device) {
-// std::runtime_error("failed to get sound device");
-// }
-
-// std::cout << "Audio Device: " << alcGetString(device, ALC_DEVICE_SPECIFIER) << "\n";
-
-// context = alcCreateContext(device, NULL);
-// if(!alcMakeContextCurrent(context)) {
-// std::runtime_error("failed to make sound context current");
-// }
-
-// alListener3f(AL_POSITION, 0.f, 0.f, 0.f);
-// alListener3f(AL_VELOCITY, 0.f, 0.f, 0.f);
-// ALfloat frontAndUpVectors[] = {
-// /* front*/1.f, 0.f, 0.f,
-// /* up */ 0.f, 1.f, 0.f
-// };
-// alListenerfv(AL_ORIENTATION, frontAndUpVectors);
-
-// }
-
-// void XeSoundDevice::listAudioDevices(const ALCchar* devices) {
-// const ALCchar *device = devices, *next = devices + 1;
-// size_t len = 0;
-
-// fprintf(stdout, "Devices list: ");
-// while (device && *device != '\0' && next && *next != '\0') {
-// fprintf(stdout, "%s, ", device);
-// len = strlen(device);
-// device += (len + 1);
-// next += (len + 2);
-// }
-// std::cout << "\n";
-}
-
-XeSoundDevice::~XeSoundDevice() {
- // alcMakeContextCurrent(nullptr);
- // alcDestroyContext(context);
- // alcCloseDevice(device);
-}
-
-} \ No newline at end of file
diff --git a/engine/xe_sound_device.hpp b/engine/xe_sound_device.hpp
deleted file mode 100644
index a6a034e..0000000
--- a/engine/xe_sound_device.hpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include <AL/alc.h>
-#include <AL/alext.h>
-#include <AL/al.h>
-
-namespace xe {
-
-class XeSoundDevice {
-
- public:
-
- XeSoundDevice();
- ~XeSoundDevice();
-
- private:
-
- void listAudioDevices(const ALCchar* devices);
-
- ALCdevice* device;
- ALCcontext* context;
-
-};
-
-} \ No newline at end of file