示例#1
0
文件: main.cpp 项目: codders/soylent
void init() {
    INIT.set_init_flags(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_AUDIO);
    INIT.init();

    int nj = SDL_NumJoysticks();
    if (nj > 0) {
        std::cout << "Opening joystick '" << SDL_JoystickName(0) << "'\n";
        joy = SDL_JoystickOpen(0);
    }
    else {
        std::cout << "No joysticks\n";
        INIT.quit();
        exit(0);
    }

    SPEC = new SDL_AudioSpec;
    SPEC->freq = 44100;
    SPEC->format = AUDIO_S16SYS;
    SPEC->channels = 2;
    SPEC->samples = 1024;
    SPEC->callback = &audio_callback;
    SPEC->userdata = NULL;
    SDL_OpenAudio(SPEC, NULL) >= 0 || DIE("Couldn't open audio: " + SDL_GetError());
    SDL_PauseAudio(0);

    VIEW.activate();
}
示例#2
0
文件: main.cpp 项目: codders/soylent
void init() {
    INIT.set_init_flags(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO);
    INIT.init();

    int nj = SDL_NumJoysticks();
    if (nj > 0) {
        std::cout << "Opening joystick '" << SDL_JoystickName(0) << "'\n";
        joy = SDL_JoystickOpen(0);
    }
    else {
        std::cout << "No joysticks\n";
        INIT.quit();
        exit(0);
    }

    glEnable(GL_TEXTURE_2D);
    VIEW.activate();

    AV.resize(3);
    AV[0].color = RED;
    AV[0].theta = 0;
    AV[0].range = 1;  AV[0].radius = 1;
    AV[1].color = GREEN;
    AV[1].range = 1;  AV[1].radius = 1;
    AV[2].color = BLUE;
    AV[2].range = 1;  AV[2].radius = 1;
}