-
Notifications
You must be signed in to change notification settings - Fork 3
/
rwrenderer.h
57 lines (44 loc) · 1.53 KB
/
rwrenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include "renderer.h"
struct Renderer;
struct CTextureDictionary;
struct RwGeometry;
struct CKAnyGeometry;
struct ProTexDict {
Renderer *_gfx;
ProTexDict *_next = nullptr;
std::unordered_map<std::string, texture_t> dict;
static uint32_t globalVersion;
ProTexDict(Renderer *gfx) : _gfx(gfx) {}
ProTexDict(Renderer *gfx, CTextureDictionary *ctd);
ProTexDict(ProTexDict &&ptd) = default;
~ProTexDict();
std::pair<bool, texture_t> find(const std::string &name);
void reset(CTextureDictionary *ctd);
};
struct ProGeometry {
Renderer *_gfx;
ProTexDict *_proTexDict;
std::unique_ptr<RVertexBuffer> vbuf;
std::unique_ptr<RIndexBuffer> ibuf;
size_t numTris;
std::string textureName;
texture_t ptdTexId = nullptr;
uint32_t ptdVersion = 0;
//ProGeometry(Renderer *gfx, RVertexBuffer *vbuf, RIndexBuffer *ibuf, size_t numTris, const std::string &textureName, ProTexDict *proTexDict) :
// gfx(gfx), vbuf(vbuf), ibuf(ibuf), numTris(numTris), textureName(textureName), proTexDict(proTexDict);
ProGeometry(Renderer *gfx, RwGeometry *geo, ProTexDict *proTexDict);
void draw(bool showTextures = true);
};
struct ProGeoCache {
Renderer *_gfx;
std::unordered_map<RwGeometry*, std::unique_ptr<ProGeometry>> dict;
ProGeoCache(Renderer *gfx);
ProGeometry* getPro(RwGeometry* geo, ProTexDict* proTexDict);
ProGeometry* getPro(const std::shared_ptr<RwGeometry>& geo, ProTexDict* proTexDict) { return getPro(geo.get(), proTexDict); }
void clear() { dict.clear(); }
};