Audio module, simple text rendering
This commit is contained in:
+15
-14
@@ -2,6 +2,7 @@
|
||||
// sudo apt install libgl-dev libglew-dev libglfw3-dev libpng-dev libglm-dev
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <stdint.h>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
@@ -22,6 +23,7 @@ using namespace glm;
|
||||
#include "graphics/Mesh.h"
|
||||
#include "graphics/VoxelRenderer.h"
|
||||
#include "graphics/LineBatch.h"
|
||||
#include "graphics/Batch2D.h"
|
||||
#include "window/Window.h"
|
||||
#include "window/Events.h"
|
||||
#include "window/Camera.h"
|
||||
@@ -40,6 +42,8 @@ using namespace glm;
|
||||
#include "physics/Hitbox.h"
|
||||
#include "physics/PhysicsSolver.h"
|
||||
|
||||
#include "audio/Audio.h"
|
||||
#include "audio/audioutil.h"
|
||||
#include "Assets.h"
|
||||
#include "objects/Player.h"
|
||||
|
||||
@@ -86,6 +90,9 @@ void update_controls(PhysicsSolver* physics,
|
||||
Player* player,
|
||||
float delta){
|
||||
|
||||
if (Events::jpressed(GLFW_KEY_ESCAPE)){
|
||||
Window::setShouldClose(true);
|
||||
}
|
||||
if (Events::jpressed(GLFW_KEY_TAB)){
|
||||
Events::toogleCursor();
|
||||
}
|
||||
@@ -244,16 +251,13 @@ void update_interaction(Chunks* chunks, PhysicsSolver* physics, Player* player,
|
||||
int WIDTH = 1280;
|
||||
int HEIGHT = 720;
|
||||
|
||||
#define GRAVITY 19.6f
|
||||
#define DEFAULT_PLAYER_SPEED 4.0f
|
||||
|
||||
vec3 spawnpoint(-320, 255, 32);
|
||||
|
||||
|
||||
int main() {
|
||||
setup_definitions();
|
||||
|
||||
Window::initialize(WIDTH, HEIGHT, "VoxelEngine Part-11");
|
||||
Audio::initialize();
|
||||
|
||||
Window::initialize(WIDTH, HEIGHT, "Window 2.0");
|
||||
Events::initialize();
|
||||
|
||||
std::cout << "-- loading assets" << std::endl;
|
||||
@@ -266,12 +270,12 @@ int main() {
|
||||
}
|
||||
std::cout << "-- loading world" << std::endl;
|
||||
|
||||
Camera *camera = new Camera(spawnpoint, radians(90.0f));
|
||||
Camera *camera = new Camera(vec3(-320,255,32), radians(90.0f));
|
||||
WorldFiles *wfile = new WorldFiles("world/", REGION_VOL * (CHUNK_VOL * 2 + 8));
|
||||
Chunks *chunks = new Chunks(34,1,34, 0,0,0);
|
||||
|
||||
|
||||
Player* player = new Player(vec3(camera->position), DEFAULT_PLAYER_SPEED, camera);
|
||||
Player* player = new Player(vec3(camera->position), 4.0f, camera);
|
||||
wfile->readPlayer(player);
|
||||
camera->rotation = mat4(1.0f);
|
||||
camera->rotate(player->camY, player->camX, 0);
|
||||
@@ -279,7 +283,7 @@ int main() {
|
||||
std::cout << "-- preparing systems" << std::endl;
|
||||
|
||||
VoxelRenderer renderer(1024*1024);
|
||||
PhysicsSolver physics(vec3(0,-GRAVITY,0));
|
||||
PhysicsSolver physics(vec3(0,-9.8f*2.0f,0));
|
||||
Lighting lighting(chunks);
|
||||
|
||||
init_renderer();
|
||||
@@ -297,16 +301,13 @@ int main() {
|
||||
|
||||
std::cout << "-- initializing finished" << std::endl;
|
||||
|
||||
|
||||
while (!Window::isShouldClose()){
|
||||
frame++;
|
||||
float currentTime = glfwGetTime();
|
||||
delta = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
|
||||
if (Events::jpressed(GLFW_KEY_ESCAPE)){
|
||||
Window::setShouldClose(true);
|
||||
}
|
||||
|
||||
if (Events::jpressed(GLFW_KEY_O)){
|
||||
occlusion = !occlusion;
|
||||
}
|
||||
@@ -336,8 +337,8 @@ int main() {
|
||||
|
||||
delete assets;
|
||||
finalize_renderer();
|
||||
Audio::finalize();
|
||||
Events::finalize();
|
||||
Window::terminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user