1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-22 02:32:39 +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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 12 deletions

View File

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

View File

@ -42,17 +42,7 @@ void render::init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int h
else
gdrv::fill_bitmap(vscreen, vscreen->Width, vscreen->Height, 0, 0, 0);
{
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);
}
recreate_screen_texture();
}
void render::uninit()
@ -69,6 +59,25 @@ void render::uninit()
dirty_list.clear();
sprite_list.clear();
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()

View File

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