Added Ogg Vorbis support

This commit is contained in:
grayson committed 2021-10-21 01:42:50 -05:00
1 parent cdea6c4b64
commit 0559415e5b
30 files changed
+1033 -63

No files matched your search

+13 -9
View File
@@ -2,17 +2,21 @@
#include "MainState.h"
int main(int argc, char* argv[]) {
nf::Config conf = { 1280, 720, false, "Example Game"};
nf::Application app(conf);
//app.setWindowIcon(...);
// app.setWindowCursor(...);
//New scope to test Application destructor
{
nf::Config conf = { 1280, 720, false, "Example Game" };
nf::Application app(conf);
//app.setWindowIcon(...);
// app.setWindowCursor(...);
//Has to be on the heap for some reason
MainState* test = new MainState;
app.addState(test, "Main State");
app.setDefaultState("Main State");
//Has to be on the heap for some reason
MainState* test = new MainState;
app.addState(test, "Main State");
app.setDefaultState("Main State");
app.run();
app.run();
}
return 0;
}
+12 -4
View File
@@ -21,6 +21,9 @@ void MainState::onEnter() {
sound.create(ap["sound.wav"]);
sound.setEntity(test);
sound2.create(ap["test.ogg"]);
sound2.setVolume(3.0);
sound2.setEntity(test);
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
@@ -60,18 +63,23 @@ void MainState::update(double deltaTime) {
offset -= 2.0 * deltaTime;
test.setRotation(0.0, 0.0, -offset * 20.0);
light.setPosition(nf::Vec3(std::sin(circle) * 10.0, 5.0, std::cos(circle) * 10.0));
test.setPosition(nf::Vec3(std::sin(circle) * 10.0, 5.0, std::cos(circle) * 10.0));
circle += 2.0 * deltaTime;
text.setText("FPS: " + std::to_string(app->getFPS()));
if (button.isClicked())
app->changeState("Main State");
if (button2.isClicked() || app->isKeyPressed(NFI_SPACE))
sound.play(true);
if (app->isKeyPressed(NFI_O))
if (button2.isClicked() || app->isKeyPressed(NFI_SPACE))
sound.play();
if (app->isKeyPressed(NFI_M))
sound2.play();
if (app->isKeyPressed(NFI_O)) {
sound.stop();
sound2.stop();
}
if (app->isKeyPressed(NFI_ESCAPE))
app->quit();
+1
View File
@@ -23,6 +23,7 @@ private:
nf::Cubemap cm;
nf::Sound sound;
nf::Sound sound2;
double circle;