From faaf7b5ed566c2a3fc12371fa3b64be0f12d2779 Mon Sep 17 00:00:00 2001 From: meowtech Date: Mon, 30 Mar 2026 21:48:37 +0000 Subject: [PATCH] changes for SDL3.. --- src/oldimpls/sdl/include.h | 4 ++-- src/screen.cpp | 24 +++++++++++++++++------- src/sdlsoundsource.cpp | 4 ++-- src/soundemitter.cpp | 8 ++++---- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/oldimpls/sdl/include.h b/src/oldimpls/sdl/include.h index b935747..fccf45f 100644 --- a/src/oldimpls/sdl/include.h +++ b/src/oldimpls/sdl/include.h @@ -1,8 +1,8 @@ +#include + #ifndef _OLDIMPLS_SDL_INCLUDE_H #define _OLDIMPLS_SDL_INCLUDE_H -#include - 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_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); diff --git a/src/screen.cpp b/src/screen.cpp index 639b6df..ada5f06 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -10,6 +10,8 @@ #include "debugwriter.h" #include "pipe.h" +// #include "oldimpls/include.h" + static void showInitError(const std::string &msg) { Debug() << msg; @@ -48,7 +50,7 @@ int screenMain(Config &conf) //} 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, ); if (!win) @@ -57,13 +59,20 @@ int screenMain(Config &conf) return 0; } - SDL_WindowShapeMode shapeMode; - shapeMode.mode = ShapeModeColorKey; - shapeMode.parameters.colorKey = colorKey; + // SDL_WindowShapeMode shapeMode; + // shapeMode.mode = ShapeModeColorKey; + // shapeMode.parameters.colorKey = colorKey; + //SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_INDEX8); //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); char messageBuf[256]; @@ -88,7 +97,8 @@ int screenMain(Config &conf) if ((shape = IMG_Load(imgname.c_str())) == NULL) break; SDL_SetWindowSize(win, shape->w, shape->h); - SDL_SetWindowShape(win, shape, &shapeMode); + // SDL_SetWindowShape(win, shape, &shapeMode); + SDL_SetWindowShape(win, shape); } // Redraw diff --git a/src/sdlsoundsource.cpp b/src/sdlsoundsource.cpp index ca59d15..ee5cfff 100644 --- a/src/sdlsoundsource.cpp +++ b/src/sdlsoundsource.cpp @@ -52,7 +52,7 @@ struct SDLSoundSource : ALDataSource sampleSize = formatSampleSize(sample->actual.format); alFormat = chooseALFormat(sampleSize, sample->actual.channels); - alFreq = sample->actual.rate; + alFreq = sample->actual.freq; } ~SDLSoundSource() @@ -98,7 +98,7 @@ struct SDLSoundSource : ALDataSource int sampleRate() { - return sample->actual.rate; + return sample->actual.freq; } void seekToOffset(float seconds) diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 2f692c0..8b4f174 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -192,13 +192,13 @@ struct SoundOpenHandler : FileSystem::OpenHandler : 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) { - SDL_CloseIO(&ops); + SDL_CloseIO(ops); return false; } @@ -214,7 +214,7 @@ struct SoundOpenHandler : FileSystem::OpenHandler ALenum alFormat = chooseALFormat(sampleSize, sample->actual.channels); AL::Buffer::uploadData(buffer->alBuffer, alFormat, sample->buffer, - buffer->bytes, sample->actual.rate); + buffer->bytes, sample->actual.freq); Sound_FreeSample(sample);