- [FIX] No es mostrava res en pantalla perque faltava el 0xff000000 al ficar pixels en la textura
- [FIX] No s'escoltava so, no estic segur de perqué. He agafat el JailAudio de mini i ja va tot. - [NEW] Afegida opció "SET INFINITELIVES" desde la consola - [NEW] Afegida opció "SET KIOSK" desde la consola - [FIX] Les SDL_texture es veien borroses - [FIX] En windows no es carregaven be els GIFs del txt per culpa del salt de linea doble que té.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "jdraw.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include "gif.c"
|
||||
#include "gif.h"
|
||||
#include "jfile.h"
|
||||
#include <vector>
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace draw
|
||||
sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * screen_zoom, screen_height * screen_zoom, screen_fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||
SDL_SetTextureScaleMode(sdl_texture, SDL_SCALEMODE_NEAREST);
|
||||
|
||||
const int num_render_drivers = SDL_GetNumRenderDrivers();
|
||||
printf("Available renderers:\n");
|
||||
@@ -135,10 +136,12 @@ namespace draw
|
||||
char *p = buffer;
|
||||
char *n = buffer;
|
||||
while (*n!=0) {
|
||||
while (*n!='\n') n++;
|
||||
while (*n!='\n' && *n!='\r') n++;
|
||||
*n=0;
|
||||
loadSurface(p);
|
||||
p=++n;
|
||||
n++;
|
||||
while (*n=='\n' || *n=='\r') n++;
|
||||
p=n;
|
||||
}
|
||||
free(buffer);
|
||||
|
||||
@@ -183,6 +186,7 @@ namespace draw
|
||||
sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN:0);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr);
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||
SDL_SetTextureScaleMode(sdl_texture, SDL_SCALEMODE_NEAREST);
|
||||
|
||||
SDL_HideCursor();
|
||||
|
||||
@@ -672,10 +676,34 @@ namespace draw
|
||||
print2(buffer, x, y, color, zoom);
|
||||
}
|
||||
|
||||
bool SaveIndexedAsBMP(const char *filename,
|
||||
const uint8_t *pixels,
|
||||
const uint32_t *palette,
|
||||
int w, int h)
|
||||
{
|
||||
SDL_Surface *surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!surface) return false;
|
||||
|
||||
uint32_t *dst = (uint32_t *)surface->pixels;
|
||||
int pitch32 = surface->pitch / 4;
|
||||
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
uint8_t idx = pixels[y * w + x];
|
||||
dst[y * pitch32 + x] = palette[idx]; // assumes ARGB8888
|
||||
}
|
||||
}
|
||||
|
||||
bool ok = SDL_SaveBMP(surface, filename);
|
||||
SDL_DestroySurface(surface);
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Refresca la pantalla
|
||||
void render()
|
||||
{
|
||||
|
||||
//SaveIndexedAsBMP("screen.bmp", screen->pixels, palette, 320, 240);
|
||||
|
||||
Uint32 *sdl_pixels; // Punter al array de pixels que enstornarà SDL_LockTexture
|
||||
int sdl_pitch; // Ací estarà guardat el pitch de la textura, com es de 32 bits, no m'afecta
|
||||
const uint32_t size = screen->w * screen->h; // tamany de la superficie
|
||||
@@ -689,7 +717,7 @@ namespace draw
|
||||
// i el enviem a la textura SDL
|
||||
for (uint32_t i = 0; i < size; ++i)
|
||||
{
|
||||
sdl_pixels[i] = palette[screen->pixels[i]];
|
||||
sdl_pixels[i] = 0xff000000 | palette[screen->pixels[i]];
|
||||
}
|
||||
|
||||
// Desbloquejem la textura
|
||||
|
||||
Reference in New Issue
Block a user