- [WIP] Reestructuració: Fase 1 acabada
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include <SDL3/SDL_opengl_glext.h>
|
||||
#endif
|
||||
|
||||
namespace mini
|
||||
{
|
||||
namespace shader
|
||||
{
|
||||
SDL_Window *win = nullptr;
|
||||
@@ -251,3 +253,4 @@ namespace shader
|
||||
if (glGetError()) { printf("GLERROR!\n"); exit(1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,14 +35,17 @@
|
||||
// Ah! una cosa mes: al compilar, en Linux afegir "-lGL", en Windows afegir "-lopengl32".
|
||||
// En Mac ni idea
|
||||
|
||||
namespace mini
|
||||
{
|
||||
namespace shader
|
||||
{
|
||||
const bool init(SDL_Window* win, SDL_Texture* backBuffer,
|
||||
const char* vertexShader, const char* fragmentShader=nullptr);
|
||||
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
//void enable();
|
||||
//void disable();
|
||||
|
||||
void render();
|
||||
}
|
||||
}
|
||||
|
||||
663
source/lua.cpp
663
source/lua.cpp
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ namespace mini
|
||||
{
|
||||
namespace lua
|
||||
{
|
||||
bool runnning();
|
||||
bool running();
|
||||
void init(const char* main_lua_file = "main.lua");
|
||||
void quit();
|
||||
void cleanup();
|
||||
|
||||
@@ -3,23 +3,25 @@
|
||||
uint16_t ants = 0xc936;
|
||||
float t = 0;
|
||||
|
||||
using namespace mini;
|
||||
|
||||
void exception_loop() {
|
||||
//if (t==0) t= time();
|
||||
if (time()-t > 0.25) {
|
||||
t = time();
|
||||
clip();
|
||||
origin(0,0);
|
||||
setdest(0);
|
||||
settrans(255);
|
||||
setcolor(0,0xffffff00);
|
||||
setcolor(1,0xff000000);
|
||||
const int w=scrw();
|
||||
const int h=scrh();
|
||||
if (sys::time()-t > 0.25) {
|
||||
t = sys::time();
|
||||
view::clip::reset();
|
||||
view::origin::set(0,0);
|
||||
surf::target::set(0);
|
||||
pal::trans::set(255);
|
||||
pal::color::set(0,0xffffff00);
|
||||
pal::color::set(1,0xff000000);
|
||||
const int w=win::res::getw();
|
||||
const int h=win::res::geth();
|
||||
mini::draw::mode::set(0);
|
||||
mini::draw::rect(0,0,w,h,1);
|
||||
mini::draw::rect(1,1,w-2,h-2,1);
|
||||
mini::draw::mode::set(1);
|
||||
fillp(ants);
|
||||
draw::pattern::set(ants);
|
||||
mini::draw::rect(0,0,w,h,0);
|
||||
mini::draw::rect(1,1,w-2,h-2,0);
|
||||
ants = (ants<<12) | (ants>>4);
|
||||
|
||||
1504
source/mini.cpp
1504
source/mini.cpp
File diff suppressed because it is too large
Load Diff
258
source/mini.h
258
source/mini.h
@@ -1,16 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
||||
void exception_loop();
|
||||
|
||||
int scrw();
|
||||
int scrh();
|
||||
|
||||
void raisewindow();
|
||||
|
||||
namespace mini
|
||||
@@ -59,33 +52,40 @@ namespace mini
|
||||
uint8_t geth();
|
||||
void set(int w, int h);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void shader_init(const char* vshader, const char* fshader);
|
||||
void shader_enable();
|
||||
void shader_disable();
|
||||
|
||||
uint8_t loadfont(const char *filename);
|
||||
uint8_t getfont();
|
||||
void setfont(uint8_t font);
|
||||
uint8_t getfontspacing();
|
||||
void setfontspacing(uint8_t spacing);
|
||||
|
||||
|
||||
uint32_t *loadpal(const char* filename, uint16_t *palsize=NULL);
|
||||
void setpal(uint32_t *pal);
|
||||
void setcolor(uint8_t index, uint32_t color);
|
||||
uint32_t getcolor(uint8_t index);
|
||||
void settrans(uint8_t index);
|
||||
uint8_t gettrans();
|
||||
uint8_t subpal(uint8_t index, uint8_t color);
|
||||
void reset_subpal();
|
||||
|
||||
namespace mini
|
||||
namespace pal
|
||||
{
|
||||
uint32_t *load(const char* filename, uint16_t *palsize=NULL);
|
||||
void set(uint32_t *pal);
|
||||
namespace color {
|
||||
void set(uint8_t index, uint32_t color);
|
||||
uint32_t get(uint8_t index);
|
||||
}
|
||||
namespace trans {
|
||||
void set(uint8_t index);
|
||||
uint8_t get();
|
||||
}
|
||||
namespace subpal {
|
||||
uint8_t set(uint8_t index, uint8_t color);
|
||||
void reset();
|
||||
}
|
||||
}
|
||||
|
||||
namespace view
|
||||
{
|
||||
namespace clip {
|
||||
void set(int x, int y, int w, int h);
|
||||
void reset();
|
||||
}
|
||||
|
||||
namespace origin {
|
||||
void set(int x, int y);
|
||||
int getx();
|
||||
int gety();
|
||||
}
|
||||
}
|
||||
|
||||
namespace draw
|
||||
{
|
||||
void line(int x0, int y0, int x1, int y1, uint8_t color);
|
||||
@@ -103,84 +103,150 @@ namespace mini
|
||||
void oval(int x0, int y0, int x1, int y1, uint8_t color);
|
||||
void ovalf(int x0, int y0, int x1, int y1, uint8_t color);
|
||||
|
||||
namespace pattern {
|
||||
void set(uint16_t pat, bool transparent = false);
|
||||
}
|
||||
|
||||
void surf(int sx, int sy, int sw, int sh, int dx, int dy, int dw=0, int dh=0, bool flip_x = false, bool flip_y = false, bool invert = false);
|
||||
void surfrot(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, bool flip_x, bool flip_y, float angle_deg);
|
||||
|
||||
void text(const char *str, int x, int y, uint8_t color);
|
||||
|
||||
namespace mode
|
||||
{
|
||||
void set(uint8_t mode);
|
||||
}
|
||||
}
|
||||
|
||||
namespace shader
|
||||
{
|
||||
void init(const char* vshader, const char* fshader);
|
||||
void enable();
|
||||
void disable();
|
||||
}
|
||||
|
||||
namespace audio
|
||||
{
|
||||
namespace music
|
||||
{
|
||||
void play(const char *filename, const int loop=-1);
|
||||
void pause();
|
||||
void resume();
|
||||
void stop(const int t=1000);
|
||||
namespace pos {
|
||||
void set(float value);
|
||||
float get();
|
||||
}
|
||||
namespace enable {
|
||||
void set(const bool value);
|
||||
const bool get();
|
||||
}
|
||||
}
|
||||
|
||||
void fillp(uint16_t pat, bool transparent = false);
|
||||
namespace sound
|
||||
{
|
||||
int load(const char *filename);
|
||||
void free(int soundfile);
|
||||
int play(int soundfile, const int volume=-1);
|
||||
void stop(int soundchannel);
|
||||
namespace enable {
|
||||
void set(const bool value);
|
||||
const bool get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print(const char *str, int x, int y, uint8_t color);
|
||||
|
||||
void clip(int x, int y, int w, int h);
|
||||
void clip();
|
||||
void origin(int x, int y);
|
||||
int camx();
|
||||
int camy();
|
||||
|
||||
uint8_t sget(int x, int y);
|
||||
|
||||
void blit(int sx, int sy, int sw, int sh, int dx, int dy, int dw=0, int dh=0, bool flip_x = false, bool flip_y = false, bool invert = false);
|
||||
void blit_r(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, bool flip_x, bool flip_y, float angle_deg);
|
||||
|
||||
bool btn(uint8_t i);
|
||||
int wbtnp();
|
||||
bool btnp(uint8_t i);
|
||||
bool anykey();
|
||||
void textenable(const bool enable);
|
||||
const char *textinput();
|
||||
|
||||
bool pad(int8_t i);
|
||||
bool padp(int8_t i);
|
||||
int wpad();
|
||||
|
||||
int mousex();
|
||||
int mousey();
|
||||
int mwheel();
|
||||
bool mbtn(uint8_t i);
|
||||
bool mbtnp(uint8_t i);
|
||||
bool doubleclick();
|
||||
void mdiscard();
|
||||
bool minside(int x, int y, int w, int h);
|
||||
|
||||
float time();
|
||||
namespace sys
|
||||
{
|
||||
float delta();
|
||||
float time();
|
||||
bool beat(int16_t i);
|
||||
|
||||
int getfps();
|
||||
|
||||
void playmusic(const char *filename, const int loop=-1);
|
||||
void pausemusic();
|
||||
void resumemusic();
|
||||
void stopmusic(const int t=1000);
|
||||
void musicpos(float value);
|
||||
float musicpos();
|
||||
void enablemusic(const bool value);
|
||||
const bool ismusicenabled();
|
||||
|
||||
int loadsound(const char *filename);
|
||||
void freesound(int soundfile);
|
||||
int playsound(int soundfile, const int volume=-1);
|
||||
void stopsound(int soundchannel);
|
||||
void enablesound(const bool value);
|
||||
const bool issoundenabled();
|
||||
|
||||
int getzoom();
|
||||
void setzoom(const int value);
|
||||
void setres(const int w, const int h);
|
||||
bool getfullscreen();
|
||||
void setfullscreen(const bool value);
|
||||
bool getcursor();
|
||||
void setcursor(const bool value);
|
||||
|
||||
const char *getconfig(const char* key);
|
||||
void setconfig(const char* key, const char* value);
|
||||
const char *configfolder();
|
||||
|
||||
void setupdatemode(const int value, const int t=0);
|
||||
int getupdatemode();
|
||||
namespace update {
|
||||
void set(const int value, const int t=0);
|
||||
int get();
|
||||
}
|
||||
|
||||
void exit();
|
||||
}
|
||||
|
||||
namespace win
|
||||
{
|
||||
namespace zoom {
|
||||
void set(const int value);
|
||||
int get();
|
||||
}
|
||||
|
||||
namespace fullscreen {
|
||||
void set(const bool value);
|
||||
bool get();
|
||||
}
|
||||
|
||||
namespace cursor {
|
||||
void set(const bool value);
|
||||
bool get();
|
||||
}
|
||||
|
||||
namespace res {
|
||||
void set(const int w, const int h);
|
||||
int getw();
|
||||
int geth();
|
||||
}
|
||||
}
|
||||
|
||||
namespace config
|
||||
{
|
||||
namespace key {
|
||||
void set(const char* key, const char* value);
|
||||
const char *get(const char* key);
|
||||
}
|
||||
|
||||
const char *folder();
|
||||
}
|
||||
|
||||
namespace font
|
||||
{
|
||||
uint8_t load(const char *filename);
|
||||
|
||||
namespace current {
|
||||
void set(uint8_t font);
|
||||
uint8_t get();
|
||||
}
|
||||
|
||||
namespace spacing {
|
||||
void set(uint8_t spacing);
|
||||
uint8_t get();
|
||||
}
|
||||
}
|
||||
|
||||
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 key
|
||||
{
|
||||
bool down(uint8_t i);
|
||||
bool press(uint8_t i);
|
||||
int press();
|
||||
bool any();
|
||||
void text(const bool enable);
|
||||
const char *utf8char();
|
||||
}
|
||||
|
||||
namespace pad
|
||||
{
|
||||
bool down(int8_t i);
|
||||
bool press(int8_t i);
|
||||
int press();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user