Optimize rendering: frame pacing, UI culling, render scale and GPU scratch buffers

This commit is contained in:
shen
2026-10-08 17:06:17 -07:00
parent d7adbb3014
commit 08cc8865be
5 changed files with 180 additions and 72 deletions
+24 -27
View File
@@ -570,6 +570,8 @@ Gr2SceneRenderer::Gr2SceneRenderer(int width, int height) {
m_view[i] = (i % 5 == 0) ? 1.0f : 0.0f;
m_proj[i] = (i % 5 == 0) ? 1.0f : 0.0f;
}
m_logicalWidth = width;
m_logicalHeight = height;
SetViewport(0, 0, width, height);
}
@@ -1147,13 +1149,8 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
// 3: Alpha-tested geometry (speedtree foliage, hair)
// 4: Translucent surfaces (water, glass) - sorted back-to-front
// 5: Additive particles, weapon shining, skill ribbons - sorted back-to-front
struct DrawOrder {
int priority = 1;
float depth = 0.0f;
const Render3DDraw* draw = nullptr;
};
std::vector<DrawOrder> sortedDraws;
sortedDraws.reserve(draws.size());
m_scratchSortedDraws.clear();
m_scratchSortedDraws.reserve(draws.size());
for (const auto& d : draws) {
DrawOrder ord;
@@ -1178,10 +1175,10 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
} else {
ord.priority = 1; // Opaque
}
sortedDraws.push_back(ord);
m_scratchSortedDraws.push_back(ord);
}
std::stable_sort(sortedDraws.begin(), sortedDraws.end(), [](const DrawOrder& a, const DrawOrder& b) {
std::stable_sort(m_scratchSortedDraws.begin(), m_scratchSortedDraws.end(), [](const DrawOrder& a, const DrawOrder& b) {
if (a.priority != b.priority) return a.priority < b.priority;
if (a.priority >= 4) return a.depth > b.depth; // Back-to-front for transparent / additive
return a.depth < b.depth; // Front-to-back for opaque
@@ -1191,16 +1188,9 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
float fog_g = static_cast<float>((m_fog_color >> 8) & 0xFF) / 255.0f;
float fog_b = static_cast<float>(m_fog_color & 0xFF) / 255.0f;
struct GpuTransformedVertex {
float x_clip, y_clip, z_clip, w_clip;
float x_screen, y_screen;
float u, v;
float r, g, b, a;
};
const float NEAR_W = 0.05f;
for (const auto& ord : sortedDraws) {
for (const auto& ord : m_scratchSortedDraws) {
const auto& draw = *ord.draw;
if (draw.indices.size() < 3 || draw.positions.size() < 9) continue;
if (draw.texture0.empty() && draw.diffuse.empty()) continue;
@@ -1222,7 +1212,8 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
float mat_a = std::clamp(draw.material_diffuse[3], 0.0f, 1.0f);
size_t num_verts = draw.positions.size() / 3;
std::vector<GpuTransformedVertex> xverts(num_verts);
m_scratchGpuXverts.resize(num_verts);
auto& xverts = m_scratchGpuXverts;
for (size_t i = 0; i < num_verts; ++i) {
float px = draw.positions[i * 3 + 0];
@@ -1299,10 +1290,12 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
xverts[i].a = va;
}
std::vector<SDL_Vertex> vertices;
std::vector<int> indices;
vertices.reserve(draw.indices.size());
indices.reserve(draw.indices.size());
m_scratchSdlVertices.clear();
m_scratchSdlIndices.clear();
m_scratchSdlVertices.reserve(draw.indices.size());
m_scratchSdlIndices.reserve(draw.indices.size());
auto& vertices = m_scratchSdlVertices;
auto& indices = m_scratchSdlIndices;
auto add_sdl_vertex = [&](const GpuTransformedVertex& gv) -> int {
SDL_Vertex sv;
@@ -1442,18 +1435,22 @@ bool Gr2SceneRenderer::ProjectToScreen(float worldX, float worldY, float worldZ,
float ndc_x = clip[0] * inv_w;
float ndc_y = clip[1] * inv_w;
if (ndc_x < -2.0f || ndc_x > 2.0f || ndc_y < -2.0f || ndc_y > 2.0f) return false;
screenX = static_cast<float>(m_viewport[0]) + (ndc_x + 1.0f) * 0.5f * static_cast<float>(m_viewport[2]);
screenY = static_cast<float>(m_viewport[1]) + (1.0f - ndc_y) * 0.5f * static_cast<float>(m_viewport[3]);
int targetW = m_logicalWidth > 0 ? m_logicalWidth : m_viewport[2];
int targetH = m_logicalHeight > 0 ? m_logicalHeight : m_viewport[3];
screenX = static_cast<float>(m_viewport[0]) + (ndc_x + 1.0f) * 0.5f * static_cast<float>(targetW);
screenY = static_cast<float>(m_viewport[1]) + (1.0f - ndc_y) * 0.5f * static_cast<float>(targetH);
return true;
}
bool Gr2SceneRenderer::ScreenToWorldRay(float screenX, float screenY, float rayOrig[3], float rayDir[3]) const {
if (m_viewport[2] <= 0 || m_viewport[3] <= 0) return false;
int targetW = m_logicalWidth > 0 ? m_logicalWidth : m_viewport[2];
int targetH = m_logicalHeight > 0 ? m_logicalHeight : m_viewport[3];
if (targetW <= 0 || targetH <= 0) return false;
if (std::abs(m_proj[0]) < 1e-6f || std::abs(m_proj[5]) < 1e-6f) return false;
// 1. Calculate NDC coordinates [-1, 1]
float ndc_x = (2.0f * (screenX - static_cast<float>(m_viewport[0]))) / static_cast<float>(m_viewport[2]) - 1.0f;
float ndc_y = 1.0f - (2.0f * (screenY - static_cast<float>(m_viewport[1]))) / static_cast<float>(m_viewport[3]);
float ndc_x = (2.0f * (screenX - static_cast<float>(m_viewport[0]))) / static_cast<float>(targetW) - 1.0f;
float ndc_y = 1.0f - (2.0f * (screenY - static_cast<float>(m_viewport[1]))) / static_cast<float>(targetH);
// 2. View space direction from D3D perspective projection
float w = m_proj[0];
+24
View File
@@ -105,6 +105,10 @@ public:
bool IsFogEnabled() const { return m_fog_enabled; }
uint32_t GetFogColor() const { return m_fog_color; }
void SetLogicalSize(int width, int height) { m_logicalWidth = width; m_logicalHeight = height; }
int GetLogicalWidth() const { return m_logicalWidth > 0 ? m_logicalWidth : m_viewport[2]; }
int GetLogicalHeight() const { return m_logicalHeight > 0 ? m_logicalHeight : m_viewport[3]; }
const float* GetViewMatrix() const { return m_view; }
const float* GetProjMatrix() const { return m_proj; }
const int* GetViewport() const { return m_viewport; }
@@ -130,14 +134,34 @@ private:
};
const TextureData* GetTexture(const std::string& texturePath);
struct GpuTransformedVertex {
float x_clip, y_clip, z_clip, w_clip;
float x_screen, y_screen;
float u, v;
float r, g, b, a;
};
struct DrawOrder {
int priority = 1;
float depth = 0.0f;
const Render3DDraw* draw = nullptr;
};
float m_eye[3] = {0.0f, 0.0f, 0.0f};
float m_view[16];
float m_proj[16];
int m_viewport[4];
int m_logicalWidth = 0;
int m_logicalHeight = 0;
std::vector<float> m_depthBuffer;
std::unordered_map<std::string, TextureData> m_textureCache;
std::unordered_map<std::string, SDL_Texture*> m_gpuTextureCache;
// Persistent scratch buffers to eliminate per-draw heap allocation churn in RenderSceneGPU
std::vector<DrawOrder> m_scratchSortedDraws;
std::vector<GpuTransformedVertex> m_scratchGpuXverts;
std::vector<SDL_Vertex> m_scratchSdlVertices;
std::vector<int> m_scratchSdlIndices;
bool m_fog_enabled = false;
uint32_t m_fog_color = 0xFFCCDDEE;
float m_fog_density = 0.0003f;
+33 -4
View File
@@ -143,7 +143,16 @@ namespace UI
{
if (!IsShow())
return;
OnRender();
long sw = 0, sh = 0;
CWindowManager::Instance().GetResolution(sw, sh);
const bool hasSize = (m_rect.right > m_rect.left) && (m_rect.bottom > m_rect.top);
const bool outOfScreen = (sw > 0 && sh > 0 && hasSize &&
(m_rect.right <= 0 || m_rect.left >= sw || m_rect.bottom <= 0 || m_rect.top >= sh));
if (!outOfScreen)
OnRender();
for (auto* child : m_pChildList)
child->Render();
}
@@ -687,6 +696,18 @@ namespace UI
break;
}
long sw = 0, sh = 0;
CWindowManager::Instance().GetResolution(sw, sh);
if (sw > 0 && sh > 0)
{
float totalW = textWidth + (m_showCursor ? (charWidth + 4.0f) : 0.0f);
if (startX + totalW <= 0.0f || startX >= static_cast<float>(sw) ||
startY + textHeight <= 0.0f || startY >= static_cast<float>(sh))
{
return;
}
}
uint8_t a = (m_color >> 24) & 0xff;
uint8_t r = (m_color >> 16) & 0xff;
uint8_t g = (m_color >> 8) & 0xff;
@@ -2532,10 +2553,21 @@ namespace UI
CGraphicDevice* pDevice = CGraphicDevice::InstancePtr();
SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr;
float curTime = CTimer::Instance().GetCurrentSecond();
long sw = 0, sh = 0;
CWindowManager::Instance().GetResolution(sw, sh);
for (auto& pair : m_slotMap) {
SSlot& slot = pair.second;
BYTE itemW = slot.byxPlacedItemSize ? slot.byxPlacedItemSize : 1;
BYTE itemH = slot.byyPlacedItemSize ? slot.byyPlacedItemSize : 1;
long slotX = m_rect.left + slot.ixPosition;
long slotY = m_rect.top + slot.iyPosition;
long slotW = std::max(static_cast<long>(itemW * 32), static_cast<long>(slot.ixCellSize));
long slotH = std::max(static_cast<long>(itemH * 32), static_cast<long>(slot.iyCellSize));
if (sw > 0 && sh > 0 && (slotX + slotW <= 0 || slotX >= sw || slotY + slotH <= 0 || slotY >= sh))
continue;
if (slot.pSlotButton)
slot.pSlotButton->SetPosition(slot.ixPosition + 1, slot.iyPosition + 19);
@@ -2558,9 +2590,6 @@ namespace UI
continue;
}
BYTE itemW = slot.byxPlacedItemSize ? slot.byxPlacedItemSize : 1;
BYTE itemH = slot.byyPlacedItemSize ? slot.byyPlacedItemSize : 1;
if (ren) {
if (slot.dwState & SLOT_STATE_CANT_MOUSE_EVENT) {
SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND);
+91 -41
View File
@@ -42,6 +42,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <thread>
namespace {
struct Field { const char* label;std::string value;std::size_t max;bool secret=false; };
@@ -104,7 +105,12 @@ int SDLKeyToDIK(SDL_Keycode key) {
int main(int argc, char** argv) {
try {
int frame_limit = 0, auto_slot = -1;
int frame_limit = 0, auto_slot = -1, fps_cap = -1;
#ifdef __ANDROID__
float render_scale = 0.75f;
#else
float render_scale = 1.0f;
#endif
bool auto_connect = false, until_loading = false, until_select = false, until_game = false;
bool use_gpu_raster = true, preview_data = false;
std::string stdlib, script_root, view_script, screenshot;
@@ -118,6 +124,8 @@ int main(int argc, char** argv) {
return argv[++i];
};
if (arg == "--frames") { frame_limit = std::stoi(next()); if (frame_limit < 1) throw std::invalid_argument("frames must be positive"); }
else if (arg == "--fps-cap") { fps_cap = std::max(0, std::stoi(next())); }
else if (arg == "--render-scale") { render_scale = std::stof(next()); }
else if (arg == "--stdlib") stdlib = next();
else if (arg == "--python-root") script_root = next();
else if (arg == "--login-ui") view_script = next();
@@ -135,9 +143,21 @@ int main(int argc, char** argv) {
else if (arg == "--until-game") until_game = true;
else if (arg == "--preview-data") preview_data = true;
else if (arg == "--software-raster") use_gpu_raster = false;
else throw std::invalid_argument("Usage: ava2_client [--frames N] [--stdlib ZIP --python-root DIR] [--login-ui SCRIPT | --phase login|select|create|loading|game] [--auth-host HOST --auth-port PORT --game-host HOST --game-port PORT --account ACCOUNT] [--auto-connect] [--auto-select 0..4] [--until-select|--until-loading|--until-game] [--software-raster] [--screenshot FILE.bmp]");
else throw std::invalid_argument("Usage: ava2_client [--frames N] [--fps-cap N] [--render-scale 0.25..1] [--stdlib ZIP --python-root DIR] [--login-ui SCRIPT | --phase login|select|create|loading|game] [--auth-host HOST --auth-port PORT --game-host HOST --game-port PORT --account ACCOUNT] [--auto-connect] [--auto-select 0..4] [--until-select|--until-loading|--until-game] [--software-raster] [--screenshot FILE.bmp]");
}
if (fps_cap < 0) {
if (const char* env = std::getenv("MT_FPS_CAP")) fps_cap = std::max(0, std::atoi(env));
else if (const char* env = std::getenv("AVA2_FPS_CAP")) fps_cap = std::max(0, std::atoi(env));
}
if (fps_cap < 0) {
fps_cap = (frame_limit > 0) ? 0 : 60;
}
if (const char* env = std::getenv("MT_RENDER_SCALE")) render_scale = std::stof(env);
else if (const char* env = std::getenv("AVA2_RENDER_SCALE")) render_scale = std::stof(env);
render_scale = std::clamp(render_scale, 0.25f, 1.0f);
// Auto-discover resource directories if not explicitly supplied
if (stdlib.empty()) {
if (std::filesystem::exists("python27.zip")) stdlib = "python27.zip";
@@ -230,7 +250,8 @@ int main(int argc, char** argv) {
SDL_SetRenderVSync(renderer.get(), 1);
SDL_StartTextInput(window.get());
float dpi_scale = SDL_GetWindowPixelDensity(window.get());
SDL_Log("AVA2 host started: platform=%s GPU=%s Retina_DPI=%.2fx", SDL_GetPlatform(), SDL_GetGPUDeviceDriver(gpu.get()), dpi_scale);
SDL_Log("AVA2 host started: platform=%s GPU=%s Retina_DPI=%.2fx FPS_Cap=%d RenderScale=%.2f",
SDL_GetPlatform(), SDL_GetGPUDeviceDriver(gpu.get()), dpi_scale, fps_cap, render_scale);
bool running = true, requested = false, entered = false;
int frames = 0, focus = 4;
@@ -331,11 +352,14 @@ int main(int argc, char** argv) {
}
}
const int view3d_w = 1280;
const int view3d_h = 720;
const int view3d_w = std::max(320, static_cast<int>(std::round(screen_width * render_scale)));
const int view3d_h = std::max(180, static_cast<int>(std::round(screen_height * render_scale)));
std::unique_ptr<ava2::Gr2SceneRenderer> renderer3d;
std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)> surface3d(nullptr, SDL_DestroySurface);
std::unique_ptr<SDL_Texture, decltype(&SDL_DestroyTexture)> texture3d(nullptr, SDL_DestroyTexture);
std::unique_ptr<SDL_Texture, decltype(&SDL_DestroyTexture)> gpu_scene_texture(nullptr, SDL_DestroyTexture);
std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)> minimap_surface(nullptr, SDL_DestroySurface);
std::unique_ptr<SDL_Texture, decltype(&SDL_DestroyTexture)> minimap_texture(nullptr, SDL_DestroyTexture);
ava2::TerrainHeightmap outdoor_terrain;
std::string raw_path = "map/metin2_map_a1/001003/height.raw";
@@ -514,12 +538,20 @@ int main(int argc, char** argv) {
if (model3d) {
renderer3d = std::make_unique<ava2::Gr2SceneRenderer>(view3d_w, view3d_h);
renderer3d->SetLogicalSize(screen_width, screen_height);
renderer3d->SetCameraLookAt(0.0f, 130.0f, -320.0f, 0.0f, 100.0f, 0.0f, 0.0f, 1.0f, 0.0f);
renderer3d->SetPerspective(45.0f, static_cast<float>(view3d_w) / static_cast<float>(view3d_h), 1.0f, 4000.0f);
surface3d.reset(SDL_CreateSurface(view3d_w, view3d_h, SDL_PIXELFORMAT_ARGB8888));
texture3d.reset(SDL_CreateTexture(renderer.get(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, view3d_w, view3d_h));
if (texture3d) {
SDL_SetTextureBlendMode(texture3d.get(), SDL_BLENDMODE_BLEND);
SDL_SetTextureScaleMode(texture3d.get(), SDL_SCALEMODE_LINEAR);
}
if (use_gpu_raster && render_scale < 0.999f) {
gpu_scene_texture.reset(SDL_CreateTexture(renderer.get(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, view3d_w, view3d_h));
if (gpu_scene_texture) {
SDL_SetTextureScaleMode(gpu_scene_texture.get(), SDL_SCALEMODE_LINEAR);
}
}
ava2::TextTailManager::Instance().SetCurrentRenderer(renderer.get());
ava2::TextTailManager::Instance().SetCurrentSceneRenderer(renderer3d.get());
@@ -981,7 +1013,20 @@ int main(int argc, char** argv) {
std::string chat_input_buffer;
auto prev_frame_time = std::chrono::steady_clock::now();
auto cap_period = fps_cap > 0 ? std::chrono::nanoseconds(1'000'000'000LL / fps_cap)
: std::chrono::nanoseconds(0);
auto next_frame_at = std::chrono::steady_clock::now();
while (running && (!frame_limit || frames < frame_limit)) {
if (cap_period.count() > 0) {
const auto now = std::chrono::steady_clock::now();
if (next_frame_at > now) {
std::this_thread::sleep_until(next_frame_at);
} else if (now - next_frame_at > cap_period) {
next_frame_at = now;
}
next_frame_at += cap_period;
}
#ifdef AVA2_HAS_PYTHON
ava2::LoginViewSnapshot snapshot;
if (python && !view_script.empty()) {
@@ -1010,7 +1055,7 @@ int main(int argc, char** argv) {
wm->RunMouseLeftButtonDown(static_cast<long>(bx), static_cast<long>(by));
if (last_phase == "game" && renderer3d) {
// Ignore clicks on the minimap radar at top-right
bool is_minimap_area = (bx >= static_cast<float>(view3d_w) - 135.0f && by <= 140.0f);
bool is_minimap_area = (bx >= static_cast<float>(screen_width) - 135.0f && by <= 140.0f);
if (!is_minimap_area) {
// 1. Mouse picking on dropped items via TextTail
auto& ttm = ava2::TextTailManager::Instance();
@@ -1709,27 +1754,18 @@ int main(int argc, char** argv) {
uint32_t clear_col = (last_phase == "game") ? current_env.fog.GetColorUint() : 0x00000000;
if (use_gpu_raster) {
// High Performance Hardware-Accelerated GPU Pipeline (Metal / Vulkan via SDL_RenderGeometry)
if (gpu_scene_texture) {
SDL_SetRenderTarget(renderer.get(), gpu_scene_texture.get());
SDL_SetRenderDrawColor(renderer.get(), (clear_col >> 16) & 0xFF, (clear_col >> 8) & 0xFF, clear_col & 0xFF, (clear_col >> 24) & 0xFF);
SDL_RenderClear(renderer.get());
}
renderer3d->RenderSceneGPU(renderer.get(), draws);
// Render Minimap Radar HUD in game phase (modeled after 40250 CPythonMiniMap)
if (last_phase == "game") {
minimap_mgr.ClearBlips();
if (preview_data) {
if (!mob_dog.IsDead()) {
minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster);
}
if (!mob_metin.IsDead()) {
minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster);
}
}
minimap_mgr.AddBlip(60.0f, 140.0f, ava2::MinimapBlipType::NPC); // NPC
SDL_FillSurfaceRect(surface3d.get(), nullptr, 0x00000000);
minimap_mgr.RenderRadar(surface3d.get(), view3d_w - 132, 5, 128, player_world_x, player_world_z, player_world_yaw);
SDL_UpdateTexture(texture3d.get(), nullptr, surface3d->pixels, surface3d->pitch);
SDL_SetTextureBlendMode(texture3d.get(), SDL_BLENDMODE_BLEND);
SDL_FRect dst = { 0.0f, 0.0f, static_cast<float>(view3d_w), static_cast<float>(view3d_h) };
SDL_RenderTexture(renderer.get(), texture3d.get(), nullptr, &dst);
if (gpu_scene_texture) {
SDL_SetRenderTarget(renderer.get(), nullptr);
SDL_FRect dst = { 0.0f, 0.0f, static_cast<float>(screen_width), static_cast<float>(screen_height) };
SDL_RenderTexture(renderer.get(), gpu_scene_texture.get(), nullptr, &dst);
}
} else {
// CPU Software Rasterizer (Fallback & Headless verification)
@@ -1737,25 +1773,39 @@ int main(int argc, char** argv) {
renderer3d->Clear(clear_col, 1.0f);
renderer3d->RenderScene(surface3d.get(), draws);
// Render Minimap Radar HUD in game phase (modeled after 40250 CPythonMiniMap)
if (last_phase == "game") {
minimap_mgr.ClearBlips();
if (preview_data) {
if (!mob_dog.IsDead()) {
minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster);
}
if (!mob_metin.IsDead()) {
minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster);
}
}
minimap_mgr.AddBlip(60.0f, 140.0f, ava2::MinimapBlipType::NPC); // NPC
minimap_mgr.RenderRadar(surface3d.get(), view3d_w - 132, 5, 128, player_world_x, player_world_z, player_world_yaw);
}
SDL_UpdateTexture(texture3d.get(), nullptr, surface3d->pixels, surface3d->pitch);
SDL_FRect dst = { 0.0f, 0.0f, static_cast<float>(view3d_w), static_cast<float>(view3d_h) };
SDL_FRect dst = { 0.0f, 0.0f, static_cast<float>(screen_width), static_cast<float>(screen_height) };
SDL_RenderTexture(renderer.get(), texture3d.get(), nullptr, &dst);
}
// Render Minimap Radar HUD in game phase (modeled after 40250 CPythonMiniMap)
if (last_phase == "game") {
minimap_mgr.ClearBlips();
if (preview_data) {
if (!mob_dog.IsDead()) {
minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster);
}
if (!mob_metin.IsDead()) {
minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster);
}
}
minimap_mgr.AddBlip(60.0f, 140.0f, ava2::MinimapBlipType::NPC); // NPC
if (!minimap_surface) {
minimap_surface.reset(SDL_CreateSurface(128, 128, SDL_PIXELFORMAT_ARGB8888));
minimap_texture.reset(SDL_CreateTexture(renderer.get(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 128, 128));
if (minimap_texture) {
SDL_SetTextureBlendMode(minimap_texture.get(), SDL_BLENDMODE_BLEND);
}
}
if (minimap_surface && minimap_texture) {
SDL_FillSurfaceRect(minimap_surface.get(), nullptr, 0x00000000);
minimap_mgr.RenderRadar(minimap_surface.get(), 0, 0, 128, player_world_x, player_world_z, player_world_yaw);
SDL_UpdateTexture(minimap_texture.get(), nullptr, minimap_surface->pixels, minimap_surface->pitch);
SDL_FRect dst = { static_cast<float>(screen_width - 132), 5.0f, 128.0f, 128.0f };
SDL_RenderTexture(renderer.get(), minimap_texture.get(), nullptr, &dst);
}
}
}
}