Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tstwidgets.cpp « qt_tstfrm - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37679e354156f5a2395187cecf9ac78936237594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "tstwidgets.hpp"

#include "../graphics/screen.hpp"
#include "../graphics/resource_manager.hpp"

#include "../graphics/opengl/utils.hpp"
#include "../graphics/opengl/framebuffer.hpp"
#include "../graphics/opengl/renderbuffer.hpp"
#include "../graphics/opengl/opengl.hpp"

#include "../platform/platform.hpp"

namespace tst
{
  void GLDrawWidget::initializeGL()
  {
    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.reset(new qt::gl::RenderContext(this));

    graphics::ResourceManager::Params rmp;
    rmp.m_texFormat = graphics::Data8Bpp;

    rmp.m_videoMemoryLimit = 20 * 1024 * 1024;

    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),
                                                       1,
                                                       graphics::ELargeStorage,
                                                       true);

    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),
                                                       1,
                                                       graphics::EMediumStorage,
                                                       true);

    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),
                                                       1,
                                                       graphics::ESmallStorage,
                                                       true);

    rmp.m_storageParams[graphics::ESmallStorage] = spp;

    spp = graphics::ResourceManager::StoragePoolParams(100 * sizeof(graphics::gl::Vertex),
                                                       sizeof(graphics::gl::Vertex),
                                                       200 * sizeof(unsigned short),
                                                       sizeof(unsigned short),
                                                       1,
                                                       graphics::ETinyStorage,
                                                       true);

    rmp.m_storageParams[graphics::ETinyStorage] = spp;


    tpp = graphics::ResourceManager::TexturePoolParams(512,
                                                       512,
                                                       1,
                                                       rmp.m_texFormat,
                                                       graphics::ELargeTexture,
                                                       true);

    rmp.m_textureParams[graphics::ELargeTexture] = tpp;

    tpp = graphics::ResourceManager::TexturePoolParams(256,
                                                       256,
                                                       1,
                                                       rmp.m_texFormat,
                                                       graphics::EMediumTexture,
                                                       true);

    rmp.m_textureParams[graphics::EMediumTexture] = tpp;

    tpp = graphics::ResourceManager::TexturePoolParams(128,
                                                       128,
                                                       1,
                                                       rmp.m_texFormat,
                                                       graphics::ESmallTexture,
                                                       true);

    rmp.m_textureParams[graphics::ESmallTexture] = tpp;


    rmp.m_glyphCacheParams = graphics::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
                                                                         "fonts_whitelist.txt",
                                                                         "fonts_blacklist.txt",
                                                                         2 * 1024 * 1024,
                                                                         graphics::EDensityMDPI);

    rmp.m_threadSlotsCount = 1;
    rmp.m_renderThreadsCount = 0;

    rmp.m_useSingleThreadedOGL = false;

    m_resourceManager.reset(new graphics::ResourceManager(rmp, "basic.skn", graphics::EDensityMDPI));

    m_primaryContext->setResourceManager(m_resourceManager);
    m_primaryContext->startThreadDrawing(0);

    Platform::FilesList fonts;
    GetPlatform().GetFontNames(fonts);
    m_resourceManager->addFonts(fonts);

    Drawer::Params params;

    m_primaryFrameBuffer.reset(new graphics::gl::FrameBuffer(true));

    params.m_frameBuffer = m_primaryFrameBuffer;
    params.m_resourceManager = m_resourceManager;
    params.m_threadSlot = m_resourceManager->guiThreadSlot();
    params.m_renderContext = m_primaryContext;

    m_primaryScreen.reset(new graphics::Screen(params));
  }

  void GLDrawWidget::resizeGL(int w, int h)
  {
    m_primaryScreen->onSize(w, h);
    m_primaryFrameBuffer->onSize(w, h);
  }

  void GLDrawWidget::paintGL()
  {
    DoDraw(m_primaryScreen);
  }
}