a45cb95030
- [NEW] music.state() - [NEW] contsants music.INVALID, music.PLAYING, music.PAUSED, music.STOPPED i music.DISABLED - [NEW] El exemple en lua inclos te una secció per a mostrar les funcionalitats de la música
129 lines
3.0 KiB
C++
129 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#define SDL3 1
|
|
#define SFML 2
|
|
#define EMSCRIPTEN 3
|
|
|
|
#ifndef BACKEND
|
|
#define BACKEND SDL3
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
namespace backend
|
|
{
|
|
enum state_t { running=0, exiting=1, quitting=2 };
|
|
extern state_t current_state;
|
|
|
|
void init();
|
|
void quit();
|
|
void poll_events();
|
|
const state_t& state();
|
|
void exit();
|
|
uint32_t get_time_ms();
|
|
char* clipboard();
|
|
void clipboard(const char* value);
|
|
|
|
namespace video
|
|
{
|
|
void init();
|
|
void quit();
|
|
void render();
|
|
void raise_window();
|
|
void cursor(const bool value);
|
|
}
|
|
|
|
namespace shader
|
|
{
|
|
void init(const char* vshader, const char* fshader);
|
|
void enable();
|
|
void disable();
|
|
void render();
|
|
}
|
|
|
|
namespace input
|
|
{
|
|
void reset();
|
|
|
|
namespace key
|
|
{
|
|
bool down(uint8_t i);
|
|
bool press(uint8_t i);
|
|
int press();
|
|
bool any();
|
|
void text(const bool enable);
|
|
const char *utf8char();
|
|
}
|
|
|
|
namespace mouse
|
|
{
|
|
int posx();
|
|
int posy();
|
|
int wheel();
|
|
bool down(uint8_t i);
|
|
bool press(uint8_t i);
|
|
bool dblclick();
|
|
void discard();
|
|
bool inside(int x, int y, int w, int h);
|
|
}
|
|
|
|
namespace pad
|
|
{
|
|
void init();
|
|
bool down(int8_t i);
|
|
bool press(int8_t i);
|
|
int press();
|
|
}
|
|
}
|
|
|
|
namespace audio
|
|
{
|
|
void init();
|
|
void quit();
|
|
|
|
namespace music
|
|
{
|
|
enum state { invalid=0, playing=1, paused=2, stopped=3, disabled=4 };
|
|
|
|
int load(const char* filename);
|
|
int load(const uint8_t* buffer, uint32_t length);
|
|
void play(int mus, int loop = -1);
|
|
void pause();
|
|
void resume();
|
|
void stop();
|
|
void fadeOut(int milliseconds);
|
|
state getState();
|
|
void destroy(int mus);
|
|
float setVolume(float vol);
|
|
void setPosition(float value);
|
|
float getPosition();
|
|
float getDuration();
|
|
void enable(bool value);
|
|
bool isEnabled();
|
|
}
|
|
|
|
namespace sound
|
|
{
|
|
int create(uint8_t* buffer, uint32_t length);
|
|
int load(uint8_t* buffer, uint32_t length);
|
|
int load(const char* filename);
|
|
int play(int snd, int loop = 0);
|
|
int playOnChannel(int snd, int chan, int loop = 0);
|
|
void destroy(int snd);
|
|
float setVolume(float vol);
|
|
void enable(bool value);
|
|
bool isEnabled();
|
|
|
|
namespace channel
|
|
{
|
|
enum state { invalid, free, playing, paused, disabled };
|
|
void pause(int chan);
|
|
void resume(int chan);
|
|
void stop(int chan);
|
|
state getState(int chan);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|