Hi Robert,
He edited the original post.
I've attached it for you.
Cheers
Sebastian
Hi Phillipp,
The source didn't make it through the osg-users mailing list so can't
comment about the implementation side.
From the error description in the first post it's clear that the
graphics context is not current when the graphics thread starts
running. osgViewer specifically calls makeCurrent() to ensure that
the context is current, if this fails then you'd see issues like you
are seeing. Whether this is the issue or not I can not say.
I could see being able to create an OSG application without X11 would
be useful. Any chance that you could open source the implementation
and submit for inclusion with the core osgViewer? This route would
help others help refine the implementation. The first step would
follow would be to make an small example program with all the required
classes in it then get this working, and then once it's refined enough
move the GraphicsContext implementation into osgViewer to sit
alongside the rest of the implementation.
Cheers,
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
/*
* EGLGraphicsWindow.cpp
*
* Created on: Apr 12, 2016
* Author: ubuntu
*/
#include "EGLGraphicsContext.h"
#include <iostream>
using namespace std;
EGLGraphicsContext::EGLGraphicsContext(osg::GraphicsContext::Traits* traits) :
osg::GraphicsContext(), _initialized(false), eglSurface(nullptr),
eglContext(
nullptr) {
_traits = traits;
realizeImplementation();
if (valid()) {
setState(new osg::State);
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext.valid()) {
getState()->setContextID(
_traits->sharedContext->getState()->getContextID());
incrementContextIDUsageCount(getState()->getContextID());
} else {
getState()->setContextID(
osg::GraphicsContext::createNewContextID());
}
}
}
EGLGraphicsContext::~EGLGraphicsContext() {
// TODO Auto-generated destructor stub
}
/** Return whether a valid and usable GraphicsContext has been created.*/
bool EGLGraphicsContext::valid() const {
return _initialized;
}
/** Realize the GraphicsContext implementation,
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
bool EGLGraphicsContext::realizeImplementation() {
if (_initialized) {
return true;
}
GetEglExtensionFunctionPointers();
eglDevice = GetEglDevice();
drmFd = GetDrmFd(eglDevice);
SetMode(drmFd, &planeID, &width, &height);
eglDpy = GetEglDisplay(eglDevice, drmFd);
SetUpEgl(eglDpy, planeID, _traits->width, _traits->height, &eglSurface,
&eglContext);
//disable vsync
if (eglSwapInterval(eglDpy, 0) == EGL_TRUE) {
cout << "swap interval changed successfully." << endl;
} else {
cout << "error while changing swap interval" << endl;
}
_initialized = true;
return true;
}
/** Return true if the graphics context has been realized, and is ready to use,
implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
bool EGLGraphicsContext::isRealizedImplementation() const {
return _initialized;
}
/** Close the graphics context implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
void EGLGraphicsContext::closeImplementation() {
_initialized = false;
}
/** Make this graphics context current implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
bool EGLGraphicsContext::makeCurrentImplementation() {
// cout << "egl context make current" << endl;
// cout << "is initialized?: " << _initialized << endl;
return eglMakeCurrent(eglDpy, eglSurface, eglSurface, eglContext)
== EGL_TRUE;
}
/** Make this graphics context current with specified read context
implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
bool EGLGraphicsContext::makeContextCurrentImplementation(
GraphicsContext* readContext) {
return makeCurrentImplementation();
}
/** Release the graphics context implementation.*/
bool EGLGraphicsContext::releaseContextImplementation() {
// cout << "egl context release" << endl;
return eglMakeCurrent(eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT) == EGL_TRUE;
}
/** Pure virtual, Bind the graphics context to associated texture
implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
void EGLGraphicsContext::bindPBufferToTextureImplementation(GLenum buffer) {
cout << "bindPBuffer not impl for egl context!!" << endl;
}
/** Swap the front and back buffers implementation.
* Pure virtual - must be implemented by concrete implementations of
GraphicsContext. */
void EGLGraphicsContext::swapBuffersImplementation() {
if (!_initialized) {
return;
}
eglSwapBuffers(eglDpy, eglSurface);
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org