#define SETUP_TOKEN_FULLSCREEN 17
#define SETUP_TOKEN_WINDOW_SCALING_PERCENT 18
#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 19
-#define SETUP_TOKEN_ASK_ON_ESCAPE 20
-#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 21
-#define SETUP_TOKEN_QUICK_SWITCH 22
-#define SETUP_TOKEN_INPUT_ON_FOCUS 23
-#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 24
-#define SETUP_TOKEN_GAME_FRAME_DELAY 25
-#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 26
-#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 27
-#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS 28
-#define SETUP_TOKEN_GRAPHICS_SET 29
-#define SETUP_TOKEN_SOUNDS_SET 30
-#define SETUP_TOKEN_MUSIC_SET 31
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 32
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 33
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 34
-#define SETUP_TOKEN_VOLUME_SIMPLE 35
-#define SETUP_TOKEN_VOLUME_LOOPS 36
-#define SETUP_TOKEN_VOLUME_MUSIC 37
-#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 38
-#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 39
-#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 40
-
-#define NUM_GLOBAL_SETUP_TOKENS 41
+#define SETUP_TOKEN_SCREEN_RENDERING_MODE 20
+#define SETUP_TOKEN_ASK_ON_ESCAPE 21
+#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 22
+#define SETUP_TOKEN_QUICK_SWITCH 23
+#define SETUP_TOKEN_INPUT_ON_FOCUS 24
+#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 25
+#define SETUP_TOKEN_GAME_FRAME_DELAY 26
+#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 27
+#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 28
+#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS 29
+#define SETUP_TOKEN_GRAPHICS_SET 30
+#define SETUP_TOKEN_SOUNDS_SET 31
+#define SETUP_TOKEN_MUSIC_SET 32
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 33
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 34
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 35
+#define SETUP_TOKEN_VOLUME_SIMPLE 36
+#define SETUP_TOKEN_VOLUME_LOOPS 37
+#define SETUP_TOKEN_VOLUME_MUSIC 38
+#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 39
+#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 40
+#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 41
+
+#define NUM_GLOBAL_SETUP_TOKENS 42
/* editor setup */
#define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0
{ TYPE_SWITCH, &si.fullscreen, "fullscreen" },
{ TYPE_INTEGER,&si.window_scaling_percent, "window_scaling_percent" },
{ TYPE_STRING, &si.window_scaling_quality, "window_scaling_quality" },
+ { TYPE_STRING, &si.screen_rendering_mode, "screen_rendering_mode" },
{ TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" },
{ TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" },
{ TYPE_SWITCH, &si.quick_switch, "quick_player_switch" },
si->fullscreen = FALSE;
si->window_scaling_percent = STD_WINDOW_SCALING_PERCENT;
si->window_scaling_quality = getStringCopy(SCALING_QUALITY_DEFAULT);
+ si->screen_rendering_mode = getStringCopy(STR_SPECIAL_RENDERING_DEFAULT);
si->ask_on_escape = TRUE;
si->ask_on_escape_editor = TRUE;
si->quick_switch = FALSE;
/* SDL internal variables */
#if defined(TARGET_SDL2)
-#define USE_TARGET_TEXTURE TRUE
-#define USE_TARGET_TEXTURE_ONLY FALSE
-
static SDL_Window *sdl_window = NULL;
static SDL_Renderer *sdl_renderer = NULL;
-#if USE_TARGET_TEXTURE
static SDL_Texture *sdl_texture_stream = NULL;
static SDL_Texture *sdl_texture_target = NULL;
-#else
-static SDL_Texture *sdl_texture = NULL;
-#endif
static boolean fullscreen_enabled = FALSE;
#endif
}
#endif
-#if USE_FINAL_SCREEN_BITMAP
- if (gfx.final_screen_bitmap != NULL) // may not be initialized yet
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_BITMAP &&
+ gfx.final_screen_bitmap != NULL) // may not be initialized yet
{
- // !!! TEST !!!
// draw global animations using bitmaps instead of using textures
// to prevent texture scaling artefacts (this is potentially slower)
// force full window redraw
rect = NULL;
}
-#endif
-#if USE_TARGET_TEXTURE
-#if USE_TARGET_TEXTURE_ONLY
- SDL_Texture *sdl_texture = sdl_texture_target;
-#else
+#if defined(TARGET_SDL2)
SDL_Texture *sdl_texture = sdl_texture_stream;
-#endif
-#endif
-#if defined(TARGET_SDL2)
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_TARGET)
+ sdl_texture = sdl_texture_target;
+
if (rect)
{
int bytes_x = screen->pitch / video.width;
// clear render target buffer
SDL_RenderClear(sdl_renderer);
-#if USE_TARGET_TEXTURE
- SDL_SetRenderTarget(sdl_renderer, sdl_texture_target);
+ // set renderer to use target texture for rendering
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_TARGET ||
+ video.screen_rendering_mode == SPECIAL_RENDERING_DOUBLE)
+ SDL_SetRenderTarget(sdl_renderer, sdl_texture_target);
- // copy backbuffer to render target buffer
- if (sdl_texture != sdl_texture_target)
- SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
-#else
- // copy backbuffer to render target buffer
- SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
-#endif
+ // copy backbuffer texture to render target buffer
+ if (video.screen_rendering_mode != SPECIAL_RENDERING_TARGET)
+ SDL_RenderCopy(sdl_renderer, sdl_texture_stream, NULL, NULL);
-#if !USE_FINAL_SCREEN_BITMAP
- FinalizeScreen();
-#endif
+ if (video.screen_rendering_mode != SPECIAL_RENDERING_BITMAP)
+ FinalizeScreen();
-#if USE_TARGET_TEXTURE
- SDL_SetRenderTarget(sdl_renderer, NULL);
- SDL_RenderCopy(sdl_renderer, sdl_texture_target, NULL, NULL);
-#endif
+ // when using target texture, copy it to screen buffer
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_TARGET ||
+ video.screen_rendering_mode == SPECIAL_RENDERING_DOUBLE)
+ {
+ SDL_SetRenderTarget(sdl_renderer, NULL);
+ SDL_RenderCopy(sdl_renderer, sdl_texture_target, NULL, NULL);
+ }
// show render target buffer on screen
SDL_RenderPresent(sdl_renderer);
{
video.window_scaling_percent = setup.window_scaling_percent;
video.window_scaling_quality = setup.window_scaling_quality;
+ video.screen_rendering_mode =
+ (strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_BITMAP) ?
+ SPECIAL_RENDERING_BITMAP :
+ strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_TARGET) ?
+ SPECIAL_RENDERING_TARGET:
+ strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_DOUBLE) ?
+ SPECIAL_RENDERING_DOUBLE : SPECIAL_RENDERING_OFF);
#if defined(TARGET_SDL2)
// SDL 2.0: support for (desktop) fullscreen mode available
video.window_width = window_scaling_factor * width;
video.window_height = window_scaling_factor * height;
-#if USE_TARGET_TEXTURE
if (sdl_texture_stream)
{
SDL_DestroyTexture(sdl_texture_stream);
SDL_DestroyTexture(sdl_texture_target);
sdl_texture_target = NULL;
}
-#else
- if (sdl_texture)
- {
- SDL_DestroyTexture(sdl_texture);
- sdl_texture = NULL;
- }
-#endif
if (!(fullscreen && fullscreen_enabled))
{
// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setup.window_scaling_quality);
-#if USE_TARGET_TEXTURE
sdl_texture_stream = SDL_CreateTexture(sdl_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_TARGET,
width, height);
-#else
- sdl_texture = SDL_CreateTexture(sdl_renderer,
- SDL_PIXELFORMAT_ARGB8888,
- SDL_TEXTUREACCESS_STREAMING,
- width, height);
-#endif
-#if USE_TARGET_TEXTURE
if (sdl_texture_stream != NULL &&
sdl_texture_target != NULL)
-#else
- if (sdl_texture != NULL)
-#endif
{
// use SDL default values for RGB masks and no alpha channel
new_surface = SDL_CreateRGBSurface(0, width, height, 32, 0,0,0, 0);
video.fullscreen_enabled = FALSE;
video.window_scaling_percent = setup.window_scaling_percent;
video.window_scaling_quality = setup.window_scaling_quality;
+ video.screen_rendering_mode =
+ (strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_BITMAP) ?
+ SPECIAL_RENDERING_BITMAP :
+ strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_TARGET) ?
+ SPECIAL_RENDERING_TARGET:
+ strEqual(setup.screen_rendering_mode, STR_SPECIAL_RENDERING_DOUBLE) ?
+ SPECIAL_RENDERING_DOUBLE : SPECIAL_RENDERING_OFF);
}
}
void SDLSetWindowScalingQuality(char *window_scaling_quality)
{
-#if USE_TARGET_TEXTURE
SDL_Texture *new_texture;
if (sdl_texture_stream == NULL ||
SDLRedrawWindow();
-#else
- if (sdl_texture == NULL)
- return;
-
- SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, window_scaling_quality);
-
- SDL_Texture *new_texture = SDL_CreateTexture(sdl_renderer,
- SDL_PIXELFORMAT_ARGB8888,
- SDL_TEXTUREACCESS_STREAMING,
- video.width, video.height);
-
- if (new_texture != NULL)
- {
- SDL_DestroyTexture(sdl_texture);
-
- sdl_texture = new_texture;
-
- SDLRedrawWindow();
- }
-#endif
-
video.window_scaling_quality = window_scaling_quality;
}
#define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE
#endif
-#if defined(TARGET_SDL2)
-#define USE_FINAL_SCREEN_BITMAP FALSE
-#else
-#define USE_FINAL_SCREEN_BITMAP TRUE
-#endif
-
#define CURSOR_MAX_WIDTH 32
#define CURSOR_MAX_HEIGHT 32
ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH);
#if defined(TARGET_SDL2)
-#if USE_FINAL_SCREEN_BITMAP
ReCreateBitmap(&gfx.final_screen_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH);
-#endif
#endif
ReCreateBitmap(&gfx.fade_bitmap_source, win_xsize, win_ysize, DEFAULT_DEPTH);
if (bitmap == NULL)
return;
-#if USE_FINAL_SCREEN_BITMAP
- BlitBitmap(bitmap, gfx.final_screen_bitmap, src_x, src_y,
- width, height, dst_x, dst_y);
-#else
- BlitTexture(bitmap, src_x, src_y, width, height, dst_x, dst_y);
-#endif
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_BITMAP)
+ BlitBitmap(bitmap, gfx.final_screen_bitmap, src_x, src_y,
+ width, height, dst_x, dst_y);
+ else
+ BlitTexture(bitmap, src_x, src_y, width, height, dst_x, dst_y);
}
void BlitToScreenMasked(Bitmap *bitmap,
if (bitmap == NULL)
return;
-#if USE_FINAL_SCREEN_BITMAP
- BlitBitmapMasked(bitmap, gfx.final_screen_bitmap, src_x, src_y,
- width, height, dst_x, dst_y);
-#else
- BlitTextureMasked(bitmap, src_x, src_y, width, height, dst_x, dst_y);
-#endif
+ if (video.screen_rendering_mode == SPECIAL_RENDERING_BITMAP)
+ BlitBitmapMasked(bitmap, gfx.final_screen_bitmap, src_x, src_y,
+ width, height, dst_x, dst_y);
+ else
+ BlitTextureMasked(bitmap, src_x, src_y, width, height, dst_x, dst_y);
}
void DrawSimpleBlackLine(Bitmap *bitmap, int from_x, int from_y,
#define SCALING_QUALITY_DEFAULT SCALING_QUALITY_LINEAR
+/* values for screen rendering mode */
+#define STR_SPECIAL_RENDERING_OFF "stream_texture_only"
+#define STR_SPECIAL_RENDERING_BITMAP "bitmap_and_stream_texture"
+#define STR_SPECIAL_RENDERING_TARGET "target_texture_only"
+#define STR_SPECIAL_RENDERING_DOUBLE "stream_and_target_texture"
+
+#if defined(TARGET_SDL2)
+#define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_DOUBLE
+#else
+#define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_BITMAP
+#endif
+
+#define SPECIAL_RENDERING_OFF 0
+#define SPECIAL_RENDERING_BITMAP 1
+#define SPECIAL_RENDERING_TARGET 2
+#define SPECIAL_RENDERING_DOUBLE 3
+
+#if defined(TARGET_SDL2)
+#define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_DOUBLE
+#else
+#define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_BITMAP
+#endif
+
/* values for touch control */
#define TOUCH_CONTROL_VIRTUAL_BUTTONS "virtual_buttons"
#define TOUCH_CONTROL_WIPE_GESTURES "wipe_gestures"
boolean window_scaling_available;
int window_scaling_percent;
char *window_scaling_quality;
+ int screen_rendering_mode;
boolean initialized;
};
int fade_border_target_status;
Bitmap *masked_border_bitmap_ptr;
-#if USE_FINAL_SCREEN_BITMAP
Bitmap *final_screen_bitmap;
-#endif
boolean clipping_enabled;
int clip_x, clip_y;
boolean fullscreen;
int window_scaling_percent;
char *window_scaling_quality;
+ char *screen_rendering_mode;
boolean ask_on_escape;
boolean ask_on_escape_editor;
boolean quick_switch;