Files
water111 5b04be2fa0 Add hfrag, clean up some background renderer stuff (#3509)
This adds hfrag, but with a few remaining issues:
- The textures aren't animated. Instead, it just uses one texture.
- The texture filtering isn't as good as at it could be.

I also cleaned up a few issues with the background renderers:
- Cleaned up some stuff that is common to hfrag, tie, tfrag, shrub
- Moved time-of-day color packing stuff to FR3 creation, rather than at
level load. This appears to reduce the frame time spikes when a level is
first drawn by about 5 or 6 ms in big levels.
- Cleaned up the x86 specific stuff used in time of day. Now there's
only one place where we have an `ifdef`, rather than spreading it all
over the rendering code.
2024-05-09 20:11:43 -04:00

63 lines
1.5 KiB
C++

#pragma once
#include "common/common_types.h"
#include "common/custom_data/Tfrag3Data.h"
#include "common/util/Timer.h"
#include "game/graphics/texture/TexturePool.h"
#include "third-party/glad/include/glad/glad.h"
struct LevelData {
std::unique_ptr<tfrag3::Level> level;
std::vector<GLuint> textures;
u64 load_id = UINT64_MAX;
struct TieOpenGL {
GLuint vertex_buffer;
GLuint index_buffer;
bool has_wind = false;
GLuint wind_indices;
};
std::array<std::vector<TieOpenGL>, tfrag3::TIE_GEOS> tie_data;
std::array<std::vector<GLuint>, tfrag3::TIE_GEOS> tfrag_vertex_data;
std::vector<GLuint> shrub_vertex_data;
GLuint collide_vertices;
GLuint merc_vertices;
GLuint merc_indices;
std::unordered_map<std::string, const tfrag3::MercModel*> merc_model_lookup;
GLuint hfrag_vertices;
GLuint hfrag_indices;
int frames_since_last_used = 0;
};
struct MercRef {
const tfrag3::MercModel* model = nullptr;
u64 load_id = 0;
const LevelData* level = nullptr;
bool operator==(const MercRef& other) const {
return model == other.model && load_id == other.load_id;
}
};
struct LoaderInput {
LevelData* lev_data;
TexturePool* tex_pool;
std::unordered_map<std::string, std::vector<MercRef>>* mercs;
};
class LoaderStage {
public:
LoaderStage(const std::string& name) : m_name(name) {}
virtual bool run(Timer& timer, LoaderInput& data) = 0;
virtual void reset() = 0;
virtual ~LoaderStage() = default;
const std::string& name() const { return m_name; }
protected:
std::string m_name;
};