diff options
Diffstat (limited to 'qt_tstfrm/tstwidgets.cpp')
-rw-r--r-- | qt_tstfrm/tstwidgets.cpp | 226 |
1 files changed, 102 insertions, 124 deletions
diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp index ead01139e2..3325509d2b 100644 --- a/qt_tstfrm/tstwidgets.cpp +++ b/qt_tstfrm/tstwidgets.cpp @@ -1,6 +1,4 @@ #include "tstwidgets.hpp" -#include "widgets_impl.hpp" -#include "screen_qt.hpp" #include "../graphics/screen.hpp" #include "../graphics/resource_manager.hpp" @@ -12,161 +10,141 @@ #include "../platform/platform.hpp" - -template class qt::GLDrawWidgetT<graphics::Screen>; - -namespace tst { - -GLDrawWidget::GLDrawWidget() : base_type(0) -{ -} - -GLDrawWidget::~GLDrawWidget() +namespace tst { -} - -void GLDrawWidget::initializeGL() -{ - try + void GLDrawWidget::initializeGL() { - graphics::gl::InitExtensions(); - graphics::gl::CheckExtensionSupport(); - } - catch (graphics::gl::platform_unsupported & e) - { - /// TODO: Show "Please Update Drivers" dialog and close the program. - } + try + { + graphics::gl::InitExtensions(); + graphics::gl::CheckExtensionSupport(); + } + catch (graphics::gl::platform_unsupported & e) + { + /// TODO: Show "Please Update Drivers" dialog and close the program. + } - m_primaryContext = make_shared_ptr(new qt::gl::RenderContext(this)); + m_primaryContext = make_shared_ptr(new qt::gl::RenderContext(this)); - graphics::ResourceManager::Params rmp; + graphics::ResourceManager::Params rmp; - rmp.m_rtFormat = graphics::Data8Bpp; - rmp.m_texFormat = graphics::Data8Bpp; + rmp.m_rtFormat = graphics::Data8Bpp; + rmp.m_texFormat = graphics::Data8Bpp; - rmp.m_videoMemoryLimit = 20 * 1024 * 1024; + rmp.m_videoMemoryLimit = 20 * 1024 * 1024; - graphics::ResourceManager::StoragePoolParams spp; - graphics::ResourceManager::TexturePoolParams tpp; + graphics::ResourceManager::StoragePoolParams spp; + graphics::ResourceManager::TexturePoolParams tpp; - spp = graphics::ResourceManager::StoragePoolParams(30000 * sizeof(graphics::gl::Vertex), - sizeof(graphics::gl::Vertex), - 50000 * sizeof(unsigned short), - sizeof(unsigned short), - 20, - graphics::ELargeStorage, - false); + spp = graphics::ResourceManager::StoragePoolParams(30000 * sizeof(graphics::gl::Vertex), + sizeof(graphics::gl::Vertex), + 50000 * sizeof(unsigned short), + sizeof(unsigned short), + 1, + graphics::ELargeStorage, + true); - rmp.m_storageParams[graphics::ELargeStorage] = spp; + rmp.m_storageParams[graphics::ELargeStorage] = spp; - spp = graphics::ResourceManager::StoragePoolParams(3000 * sizeof(graphics::gl::Vertex), - sizeof(graphics::gl::Vertex), - 5000 * sizeof(unsigned short), - sizeof(unsigned short), - 100, - graphics::EMediumStorage, - false); + spp = graphics::ResourceManager::StoragePoolParams(3000 * sizeof(graphics::gl::Vertex), + sizeof(graphics::gl::Vertex), + 5000 * sizeof(unsigned short), + sizeof(unsigned short), + 1, + graphics::EMediumStorage, + true); - rmp.m_storageParams[graphics::EMediumStorage] = spp; + rmp.m_storageParams[graphics::EMediumStorage] = spp; - spp = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex), - sizeof(graphics::gl::Vertex), - 500 * sizeof(unsigned short), - sizeof(unsigned short), - 10, - graphics::ESmallStorage, - false); + spp = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex), + sizeof(graphics::gl::Vertex), + 500 * sizeof(unsigned short), + sizeof(unsigned short), + 1, + graphics::ESmallStorage, + true); - rmp.m_storageParams[graphics::ESmallStorage] = spp; + rmp.m_storageParams[graphics::ESmallStorage] = spp; - tpp = graphics::ResourceManager::TexturePoolParams(512, - 512, - 10, - rmp.m_texFormat, - graphics::ELargeTexture, - false); + spp = graphics::ResourceManager::StoragePoolParams(500 * sizeof(graphics::gl::Vertex), + sizeof(graphics::gl::Vertex), + 500 * sizeof(unsigned short), + sizeof(unsigned short), + 1, + graphics::ETinyStorage, + true); - rmp.m_textureParams[graphics::ELargeTexture] = tpp; + rmp.m_storageParams[graphics::ETinyStorage] = spp; - tpp = graphics::ResourceManager::TexturePoolParams(512, - 256, - 5, - rmp.m_texFormat, - graphics::ESmallTexture, - false); - rmp.m_textureParams[graphics::ESmallTexture]; + tpp = graphics::ResourceManager::TexturePoolParams(512, + 512, + 1, + rmp.m_texFormat, + graphics::ELargeTexture, + true); - rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt", - "fonts_whitelist.txt", - "fonts_blacklist.txt", - 2 * 1024 * 1024); + rmp.m_textureParams[graphics::ELargeTexture] = tpp; - rmp.m_threadSlotsCount = 1; - rmp.m_renderThreadsCount = 0; + tpp = graphics::ResourceManager::TexturePoolParams(256, + 256, + 1, + rmp.m_texFormat, + graphics::EMediumTexture, + true); - rmp.m_useSingleThreadedOGL = false; + rmp.m_textureParams[graphics::EMediumTexture] = tpp; - m_resourceManager.reset(new graphics::ResourceManager(rmp)); + tpp = graphics::ResourceManager::TexturePoolParams(128, + 128, + 1, + rmp.m_texFormat, + graphics::ESmallTexture, + true); - m_primaryContext->setResourceManager(m_resourceManager); - m_primaryContext->startThreadDrawing(0); + rmp.m_textureParams[graphics::ESmallTexture] = tpp; - Platform::FilesList fonts; - GetPlatform().GetFontNames(fonts); - m_resourceManager->addFonts(fonts); - m_frameBuffer = make_shared_ptr(new graphics::gl::FrameBuffer()); + rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt", + "fonts_whitelist.txt", + "fonts_blacklist.txt", + 2 * 1024 * 1024); - Drawer::Params params; - params.m_resourceManager = m_resourceManager; - params.m_frameBuffer = m_frameBuffer; - params.m_threadSlot = m_resourceManager->guiThreadSlot(); - params.m_renderContext = m_primaryContext; - params.m_skinName = "basic_mdpi.skn"; + rmp.m_threadSlotsCount = 1; + rmp.m_renderThreadsCount = 0; - m_p = make_shared_ptr(new graphics::Screen(params)); + rmp.m_useSingleThreadedOGL = false; - m_primaryFrameBuffer = make_shared_ptr(new graphics::gl::FrameBuffer(true)); + m_resourceManager.reset(new graphics::ResourceManager(rmp)); - params.m_frameBuffer = m_primaryFrameBuffer; - m_primaryScreen = make_shared_ptr(new graphics::Screen(params)); -} - -void GLDrawWidget::resizeGL(int w, int h) -{ - m_p->onSize(w, h); - m_primaryScreen->onSize(w, h); + m_primaryContext->setResourceManager(m_resourceManager); + m_primaryContext->startThreadDrawing(0); - m_frameBuffer->onSize(w, h); - m_primaryFrameBuffer->onSize(w, h); + Platform::FilesList fonts; + GetPlatform().GetFontNames(fonts); + m_resourceManager->addFonts(fonts); - m_depthBuffer.reset(); - m_depthBuffer = make_shared_ptr(new graphics::gl::RenderBuffer(w, h, true)); - m_frameBuffer->setDepthBuffer(m_depthBuffer); + Drawer::Params params; - m_renderTarget.reset(); - m_renderTarget = make_shared_ptr(new graphics::gl::RGBA8Texture(w, h)); - m_p->setRenderTarget(m_renderTarget); -} - -void GLDrawWidget::paintGL() -{ -// m_renderTarget->dump("renderTarget.png"); + m_primaryFrameBuffer = make_shared_ptr(new graphics::gl::FrameBuffer(true)); - m_p->beginFrame(); - m_p->clear(graphics::Color(182, 182, 182, 255)); - DoDraw(m_p); - m_p->endFrame(); + params.m_frameBuffer = m_primaryFrameBuffer; + params.m_resourceManager = m_resourceManager; + params.m_threadSlot = m_resourceManager->guiThreadSlot(); + params.m_renderContext = m_primaryContext; + params.m_skinName = "basic_mdpi.skn"; - m_primaryScreen->beginFrame(); + m_primaryScreen = make_shared_ptr(new graphics::Screen(params)); + } - m_primaryScreen->immDrawTexturedRect( - m2::RectF(0, 0, m_renderTarget->width(), m_renderTarget->height()), - m2::RectF(0, 0, 1, 1), - m_renderTarget - ); + void GLDrawWidget::resizeGL(int w, int h) + { + m_primaryScreen->onSize(w, h); + m_primaryFrameBuffer->onSize(w, h); + } - m_primaryScreen->endFrame(); -} + void GLDrawWidget::paintGL() + { + DoDraw(m_primaryScreen); + } } |