Index: ps/trunk/source/graphics/GameView.cpp =================================================================== --- ps/trunk/source/graphics/GameView.cpp +++ ps/trunk/source/graphics/GameView.cpp @@ -224,7 +224,6 @@ RegMemFun(this, &CGameView::Initialize, L"CGameView init", 1); RegMemFun(g_TexMan.GetSingletonPtr(), &CTerrainTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 60); - RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 5); } void CGameView::BeginFrame() @@ -303,7 +302,6 @@ void CGameView::UnloadResources() { g_TexMan.UnloadTerrainTextures(); - g_Renderer.UnloadAlphaMaps(); g_Renderer.GetWaterManager()->UnloadWaterTextures(); } Index: ps/trunk/source/renderer/Renderer.h =================================================================== --- ps/trunk/source/renderer/Renderer.h +++ ps/trunk/source/renderer/Renderer.h @@ -70,9 +70,6 @@ private SceneCollector { public: - // various enumerations and renderer related constants - enum { NumAlphaMaps=14 }; - enum CullGroup { CULL_DEFAULT, @@ -227,12 +224,6 @@ // bind a GL texture object to active unit void BindTexture(int unit, unsigned int tex); - // load the default set of alphamaps. - // return a negative error code if anything along the way fails. - // called via delay-load mechanism. - int LoadAlphaMaps(); - void UnloadAlphaMaps(); - // return stats accumulated for current frame Stats& GetStats() { return m_Stats; } @@ -366,9 +357,6 @@ void ReloadShaders(); void RecomputeSystemShaderDefines(); - // hotloading - static Status ReloadChangedFileCB(void* param, const VfsPath& path); - // RENDERER DATA: /// Private data that is not needed by inline functions CRendererInternals* m; @@ -412,12 +400,6 @@ float m_ClearColor[4]; // current lighting setup CLightEnv* m_LightEnv; - // ogl_tex handle of composite alpha map (all the alpha maps packed into one texture) - Handle m_hCompositeAlphaMap; - // coordinates of each (untransformed) alpha map within the packed texture - struct { - float u0,u1,v0,v1; - } m_AlphaMapCoords[NumAlphaMaps]; // card capabilities Caps m_Caps; // build card cap bits Index: ps/trunk/source/renderer/Renderer.cpp =================================================================== --- ps/trunk/source/renderer/Renderer.cpp +++ ps/trunk/source/renderer/Renderer.cpp @@ -73,7 +73,6 @@ #include "renderer/WaterManager.h" #include -#include #include #include @@ -418,20 +417,14 @@ m_CurrentScene = nullptr; - m_hCompositeAlphaMap = 0; - m_Stats.Reset(); - - RegisterFileReloadFunc(ReloadChangedFileCB, this); } /////////////////////////////////////////////////////////////////////////////////// // CRenderer destructor CRenderer::~CRenderer() { - UnregisterFileReloadFunc(ReloadChangedFileCB, this); - - // we no longer UnloadAlphaMaps / UnloadWaterTextures here - + // We no longer UnloadWaterTextures here - // that is the responsibility of the module that asked for // them to be loaded (i.e. CGameView). delete m; @@ -1718,181 +1711,6 @@ #endif } -/////////////////////////////////////////////////////////////////////////////////////////////////// -// LoadAlphaMaps: load the 14 default alpha maps, pack them into one composite texture and -// calculate the coordinate of each alphamap within this packed texture -// NB: A variant of this function is duplicated in TerrainTextureEntry.cpp, for use with the Shader -// renderpath. This copy is kept to load the 'standard' maps for the fixed pipeline and should -// be removed if/when the fixed pipeline goes. -int CRenderer::LoadAlphaMaps() -{ - const wchar_t* const key = L"(alpha map composite)"; - Handle ht = ogl_tex_find(key); - // alpha map texture had already been created and is still in memory: - // reuse it, do not load again. - if(ht > 0) - { - m_hCompositeAlphaMap = ht; - return 0; - } - - // - // load all textures and store Handle in array - // - Handle textures[NumAlphaMaps] = {0}; - VfsPath path(L"art/textures/terrain/alphamaps/standard"); - const wchar_t* fnames[NumAlphaMaps] = { - L"blendcircle.png", - L"blendlshape.png", - L"blendedge.png", - L"blendedgecorner.png", - L"blendedgetwocorners.png", - L"blendfourcorners.png", - L"blendtwooppositecorners.png", - L"blendlshapecorner.png", - L"blendtwocorners.png", - L"blendcorner.png", - L"blendtwoedges.png", - L"blendthreecorners.png", - L"blendushape.png", - L"blendbad.png" - }; - size_t base = 0; // texture width/height (see below) - // for convenience, we require all alpha maps to be of the same BPP - // (avoids another ogl_tex_get_size call, and doesn't hurt) - size_t bpp = 0; - for(size_t i=0;i data; - AllocateAligned(data, total_w*total_h, maxSectorSize); - // for each tile on row - for (size_t i = 0; i < NumAlphaMaps; i++) - { - // get src of copy - u8* src = 0; - ignore_result(ogl_tex_get_data(textures[i], &src)); - - size_t srcstep = bpp/8; - - // get destination of copy - u8* dst = data.get() + (i*tile_w); - - // for each row of image - for (size_t j = 0; j < base; j++) - { - // duplicate first pixel - *dst++ = *src; - *dst++ = *src; - - // copy a row - for (size_t k = 0; k < base; k++) - { - *dst++ = *src; - src += srcstep; - } - - // duplicate last pixel - *dst++ = *(src-srcstep); - *dst++ = *(src-srcstep); - - // advance write pointer for next row - dst += total_w-tile_w; - } - - m_AlphaMapCoords[i].u0 = float(i*tile_w+2) / float(total_w); - m_AlphaMapCoords[i].u1 = float((i+1)*tile_w-2) / float(total_w); - m_AlphaMapCoords[i].v0 = 0.0f; - m_AlphaMapCoords[i].v1 = 1.0f; - } - - for (size_t i = 0; i < NumAlphaMaps; i++) - ignore_result(ogl_tex_free(textures[i])); - - // upload the composite texture - Tex t; - ignore_result(t.wrap(total_w, total_h, 8, TEX_GREY, data, 0)); - - /*VfsPath filename("blendtex.png"); - - DynArray da; - RETURN_STATUS_IF_ERR(tex_encode(&t, filename.Extension(), &da)); - - // write to disk - //Status ret = INFO::OK; - { - std::shared_ptr file = DummySharedPtr(da.base); - const ssize_t bytes_written = g_VFS->CreateFile(filename, file, da.pos); - if(bytes_written > 0) - ENSURE(bytes_written == (ssize_t)da.pos); - //else - // ret = (Status)bytes_written; - } - - ignore_result(da_free(&da));*/ - - m_hCompositeAlphaMap = ogl_tex_wrap(&t, g_VFS, key); - ignore_result(ogl_tex_set_filter(m_hCompositeAlphaMap, GL_LINEAR)); - ignore_result(ogl_tex_set_wrap (m_hCompositeAlphaMap, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE)); - int ret = ogl_tex_upload(m_hCompositeAlphaMap, GL_ALPHA, 0, 0); - - return ret; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// UnloadAlphaMaps: frees the resources allocates by LoadAlphaMaps -void CRenderer::UnloadAlphaMaps() -{ - ogl_tex_free(m_hCompositeAlphaMap); - m_hCompositeAlphaMap = 0; -} - - - -Status CRenderer::ReloadChangedFileCB(void* param, const VfsPath& path) -{ - CRenderer* renderer = static_cast(param); - - // If an alpha map changed, and we already loaded them, then reload them - if (boost::algorithm::starts_with(path.string(), L"art/textures/terrain/alphamaps/")) - { - if (renderer->m_hCompositeAlphaMap) - { - renderer->UnloadAlphaMaps(); - renderer->LoadAlphaMaps(); - } - } - - return INFO::OK; -} - void CRenderer::MakeShadersDirty() { m->ShadersDirty = true;