change 'graphics' namespace to 'gfx' and 'audio' namespace to 'sfx' to make it less cluttery and easier to type out
This commit is contained in:
parent
d28201824b
commit
adde85b8f6
@ -23,7 +23,7 @@
|
||||
|
||||
#include "mixdata.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
namespace impl{
|
||||
class channel;
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <tuple> //tuple, get
|
||||
#include <utility> //forward, integer_sequence
|
||||
|
||||
namespace audio::detail{
|
||||
namespace sfx::detail{
|
||||
template<typename Func, typename... Args>
|
||||
struct callback_helper{
|
||||
Func&& m_f;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef OUR_DICK_AUDIO_ERROR_HPP
|
||||
#define OUR_DICK_AUDIO_ERROR_HPP
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//Combine errors from multiple libraries into one to make for easier end usage
|
||||
class error
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <portaudio.h>
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//supported audio frame data formats
|
||||
enum class frame_fmt{
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#include "util/ring_buffer.hpp"
|
||||
#include "audio/mixdata.hpp"
|
||||
|
||||
namespace audio::impl{
|
||||
namespace sfx::impl{
|
||||
|
||||
class channel
|
||||
{
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include "channel.hpp"
|
||||
#include "audio/stream.hpp"
|
||||
|
||||
namespace audio::impl{
|
||||
namespace sfx::impl{
|
||||
|
||||
//channel reservation needs to be thread safe and lock free
|
||||
class mixer
|
||||
@ -41,7 +41,7 @@ namespace audio::impl{
|
||||
//producer thread stuff
|
||||
std::mutex m_copy_lock;
|
||||
std::unique_lock<std::mutex> m_lk;
|
||||
audio::stream m_output_sink;
|
||||
sfx::stream m_output_sink;
|
||||
|
||||
public:
|
||||
mixer(int output_channels, size_t channel_count, size_t samplerate);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef OUR_DICK_AUDIO_INIT_HPP
|
||||
#define OUR_DICK_AUDIO_INIT_HPP
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//initializer/deinitializer for portaudio
|
||||
class pa_system
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <cstdlib> //size_t
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//raw chunk of mixdata used by mixer
|
||||
struct mixdata {
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <cstdlib> //size_t
|
||||
#include "channel.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
namespace impl{
|
||||
class mixer;
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
#include "error.hpp"
|
||||
#include "mixdata.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//Sound file reader. Reads directly into mixchunks which can be passed directly to a mixer channel
|
||||
class sndrd
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include "detail.hpp"
|
||||
#include "error.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//Represents an audio device under the control of portaudio
|
||||
class stream
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include "gl_include.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
class gl_buffer;
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef OUR_DICK_GRAPHICS_IMAGE_HPP
|
||||
#define OUR_DICK_GRAPHICS_IMAGE_HPP
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
//class handling image loading from files
|
||||
class image
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#ifndef OUR_DICK_GRAPHICS_INIT_HPP
|
||||
#define OUR_DICK_GRAPHICS_INIT_HPP
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
//initializer/deinitializer for glfw
|
||||
class glfw_system
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "gl_include.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
//class representing an opengl shader (NOT an opengl program)
|
||||
class shader
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include "math/math.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
using namespace math;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "image.hpp"
|
||||
#include "gl_include.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
//class representing an opengl 2D texture
|
||||
class texture
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "gl_include.hpp"
|
||||
#include "math/math.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
using namespace math;
|
||||
|
||||
class vertex_attribute;
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#include <cstdlib> //size_t, ptrdiff_t
|
||||
#include <utility> //exchange, swap
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
template<typename T>
|
||||
class scoped_vbo_map;
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "gl_include.hpp"
|
||||
#include "math/math.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
using namespace math;
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ private:
|
||||
using input_callback = void(*)(GLFWwindow*, int, int, int, int);
|
||||
close_callback m_window_close_callback;
|
||||
input_callback m_input_handler;
|
||||
graphics::window m_main_window;
|
||||
gfx::window m_main_window;
|
||||
|
||||
public:
|
||||
enum renderer_error{
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "audio/channel.hpp"
|
||||
#include "audio/impl/channel.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
//needs to be thread safe, lock free, and avoid false sharing
|
||||
channel::channel(impl::channel& c):
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include <portaudio.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
static int map_lib_errors(int liberr){
|
||||
//portaudio and sndfile have no error overlaps, so a switch covers both
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "audio/impl/mixer.hpp"
|
||||
#include <utility> //swap, move
|
||||
|
||||
namespace audio::impl{
|
||||
namespace sfx::impl{
|
||||
|
||||
channel::channel():
|
||||
channel(64){}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "audio/impl/channel.hpp"
|
||||
#include "audio/mixdata.hpp"
|
||||
|
||||
namespace audio::impl{
|
||||
namespace sfx::impl{
|
||||
|
||||
mixer::mixer(int output_channels, size_t channel_count, size_t samplerate):
|
||||
m_paused(false),
|
||||
|
||||
@ -30,12 +30,12 @@
|
||||
#ifdef ENABLE_ALSA_DEBUG
|
||||
#include <cstdarg> //va_arg (missing include in alsa headers)
|
||||
#include <alsa/error.h> //snd_lib_error_set_handler
|
||||
namespace audio::detail{
|
||||
namespace sfx::detail{
|
||||
static void linux_alsa_error_handler(const char* /*file*/, int /*line*/, const char* /*function*/, int /*err*/, const char* /*fmt*/,...){}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
pa_system::pa_system(){
|
||||
#ifdef ENABLE_ALSA_DEBUG
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include <utility> //exchange, swap, move
|
||||
#include <cstring> //memcpy, memset
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
mixchunk::mixchunk(size_t frames, size_t channels, size_t samplerate):
|
||||
m_data{new float[frames * channels](), frames, channels, samplerate, 1, true}{}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "audio/mixer.hpp"
|
||||
#include "audio/impl/mixer.hpp"
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
mixer::mixer(mode m, size_t channel_count, size_t samplerate):
|
||||
m_mix(new impl::mixer(static_cast<int>(m), channel_count, samplerate)){}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <utility> //exchange, swap
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
sndrd::sndrd(const char* f, mode m)noexcept:
|
||||
m_info(),
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
#define PORTAUDIO_FIXED_LATENCY 0.030
|
||||
|
||||
namespace audio{
|
||||
namespace sfx{
|
||||
|
||||
stream::~stream(){
|
||||
close();
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include <utility> //exchange
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
buffer_iface::buffer_iface(const buffer_iface&):
|
||||
m_bound(nullptr){}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include <cstring> //memcpy
|
||||
#include <utility> //exchange
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
image::image(const char* file, bool flip, int req_chan){
|
||||
stbi_set_flip_vertically_on_load(flip);
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include "graphics/gl_include.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
glfw_system::glfw_system(){
|
||||
try_init();
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include <utility> //exchange, swap
|
||||
#include <string>
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
shader::shader(type t):
|
||||
m_shader_id(glCreateShader(static_cast<GLuint>(t))){}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include <string>
|
||||
#include <memory> //unique_ptr
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
shader_program::shader_program():
|
||||
m_shader_id(glCreateProgram()){}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include <utility> //exchange, swap
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
texture::texture(){
|
||||
glGenTextures(1, &m_tex_id);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "graphics/vao.hpp"
|
||||
#include <utility> //exchange, swap
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
void vertex_attribute::enable_array_mode(){
|
||||
glBindVertexArray(m_vao);
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
#include <utility> //exchange, swap, move
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
vbo::vbo(size_t size, usage t):
|
||||
m_buffer_size(0)
|
||||
|
||||
@ -23,7 +23,8 @@
|
||||
#include <cstring> //strlen, strncpy
|
||||
#include "config.hpp"
|
||||
|
||||
namespace graphics{
|
||||
namespace gfx{
|
||||
|
||||
static int initialize_global_glfw(){
|
||||
glfw_system& system = glfw_system::instance();
|
||||
return system.status();
|
||||
|
||||
26
src/main.cpp
26
src/main.cpp
@ -108,9 +108,9 @@ void handle_input_events(GLFWwindow* window, int key, int, int, int){
|
||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||
}
|
||||
|
||||
audio::mixchunk read_audio_file(const char* filename){
|
||||
sfx::mixchunk read_audio_file(const char* filename){
|
||||
debug_print("Reading in %s\n", filename);
|
||||
audio::sndrd f(filename, audio::sndrd::mode::r);
|
||||
sfx::sndrd f(filename, sfx::sndrd::mode::r);
|
||||
if(!f.valid()){
|
||||
return {};
|
||||
}
|
||||
@ -138,15 +138,15 @@ std::string select_audio_file(){
|
||||
return {};
|
||||
}
|
||||
|
||||
void gay_thread(audio::mixer& m, std::atomic_bool& should_gay_thread_stop){
|
||||
void gay_thread(sfx::mixer& m, std::atomic_bool& should_gay_thread_stop){
|
||||
while(!should_gay_thread_stop){
|
||||
audio::mixchunk ch = read_audio_file(select_audio_file().c_str());
|
||||
sfx::mixchunk ch = read_audio_file(select_audio_file().c_str());
|
||||
m.get_channel(0).play(ch);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
}
|
||||
}
|
||||
|
||||
graphics::shader_program create_example_shader(){
|
||||
gfx::shader_program create_example_shader(){
|
||||
static constexpr const char vertex_source[] = "#version 330 core\n"
|
||||
"layout (location = 0) in vec3 aPos;"
|
||||
"void main(){"
|
||||
@ -157,9 +157,9 @@ graphics::shader_program create_example_shader(){
|
||||
"void main(){"
|
||||
"FragColor = vec4(0.0, 0.5, 0.6, 1.0);"
|
||||
"}";
|
||||
graphics::shader_program prog;
|
||||
graphics::shader vert(vertex_source, graphics::shader::type::VERTEX);
|
||||
graphics::shader frag(fragment_source, graphics::shader::type::FRAGMENT);
|
||||
gfx::shader_program prog;
|
||||
gfx::shader vert(vertex_source, gfx::shader::type::VERTEX);
|
||||
gfx::shader frag(fragment_source, gfx::shader::type::FRAGMENT);
|
||||
bool error = false;
|
||||
if(vert.has_compile_error()){
|
||||
debug_print_error("%s\n", vert.get_error().c_str());
|
||||
@ -188,7 +188,7 @@ int main(){
|
||||
|
||||
srand(time(NULL));
|
||||
game_state gs = {};
|
||||
audio::mixer mix(audio::mixer::mode::STEREO, 1, 44100);
|
||||
sfx::mixer mix(sfx::mixer::mode::STEREO, 1, 44100);
|
||||
|
||||
render_manager manager(640, 480, "Tic-Tac-Gugh");
|
||||
manager.handle_window_close_event(handle_window_close);
|
||||
@ -198,16 +198,16 @@ int main(){
|
||||
std::thread t(gay_thread, std::ref(mix), std::ref(should_gay_thread_stop));
|
||||
|
||||
//create our gl objects
|
||||
graphics::vbo vbo(sizeof(vertices), graphics::vbo::usage::STATIC_DRAW);
|
||||
graphics::shader_program prog = create_example_shader();
|
||||
graphics::vao vao;
|
||||
gfx::vbo vbo(sizeof(vertices), gfx::vbo::usage::STATIC_DRAW);
|
||||
gfx::shader_program prog = create_example_shader();
|
||||
gfx::vao vao;
|
||||
|
||||
//put the vertex data in the gl state
|
||||
vbo.buffer(vertices, sizeof(vertices));
|
||||
|
||||
//tell gl how to interpret the data in the vbo
|
||||
vao.bind();
|
||||
vbo.bind(graphics::buffer::array);
|
||||
vbo.bind(gfx::buffer::array);
|
||||
auto attrib = vao.get_attribute(0);
|
||||
attrib.set_float_pointer(3, 3, 0);
|
||||
attrib.enable_array_mode();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user