Code Monkey home page Code Monkey logo

Comments (8)

Dgame avatar Dgame commented on June 14, 2024

It's still alive, but not actively maintained since I'm not programming that much in D anymore as I've used to be. I've fixed the conversion bug and fixed the error of the assertion error ;). I suppose the error was caused due to a large stacktrace. It looks like the real error happened here: https://github.com/Dgame/Dgame/blob/master/source/Dgame/Window/Internal/Init.d#L111
It seems that your SDL is missing the required ogg and mp3 support.

from dgame.

Windspar avatar Windspar commented on June 14, 2024

They are install. An I still receive error. It looks like a derelict bug.

SDL version: 2.0.8
core.exception.AssertError@/home/drake/.dub/packages/dgame-0.6.6/dgame/source/Dgame/Internal/Error.d(36): Error: Failed to init the required ogg and mp3 support: OGG support not available

My c program runs fine.

#include <stdio.h>
#include "SDL.h"
#include "SDL_mixer.h"

// gcc -o sdl_window sdl_window.c -I/usr/include/SDL2 -lSDL2 -lSDL2_mixer

int main() {
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) != 0) {
        SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
        return 1;
    }

    int mixFlags = MIX_INIT_OGG | MIX_INIT_MP3;
    int mixInit = Mix_Init(mixFlags);
    if(mixInit & mixFlags != mixFlags) {
        SDL_Log("Unable to initialize Mixer ogg or mp3: %s", Mix_GetError());
        SDL_Quit();
        return 1;
    }

    printf("Everything is good");
    SDL_Quit();
    return 0;
}

my derelict sdl2 program get same error.

import std.stdio : writeln;
import derelict.sdl2.sdl;
import derelict.sdl2.mixer;

void main() {
    DerelictSDL2.load();
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) != 0) {
        writeln("Unable to initialize SDL: ", SDL_GetError());
        return;
    }

    DerelictSDL2Mixer.load();
    int mixFlags = MIX_INIT_OGG | MIX_INIT_MP3;
    int mixInit = Mix_Init(mixFlags);
    if ((mixInit & mixFlags) != mixFlags) {
        writeln("Unable to initialize Mixer ogg or mp3: ", Mix_GetError());
        SDL_Quit();
        return;
    }

    Mix_Quit();
    SDL_Quit();
}

from dgame.

Dgame avatar Dgame commented on June 14, 2024

Strange. But aldacron is quick in fixing such stuff, just open an issue.

from dgame.

Windspar avatar Windspar commented on June 14, 2024

Never mine.
if(mixInit & mixFlags != mixFlags)
forgot () around mixInit & mixFlags
my c program get the same error.

from dgame.

Dgame avatar Dgame commented on June 14, 2024

Omg, I got caught in the same trap. Silly me. Well, I could change that requirement since sound support is not your concern as long as you don't use the Sound package. But that would have to wait until next week.

from dgame.

Windspar avatar Windspar commented on June 14, 2024

Found the bug. Fix is open audio before Mix_Init.
No more error.

import std.stdio : writeln;
import derelict.sdl2.sdl;
import derelict.sdl2.mixer;

void main() {
    DerelictSDL2.load();
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) != 0) {
        writeln("Unable to initialize SDL: ", SDL_GetError());
        return;
    }

    DerelictSDL2Mixer.load();

    if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1) {
        writeln("Audio Error");
        SDL_Quit();
        return;
    }

    int mixFlags = MIX_INIT_OGG | MIX_INIT_MP3;
    int mixInit = Mix_Init(mixFlags);
    if ((mixInit & mixFlags) != mixFlags) {
        if ((mixInit & MIX_INIT_OGG) !=  MIX_INIT_OGG)
            writeln("Unable to find ogg");

        if ((mixInit & MIX_INIT_MP3) !=  MIX_INIT_MP3)
            writeln("Unable to find mp3");

        writeln(Mix_GetError());
        SDL_Quit();
        return;
    }

    Mix_Quit();
    SDL_Quit();
}

from dgame.

Windspar avatar Windspar commented on June 14, 2024

I change the order of open audio in dgame/window/internal/init.d. My program runs now. Thanks for your time.

// Initialize SDL_mixer
    result = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096);
    assert_fmt(result == 0, "Warning: Could not open Mix_OpenAudio: %s\n", Mix_GetError());

    result = Mix_Init(MIX_INIT_OGG | MIX_INIT_MP3);
    assert_fmt(result != 0, "Error: Failed to init the required ogg and mp3 support: %s\n", Mix_GetError());

    if ((result & MIX_INIT_OGG) == 0)
        print_fmt("Warning: No ogg support: %s\n", Mix_GetError());
    else if ((result & MIX_INIT_MP3) == 0)
        print_fmt("Warning: No mp3 support: %s\n", Mix_GetError());

from dgame.

Dgame avatar Dgame commented on June 14, 2024

Seems to work with SDL 2.0.3 & 2.0.4 as well, thanks for your work!

from dgame.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.