Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/WaterManager.cpp
Show First 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | if (!g_Renderer.GetCapabilities().m_PrettyWater) | ||||
m_RenderWater = true; | m_RenderWater = true; | ||||
return 0; | return 0; | ||||
} | } | ||||
#if CONFIG2_GLES | #if CONFIG2_GLES | ||||
#warning Fix WaterManager::LoadWaterTextures on GLES | #warning Fix WaterManager::LoadWaterTextures on GLES | ||||
#else | #else | ||||
// Load normalmaps (for fancy water) | // Load normalmaps (for fancy water) | ||||
for (size_t i = 0; i < ARRAY_SIZE(m_NormalMap); ++i) | ReloadWaterNormalTextures(); | ||||
vladislavbelov: Only disadvantage that I see, you don't reuse `pathname`. But it shouldn't touch performance. | |||||
{ | |||||
swprintf_s(pathname, ARRAY_SIZE(pathname), L"art/textures/animated/water/%ls/normal00%02d.png", m_WaterType.c_str(), (int)i+1); | |||||
CTextureProperties textureProps(pathname); | |||||
textureProps.SetWrap(GL_REPEAT); | |||||
textureProps.SetMaxAnisotropy(4); | |||||
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); | |||||
texture->Prefetch(); | |||||
m_NormalMap[i] = texture; | |||||
} | |||||
// Load CoastalWaves | // Load CoastalWaves | ||||
{ | { | ||||
CTextureProperties textureProps(L"art/textures/terrain/types/water/coastalWave.png"); | CTextureProperties textureProps(L"art/textures/terrain/types/water/coastalWave.png"); | ||||
textureProps.SetWrap(GL_REPEAT); | textureProps.SetWrap(GL_REPEAT); | ||||
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); | CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); | ||||
texture->Prefetch(); | texture->Prefetch(); | ||||
m_WaveTex = texture; | m_WaveTex = texture; | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | void WaterManager::Resize() | ||||
glBindTexture(GL_TEXTURE_2D, m_FancyTextureOther); | glBindTexture(GL_TEXTURE_2D, m_FancyTextureOther); | ||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL); | glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL); | ||||
glBindTexture(GL_TEXTURE_2D, m_FancyTextureDepth); | glBindTexture(GL_TEXTURE_2D, m_FancyTextureDepth); | ||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); | glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); | ||||
glBindTexture(GL_TEXTURE_2D, 0); | glBindTexture(GL_TEXTURE_2D, 0); | ||||
} | } | ||||
// This is for Atlas. TODO: this copies code from init, should reuse it. | // Load normalmaps (for fancy water) | ||||
StanUnsubmitted Not Done Inline ActionsDoxygen. Stan: Doxygen. | |||||
void WaterManager::ReloadWaterNormalTextures() | void WaterManager::ReloadWaterNormalTextures() | ||||
{ | { | ||||
wchar_t pathname[PATH_MAX]; | wchar_t pathname[PATH_MAX]; | ||||
// Load normalmaps (for fancy water) | |||||
for (size_t i = 0; i < ARRAY_SIZE(m_NormalMap); ++i) | for (size_t i = 0; i < ARRAY_SIZE(m_NormalMap); ++i) | ||||
StanUnsubmitted Not Done Inline ActionsAny reason not to use int here ? Stan: Any reason not to use int here ? | |||||
{ | { | ||||
swprintf_s(pathname, ARRAY_SIZE(pathname), L"art/textures/animated/water/%ls/normal00%02d.png", m_WaterType.c_str(), (int)i+1); | swprintf_s(pathname, ARRAY_SIZE(pathname), L"art/textures/animated/water/%ls/normal00%02d.png", m_WaterType.c_str(), static_cast<int>(i) + 1); | ||||
Not Done Inline ActionsCould you also replace (int)i+1 by static_cast<int>(i) + 1 or replace format %02d by %02zu? vladislavbelov: Could you also replace `(int)i+1` by `static_cast<int>(i) + 1` or replace format `%02d` by… | |||||
StanUnsubmitted Not Done Inline ActionsCan't we replace ARRAY_SIZE(pathname) by PATH_MAX so we don't call a macro to do whatever each time ? Stan: Can't we replace ARRAY_SIZE(pathname) by PATH_MAX so we don't call a macro to do whatever each… | |||||
SilierAuthorUnsubmitted Done Inline ActionsIt will be done in another patch as it is case in more places and kind of unrelated to reason of this patch. Silier: It will be done in another patch as it is case in more places and kind of unrelated to reason… | |||||
StanUnsubmitted Done Inline ActionsSure, maybe it's just an optimization. I don't know if that macro call is cached... Stan: Sure, maybe it's just an optimization. I don't know if that macro call is cached... | |||||
CTextureProperties textureProps(pathname); | CTextureProperties textureProps(pathname); | ||||
textureProps.SetWrap(GL_REPEAT); | textureProps.SetWrap(GL_REPEAT); | ||||
textureProps.SetMaxAnisotropy(4); | textureProps.SetMaxAnisotropy(4); | ||||
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); | CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); | ||||
texture->Prefetch(); | texture->Prefetch(); | ||||
m_NormalMap[i] = texture; | m_NormalMap[i] = texture; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 736 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Only disadvantage that I see, you don't reuse pathname. But it shouldn't touch performance.