desktop version for debug yopme render policy

This commit is contained in:
ExMix 2013-09-09 18:46:30 +03:00 committed by Alex Zolotarev
parent 55c59feaa0
commit 5a69a85c58
8 changed files with 293 additions and 1 deletions

View file

@ -36,7 +36,8 @@ SUBDIRS = 3party \
graphics/graphics_tests \
gui/gui_tests \
qt \
map_server
map_server \
yopme_desktop
} else {
# libraries which are used on mobile devices
SUBDIRS = 3party \

118
yopme_desktop/glwidget.cpp Normal file
View file

@ -0,0 +1,118 @@
#include "glwidget.hpp"
#include "../base/logging.hpp"
#include "../graphics/render_context.hpp"
#include "../map/qgl_render_context.hpp"
#include "../map/simple_render_policy.hpp"
#include "../map/yopme_render_policy.hpp"
#include "../graphics/render_context.hpp"
#include "../std/shared_ptr.hpp"
#include "../platform/video_timer.hpp"
#include "../platform/platform.hpp"
namespace
{
void empty()
{
}
class EmptyVideoTimer : public VideoTimer
{
typedef VideoTimer base_t;
public:
EmptyVideoTimer(TFrameFn func)
: base_t(bind(&empty))
{
}
~EmptyVideoTimer() { stop(); }
void start()
{
if (m_state == EStopped)
m_state = ERunning;
}
void resume()
{
if (m_state == EPaused)
{
m_state = EStopped;
start();
}
}
void pause()
{
stop();
m_state = EPaused;
}
void stop()
{
if (m_state == ERunning)
m_state = EStopped;
}
void perform() {}
};
}
GLWidget::GLWidget(QWidget * parent)
: QGLWidget(parent)
{
m_f.AddLocalMaps();
}
void GLWidget::initializeGL()
{
EmptyVideoTimer * timer = new EmptyVideoTimer(bind(&QGLWidget::updateGL, this));
shared_ptr<graphics::RenderContext> primaryRC(new qt::gl::RenderContext(this));
graphics::ResourceManager::Params rmParams;
rmParams.m_rtFormat = graphics::Data8Bpp;
rmParams.m_texFormat = graphics::Data8Bpp;
rmParams.m_texRtFormat = graphics::Data8Bpp;
rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit();
RenderPolicy::Params rpParams;
rpParams.m_videoTimer = timer;
rpParams.m_useDefaultFB = true;
rpParams.m_rmParams = rmParams;
rpParams.m_primaryRC = primaryRC;
rpParams.m_density = graphics::EDensityMDPI;
rpParams.m_skinName = "basic.skn";
rpParams.m_screenHeight = 640;
rpParams.m_screenWidth = 340;
try
{
//m_f.SetRenderPolicy(new SimpleRenderPolicy(rpParams));
m_f.SetRenderPolicy(new YopmeRP(rpParams));
}
catch (RootException & e)
{
LOG(LERROR, (e.what()));
}
}
void GLWidget::resizeGL(int w, int h)
{
m_f.OnSize(w, h);
m_f.Invalidate();
updateGL();
}
void GLWidget::paintGL()
{
m_f.GetNavigator().SetFromRect(m2::AnyRectD(
m2::RectD(MercatorBounds::LonToX(26.90),
MercatorBounds::LatToY(53.42),
MercatorBounds::LonToX(27.80),
MercatorBounds::LatToY(54.64))));
shared_ptr<PaintEvent> e(new PaintEvent(m_f.GetRenderPolicy()->GetDrawer().get()));
m_f.BeginPaint(e);
m_f.DoPaint(e);
m_f.EndPaint(e);
}

View file

@ -0,0 +1,19 @@
#pragma once
#include <QtOpenGL/QGLWidget>
#include "../map/framework.hpp"
class GLWidget : public QGLWidget
{
public:
GLWidget(QWidget * parent);
protected:
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
private:
Framework m_f;
};

11
yopme_desktop/main.cpp Normal file
View file

@ -0,0 +1,11 @@
#include "mainwindow.hpp"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View file

@ -0,0 +1,16 @@
#include "mainwindow.hpp"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_w = new GLWidget(this);
setCentralWidget(m_w);
}
MainWindow::~MainWindow()
{
delete ui;
}

View file

@ -0,0 +1,24 @@
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
#include "glwidget.hpp"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
GLWidget * m_w;
};
#endif // MAINWINDOW_HPP

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>640</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,63 @@
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-08T12:17:34
#
#-------------------------------------------------
ROOT_DIR = ..
DEPENDENCIES = map gui search storage indexer graphics platform anim geometry coding base \
bzip2 freetype expat fribidi tomcrypt jansson protobuf zlib
include($$ROOT_DIR/common.pri)
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = yopme_desktop
TEMPLATE = app
macx-* {
LIBS *= "-framework CoreLocation" "-framework Foundation" "-framework CoreWLAN" \
"-framework QuartzCore" "-framework IOKit"
# Bundle Resouces
OTHER_RES.path = Contents/Resources
OTHER_RES.files = ../data/about.html \
../data/eula.html \
../data/welcome.html \
../data/countries.txt \
../data/languages.txt \
../data/categories.txt \
../data/packed_polygons.bin
CLASSIFICATOR_RES.path = Contents/Resources
CLASSIFICATOR_RES.files = ../data/classificator.txt \
../data/types.txt \
../data/drules_proto.bin
SKIN_RES.path = Contents/Resources/resources-mdpi
SKIN_RES.files = ../data/resources-mdpi/basic.skn ../data/resources-mdpi/symbols.png
FONT_RES.path = Contents/Resources
FONT_RES.files = ../data/01_dejavusans.ttf \
../data/02_wqy-microhei.ttf \
../data/03_jomolhari-id-a3d.ttf \
../data/04_padauk.ttf \
../data/05_khmeros.ttf \
../data/06_code2000.ttf \
../data/fonts_blacklist.txt \
../data/fonts_whitelist.txt \
../data/unicode_blocks.txt
MWM_RES.path = Contents/Resources
MWM_RES.files = ../data/World.mwm ../data/WorldCoasts.mwm ../data/Belarus.mwm
QMAKE_BUNDLE_DATA += OTHER_RES CLASSIFICATOR_RES SKIN_RES FONT_RES MWM_RES
}
SOURCES += main.cpp\
mainwindow.cpp \
glwidget.cpp
HEADERS += mainwindow.hpp \
glwidget.hpp
FORMS += mainwindow.ui