- [WIP] Fase 2 quasi acabada

- [FIX] Arreglos per al debugger
- [FIX] Calcul de la posició del mouse en coordenades tenint en compte view.origin
This commit is contained in:
2026-04-13 20:09:57 +02:00
parent 0142d79d91
commit 380295aed0
22 changed files with 232 additions and 160 deletions

View File

@@ -403,6 +403,31 @@ namespace mini
} }
} }
void tileblit(uint8_t n, int x, int y, int tw, int th) {
//const int tw = tile_width;
//const int th = tile_height;
const int tiles_per_row = mini::surf::state.source_surface->w / tw;
// Coordenadas del tile dentro del spritesheet
int tx = (n % tiles_per_row) * tw;
int ty = (n / tiles_per_row) * th;
int src_y = ty;
for (int yi = 0; yi < th; ++yi) {
int src_x = tx;
for (int xi = 0; xi < tw; ++xi) {
uint8_t c = mini::draw::pixel::get(src_x, src_y);
mini::draw::pixel::subst_pset(x + xi, y + yi, c);
src_x++;
}
src_y++;
}
}
const uint8_t printchar(uint8_t c, int x, int y) { const uint8_t printchar(uint8_t c, int x, int y) {
font::char_t &chr = font::current_font->chars[c]; font::char_t &chr = font::current_font->chars[c];
draw::surf(chr.x, chr.y, chr.w, chr.h, x, y-chr.base); draw::surf(chr.x, chr.y, chr.w, chr.h, x, y-chr.base);

View File

@@ -47,6 +47,7 @@ namespace mini
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 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 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 tileblit(uint8_t n, int x, int y, int tw, int th);
void text(const char *str, int x, int y, uint8_t color); void text(const char *str, int x, int y, uint8_t color);

View File

@@ -1,4 +1,7 @@
#include "font.h" #include "font.h"
#include "default_font_gif.h"
#include "default_font_fnt.h"
#include "mini/surf/surf.h" #include "mini/surf/surf.h"
#include "mini/file/file.h" #include "mini/file/file.h"
#include "aux/log.h" #include "aux/log.h"
@@ -99,6 +102,14 @@ namespace mini
return i; return i;
} }
void init() {
//uint8_t font_surf =
surf::load(default_font_gif, "default_font");
//surfaces[font_surf].flags |= SURF_GENERATED;
font::load_from_buffer((const char*)default_font_fnt, 0, "default_font");
current_font = &fonts[0];
}
namespace current { namespace current {
void set(uint8_t font) { void set(uint8_t font) {
current_font = &fonts[font]; current_font = &fonts[font];

View File

@@ -18,6 +18,8 @@ namespace mini
}; };
extern font_t *current_font; extern font_t *current_font;
void init();
uint8_t load(const char *filename); uint8_t load(const char *filename);
namespace current { namespace current {

View File

@@ -1,5 +1,6 @@
#include "key.h" #include "key.h"
#include "mini/pad/pad.h" #include "mini/pad/pad.h"
#include "mini/win/win.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -34,11 +35,10 @@ namespace mini
} }
void text(const bool enable) { void text(const bool enable) {
// [TODO] if (enable)
//if (enable) SDL_StartTextInput(win::state.window);
// SDL_StartTextInput(mini_win); else
//else SDL_StopTextInput(win::state.window);
// SDL_StopTextInput(mini_win);
} }
const char* utf8char() { const char* utf8char() {

View File

@@ -132,6 +132,8 @@ namespace mini
lua_pop(L,1); lua_pop(L,1);
lua_pop(L,1); lua_pop(L,1);
debug::init(L);
//std::thread(debugCommandThread).detach(); //std::thread(debugCommandThread).detach();
printf("stdin isatty: %d\n", isatty(0)); printf("stdin isatty: %d\n", isatty(0));
is_playing = true; is_playing = true;

View File

@@ -143,9 +143,13 @@ namespace mini
//const char* src = chunkToPath(ar.source).c_str(); //const char* src = chunkToPath(ar.source).c_str();
json frame = { json frame = {
{ "file", chunkToPath(ar.source).c_str() }, { "id", depth + 1 },
{ "name", ar.name ? ar.name : "?" },
{ "line", ar.currentline }, { "line", ar.currentline },
{ "name", ar.name ? ar.name : "?" } { "column", 1 },
{ "source", {
{ "path", chunkToPath(ar.source) }
}}
}; };
frames.push_back(frame); frames.push_back(frame);
@@ -153,7 +157,8 @@ namespace mini
} }
return json{ return json{
{ "frames", frames } { "stackFrames", frames },
{ "totalFrames", depth }
}; };
} }
@@ -1340,6 +1345,10 @@ namespace mini
} }
} }
void init(lua_State* L) {
lua_sethook(L, luaHook, LUA_MASKCALL | LUA_MASKRET, 0);
}
void kill_thread() { void kill_thread() {
g_running = false; g_running = false;
stdinThread.request_stop(); stdinThread.request_stop();

View File

@@ -8,6 +8,7 @@ namespace mini
namespace debug namespace debug
{ {
bool call_and_handle_exceptions(lua_State* L); bool call_and_handle_exceptions(lua_State* L);
void init(lua_State* L);
void kill_thread(); void kill_thread();
void process_commands(lua_State* L); void process_commands(lua_State* L);
void toggle(lua_State* L); void toggle(lua_State* L);

View File

@@ -2,6 +2,10 @@
#include "external/lua/lua.hpp" #include "external/lua/lua.hpp"
#include "mini/mini.h" #include "mini/mini.h"
#include "mini/surf/surf.h"
#include "mini/draw/draw.h"
#include "mini/pal/pal.h"
#include "mini/font/font.h"
#include "mini/win/win.h" #include "mini/win/win.h"
#include "mini/view/view.h" #include "mini/view/view.h"
#include "mini/shader/shader.h" #include "mini/shader/shader.h"
@@ -198,21 +202,6 @@ namespace mini
return 0; return 0;
} }
} }
static int pixel(lua_State *L) {
if (lua_gettop(L)==2) {
int x = luaL_checknumber(L, 1);
int y = luaL_checknumber(L, 2);
lua_pushinteger(L, mini::surf::pixel::get(x, y));
return 1;
} else {
int x = luaL_checknumber(L, 1);
int y = luaL_checknumber(L, 2);
uint8_t color = luaL_checkinteger(L, 3);
mini::surf::pixel::set(x, y, color);
return 0;
}
}
} }
namespace map namespace map
@@ -400,6 +389,21 @@ namespace mini
namespace draw namespace draw
{ {
static int pixel(lua_State *L) {
if (lua_gettop(L)==2) {
int x = luaL_checknumber(L, 1);
int y = luaL_checknumber(L, 2);
lua_pushinteger(L, mini::draw::pixel::get(x, y));
return 1;
} else {
int x = luaL_checknumber(L, 1);
int y = luaL_checknumber(L, 2);
uint8_t color = luaL_checkinteger(L, 3);
mini::draw::pixel::set(x, y, color);
return 0;
}
}
static int line(lua_State *L) { static int line(lua_State *L) {
int x0 = luaL_checknumber(L, 1); int x0 = luaL_checknumber(L, 1);
int y0 = luaL_checknumber(L, 2); int y0 = luaL_checknumber(L, 2);
@@ -1033,7 +1037,6 @@ namespace mini
lua_pushcfunction(L,wrappers::surf::source); lua_setfield(L, -2, "source"); lua_pushcfunction(L,wrappers::surf::source); lua_setfield(L, -2, "source");
lua_pushcfunction(L,wrappers::surf::cls); lua_setfield(L, -2, "cls"); lua_pushcfunction(L,wrappers::surf::cls); lua_setfield(L, -2, "cls");
lua_pushcfunction(L,wrappers::surf::clip); lua_setfield(L, -2, "clip"); lua_pushcfunction(L,wrappers::surf::clip); lua_setfield(L, -2, "clip");
lua_pushcfunction(L,wrappers::surf::pixel); lua_setfield(L, -2, "pixel");
lua_pushinteger(L, 0); lua_setfield(L, -2, "SCREEN"); lua_pushinteger(L, 0); lua_setfield(L, -2, "SCREEN");
lua_setglobal(L, "surf"); lua_setglobal(L, "surf");
@@ -1059,6 +1062,7 @@ namespace mini
lua_setglobal(L, "view"); lua_setglobal(L, "view");
lua_newtable(L); lua_newtable(L);
lua_pushcfunction(L,wrappers::draw::pixel); lua_setfield(L, -2, "pixel");
lua_pushcfunction(L,wrappers::draw::line); lua_setfield(L, -2, "line"); lua_pushcfunction(L,wrappers::draw::line); lua_setfield(L, -2, "line");
lua_pushcfunction(L,wrappers::draw::hline); lua_setfield(L, -2, "hline"); lua_pushcfunction(L,wrappers::draw::hline); lua_setfield(L, -2, "hline");
lua_pushcfunction(L,wrappers::draw::vline); lua_setfield(L, -2, "vline"); lua_pushcfunction(L,wrappers::draw::vline); lua_setfield(L, -2, "vline");

View File

@@ -1,6 +1,9 @@
#include "mini.h" #include "mini.h"
#include "win/win.h" #include "win/win.h"
#include "view/view.h" #include "view/view.h"
#include "surf/surf.h"
#include "pal/pal.h"
#include "draw/draw.h"
uint16_t ants = 0xc936; uint16_t ants = 0xc936;
float t = 0; float t = 0;
@@ -19,13 +22,13 @@ void exception_loop() {
pal::color::set(1,0xff000000); pal::color::set(1,0xff000000);
const int w=win::res::getw(); const int w=win::res::getw();
const int h=win::res::geth(); const int h=win::res::geth();
mini::draw::mode::set(0); draw::mode::set(0);
mini::draw::rect(0,0,w,h,1); draw::rect(0,0,w,h,1);
mini::draw::rect(1,1,w-2,h-2,1); draw::rect(1,1,w-2,h-2,1);
mini::draw::mode::set(1); draw::mode::set(1);
draw::pattern::set(ants); draw::pattern::set(ants);
mini::draw::rect(0,0,w,h,0); draw::rect(0,0,w,h,0);
mini::draw::rect(1,1,w-2,h-2,0); draw::rect(1,1,w-2,h-2,0);
ants = (ants<<12) | (ants>>4); ants = (ants<<12) | (ants>>4);
} }
} }

View File

@@ -2,6 +2,7 @@
#include "version.h" #include "version.h"
#include "surf/surf.h" #include "surf/surf.h"
#include "pal/pal.h"
#include "font/font.h" #include "font/font.h"
#include "draw/draw.h" #include "draw/draw.h"
#include "win/win.h" #include "win/win.h"
@@ -15,8 +16,6 @@
#include "file/file.h" #include "file/file.h"
#include "lua/lua.h" #include "lua/lua.h"
#include "aux/log.h" #include "aux/log.h"
#include "aux/default_font_gif.h"
#include "aux/default_font_fnt.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -60,11 +59,8 @@ bool should_quit = false;
Uint32 *pixels; Uint32 *pixels;
int pitch; int pitch;
uint32_t palette[256] = { 0xFF1a1c2c, 0xFF5d275d, 0xFFb13e53, 0xFFef7d57, 0xFFffcd75, 0xFFa7f070, 0xFF38b764, 0xFF257179,
0xFF29366f, 0xFF3b5dc9, 0xFF41a6f6, 0xFF73eff7, 0xFFf4f4f4, 0xFF94b0c2, 0xFF566c86, 0xFF333c57 };
mini::surf::surface_t* map_surface = NULL;
surf::surface_t* map_surface = NULL;
int16_t beats, num_beats = 0; int16_t beats, num_beats = 0;
@@ -124,31 +120,6 @@ namespace mini
} }
} }
static inline void tileblit(uint8_t n, int x, int y) {
const int tw = tile_width;
const int th = tile_height;
const int tiles_per_row = mini::surf::state.source_surface->w / tw;
// Coordenadas del tile dentro del spritesheet
int tx = (n % tiles_per_row) * tw;
int ty = (n / tiles_per_row) * th;
int src_y = ty;
for (int yi = 0; yi < th; ++yi) {
int src_x = tx;
for (int xi = 0; xi < tw; ++xi) {
uint8_t c = mini::draw::pixel::get(src_x, src_y);
mini::draw::pixel::subst_pset(x + xi, y + yi, c);
src_x++;
}
src_y++;
}
}
void draw() { void draw() {
if (!map_surface || !mini::surf::state.source_surface) return; if (!map_surface || !mini::surf::state.source_surface) return;
@@ -205,7 +176,7 @@ namespace mini
uint8_t tile = tile::get(celx + x, cely + y); uint8_t tile = tile::get(celx + x, cely + y);
if (!tile) continue; if (!tile) continue;
int tx = sx + x * tw; int tx = sx + x * tw;
tileblit(tile, tx - ox, ty - oy); draw::tileblit(tile, tx - ox, ty - oy, tile_width, tile_height);
} }
} }
} }
@@ -236,53 +207,6 @@ namespace mini
} }
namespace pal
{
uint32_t *load(const char* filename, uint16_t *palsize) {
int size;
uint8_t *buffer = (uint8_t*)file::getfilebuffer(filename, size);
// [TODO]
uint32_t *pal = nullptr; //LoadPalette(buffer, palsize);
free(buffer);
return pal;
}
void set(uint32_t *pal) {
for (int i=0; i<256; ++i) palette[i] = pal[i] | 0xff000000;
}
namespace color {
void set(uint8_t index, uint32_t color) {
palette[index] = color | 0xff000000;
}
uint32_t get(uint8_t index) {
return palette[index];
}
}
namespace trans {
void set(uint8_t index) {
ds::trans = index;
}
uint8_t get() {
return ds::trans;
}
}
namespace subpal {
uint8_t set(uint8_t index, uint8_t color) {
const uint8_t old = ds::draw_palette[SDL_clamp(index,0,255)];
ds::draw_palette[SDL_clamp(index,0,255)] = SDL_clamp(color,0,255);
return old;
}
void reset() {
for (int i=0;i<256;++i) ds::draw_palette[i]=i;
}
}
}
@@ -337,8 +261,8 @@ void reinit() {
mini::view::init(); mini::view::init();
// Reset draw state // Reset draw state
ds::mode = DRAWMODE_NORMAL; mini::draw::state.mode = DRAWMODE_NORMAL;
ds::fill_pattern = 0b1111111111111111; mini::draw::state.fill_pattern = 0b1111111111111111;
// Reset surf state // Reset surf state
for (unsigned int i=0; i<MAX_SURFACES; ++i) mini::surf::destroy(i); for (unsigned int i=0; i<MAX_SURFACES; ++i) mini::surf::destroy(i);
@@ -347,7 +271,7 @@ void reinit() {
// Reset pal state // Reset pal state
mini::pal::subpal::reset(); mini::pal::subpal::reset();
ds::trans=0; mini::draw::state.trans=0;
} }
using namespace mini; using namespace mini;
@@ -421,10 +345,7 @@ int main(int argc,char*argv[]){
reinit(); reinit();
uint8_t font_surf = surf::load(default_font_gif, "default_font"); font::init();
//surfaces[font_surf].flags |= SURF_GENERATED;
font::load_from_buffer((const char*)default_font_fnt, 0, "default_font");
current_font = &fonts[0];
lua::init(main_lua_file); lua::init(main_lua_file);
lua::callbacks::init(); lua::callbacks::init();
@@ -495,8 +416,8 @@ int main(int argc,char*argv[]){
mouse::state.buttons = SDL_GetMouseState(&real_mouse_x, &real_mouse_y); mouse::state.buttons = SDL_GetMouseState(&real_mouse_x, &real_mouse_y);
float mx, my; float mx, my;
SDL_RenderCoordinatesFromWindow(win::state.renderer, real_mouse_x, real_mouse_y, &mx, &my); SDL_RenderCoordinatesFromWindow(win::state.renderer, real_mouse_x, real_mouse_y, &mx, &my);
mouse::state.x = int(mx/win::state.zoom)-view::state.origin[0]; mouse::state.x = int(mx/win::state.zoom);
mouse::state.y = int(my/win::state.zoom)-view::state.origin[1]; mouse::state.y = int(my/win::state.zoom);
if (SDL_GetTicks()-dt>13) { if (SDL_GetTicks()-dt>13) {
dt = SDL_GetTicks(); dt = SDL_GetTicks();
@@ -523,7 +444,7 @@ int main(int argc,char*argv[]){
SDL_SetRenderDrawColor(win::state.renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(win::state.renderer, 0, 0, 0, 255);
SDL_RenderClear(win::state.renderer); SDL_RenderClear(win::state.renderer);
SDL_LockTexture(win::state.tex_back, NULL, (void**)&pixels, &pitch); SDL_LockTexture(win::state.tex_back, NULL, (void**)&pixels, &pitch);
for (uint32_t i=0;i<surf::state.screen_surface->size;++i) pixels[i] = palette[surf::state.screen_surface->p[i]]; for (uint32_t i=0;i<surf::state.screen_surface->size;++i) pixels[i] = pal::palette[surf::state.screen_surface->p[i]];
SDL_UnlockTexture(win::state.tex_back); SDL_UnlockTexture(win::state.tex_back);
SDL_RenderTexture(win::state.renderer, win::state.tex_back, NULL, NULL); //NEW SDL_RenderTexture(win::state.renderer, win::state.tex_back, NULL, NULL); //NEW

View File

@@ -27,24 +27,6 @@ namespace mini
} }
} }
namespace pal
{
uint32_t *load(const char* filename, uint16_t *palsize=nullptr);
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 sys namespace sys
{ {
float delta(); float delta();

View File

@@ -1,4 +1,5 @@
#include "mouse.h" #include "mouse.h"
#include "mini/view/view.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -9,11 +10,11 @@ namespace mini
state_t state; state_t state;
int posx() { int posx() {
return state.x; return state.x-view::state.origin[0];
} }
int posy() { int posy() {
return state.y; return state.y-view::state.origin[1];
} }
int wheel() { int wheel() {
@@ -38,7 +39,9 @@ namespace mini
} }
bool inside(int x, int y, int w, int h) { bool inside(int x, int y, int w, int h) {
return (state.x>=x) && (state.y>=y) && (state.x<x+w) && (state.y<y+h); const int mx = state.x - view::state.origin[0];
const int my = state.y - view::state.origin[1];
return (mx>=x) && (my>=y) && (mx<x+w) && (my<y+h);
} }
} }
} }

80
source/mini/pal/pal.cpp Normal file
View File

@@ -0,0 +1,80 @@
#include "pal.h"
#include "mini/file/file.h"
#include "mini/draw/draw.h"
#include <SDL3/SDL.h>
#include <stdlib.h>
namespace mini
{
namespace pal
{
uint32_t palette[256] = { 0xFF1a1c2c, 0xFF5d275d, 0xFFb13e53, 0xFFef7d57, 0xFFffcd75, 0xFFa7f070, 0xFF38b764, 0xFF257179,
0xFF29366f, 0xFF3b5dc9, 0xFF41a6f6, 0xFF73eff7, 0xFFf4f4f4, 0xFF94b0c2, 0xFF566c86, 0xFF333c57 };
uint32_t* LoadPalette(uint8_t *buffer, uint16_t *size = NULL )
{
buffer += 10;
const uint8_t fields = *buffer;
uint32_t *global_color_table = (uint32_t *)calloc(1, 1024);;
if (size) *size = 0;
if (fields & 0x80) {
int global_color_table_size = 1 << (((fields & 0x07) + 1));
if (size) *size = global_color_table_size;
for (int i=0; i<global_color_table_size;++i) {
buffer+=3;
global_color_table[i] = (buffer[0]<<16) + (buffer[1]<<8) + buffer[2];
}
}
return global_color_table;
}
uint32_t *load(const char* filename, uint16_t *palsize) {
int size;
uint8_t *buffer = (uint8_t*)file::getfilebuffer(filename, size);
uint32_t *pal = LoadPalette(buffer, palsize);
free(buffer);
return pal;
}
void set(uint32_t *pal) {
for (int i=0; i<256; ++i) palette[i] = pal[i] | 0xff000000;
}
namespace color {
void set(uint8_t index, uint32_t color) {
palette[index] = color | 0xff000000;
}
uint32_t get(uint8_t index) {
return palette[index];
}
}
namespace trans {
void set(uint8_t index) {
draw::state.trans = index;
}
uint8_t get() {
return draw::state.trans;
}
}
namespace subpal {
uint8_t set(uint8_t index, uint8_t color) {
const uint8_t old = draw::state.draw_palette[SDL_clamp(index,0,255)];
draw::state.draw_palette[SDL_clamp(index,0,255)] = SDL_clamp(color,0,255);
return old;
}
void reset() {
for (int i=0;i<256;++i) draw::state.draw_palette[i]=i;
}
}
}
}

26
source/mini/pal/pal.h Normal file
View File

@@ -0,0 +1,26 @@
#pragma once
#include <stdint.h>
namespace mini
{
namespace pal
{
extern uint32_t palette[256];
uint32_t *load(const char* filename, uint16_t *palsize=nullptr);
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();
}
}
}

View File

@@ -3,8 +3,8 @@
#include "aux/gif.h" #include "aux/gif.h"
#include "aux/gifenc.h" #include "aux/gifenc.h"
#include "aux/log.h" #include "aux/log.h"
#include "file/file.h" #include "mini/file/file.h"
#include "draw/draw.h" #include "mini/draw/draw.h"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -179,8 +179,8 @@ namespace mini
void set(int x, int y, int w, int h) { void set(int x, int y, int w, int h) {
state.dest_surface->clip[0]=x; state.dest_surface->clip[0]=x;
state.dest_surface->clip[1]=y; state.dest_surface->clip[1]=y;
state.dest_surface->clip[2]=w-x-1; state.dest_surface->clip[2]=x+(w-1);
state.dest_surface->clip[3]=h-y-1; state.dest_surface->clip[3]=y+(h-1);
recalculate(); recalculate();
} }
void reset(int surface) { void reset(int surface) {

View File

@@ -25,12 +25,14 @@ namespace mini
surface_t surfaces[MAX_SURFACES]; surface_t surfaces[MAX_SURFACES];
surface_t* screen_surface = &surfaces[0]; surface_t* screen_surface = &surfaces[0];
surface_t* dest_surface = screen_surface; surface_t* dest_surface = screen_surface;
surface_t* source_surface = NULL; surface_t* source_surface = nullptr;
}; };
extern state_t state; extern state_t state;
uint8_t create(int w, int h); uint8_t create(int w, int h);
uint8_t load(const char* filename, const bool external = false); uint8_t load(const char* filename, const bool external = false);
uint8_t load(uint8_t* buffer, const char* name);
void reloadsurfs();
void save(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors=0); void save(uint8_t surface, const char* filename, uint8_t *pal, uint8_t colors=0);
void destroy(uint8_t surface); void destroy(uint8_t surface);
int width(uint8_t surface); int width(uint8_t surface);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define MINI_VERSION "1.4.10" #define MINI_VERSION "1.5.0"

View File

@@ -18,7 +18,7 @@ namespace mini
while (state.width*state.zoom > dm->w || state.height*state.zoom > dm->h) state.zoom--; while (state.width*state.zoom > dm->w || state.height*state.zoom > dm->h) state.zoom--;
// Crear SDL_Window i SDL_Renderer // Crear SDL_Window i SDL_Renderer
state.window = SDL_CreateWindow(state.title, state.width*state.zoom, state.height*state.zoom, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE|(state.fullscreen?SDL_WINDOW_FULLSCREEN:0)); state.window = SDL_CreateWindow(state.title, state.width*state.zoom, state.height*state.zoom, SDL_WINDOW_OPENGL|(state.fullscreen?SDL_WINDOW_FULLSCREEN:0));
//windowID = SDL_GetWindowID(mini_win); //windowID = SDL_GetWindowID(mini_win);
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
state.renderer = SDL_CreateRenderer(state.window, NULL); state.renderer = SDL_CreateRenderer(state.window, NULL);

View File

@@ -71,18 +71,6 @@ function surf.clip() end
---Set the clipping region of the current target surface ---Set the clipping region of the current target surface
function surf.clip(x, y, w, h) end function surf.clip(x, y, w, h) end
---@param x number
---@param y number
---@return number color
---Get color of pixel (x,y) on the source surface.
function surf.pixel(x, y) end
---@param x number
---@param y number
---@param color number
---Set the color for pixel (x,y) on the target surface.
function surf.pixel(x, y, color) end
surf.SCREEN = 0 surf.SCREEN = 0
@@ -204,6 +192,18 @@ function view.tolocal(x, y) end
draw = {} draw = {}
---@param x number
---@param y number
---@return number color
---Get color of pixel (x,y) on the source surface.
function draw.pixel(x, y) end
---@param x number
---@param y number
---@param color number
---Set the color for pixel (x,y) on the target surface.
function draw.pixel(x, y, color) end
---@param x1 number ---@param x1 number
---@param y1 number ---@param y1 number
---@param x2 number ---@param x2 number