mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
output: read vertex buffer size from level (#1400)
This replaces the fixed vertex buffer size of 1500 with a maximum value read from the level - so the "biggest" room, object or static mesh determines the array size. Resolves #1398.
This commit is contained in:
parent
f44cbcfdac
commit
d0ba0e5751
7 changed files with 49 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
|||
- fixed lightning rendering z-buffer issues (#1385, regression from 1.4)
|
||||
- fixed possible game crashes if more than 16 savegame slots are set (#1374)
|
||||
- fixed savegame slots higher than 64 not working (#1395)
|
||||
- fixed a crash in custom levels if a room had more than 1500 vertices (#1398)
|
||||
|
||||
## [4.1.2](https://github.com/LostArtefacts/TR1X/compare/4.1.1...4.1.2) - 2024-04-28
|
||||
- fixed pictures display time (#1349, regression from 4.1)
|
||||
|
|
|
@ -458,6 +458,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
|
|||
- expanded moveable limit from 256 to 10240
|
||||
- expanded maximum textures from 2048 to 8192
|
||||
- expanded maximum texture pages from 32 to 128
|
||||
- expanded maximum vertices of a single drawable object from 1500 to unlimited
|
||||
- expanded the number of visible enemies from 8 to 32
|
||||
- ported audio decoding library to ffmpeg
|
||||
- ported video decoding library to ffmpeg
|
||||
|
|
|
@ -50,6 +50,7 @@ static const char *GameBuf_GetBufferName(GAME_BUFFER buffer)
|
|||
case GBUF_SAMPLES: return "Samples";
|
||||
case GBUF_TRAP_DATA: return "Trap data";
|
||||
case GBUF_CREATURE_DATA: return "Creature data";
|
||||
case GBUF_VERTEX_BUFFER: return "Vertex buffer";
|
||||
}
|
||||
// clang-format on
|
||||
return "Unknown";
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum GAME_BUFFER {
|
|||
GBUF_SAMPLES,
|
||||
GBUF_TRAP_DATA,
|
||||
GBUF_CREATURE_DATA,
|
||||
GBUF_VERTEX_BUFFER,
|
||||
} GAME_BUFFER;
|
||||
|
||||
void GameBuf_Init(void);
|
||||
|
|
|
@ -54,6 +54,7 @@ static bool Level_LoadTexturePages(MYFILE *fp);
|
|||
static bool Level_LoadFromFile(
|
||||
const char *filename, int32_t level_num, bool is_demo);
|
||||
static void Level_CompleteSetup(int32_t level_num);
|
||||
static size_t Level_CalculateMaxVertices(void);
|
||||
|
||||
static bool Level_LoadFromFile(
|
||||
const char *filename, int32_t level_num, bool is_demo)
|
||||
|
@ -890,6 +891,10 @@ static void Level_CompleteSetup(int32_t level_num)
|
|||
// Configure enemies who carry and drop items
|
||||
Carrier_InitialiseLevel(level_num);
|
||||
|
||||
const size_t max_vertices = Level_CalculateMaxVertices();
|
||||
LOG_INFO("Maximum vertices: %d", max_vertices);
|
||||
Output_ReserveVertexBuffer(max_vertices);
|
||||
|
||||
// Move the prepared texture pages into g_TexturePagePtrs.
|
||||
uint8_t *base = GameBuf_Alloc(
|
||||
m_LevelInfo.texture_page_count * PAGE_SIZE, GBUF_TEXTURE_PAGES);
|
||||
|
@ -925,6 +930,38 @@ static void Level_CompleteSetup(int32_t level_num)
|
|||
Memory_FreePointer(&sample_sizes);
|
||||
}
|
||||
|
||||
static size_t Level_CalculateMaxVertices(void)
|
||||
{
|
||||
size_t max_vertices = 0;
|
||||
for (int32_t i = 0; i < O_NUMBER_OF; i++) {
|
||||
const OBJECT_INFO *object_info = &g_Objects[i];
|
||||
if (!object_info->loaded) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int32_t j = 0; j < object_info->nmeshes; j++) {
|
||||
max_vertices =
|
||||
MAX(max_vertices, *(g_Meshes[object_info->mesh_index + j] + 5));
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < STATIC_NUMBER_OF; i++) {
|
||||
const STATIC_INFO *static_info = &g_StaticObjects[i];
|
||||
if (!static_info->loaded || static_info->nmeshes < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
max_vertices =
|
||||
MAX(max_vertices, *(g_Meshes[static_info->mesh_number] + 5));
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < g_RoomCount; i++) {
|
||||
max_vertices = MAX(max_vertices, *g_RoomInfo[i].data);
|
||||
}
|
||||
|
||||
return max_vertices;
|
||||
}
|
||||
|
||||
bool Level_Load(int level_num)
|
||||
{
|
||||
LOG_INFO("%d (%s)", level_num, g_GameFlow.levels[level_num].level_file);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "config.h"
|
||||
#include "game/clock.h"
|
||||
#include "game/console.h"
|
||||
#include "game/gamebuf.h"
|
||||
#include "game/overlay.h"
|
||||
#include "game/phase/phase.h"
|
||||
#include "game/picture.h"
|
||||
|
@ -48,7 +49,7 @@ static int32_t m_WibbleTable[WIBBLE_SIZE] = { 0 };
|
|||
static int32_t m_ShadeTable[WIBBLE_SIZE] = { 0 };
|
||||
static int32_t m_RandTable[WIBBLE_SIZE] = { 0 };
|
||||
|
||||
static PHD_VBUF m_VBuf[1500] = { 0 };
|
||||
static PHD_VBUF *m_VBuf = NULL;
|
||||
static int32_t m_DrawDistFade = 0;
|
||||
static int32_t m_DrawDistMax = 0;
|
||||
static RGB_F m_WaterColor = { 0 };
|
||||
|
@ -402,6 +403,11 @@ void Output_Shutdown(void)
|
|||
Memory_FreePointer(&m_BackdropImagePath);
|
||||
}
|
||||
|
||||
void Output_ReserveVertexBuffer(const size_t size)
|
||||
{
|
||||
m_VBuf = GameBuf_Alloc(size * sizeof(PHD_VBUF), GBUF_VERTEX_BUFFER);
|
||||
}
|
||||
|
||||
void Output_SetWindowSize(int width, int height)
|
||||
{
|
||||
S_Output_SetWindowSize(width, height);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
bool Output_Init(void);
|
||||
void Output_Shutdown(void);
|
||||
void Output_ReserveVertexBuffer(size_t size);
|
||||
|
||||
void Output_SetWindowSize(int width, int height);
|
||||
void Output_ApplyRenderSettings(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue