changes for SDL3..

This commit is contained in:
meowtech 2026-03-30 21:48:37 +00:00
parent f142b26df1
commit faaf7b5ed5
4 changed files with 25 additions and 15 deletions

View file

@ -1,8 +1,8 @@
#include <SDL3/SDL_surface.h>
#ifndef _OLDIMPLS_SDL_INCLUDE_H #ifndef _OLDIMPLS_SDL_INCLUDE_H
#define _OLDIMPLS_SDL_INCLUDE_H #define _OLDIMPLS_SDL_INCLUDE_H
#include <SDL3/SDL_surface.h>
static SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); static SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
static SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format); static SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format);
static SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); static SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

View file

@ -10,6 +10,8 @@
#include "debugwriter.h" #include "debugwriter.h"
#include "pipe.h" #include "pipe.h"
// #include "oldimpls/include.h"
static void showInitError(const std::string &msg) static void showInitError(const std::string &msg)
{ {
Debug() << msg; Debug() << msg;
@ -48,7 +50,7 @@ int screenMain(Config &conf)
//} //}
SDL_Window *win; SDL_Window *win;
win = SDL_CreateWindow("The Journal", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOW_RESIZABLE); win = SDL_CreateWindow("The Journal", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOW_RESIZABLE | SDL_WINDOW_TRANSPARENT);
//SDL_SetWindowShape(win, ); //SDL_SetWindowShape(win, );
if (!win) if (!win)
@ -57,13 +59,20 @@ int screenMain(Config &conf)
return 0; return 0;
} }
SDL_WindowShapeMode shapeMode; // SDL_WindowShapeMode shapeMode;
shapeMode.mode = ShapeModeColorKey; // shapeMode.mode = ShapeModeColorKey;
shapeMode.parameters.colorKey = colorKey; // shapeMode.parameters.colorKey = colorKey;
//SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8); //SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8);
//SDL_PIXELFORMAT_UNKNOWN - 0,0,0,0 ....maybe? //SDL_PIXELFORMAT_UNKNOWN - 0,0,0,0 ....maybe?
SDL_Surface *shape = SDL_CreateSurface(DEFAULT_WIDTH, DEFAULT_HEIGHT, SDL_PIXELFORMAT_UNKNOWN);
SDL_Palette *palette = SDL_CreateSurfacePalette(surface); //SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8);
//SDL_Surface *shape = SDL_CreateSurface(DEFAULT_WIDTH, DEFAULT_HEIGHT, SDL_PIXELFORMAT_UNKNOWN);
// i have no idea if it works.
//SDL_Surface *shape = SDL_CreateRGBSurface(0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 8, 0, 0, 0, 0);
SDL_Surface *shape = SDL_CreateSurface(DEFAULT_WIDTH, DEFAULT_HEIGHT, SDL_PixelFormat::SDL_PIXELFORMAT_RGBA32);
SDL_Palette *palette = SDL_CreateSurfacePalette(shape);
SDL_SetPaletteColors(palette, &black, 0, 1); SDL_SetPaletteColors(palette, &black, 0, 1);
char messageBuf[256]; char messageBuf[256];
@ -88,7 +97,8 @@ int screenMain(Config &conf)
if ((shape = IMG_Load(imgname.c_str())) == NULL) if ((shape = IMG_Load(imgname.c_str())) == NULL)
break; break;
SDL_SetWindowSize(win, shape->w, shape->h); SDL_SetWindowSize(win, shape->w, shape->h);
SDL_SetWindowShape(win, shape, &shapeMode); // SDL_SetWindowShape(win, shape, &shapeMode);
SDL_SetWindowShape(win, shape);
} }
// Redraw // Redraw

View file

@ -52,7 +52,7 @@ struct SDLSoundSource : ALDataSource
sampleSize = formatSampleSize(sample->actual.format); sampleSize = formatSampleSize(sample->actual.format);
alFormat = chooseALFormat(sampleSize, sample->actual.channels); alFormat = chooseALFormat(sampleSize, sample->actual.channels);
alFreq = sample->actual.rate; alFreq = sample->actual.freq;
} }
~SDLSoundSource() ~SDLSoundSource()
@ -98,7 +98,7 @@ struct SDLSoundSource : ALDataSource
int sampleRate() int sampleRate()
{ {
return sample->actual.rate; return sample->actual.freq;
} }
void seekToOffset(float seconds) void seekToOffset(float seconds)

View file

@ -192,13 +192,13 @@ struct SoundOpenHandler : FileSystem::OpenHandler
: buffer(0) : buffer(0)
{} {}
bool tryRead(SDL_IOStream &ops, const char *ext) bool tryRead(SDL_IOStream* &ops, const char *ext)
{ {
Sound_Sample *sample = Sound_NewSample(&ops, ext, 0, STREAM_BUF_SIZE); Sound_Sample *sample = Sound_NewSample(ops, ext, 0, STREAM_BUF_SIZE);
if (!sample) if (!sample)
{ {
SDL_CloseIO(&ops); SDL_CloseIO(ops);
return false; return false;
} }
@ -214,7 +214,7 @@ struct SoundOpenHandler : FileSystem::OpenHandler
ALenum alFormat = chooseALFormat(sampleSize, sample->actual.channels); ALenum alFormat = chooseALFormat(sampleSize, sample->actual.channels);
AL::Buffer::uploadData(buffer->alBuffer, alFormat, sample->buffer, AL::Buffer::uploadData(buffer->alBuffer, alFormat, sample->buffer,
buffer->bytes, sample->actual.rate); buffer->bytes, sample->actual.freq);
Sound_FreeSample(sample); Sound_FreeSample(sample);