replace defines where possible
This commit is contained in:
parent
24b3048c73
commit
e0eacb51be
@ -7,10 +7,10 @@
|
||||
#include <map>
|
||||
#include <queue>
|
||||
|
||||
#define ASSET_TEXTURE 1
|
||||
#define ASSET_SHADER 2
|
||||
#define ASSET_FONT 3
|
||||
#define ASSET_ATLAS 4
|
||||
const short ASSET_TEXTURE = 1;
|
||||
const short ASSET_SHADER = 2;
|
||||
const short ASSET_FONT = 3;
|
||||
const short ASSET_ATLAS = 4;
|
||||
|
||||
class Assets;
|
||||
|
||||
|
||||
@ -17,12 +17,12 @@ std::vector<ALBuffer*> Audio::freebuffers;
|
||||
|
||||
bool ALSource::setBuffer(ALBuffer* buffer) {
|
||||
alSourcei(id, AL_BUFFER, buffer->id);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALSource::play(){
|
||||
alSourcePlay(id);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALSource::isPlaying() {
|
||||
@ -33,33 +33,33 @@ bool ALSource::isPlaying() {
|
||||
|
||||
bool ALSource::setPosition(glm::vec3 position) {
|
||||
alSource3f(id, AL_POSITION, position.x, position.y, position.z);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALSource::setVelocity(glm::vec3 velocity) {
|
||||
alSource3f(id, AL_VELOCITY, velocity.x, velocity.y, velocity.z);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALSource::setLoop(bool loop) {
|
||||
alSourcei(id, AL_LOOPING, AL_TRUE ? loop : AL_FALSE);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALSource::setGain(float gain) {
|
||||
alSourcef(id, AL_GAIN, gain);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
|
||||
bool ALSource::setPitch(float pitch) {
|
||||
alSourcef(id, AL_PITCH, pitch);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
bool ALBuffer::load(int format, const char* data, int size, int freq) {
|
||||
alBufferData(id, format, data, size, freq);
|
||||
return alCheck();
|
||||
return alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ bool Audio::initialize() {
|
||||
alcCloseDevice(device);
|
||||
return false;
|
||||
}
|
||||
if (!alCheck())
|
||||
if (!alCheckErrorsMacro())
|
||||
return false;
|
||||
|
||||
ALCint size;
|
||||
@ -91,13 +91,13 @@ bool Audio::initialize() {
|
||||
void Audio::finalize(){
|
||||
for (ALSource* source : allsources){
|
||||
if (source->isPlaying()){
|
||||
alSourceStop(source->id); alCheck();
|
||||
alSourceStop(source->id); alCheckErrorsMacro();
|
||||
}
|
||||
alDeleteSources(1, &source->id); alCheck();
|
||||
alDeleteSources(1, &source->id); alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
for (ALBuffer* buffer : allbuffers){
|
||||
alDeleteBuffers(1, &buffer->id); alCheck();
|
||||
alDeleteBuffers(1, &buffer->id); alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
alcMakeContextCurrent(context);
|
||||
@ -121,7 +121,7 @@ ALSource* Audio::getFreeSource(){
|
||||
}
|
||||
ALuint id;
|
||||
alGenSources(1, &id);
|
||||
if (!alCheck())
|
||||
if (!alCheckErrorsMacro())
|
||||
return nullptr;
|
||||
|
||||
ALSource* source = new ALSource(id);
|
||||
@ -141,7 +141,7 @@ ALBuffer* Audio::getFreeBuffer(){
|
||||
}
|
||||
ALuint id;
|
||||
alGenBuffers(1, &id);
|
||||
if (!alCheck())
|
||||
if (!alCheckErrorsMacro())
|
||||
return nullptr;
|
||||
|
||||
ALBuffer* buffer = new ALBuffer(id);
|
||||
@ -160,7 +160,7 @@ void Audio::freeBuffer(ALBuffer* buffer){
|
||||
bool Audio::get_available_devices(std::vector<std::string>& devicesVec){
|
||||
const ALCchar* devices;
|
||||
devices = alcGetString(device, ALC_DEVICE_SPECIFIER);
|
||||
if (!alCheck())
|
||||
if (!alCheckErrorsMacro())
|
||||
return false;
|
||||
|
||||
const char* ptr = devices;
|
||||
@ -180,9 +180,9 @@ void Audio::setListener(glm::vec3 position, glm::vec3 velocity, glm::vec3 at, gl
|
||||
ALfloat listenerOri[] = { at.x, at.y, at.z, up.x, up.y, up.z };
|
||||
|
||||
alListener3f(AL_POSITION, position.x, position.y, position.z);
|
||||
alCheck();
|
||||
alCheckErrorsMacro();
|
||||
alListener3f(AL_VELOCITY, velocity.x, velocity.y, velocity.z);
|
||||
alCheck();
|
||||
alCheckErrorsMacro();
|
||||
alListenerfv(AL_ORIENTATION, listenerOri);
|
||||
alCheck();
|
||||
alCheckErrorsMacro();
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include <AL/al.h>
|
||||
|
||||
#define alCheck() check_al_errors(__FILE__, __LINE__)
|
||||
#define alCheckErrorsMacro() check_al_errors(__FILE__, __LINE__)
|
||||
|
||||
bool check_al_errors(const std::string& filename, const std::uint_fast32_t line);
|
||||
|
||||
|
||||
@ -4,27 +4,27 @@
|
||||
#include <limits.h>
|
||||
#include "typedefs.h"
|
||||
|
||||
#define ENGINE_VERSION_MAJOR 0
|
||||
#define ENGINE_VERSION_MINOR 15
|
||||
#define STR_(x) #x
|
||||
#define STR(x) STR_(x)
|
||||
#define ENGINE_VERSION STR(ENGINE_VERSION_MAJOR) "." STR(ENGINE_VERSION_MINOR)
|
||||
const int ENGINE_VERSION_MAJOR = 0;
|
||||
const int ENGINE_VERSION_MINOR = 15;
|
||||
#define TOSTR_MACRO(x) #x
|
||||
#define ENGINE_VERSION TOSTR_MACRO(ENGINE_VERSION_MAJOR) "." TOSTR_MACRO(ENGINE_VERSION_MINOR);
|
||||
|
||||
#define CHUNK_W 16
|
||||
#define CHUNK_H 256
|
||||
#define CHUNK_D 16
|
||||
const int CHUNK_W = 16;
|
||||
const int CHUNK_H = 256;
|
||||
const int CHUNK_D = 16;
|
||||
|
||||
/* Chunk volume (count of voxels per Chunk) */
|
||||
#define CHUNK_VOL (CHUNK_W * CHUNK_H * CHUNK_D)
|
||||
const int CHUNK_VOL = (CHUNK_W * CHUNK_H * CHUNK_D);
|
||||
|
||||
/* BLOCK_VOID is block id used to mark non-existing voxel (voxel of missing chunk) */
|
||||
#define BLOCK_VOID (blockid_t)((2 << (sizeof(blockid_t)*CHAR_BIT)) - 1)
|
||||
const blockid_t BLOCK_VOID = UCHAR_MAX;
|
||||
|
||||
inline uint vox_index(int x, int y, int z, int w=CHUNK_W, int d=CHUNK_D) {
|
||||
return (y * d + z) * w + x;
|
||||
}
|
||||
|
||||
#define SHADERS_FOLDER "shaders"
|
||||
//cannot replace defines with const while used for substitution
|
||||
#define SHADERS_FOLDER "shaders"
|
||||
#define TEXTURES_FOLDER "textures"
|
||||
#define FONTS_FOLDER "fonts"
|
||||
|
||||
|
||||
@ -3,22 +3,22 @@
|
||||
|
||||
/* blocks and bindings used in engine code */
|
||||
|
||||
#define BLOCK_AIR 0
|
||||
const int BLOCK_AIR = 0;
|
||||
|
||||
#define BIND_MOVE_FORWARD "movement.forward"
|
||||
#define BIND_MOVE_BACK "movement.back"
|
||||
#define BIND_MOVE_LEFT "movement.left"
|
||||
#define BIND_MOVE_RIGHT "movement.right"
|
||||
#define BIND_MOVE_JUMP "movement.jump"
|
||||
#define BIND_MOVE_SPRINT "movement.sprint"
|
||||
#define BIND_MOVE_CROUCH "movement.crouch"
|
||||
#define BIND_MOVE_CHEAT "movement.cheat"
|
||||
#define BIND_CAM_ZOOM "camera.zoom"
|
||||
#define BIND_PLAYER_NOCLIP "player.noclip"
|
||||
#define BIND_PLAYER_FLIGHT "player.flight"
|
||||
#define BIND_PLAYER_ATTACK "player.attack"
|
||||
#define BIND_PLAYER_BUILD "player.build"
|
||||
#define BIND_PLAYER_PICK "player.pick"
|
||||
#define BIND_HUD_INVENTORY "hud.inventory"
|
||||
const std::string BIND_MOVE_FORWARD = "movement.forward";
|
||||
const std::string BIND_MOVE_BACK = "movement.back";
|
||||
const std::string BIND_MOVE_LEFT = "movement.left";
|
||||
const std::string BIND_MOVE_RIGHT = "movement.right";
|
||||
const std::string BIND_MOVE_JUMP = "movement.jump";
|
||||
const std::string BIND_MOVE_SPRINT = "movement.sprint";
|
||||
const std::string BIND_MOVE_CROUCH = "movement.crouch";
|
||||
const std::string BIND_MOVE_CHEAT = "movement.cheat";
|
||||
const std::string BIND_CAM_ZOOM = "camera.zoom";
|
||||
const std::string BIND_PLAYER_NOCLIP = "player.noclip";
|
||||
const std::string BIND_PLAYER_FLIGHT = "player.flight";
|
||||
const std::string BIND_PLAYER_ATTACK = "player.attack";
|
||||
const std::string BIND_PLAYER_BUILD = "player.build";
|
||||
const std::string BIND_PLAYER_PICK = "player.pick";
|
||||
const std::string BIND_HUD_INVENTORY = "hud.inventory";
|
||||
|
||||
#endif // SRC_CORE_DEFS_H_
|
||||
Loading…
x
Reference in New Issue
Block a user