Moves water textures and terrain alpha composite map to GL texture class following 57ba7c4a1c
.
Tested By: Stan Differential Revision: https://code.wildfiregames.com/D4394 This was SVN commit r26120.
This commit is contained in:
parent
f59f637cbb
commit
60a422b668
@ -331,13 +331,13 @@ void CTerrainTextureEntry::LoadAlphaMaps(const VfsPath& alphaMapType)
|
||||
for (size_t i = 0; i < NUM_ALPHA_MAPS; i++)
|
||||
ignore_result(ogl_tex_free(textures[i]));
|
||||
|
||||
// upload the composite texture
|
||||
// Enable the following to save a png of the generated texture
|
||||
// in the public/ directory, for debugging.
|
||||
#if 0
|
||||
Tex t;
|
||||
ignore_result(t.wrap(totalWidth, totalHeight, 8, TEX_GREY, data, 0));
|
||||
|
||||
// uncomment the following to save a png of the generated texture
|
||||
// in the public/ directory, for debugging
|
||||
/*VfsPath filename("blendtex.png");
|
||||
const VfsPath filename("blendtex.png");
|
||||
|
||||
DynArray da;
|
||||
RETURN_STATUS_IF_ERR(tex_encode(&t, filename.Extension(), &da));
|
||||
@ -353,13 +353,19 @@ void CTerrainTextureEntry::LoadAlphaMaps(const VfsPath& alphaMapType)
|
||||
// ret = (Status)bytes_written;
|
||||
}
|
||||
|
||||
ignore_result(da_free(&da));*/
|
||||
ignore_result(da_free(&da));
|
||||
#endif
|
||||
|
||||
Handle hCompositeAlphaMap = ogl_tex_wrap(&t, g_VFS, key);
|
||||
ignore_result(ogl_tex_set_filter(hCompositeAlphaMap, GL_LINEAR));
|
||||
ignore_result(ogl_tex_set_wrap (hCompositeAlphaMap, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE));
|
||||
ogl_tex_upload(hCompositeAlphaMap, GL_ALPHA, 0, 0);
|
||||
result.m_hCompositeAlphaMap = hCompositeAlphaMap;
|
||||
result.m_CompositeAlphaMap = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::A8, totalWidth, totalHeight,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
|
||||
// Upload the composite texture.
|
||||
g_Renderer.BindTexture(0, result.m_CompositeAlphaMap->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, totalWidth, totalHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data.get());
|
||||
g_Renderer.BindTexture(0, 0);
|
||||
|
||||
m_TerrainAlpha = it;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -17,23 +17,20 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "TerrainTextureManager.h"
|
||||
#include "TerrainTextureEntry.h"
|
||||
#include "TerrainProperties.h"
|
||||
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
#include "graphics/TerrainTextureEntry.h"
|
||||
#include "graphics/TerrainProperties.h"
|
||||
#include "lib/ogl.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
CTerrainTextureManager::CTerrainTextureManager()
|
||||
: m_LastGroupIndex(0)
|
||||
@ -51,10 +48,7 @@ CTerrainTextureManager::~CTerrainTextureManager()
|
||||
UnloadTerrainTextures();
|
||||
|
||||
for (std::pair<const VfsPath, TerrainAlpha>& ta : m_TerrainAlphas)
|
||||
{
|
||||
ogl_tex_free(ta.second.m_hCompositeAlphaMap);
|
||||
ta.second.m_hCompositeAlphaMap = 0;
|
||||
}
|
||||
ta.second.m_CompositeAlphaMap.reset();
|
||||
}
|
||||
|
||||
void CTerrainTextureManager::UnloadTerrainTextures()
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/Singleton.h"
|
||||
#include "renderer/backend/gl/Texture.h"
|
||||
|
||||
// access to sole CTerrainTextureManager object
|
||||
#define g_TexMan CTerrainTextureManager::GetSingleton()
|
||||
@ -72,10 +73,11 @@ public:
|
||||
struct TerrainAlpha
|
||||
{
|
||||
// ogl_tex handle of composite alpha map (all the alpha maps packed into one texture)
|
||||
Handle m_hCompositeAlphaMap;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_CompositeAlphaMap;
|
||||
// coordinates of each (untransformed) alpha map within the packed texture
|
||||
struct {
|
||||
float u0,u1,v0,v1;
|
||||
struct
|
||||
{
|
||||
float u0, u1, v0, v1;
|
||||
} m_AlphaMapCoords[NUM_ALPHA_MAPS];
|
||||
};
|
||||
|
||||
|
@ -957,7 +957,7 @@ void CPatchRData::RenderBlends(
|
||||
const CShaderProgramPtr& shader = techBase->GetShader(pass);
|
||||
TerrainRenderer::PrepareShader(shader, shadow);
|
||||
|
||||
Handle lastBlendTex = 0;
|
||||
Renderer::Backend::GL::CTexture* lastBlendTex = nullptr;
|
||||
|
||||
for (BatchesStack::iterator itt = itTechBegin; itt != itTechEnd; ++itt)
|
||||
{
|
||||
@ -970,10 +970,10 @@ void CPatchRData::RenderBlends(
|
||||
for (const CMaterial::TextureSampler& samp : samplers)
|
||||
shader->BindTexture(samp.Name, samp.Sampler);
|
||||
|
||||
Handle currentBlendTex = itt->m_Texture->m_TerrainAlpha->second.m_hCompositeAlphaMap;
|
||||
Renderer::Backend::GL::CTexture* currentBlendTex = itt->m_Texture->m_TerrainAlpha->second.m_CompositeAlphaMap.get();
|
||||
if (currentBlendTex != lastBlendTex)
|
||||
{
|
||||
shader->BindTexture(str_blendTex, currentBlendTex);
|
||||
shader->BindTexture(str_blendTex, currentBlendTex->GetHandle());
|
||||
lastBlendTex = currentBlendTex;
|
||||
}
|
||||
|
||||
|
@ -440,20 +440,20 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
|
||||
|
||||
if (waterManager->m_WaterFancyEffects)
|
||||
{
|
||||
fancyWaterShader->BindTexture(str_waterEffectsTex, waterManager->m_FancyTexture);
|
||||
fancyWaterShader->BindTexture(str_waterEffectsTex, waterManager->m_FancyTexture->GetHandle());
|
||||
}
|
||||
|
||||
if (waterManager->m_WaterRefraction && waterManager->m_WaterRealDepth)
|
||||
{
|
||||
fancyWaterShader->BindTexture(str_depthTex, waterManager->m_RefrFboDepthTexture);
|
||||
fancyWaterShader->BindTexture(str_depthTex, waterManager->m_RefrFboDepthTexture->GetHandle());
|
||||
fancyWaterShader->Uniform(str_projInvTransform, waterManager->m_RefractionProjInvMatrix);
|
||||
fancyWaterShader->Uniform(str_viewInvTransform, waterManager->m_RefractionViewInvMatrix);
|
||||
}
|
||||
|
||||
if (waterManager->m_WaterRefraction)
|
||||
fancyWaterShader->BindTexture(str_refractionMap, waterManager->m_RefractionTexture);
|
||||
fancyWaterShader->BindTexture(str_refractionMap, waterManager->m_RefractionTexture->GetHandle());
|
||||
if (waterManager->m_WaterReflection)
|
||||
fancyWaterShader->BindTexture(str_reflectionMap, waterManager->m_ReflectionTexture);
|
||||
fancyWaterShader->BindTexture(str_reflectionMap, waterManager->m_ReflectionTexture->GetHandle());
|
||||
fancyWaterShader->BindTexture(str_losTex, losTexture.GetTextureSmooth());
|
||||
|
||||
const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "graphics/ShaderProgram.h"
|
||||
#include "lib/bits.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/ogl.h"
|
||||
#include "lib/tex/tex.h"
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
#include "maths/MathUtil.h"
|
||||
#include "maths/Vector2D.h"
|
||||
#include "ps/CLogger.h"
|
||||
@ -77,8 +77,6 @@ WaterManager::WaterManager()
|
||||
m_RenderWater = false; // disabled until textures are successfully loaded
|
||||
m_WaterHeight = 5.0f;
|
||||
|
||||
m_ReflectionTexture = 0;
|
||||
m_RefractionTexture = 0;
|
||||
m_RefTextureSize = 0;
|
||||
|
||||
m_ReflectionFbo = 0;
|
||||
@ -110,11 +108,6 @@ WaterManager::WaterManager()
|
||||
m_NeedsReloading = false;
|
||||
m_NeedInfoUpdate = true;
|
||||
|
||||
m_FancyTexture = 0;
|
||||
m_FancyTextureDepth = 0;
|
||||
m_ReflFboDepthTexture = 0;
|
||||
m_RefrFboDepthTexture = 0;
|
||||
|
||||
m_MapSize = 0;
|
||||
|
||||
m_updatei0 = 0;
|
||||
@ -145,10 +138,10 @@ WaterManager::~WaterManager()
|
||||
if (!g_Renderer.GetCapabilities().m_PrettyWater)
|
||||
return;
|
||||
|
||||
glDeleteTextures(1, &m_FancyTexture);
|
||||
glDeleteTextures(1, &m_FancyTextureDepth);
|
||||
glDeleteTextures(1, &m_ReflFboDepthTexture);
|
||||
glDeleteTextures(1, &m_RefrFboDepthTexture);
|
||||
m_FancyTexture.reset();
|
||||
m_FancyTextureDepth.reset();
|
||||
m_ReflFboDepthTexture.reset();
|
||||
m_RefrFboDepthTexture.reset();
|
||||
|
||||
glDeleteFramebuffersEXT(1, &m_FancyEffectsFBO);
|
||||
glDeleteFramebuffersEXT(1, &m_RefractionFbo);
|
||||
@ -214,54 +207,43 @@ int WaterManager::LoadWaterTextures()
|
||||
m_RefTextureSize = round_up_to_pow2(m_RefTextureSize);
|
||||
|
||||
// Create reflection texture
|
||||
glGenTextures(1, &m_ReflectionTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ReflectionTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
m_ReflectionTexture = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::R8G8B8A8, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::MIRRORED_REPEAT));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_ReflectionTexture->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
// Create refraction texture
|
||||
glGenTextures(1, &m_RefractionTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_RefractionTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
m_RefractionTexture = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::R8G8B8A8, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::MIRRORED_REPEAT));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_RefractionTexture->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
// Create depth textures
|
||||
glGenTextures(1, &m_ReflFboDepthTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ReflFboDepthTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
|
||||
m_ReflFboDepthTexture = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::D32, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
|
||||
glGenTextures(1, &m_RefrFboDepthTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_RefrFboDepthTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ReflFboDepthTexture->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
|
||||
|
||||
// Create the Fancy Effects texture
|
||||
glGenTextures(1, &m_FancyTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_FancyTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
m_RefrFboDepthTexture = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::D32, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
|
||||
glGenTextures(1, &m_FancyTextureDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, m_FancyTextureDepth);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glBindTexture(GL_TEXTURE_2D, m_RefrFboDepthTexture->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
@ -275,8 +257,8 @@ int WaterManager::LoadWaterTextures()
|
||||
m_ReflectionFbo = 0;
|
||||
glGenFramebuffersEXT(1, &m_ReflectionFbo);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_ReflectionFbo);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ReflectionTexture, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_ReflFboDepthTexture, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ReflectionTexture->GetHandle(), 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_ReflFboDepthTexture->GetHandle(), 0);
|
||||
|
||||
ogl_WarnIfError();
|
||||
|
||||
@ -291,8 +273,8 @@ int WaterManager::LoadWaterTextures()
|
||||
m_RefractionFbo = 0;
|
||||
glGenFramebuffersEXT(1, &m_RefractionFbo);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_RefractionFbo);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_RefractionTexture, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_RefrFboDepthTexture, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_RefractionTexture->GetHandle(), 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_RefrFboDepthTexture->GetHandle(), 0);
|
||||
|
||||
ogl_WarnIfError();
|
||||
|
||||
@ -306,8 +288,8 @@ int WaterManager::LoadWaterTextures()
|
||||
|
||||
glGenFramebuffersEXT(1, &m_FancyEffectsFBO);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FancyTexture, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_FancyTextureDepth, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FancyTexture->GetHandle(), 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_FancyTextureDepth->GetHandle(), 0);
|
||||
|
||||
ogl_WarnIfError();
|
||||
|
||||
@ -332,11 +314,24 @@ int WaterManager::LoadWaterTextures()
|
||||
// Resize: Updates the fancy water textures.
|
||||
void WaterManager::Resize()
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, m_FancyTexture);
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
|
||||
// Create the Fancy Effects texture
|
||||
m_FancyTexture = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::R8G8B8A8, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
|
||||
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);
|
||||
glBindTexture(GL_TEXTURE_2D, m_FancyTexture->GetHandle());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
|
||||
|
||||
m_FancyTextureDepth = Renderer::Backend::GL::CTexture::Create2D(
|
||||
Renderer::Backend::Format::D32, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_FancyTextureDepth->GetHandle());
|
||||
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);
|
||||
}
|
||||
@ -361,17 +356,17 @@ void WaterManager::ReloadWaterNormalTextures()
|
||||
// Unload water textures
|
||||
void WaterManager::UnloadWaterTextures()
|
||||
{
|
||||
for(size_t i = 0; i < ARRAY_SIZE(m_WaterTexture); i++)
|
||||
for (size_t i = 0; i < ARRAY_SIZE(m_WaterTexture); i++)
|
||||
m_WaterTexture[i].reset();
|
||||
|
||||
if (!g_Renderer.GetCapabilities().m_PrettyWater)
|
||||
return;
|
||||
|
||||
for(size_t i = 0; i < ARRAY_SIZE(m_NormalMap); i++)
|
||||
for (size_t i = 0; i < ARRAY_SIZE(m_NormalMap); i++)
|
||||
m_NormalMap[i].reset();
|
||||
|
||||
glDeleteTextures(1, &m_ReflectionTexture);
|
||||
glDeleteTextures(1, &m_RefractionTexture);
|
||||
m_ReflectionTexture.reset();
|
||||
m_RefractionTexture.reset();
|
||||
glDeleteFramebuffersEXT(1, &m_RefractionFbo);
|
||||
glDeleteFramebuffersEXT(1, &m_ReflectionFbo);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "lib/ogl.h"
|
||||
#include "maths/Matrix3D.h"
|
||||
#include "maths/Vector2D.h"
|
||||
#include "renderer/backend/gl/Texture.h"
|
||||
#include "renderer/VertexBufferManager.h"
|
||||
|
||||
class CFrustum;
|
||||
@ -59,10 +60,10 @@ public:
|
||||
CTexturePtr m_WaveTex;
|
||||
CTexturePtr m_FoamTex;
|
||||
|
||||
GLuint m_FancyTexture;
|
||||
GLuint m_FancyTextureDepth;
|
||||
GLuint m_ReflFboDepthTexture;
|
||||
GLuint m_RefrFboDepthTexture;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_FancyTexture;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_FancyTextureDepth;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_ReflFboDepthTexture;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_RefrFboDepthTexture;
|
||||
|
||||
// used to know what to update when updating parts of the terrain only.
|
||||
u32 m_updatei0;
|
||||
@ -94,8 +95,8 @@ public:
|
||||
float m_RepeatPeriod;
|
||||
|
||||
// Reflection and refraction textures for fancy water
|
||||
GLuint m_ReflectionTexture;
|
||||
GLuint m_RefractionTexture;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_ReflectionTexture;
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> m_RefractionTexture;
|
||||
size_t m_RefTextureSize;
|
||||
|
||||
// framebuffer objects
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Texture.h"
|
||||
|
||||
#include "lib/config2.h"
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
#include "renderer/backend/gl/Device.h"
|
||||
|
||||
namespace Renderer
|
||||
@ -86,11 +87,14 @@ std::unique_ptr<CTexture> CTexture::Create2D(const Format format,
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, AddressModeToGLEnum(defaultSamplerDesc.addressModeV));
|
||||
|
||||
#if !CONFIG2_GLES
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipCount - 1);
|
||||
|
||||
if (defaultSamplerDesc.mipLODBias != 0.0f)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, defaultSamplerDesc.mipLODBias);
|
||||
#endif
|
||||
#endif // !CONFIG2_GLES
|
||||
|
||||
if (defaultSamplerDesc.anisotropyEnabled)
|
||||
if (defaultSamplerDesc.anisotropyEnabled && ogl_tex_has_anisotropy())
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, defaultSamplerDesc.maxAnisotropy);
|
||||
|
||||
if (defaultSamplerDesc.addressModeU == Sampler::AddressMode::CLAMP_TO_BORDER ||
|
||||
|
Loading…
Reference in New Issue
Block a user