forked from organicmaps/organicmaps
OGLContextFactory + Qt impl.
This commit is contained in:
parent
1fb2f88afd
commit
6476b1cfea
7 changed files with 62 additions and 10 deletions
|
@ -25,3 +25,6 @@ OTHER_FILES += \
|
|||
shaders/texturing_vertex_shader.vsh \
|
||||
shaders/shader_index.txt \
|
||||
shaders/texturing_fragment_shader.fsh
|
||||
|
||||
HEADERS += \
|
||||
oglcontextfactory.hpp
|
||||
|
|
9
drape/oglcontextfactory.hpp
Normal file
9
drape/oglcontextfactory.hpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "oglcontext.hpp"
|
||||
|
||||
class OGLContextFactory
|
||||
{
|
||||
virtual OGLContext * getDrawContext() = 0;
|
||||
virtual OGLContext * getResourcesUploadContext() = 0;
|
||||
};
|
|
@ -24,12 +24,14 @@ HEADERS += \
|
|||
mainwindow.hpp \
|
||||
glwidget.hpp \
|
||||
qtoglcontext.hpp \
|
||||
qtoglcontextfactory.hpp
|
||||
|
||||
SOURCES += \
|
||||
mainwindow.cpp \
|
||||
main.cpp \
|
||||
glwidget.cpp \
|
||||
qtoglcontext.cpp \
|
||||
qtoglcontextfactory.cpp
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
|
|
@ -2,21 +2,15 @@
|
|||
|
||||
#include "../base/assert.hpp"
|
||||
|
||||
QtOGLContext::QtOGLContext(QWindow * surface)
|
||||
{
|
||||
m_isContextCreated = false;
|
||||
m_surface = surface;
|
||||
m_nativeContext = new QOpenGLContext(m_surface);
|
||||
m_nativeContext->setFormat(m_surface->requestedFormat());
|
||||
}
|
||||
|
||||
QtOGLContext::QtOGLContext(QWindow * surface, QtOGLContext * contextToShareWith)
|
||||
{
|
||||
m_isContextCreated = false;
|
||||
m_surface = surface;
|
||||
m_nativeContext = new QOpenGLContext(m_surface);
|
||||
m_nativeContext->setFormat(m_surface->requestedFormat());
|
||||
m_nativeContext->setShareContext(contextToShareWith->m_nativeContext);
|
||||
|
||||
if (contextToShareWith != NULL)
|
||||
m_nativeContext->setShareContext(contextToShareWith->m_nativeContext);
|
||||
}
|
||||
|
||||
void QtOGLContext::makeCurrent()
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
class QtOGLContext: public OGLContext
|
||||
{
|
||||
public:
|
||||
QtOGLContext(QWindow * surface);
|
||||
QtOGLContext(QWindow *surface, QtOGLContext * contextToShareWith);
|
||||
|
||||
virtual void present();
|
||||
|
|
25
drape_head/qtoglcontextfactory.cpp
Normal file
25
drape_head/qtoglcontextfactory.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "qtoglcontextfactory.hpp"
|
||||
|
||||
#include "../base/assert.hpp"
|
||||
|
||||
QtOGLContextFactory::QtOGLContextFactory(QWindow * surface)
|
||||
: m_surface(surface)
|
||||
, m_drawContext(NULL)
|
||||
, m_uploadContext(NULL)
|
||||
{}
|
||||
|
||||
OGLContext * QtOGLContextFactory::getDrawContext()
|
||||
{
|
||||
if (m_drawContext == NULL)
|
||||
m_drawContext = new QtOGLContext(m_surface, m_uploadContext);
|
||||
|
||||
return m_drawContext;
|
||||
}
|
||||
|
||||
OGLContext * QtOGLContextFactory::getResourcesUploadContext()
|
||||
{
|
||||
if (m_uploadContext != NULL)
|
||||
m_uploadContext = new QtOGLContext(m_surface, m_drawContext);
|
||||
|
||||
return m_uploadContext;
|
||||
}
|
20
drape_head/qtoglcontextfactory.hpp
Normal file
20
drape_head/qtoglcontextfactory.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../drape/oglcontextfactory.hpp"
|
||||
#include "qtoglcontext.hpp"
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
class QtOGLContextFactory
|
||||
{
|
||||
public:
|
||||
QtOGLContextFactory(QWindow * surface);
|
||||
|
||||
virtual OGLContext * getDrawContext();
|
||||
virtual OGLContext * getResourcesUploadContext();
|
||||
|
||||
private:
|
||||
QWindow * m_surface;
|
||||
QtOGLContext * m_drawContext;
|
||||
QtOGLContext * m_uploadContext;
|
||||
};
|
Loading…
Add table
Reference in a new issue