Cogs.Core
CogsTerrainBase.h
1#pragma once
2
3#include "Rendering/DataFormat.h"
4
5#include <stdint.h>
6
7#undef COGSTERRAIN_DLL_API
8
9#ifdef _WIN32
10 // Alignment specifier causing structure padding is intended behavior.
11 #pragma warning(disable:4324)
12
13 // Nameless struct/union no longer non-standard (C11).
14 #pragma warning(disable:4201)
15
16 // When building the library:
17 #ifdef COGSCORE_TERRAIN_BUILD
18 #ifdef COGSTERRAIN_DLL
19 #define COGSTERRAIN_API __declspec(dllexport)
20 #else
21 #define COGSTERRAIN_API
22 #endif
23 // When using the library:
24 #else
25 #ifdef COGSTERRAIN_DLL
26 #define COGSTERRAIN_API __declspec(dllimport)
27 #else
28 #define COGSTERRAIN_API
29 #endif
30 #endif
31#else
32 #define COGSTERRAIN_API
33#endif
34
35namespace Cogs
36{
37 struct TileData;
38}
39
40typedef void TileLoadCallback(void * userData, int level, int x, int y, Cogs::TileData * data);
41typedef bool TileRequestCallback(void * userData, TileLoadCallback tileLoadCallback, int level, int x, int y);
42
43typedef void AllocationCallback(void * userData, unsigned int size);
44typedef void DeallocationCallback(void * userData, unsigned int size);
45
46struct CogsContext;
47
48namespace Cogs
49{
51 {
52 size_t clipmapPosts = 255;
53 double imageryResolutionFactor[16];
54 size_t imageryIndexOffset[16];
55 bool precomputeNormals = false;
56 };
57
59 {
60 enum ERasterSourceFlags
61 {
62 None = 0,
63 Queryable = 1,
64 CompressCache = 1 << 1,
65 };
66 };
67
69 {
70 const char * name;
71
72 int64_t id;
73
74 TextureFormat format;
75 float noData;
76
77 double minX;
78 double minY;
79 double maxX;
80 double maxY;
81
82 int numLevels;
83 int tileWidth;
84 int tileHeight;
85 double deltaX;
86 double deltaY;
87
88 unsigned int cacheSize;
89 unsigned int flags;
90
91 TileRequestCallback * tileRequestCallback;
92 AllocationCallback * allocationCallback;
93 DeallocationCallback * deallocationCallback;
94 };
95
97 {
99 {
100 None = 0,
102 IsHeight = 1 << 0,
106 ShouldFlip = 1 << 2,
108 LinearColorSpace = 1 << 3
109 };
110 };
111
112 struct TileData
113 {
114 bool isHeight() const { return (flags & TileDataFlags::IsHeight) != 0; }
115 bool isLinear() const { return (flags & TileDataFlags::LinearColorSpace) != 0; }
116 bool shouldFlip() const { return (flags & TileDataFlags::ShouldFlip) != 0; }
117 bool shouldConvert() const
118 {
119 return (flags & TileDataFlags::ShouldConvert) != 0 ||
120 format == TextureFormat::B8G8R8 ||
121 format == TextureFormat::B8G8R8A8;
122 }
123
124 const void * imageData;
125
126 int width;
127 int height;
128 TextureFormat format;
129 int stride;
130 int flags;
131 float minZ;
132 float maxZ;
133 };
134
136 {
137 void * userData;
138
139 double * positions;
140 int numPositions;
141
142 int layer;
143 int level;
144 int policy;
145 };
146
148 {
149 void * userData;
150
151 void * results;
152 int numResults;
153
154 int resultLevel;
155 };
156
158 {
159 const char * customComputeColor;
160 };
161
162#define METRICS_MAX_SOURCES 8
163
165 {
166 int64_t numFrames;
167
168 int64_t clipmapTextureBuffer;
169
170 int64_t sourceMemoryBuffers[8];
171 int64_t sourceTextureBuffers[8];
172 };
173
174 typedef void TerrainQueryCallback(TerrainQueryResults * results);
175}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
@ ShouldFlip
Tile data should be flipped on the Y axis.
@ LinearColorSpace
Target format of conversion should be in linear (non-sRGB) color space.
@ ShouldConvert
Tile data should be converted/padded from the incoming format (must be BGR, BGRA or RGB) to regular R...
@ IsHeight
Tile contains height data, min/max values should be provided.