mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #5103: OpenGL: ride track preview not rendered
This commit is contained in:
parent
6098c1c3cc
commit
f842d8a693
|
@ -9,6 +9,7 @@
|
|||
- Feature: [#9154] Change map toolbar icon with current viewport rotation.
|
||||
- Change: [#7877] Files are now sorted in logical rather than dictionary order.
|
||||
- Change: [#8688] Move common actions from debug menu into cheats menu.
|
||||
- Fix: [#5103] OpenGL: ride track preview not rendered.
|
||||
- Fix: [#5579] Network desync immediately after connecting.
|
||||
- Fix: [#5893] Looking at guest window tabs other than the main tab eventually causes assertion.
|
||||
- Fix: [#5905] Urban Park merry-go-round has entrance and exit swapped (original bug).
|
||||
|
|
|
@ -148,6 +148,7 @@ public:
|
|||
{
|
||||
_window = (SDL_Window*)_uiContext->GetWindow();
|
||||
_drawingContext = new OpenGLDrawingContext(this);
|
||||
_bitsDPI.DrawingEngine = this;
|
||||
# ifdef __ENABLE_LIGHTFX__
|
||||
lightfx_set_available(false);
|
||||
# endif
|
||||
|
|
|
@ -238,6 +238,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
g1temp.height = 217;
|
||||
g1temp.flags = G1_FLAG_BMP;
|
||||
gfx_set_g1_element(SPR_TEMP, &g1temp);
|
||||
drawing_engine_invalidate_image(SPR_TEMP);
|
||||
gfx_draw_sprite(dpi, SPR_TEMP, x, y, 0);
|
||||
|
||||
x = w->x + (widget->left + widget->right) / 2;
|
||||
|
|
|
@ -544,20 +544,14 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
x = w->x + (widget->left + widget->right) / 2;
|
||||
y = w->y + (widget->top + widget->bottom) / 2;
|
||||
|
||||
if (drawing_engine_get_type() != DRAWING_ENGINE_OPENGL)
|
||||
{
|
||||
rct_g1_element g1temp = {};
|
||||
g1temp.offset = _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * TRACK_PREVIEW_IMAGE_SIZE);
|
||||
g1temp.width = 370;
|
||||
g1temp.height = 217;
|
||||
g1temp.flags = G1_FLAG_BMP;
|
||||
gfx_set_g1_element(SPR_TEMP, &g1temp);
|
||||
gfx_draw_sprite(dpi, SPR_TEMP, trackPreviewX, trackPreviewY, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx_draw_string_centred_clipped(dpi, STR_NOT_SUPPPORTED_IN_OPENGL, nullptr, COLOUR_BLACK, x, y, 368);
|
||||
}
|
||||
rct_g1_element g1temp = {};
|
||||
g1temp.offset = _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * TRACK_PREVIEW_IMAGE_SIZE);
|
||||
g1temp.width = 370;
|
||||
g1temp.height = 217;
|
||||
g1temp.flags = G1_FLAG_BMP;
|
||||
gfx_set_g1_element(SPR_TEMP, &g1temp);
|
||||
drawing_engine_invalidate_image(SPR_TEMP);
|
||||
gfx_draw_sprite(dpi, SPR_TEMP, trackPreviewX, trackPreviewY, 0);
|
||||
|
||||
y = w->y + widget->bottom - 12;
|
||||
|
||||
|
@ -810,10 +804,7 @@ static bool track_list_load_design_for_preview(utf8* path)
|
|||
_loadedTrackDesign = track_design_open(path);
|
||||
if (_loadedTrackDesign != nullptr)
|
||||
{
|
||||
if (drawing_engine_get_type() != DRAWING_ENGINE_OPENGL)
|
||||
{
|
||||
track_design_draw_preview(_loadedTrackDesign, _trackDesignPreviewPixels.data());
|
||||
}
|
||||
track_design_draw_preview(_loadedTrackDesign, _trackDesignPreviewPixels.data());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -619,7 +619,7 @@ void FASTCALL gfx_draw_sprite_palette_set_software(
|
|||
|
||||
if (dpi->zoom_level != 0 && (g1->flags & G1_FLAG_HAS_ZOOM_SPRITE))
|
||||
{
|
||||
rct_drawpixelinfo zoomed_dpi;
|
||||
rct_drawpixelinfo zoomed_dpi = *dpi;
|
||||
zoomed_dpi.bits = dpi->bits;
|
||||
zoomed_dpi.x = dpi->x >> 1;
|
||||
zoomed_dpi.y = dpi->y >> 1;
|
||||
|
|
|
@ -591,12 +591,7 @@ bool clip_drawpixelinfo(rct_drawpixelinfo* dst, rct_drawpixelinfo* src, int32_t
|
|||
int32_t right = x + width;
|
||||
int32_t bottom = y + height;
|
||||
|
||||
dst->bits = src->bits;
|
||||
dst->x = src->x;
|
||||
dst->y = src->y;
|
||||
dst->width = src->width;
|
||||
dst->height = src->height;
|
||||
dst->pitch = src->pitch;
|
||||
*dst = *src;
|
||||
dst->zoom_level = 0;
|
||||
|
||||
if (x > dst->x)
|
||||
|
|
|
@ -18,6 +18,11 @@ namespace OpenRCT2
|
|||
interface IPlatformEnvironment;
|
||||
}
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
interface IDrawingEngine;
|
||||
}
|
||||
|
||||
struct rct_g1_element
|
||||
{
|
||||
uint8_t* offset; // 0x00
|
||||
|
@ -31,13 +36,15 @@ struct rct_g1_element
|
|||
|
||||
struct rct_drawpixelinfo
|
||||
{
|
||||
uint8_t* bits; // 0x00
|
||||
int16_t x; // 0x04
|
||||
int16_t y; // 0x06
|
||||
int16_t width; // 0x08
|
||||
int16_t height; // 0x0A
|
||||
int16_t pitch; // 0x0C note: this is actually (pitch - width)
|
||||
uint16_t zoom_level; // 0x0E
|
||||
uint8_t* bits{};
|
||||
int16_t x{};
|
||||
int16_t y{};
|
||||
int16_t width{};
|
||||
int16_t height{};
|
||||
int16_t pitch{}; // note: this is actually (pitch - width)
|
||||
uint16_t zoom_level{};
|
||||
|
||||
OpenRCT2::Drawing::IDrawingEngine* DrawingEngine{};
|
||||
};
|
||||
|
||||
struct rct_g1_element_32bit
|
||||
|
|
|
@ -170,8 +170,7 @@ void lightfx_update_buffers(rct_drawpixelinfo* info)
|
|||
{
|
||||
_light_rendered_buffer_front = realloc(_light_rendered_buffer_front, info->width * info->height);
|
||||
_light_rendered_buffer_back = realloc(_light_rendered_buffer_back, info->width * info->height);
|
||||
|
||||
std::memcpy(&_pixelInfo, info, sizeof(rct_drawpixelinfo));
|
||||
_pixelInfo = *info;
|
||||
}
|
||||
|
||||
extern void viewport_paint_setup();
|
||||
|
|
|
@ -170,7 +170,7 @@ void gfx_draw_all_dirty_blocks()
|
|||
|
||||
void gfx_clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -180,7 +180,7 @@ void gfx_clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
|
|||
|
||||
void gfx_fill_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t colour)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -191,7 +191,7 @@ void gfx_fill_rect(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t ri
|
|||
void gfx_filter_rect(
|
||||
rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, FILTER_PALETTE_ID palette)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -201,7 +201,7 @@ void gfx_filter_rect(
|
|||
|
||||
void gfx_draw_line(rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t colour)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -211,7 +211,7 @@ void gfx_draw_line(rct_drawpixelinfo* dpi, int32_t x1, int32_t y1, int32_t x2, i
|
|||
|
||||
void FASTCALL gfx_draw_sprite(rct_drawpixelinfo* dpi, int32_t image, int32_t x, int32_t y, uint32_t tertiary_colour)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -221,7 +221,7 @@ void FASTCALL gfx_draw_sprite(rct_drawpixelinfo* dpi, int32_t image, int32_t x,
|
|||
|
||||
void FASTCALL gfx_draw_glpyh(rct_drawpixelinfo* dpi, int32_t image, int32_t x, int32_t y, uint8_t* palette)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -231,7 +231,7 @@ void FASTCALL gfx_draw_glpyh(rct_drawpixelinfo* dpi, int32_t image, int32_t x, i
|
|||
|
||||
void FASTCALL gfx_draw_sprite_raw_masked(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t maskImage, int32_t colourImage)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
@ -241,7 +241,7 @@ void FASTCALL gfx_draw_sprite_raw_masked(rct_drawpixelinfo* dpi, int32_t x, int3
|
|||
|
||||
void FASTCALL gfx_draw_sprite_solid(rct_drawpixelinfo* dpi, int32_t image, int32_t x, int32_t y, uint8_t colour)
|
||||
{
|
||||
auto drawingEngine = GetDrawingEngine();
|
||||
auto drawingEngine = dpi->DrawingEngine;
|
||||
if (drawingEngine != nullptr)
|
||||
{
|
||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
||||
|
|
|
@ -49,15 +49,10 @@ static void scrolling_text_set_bitmap_for_ttf(
|
|||
void scrolling_text_initialise_bitmaps()
|
||||
{
|
||||
uint8_t drawingSurface[64];
|
||||
rct_drawpixelinfo dpi = {
|
||||
/* .bits = */ (uint8_t*)&drawingSurface,
|
||||
/* .x = */ 0,
|
||||
/* .y = */ 0,
|
||||
/* .width = */ 8,
|
||||
/* .height = */ 8,
|
||||
/* .pitch = */ 0,
|
||||
/* .zoom_level = */ 0,
|
||||
};
|
||||
rct_drawpixelinfo dpi;
|
||||
dpi.bits = (uint8_t*)&drawingSurface;
|
||||
dpi.width = 8;
|
||||
dpi.height = 8;
|
||||
|
||||
for (int32_t i = 0; i < FONT_SPRITE_GLYPH_COUNT; i++)
|
||||
{
|
||||
|
|
|
@ -131,6 +131,7 @@ void X8RainDrawer::Restore()
|
|||
X8DrawingEngine::X8DrawingEngine([[maybe_unused]] const std::shared_ptr<Ui::IUiContext>& uiContext)
|
||||
{
|
||||
_drawingContext = new X8DrawingContext(this);
|
||||
_bitsDPI.DrawingEngine = this;
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
lightfx_set_available(true);
|
||||
_lastLightFXenabled = (gConfigGeneral.enable_light_fx != 0);
|
||||
|
|
|
@ -903,7 +903,7 @@ void viewport_paint(
|
|||
y >>= viewport->zoom;
|
||||
y += viewport->y;
|
||||
|
||||
rct_drawpixelinfo dpi1;
|
||||
rct_drawpixelinfo dpi1 = *dpi;
|
||||
dpi1.bits = dpi->bits + (x - dpi->x) + ((y - dpi->y) * (dpi->width + dpi->pitch));
|
||||
dpi1.x = left;
|
||||
dpi1.y = top;
|
||||
|
|
|
@ -2098,7 +2098,7 @@ bool window_is_visible(rct_window* w)
|
|||
*/
|
||||
void window_draw_all(rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom)
|
||||
{
|
||||
rct_drawpixelinfo windowDPI;
|
||||
rct_drawpixelinfo windowDPI = *dpi;
|
||||
windowDPI.bits = dpi->bits + left + ((dpi->width + dpi->pitch) * top);
|
||||
windowDPI.x = left;
|
||||
windowDPI.y = top;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "../audio/audio.h"
|
||||
#include "../core/File.h"
|
||||
#include "../core/String.hpp"
|
||||
#include "../drawing/X8DrawingEngine.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../management/Finance.h"
|
||||
|
@ -54,6 +55,9 @@
|
|||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
struct map_backup
|
||||
{
|
||||
TileElement tile_elements[MAX_TILE_ELEMENTS];
|
||||
|
@ -2245,6 +2249,9 @@ void track_design_draw_preview(rct_track_td6* td6, uint8_t* pixels)
|
|||
dpi.pitch = 0;
|
||||
dpi.bits = pixels;
|
||||
|
||||
auto drawingEngine = std::make_unique<X8DrawingEngine>(GetContext()->GetUiContext());
|
||||
dpi.DrawingEngine = drawingEngine.get();
|
||||
|
||||
CoordsXY offset = { size_x / 2, size_y / 2 };
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue