18 #include "precompiled.h"
41 m_pProperties(properties),
43 m_BaseColorValid(false)
54 #define EL(x) int el_##x = XeroFile.GetElementID(#x)
55 #define AT(x) int at_##x = XeroFile.GetAttributeID(#x)
78 std::vector<std::pair<CStr, VfsPath> > samplers;
85 int child_name = child.GetNodeName();
87 if (child_name == el_textures)
91 ENSURE(textures_element.GetNodeName() == el_texture);
97 if (se.Name == at_file)
98 path =
VfsPath(
"art/textures/terrain") / se.Value.FromUTF8();
99 else if (se.Name == at_name)
102 samplers.push_back(make_pair(name, path));
106 else if (child_name == el_material)
108 VfsPath mat =
VfsPath(
"art/materials") / child.GetText().FromUTF8();
112 else if (child_name == el_alphamap)
114 alphamap = child.GetText().FromUTF8();
116 else if (child_name == el_props)
119 ret->LoadXml(child, &XeroFile, path);
122 else if (child_name == el_tag)
124 m_Tag = child.GetText();
129 for (
size_t i = 0; i < samplers.size(); ++i)
149 float texAngle = 0.f;
166 GroupVector::iterator it=
m_Groups.begin();
168 (*it)->AddTerrain(
this);
174 (*it)->RemoveTerrain(
this);
206 std::wstring
key = L
"(alpha map composite" + amtype.
string() + L
")";
208 CTerrainTextureManager::TerrainAlphaMap::iterator it =
g_TexMan.m_TerrainAlphas.find(amtype);
210 if (it !=
g_TexMan.m_TerrainAlphas.end())
217 it =
g_TexMan.m_TerrainAlphas.find(amtype);
225 VfsPath path(L
"art/textures/terrain/alphamaps");
226 path = path / amtype;
232 L
"blendedgecorner.png",
233 L
"blendedgetwocorners.png",
234 L
"blendfourcorners.png",
235 L
"blendtwooppositecorners.png",
236 L
"blendlshapecorner.png",
237 L
"blendtwocorners.png",
239 L
"blendtwoedges.png",
240 L
"blendthreecorners.png",
256 LOGERROR((L
"Failed to load alphamap: " + amtype.
string()).c_str());
259 if (path != standard)
268 size_t this_width = 0, this_height = 0, this_bpp = 0;
270 if(this_width != this_height)
279 else if(base != this_width || bpp != this_bpp)
286 size_t tile_w = 2+base+2;
298 size_t srcstep = bpp/8;
301 u8* dst = data.get() + (i*tile_w);
304 for (
size_t j = 0; j < base; j++)
311 for (
size_t k = 0; k < base; k++)
318 *dst++ = *(src-srcstep);
319 *dst++ = *(src-srcstep);
322 dst += total_w-tile_w;
360 (void)
ogl_tex_set_wrap (hCompositeAlphaMap, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
struct TerrainAlpha::@16 m_AlphaMapCoords[NUM_ALPHA_MAPS]
shared_ptr< CTerrainProperties > CTerrainPropertiesPtr
Path VfsPath
VFS path of the form "(dir/)*file?".
PSRETURN Load(const PIVFS &vfs, const VfsPath &filename)
Load from an XML file (with invisible XMB caching).
#define XERO_ITER_ATTR(parent_element, attribute)
const PSRETURN PSRETURN_OK
std::string utf8_from_wstring(const std::wstring &src, Status *err)
opposite of wstring_from_utf8
Handle ogl_tex_wrap(Tex *t, const PIVFS &vfs, const VfsPath &pathname, size_t flags)
Make the Tex object ready for use as an OpenGL texture and return a handle to it. ...
Status ogl_tex_free(Handle &ht)
Release this texture reference.
const float * GetTextureMatrix()
static const uintptr_t maxSectorSize
Represents the filename and GL parameters of a texture, for passing to CTextureManager::CreateTexture...
void AddSampler(const TextureSampler &texture)
indicates the image is 8bpp greyscale.
#define XERO_ITER_EL(parent_element, child_element)
void LoadAlphaMaps(VfsPath &amtype)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
T round_up_to_pow2(T x)
round up to next larger power of two.
Status ogl_tex_set_wrap(Handle ht, GLint wrap_s, GLint wrap_t)
Override default wrap mode (GL_REPEAT) for this texture.
const String & string() const
const CTexturePtr & GetTexture()
CTerrainTextureEntry(CTerrainPropertiesPtr props, const VfsPath &path)
i64 Handle
`handle' representing a reference to a resource (sound, texture, etc.)
static bool IsInitialised()
CMatrix3D m_TextureMatrix
stores all data describing an image.
std::string GetElementString(const int ID) const
Handle ogl_tex_load(const PIVFS &vfs, const VfsPath &pathname, size_t flags)
Load and return a handle to the texture.
void SetMaxAnisotropy(float aniso)
Set maximum anisotropy value.
static Status AllocateAligned(shared_ptr< T > &p, size_t size, size_t alignment=cacheLineSize)
XMBElement GetRoot() const
CTerrainPropertiesPtr m_pProperties
Status ogl_tex_set_filter(Handle ht, GLint filter)
Override default filter (see ogl_tex_set_defaults) for this texture.
Status ogl_tex_get_data(Handle ht, u8 **p)
Retrieve pixel data of the texture.
Status tex_wrap(size_t w, size_t h, size_t bpp, size_t flags, const shared_ptr< u8 > &data, size_t ofs, Tex *t)
store the given image data into a Tex object; this will be as if it had been loaded via tex_load...
#define DEBUG_DISPLAY_ERROR(description)
void SetWrap(GLint wrap)
Set wrapping mode (typically GL_REPEAT, GL_CLAMP_TO_EDGE, etc).
Handle m_hCompositeAlphaMap
CTerrainTextureManager::TerrainAlphaMap::iterator m_TerrainAlpha
Status ogl_tex_upload(const Handle ht, GLenum fmt_ovr, int q_flags_ovr, GLint int_fmt_ovr)
Upload texture to OpenGL.
Status ogl_tex_get_size(Handle ht, size_t *w, size_t *h, size_t *bpp)
Retrieve dimensions and bit depth of the texture.
shared_ptr< CTexture > CTexturePtr