1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-12-18 18:37:55 +01:00

Change texture filtering without restarting. (#67)

This commit is contained in:
MaikelChan 2021-10-25 05:42:36 +02:00 committed by GitHub
parent 5789492021
commit 34cb964ea5
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 12 deletions

View file

@ -3,6 +3,7 @@
#include "fullscrn.h" #include "fullscrn.h"
#include "midi.h" #include "midi.h"
#include "render.h"
#include "Sound.h" #include "Sound.h"
#include "winmain.h" #include "winmain.h"
@ -246,7 +247,7 @@ void options::toggle(Menu1 uIDCheckItem)
break; break;
case Menu1::WindowLinearFilter: case Menu1::WindowLinearFilter:
Options.LinearFiltering ^= true; Options.LinearFiltering ^= true;
winmain::Restart(); render::recreate_screen_texture();
break; break;
default: default:
break; break;

View file

@ -42,17 +42,7 @@ void render::init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int h
else else
gdrv::fill_bitmap(vscreen, vscreen->Width, vscreen->Height, 0, 0, 0); gdrv::fill_bitmap(vscreen, vscreen->Width, vscreen->Height, 0, 0, 0);
{ recreate_screen_texture();
UsingSdlHint hint{SDL_HINT_RENDER_SCALE_QUALITY, options::Options.LinearFiltering ? "linear" : "nearest"};
vScreenTex = SDL_CreateTexture
(
winmain::Renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
width, height
);
SDL_SetTextureBlendMode(vScreenTex, SDL_BLENDMODE_NONE);
}
} }
void render::uninit() void render::uninit()
@ -69,6 +59,25 @@ void render::uninit()
dirty_list.clear(); dirty_list.clear();
sprite_list.clear(); sprite_list.clear();
SDL_DestroyTexture(vScreenTex); SDL_DestroyTexture(vScreenTex);
vScreenTex = nullptr;
}
void render::recreate_screen_texture()
{
if (vScreenTex != nullptr)
{
SDL_DestroyTexture(vScreenTex);
}
UsingSdlHint hint{ SDL_HINT_RENDER_SCALE_QUALITY, options::Options.LinearFiltering ? "linear" : "nearest" };
vScreenTex = SDL_CreateTexture
(
winmain::Renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
vscreen_rect.Width, vscreen_rect.Height
);
SDL_SetTextureBlendMode(vScreenTex, SDL_BLENDMODE_NONE);
} }
void render::update() void render::update()

View file

@ -35,6 +35,7 @@ public:
static void init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int height); static void init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int height);
static void uninit(); static void uninit();
static void recreate_screen_texture();
static void update(); static void update();
static void sprite_modified(render_sprite_type_struct* sprite); static void sprite_modified(render_sprite_type_struct* sprite);
static render_sprite_type_struct* create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp, static render_sprite_type_struct* create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp,