new parameters for Mix_OpenAudio

This commit is contained in:
Frank DeMarco 2021-04-11 00:30:15 -04:00
parent ad7d42155d
commit ca44bc4b3a
6 changed files with 31 additions and 36 deletions

View File

@ -36,19 +36,19 @@ void Display::get_screen_pixels(unsigned char* pixels, int w, int h, int x, int
{ {
if (get_root()->is_gl_context) if (get_root()->is_gl_context)
{ {
GLenum format; // GLenum format;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN // #if SDL_BYTEORDER == SDL_BIG_ENDIAN
format = GL_BGRA; // format = GL_BGRA;
#else // #else
format = GL_RGBA; // format = GL_RGBA;
#endif // #endif
glReadBuffer(GL_FRONT); // glReadBuffer(GL_FRONT);
glReadPixels(x, y, w, h, format, GL_UNSIGNED_BYTE, pixels); // glReadPixels(x, y, w, h, format, GL_UNSIGNED_BYTE, pixels);
// SDL_Log("(%i, %i, %i) (%i, %i, %i, %i)", // // SDL_Log("(%i, %i, %i) (%i, %i, %i, %i)",
// glCheckFramebufferStatus(GL_FRAMEBUFFER), // // glCheckFramebufferStatus(GL_FRAMEBUFFER),
// glCheckFramebufferStatus(GL_READ_FRAMEBUFFER), // // glCheckFramebufferStatus(GL_READ_FRAMEBUFFER),
// glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER), // // glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER),
// pixels[0], pixels[1], pixels[2], pixels[3]); // // pixels[0], pixels[1], pixels[2], pixels[3]);
} }
else else
{ {

View File

@ -19,11 +19,6 @@ SDL_Surface* FramerateIndicator::get_surface()
std::string padded = sfw::pad(get_root()->frame_count_this_second, 2); std::string padded = sfw::pad(get_root()->frame_count_this_second, 2);
SDL_Surface* shaded = TTF_RenderText_Shaded( SDL_Surface* shaded = TTF_RenderText_Shaded(
get_root()->bp_mono_font, padded.c_str(), {0, 0, 0, 255}, {255, 255, 255, 255}); get_root()->bp_mono_font, padded.c_str(), {0, 0, 0, 255}, {255, 255, 255, 255});
// SDL_Surface* converted = SDL_ConvertSurfaceFormat(
// shaded, SDL_PIXELFORMAT_ARGB8888, 0);
// SDL_Surface* flipped = zoomSurface(converted, 1, -1, SMOOTHING_OFF);
// SDL_FreeSurface(shaded);
// SDL_FreeSurface(converted);
if (!shaded) if (!shaded)
{ {
get_root()->print_sdl_error("Could not create text"); get_root()->print_sdl_error("Could not create text");
@ -69,12 +64,13 @@ Game::Game()
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); // SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
// SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
// SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
// SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
// SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
// SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
SDL_Log("GLEW %s", glewGetString(GLEW_VERSION)); SDL_Log("GLEW %s", glewGetString(GLEW_VERSION));
auto window_size = get_configuration()["display"]["dimensions"].get<glm::ivec2>(); auto window_size = get_configuration()["display"]["dimensions"].get<glm::ivec2>();
window = SDL_CreateWindow( window = SDL_CreateWindow(
@ -124,8 +120,7 @@ Game::Game()
{ {
print_error("Could not load BPmono.ttf"); print_error("Could not load BPmono.ttf");
} }
#if !defined(__EMSCRIPTEN__) if (Mix_Init(MIX_INIT_OGG) == 0)
if (Mix_Init(MIX_INIT_FLAC) == 0)
{ {
print_sdl_error("Could not initialize SDL mixer"); print_sdl_error("Could not initialize SDL mixer");
flag_to_end(); flag_to_end();
@ -135,9 +130,9 @@ Game::Game()
SDL_Log("initialized SDL mixer %d.%d.%d", SDL_MIXER_MAJOR_VERSION, SDL_Log("initialized SDL mixer %d.%d.%d", SDL_MIXER_MAJOR_VERSION,
SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL); SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL);
} }
#endif // if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT,
if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, // MIX_DEFAULT_CHANNELS, 1024) < 0)
MIX_DEFAULT_CHANNELS, 1024) < 0) if (Mix_OpenAudio(11025, AUDIO_U8, MIX_DEFAULT_CHANNELS, 2048) < 0)
{ {
print_sdl_error("Could not set up audio"); print_sdl_error("Could not set up audio");
} }

View File

@ -114,7 +114,7 @@ void Input::respond(SDL_Event &event)
} }
} }
void Input::post_command(std::string& name, const bool& cancel) const void Input::post_command(std::string& name, const bool& cancel)
{ {
SDL_Event relay; SDL_Event relay;
bool* cancel_pointer = new bool(cancel); bool* cancel_pointer = new bool(cancel);

View File

@ -56,7 +56,7 @@ struct Input : Node
void add_to_key_map( void add_to_key_map(
std::string, SDL_Keycode, bool = false, bool = false, bool = false); std::string, SDL_Keycode, bool = false, bool = false, bool = false);
void print_key_combination(const KeyCombination&) const; void print_key_combination(const KeyCombination&) const;
void post_command(std::string&, const bool&) const; static void post_command(std::string&, const bool&);
void suppress(); void suppress();
void unsuppress(); void unsuppress();
bool is_suppressed(); bool is_suppressed();

View File

@ -635,9 +635,9 @@ bool Sprite::collide(const Box& box, bool precise, Box* overlap, bool all, SDL_T
const_cast<SDL_Renderer*>(get_renderer()), collision_check_frame, overlap->stamp(-get_nw(ii))); const_cast<SDL_Renderer*>(get_renderer()), collision_check_frame, overlap->stamp(-get_nw(ii)));
if (other_texture == nullptr) if (other_texture == nullptr)
{ {
for (int x = 0; x < static_cast<int>(overlap->get_w()); x++) for (int x = 0; x < region_pixels.rect.w; x++)
{ {
for (int y = 0; y < static_cast<int>(overlap->get_h()); y++) for (int y = 0; y < region_pixels.rect.h; y++)
{ {
if (region_pixels.get(x, y).a > 0) if (region_pixels.get(x, y).a > 0)
{ {
@ -651,9 +651,9 @@ bool Sprite::collide(const Box& box, bool precise, Box* overlap, bool all, SDL_T
{ {
Pixels other_region_pixels = Pixels( Pixels other_region_pixels = Pixels(
const_cast<SDL_Renderer*>(get_renderer()), other_texture, overlap->stamp(-box.get_nw())); const_cast<SDL_Renderer*>(get_renderer()), other_texture, overlap->stamp(-box.get_nw()));
for (int x = 0; x < static_cast<int>(overlap->get_w()); x++) for (int x = 0; x < region_pixels.rect.w && x < other_region_pixels.rect.w; x++)
{ {
for (int y = 0; y < static_cast<int>(overlap->get_h()); y++) for (int y = 0; y < region_pixels.rect.h && y < other_region_pixels.rect.h; y++)
{ {
if (region_pixels.get(x, y).a > 0 && other_region_pixels.get(x, y).a > 0) if (region_pixels.get(x, y).a > 0 && other_region_pixels.get(x, y).a > 0)
{ {

View File

@ -41,7 +41,7 @@ struct Sprite : Node
glm::bvec2 wrap = {false, false}; glm::bvec2 wrap = {false, false};
int texture_access = SDL_TEXTUREACCESS_TARGET, wipe_index = 0, wipe_increment = -1; int texture_access = SDL_TEXTUREACCESS_TARGET, wipe_index = 0, wipe_increment = -1;
Box wrap_frame, unscaled_subsection; Box wrap_frame, unscaled_subsection;
bool leave_memory_allocated = false, hidden = false, draw_children_on_frame = true; bool leave_memory_allocated = false, hidden = false, draw_children_on_frame = true, draw_floating = true;
std::vector<std::vector<Box>> wipe_blinds; std::vector<std::vector<Box>> wipe_blinds;
SDL_Rect subsection_int_rect, subsection_destination; SDL_Rect subsection_int_rect, subsection_destination;
std::list<Child> children = {}; std::list<Child> children = {};