Skip to content

Compile errors on Visual Studio #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/osgQOpenGL/osgQOpenGLWidget
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <OpenThreads/ReadWriteMutex>

#ifdef WIN32
#define __gl_h_
//#define __gl_h_
#include <osg/GL>
#endif

Expand All @@ -39,6 +39,7 @@ protected:
bool _osgWantsToRenderFrame{true};
OpenThreads::ReadWriteMutex _osgMutex;
osg::ArgumentParser* _arguments {nullptr};
bool _isFirstFrame {true};

friend class OSGRenderer;

Expand Down
4 changes: 2 additions & 2 deletions include/osgQOpenGL/osgQOpenGLWindow
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <OpenThreads/ReadWriteMutex>

#ifdef WIN32
#define __gl_h_
//#define __gl_h_
#include <osg/GL>
#endif

Expand All @@ -37,7 +37,7 @@ protected:
OSGRenderer* m_renderer {nullptr};
bool _osgWantsToRenderFrame{true};
OpenThreads::ReadWriteMutex _osgMutex;

bool _isFirstFrame {true};
friend class OSGRenderer;

QWidget* _widget = nullptr;
Expand Down
9 changes: 0 additions & 9 deletions src/osgQOpenGL/OSGRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,6 @@ void OSGRenderer::setupOSG(int windowWidth, int windowHeight, float windowScale)
osgViewer::Viewer::Windows windows;
getWindows(windows);

for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
itr != windows.end(); ++itr)
{
(*itr)->getState()->setUseModelViewAndProjectionUniforms(true);
(*itr)->getState()->setUseVertexAttributeAliasing(true);
(*itr)->getState()->setShaderCompositionEnabled(
false); // TODO: check if we need it ???
}

_timerId = startTimer(10, Qt::PreciseTimer);
_lastFrameStartTime.setStartTick(0);
}
Expand Down
15 changes: 11 additions & 4 deletions src/osgQOpenGL/osgQOpenGLWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ void osgQOpenGLWidget::resizeGL(int w, int h)
void osgQOpenGLWidget::paintGL()
{
OpenThreads::ScopedReadLock locker(_osgMutex);
m_renderer->frame();
if (_isFirstFrame) {
_isFirstFrame = false;
m_renderer->getCamera()->getGraphicsContext()->setDefaultFboId(defaultFramebufferObject());
}
m_renderer->frame();
}

void osgQOpenGLWidget::keyPressEvent(QKeyEvent* event)
Expand Down Expand Up @@ -205,9 +209,12 @@ void osgQOpenGLWidget::createRenderer()
{
// call this before creating a View...
setDefaultDisplaySettings();

m_renderer = new OSGRenderer(_arguments, this);
QScreen* screen = windowHandle()
if (!_arguments) {
m_renderer = new OSGRenderer(this);
} else {
m_renderer = new OSGRenderer(_arguments, this);
}
QScreen* screen = windowHandle()
&& windowHandle()->screen() ? windowHandle()->screen() :
qApp->screens().front();
m_renderer->setupOSG(width(), height(), screen->devicePixelRatio());
Expand Down
4 changes: 4 additions & 0 deletions src/osgQOpenGL/osgQOpenGLWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ void osgQOpenGLWindow::resizeGL(int w, int h)
void osgQOpenGLWindow::paintGL()
{
OpenThreads::ScopedReadLock locker(_osgMutex);
if (_isFirstFrame) {
_isFirstFrame = false;
m_renderer->getCamera()->getGraphicsContext()->setDefaultFboId(defaultFramebufferObject());
}
m_renderer->frame();
}

Expand Down