Added EGL support into build system for GLES1 + GLES2.
Added EGL support into GraphicsWindowX11.
This commit is contained in:
parent
0ca4c82e3a
commit
93d83010f8
@ -287,6 +287,8 @@ OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions libr
|
|||||||
OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF)
|
OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF)
|
||||||
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF)
|
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF)
|
||||||
|
|
||||||
|
SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
|
||||||
|
|
||||||
# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||||
# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
|
# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||||
# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||||
|
@ -51,7 +51,12 @@ ENDMACRO(LINK_EXTERNAL TRGTNAME)
|
|||||||
#######################################################################################################
|
#######################################################################################################
|
||||||
|
|
||||||
MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
|
MACRO(LINK_CORELIB_DEFAULT CORELIB_NAME)
|
||||||
LINK_EXTERNAL(${CORELIB_NAME} ${OPENGL_LIBRARIES})
|
SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
|
||||||
|
IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
|
||||||
|
SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
LINK_EXTERNAL(${CORELIB_NAME} ${ALL_GL_LIBRARIES})
|
||||||
LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY)
|
LINK_WITH_VARIABLES(${CORELIB_NAME} OPENTHREADS_LIBRARY)
|
||||||
IF(OPENSCENEGRAPH_SONAMES)
|
IF(OPENSCENEGRAPH_SONAMES)
|
||||||
SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OPENSCENEGRAPH_VERSION} SOVERSION ${OPENSCENEGRAPH_SOVERSION})
|
SET_TARGET_PROPERTIES(${CORELIB_NAME} PROPERTIES VERSION ${OPENSCENEGRAPH_VERSION} SOVERSION ${OPENSCENEGRAPH_SOVERSION})
|
||||||
@ -95,6 +100,11 @@ MACRO(SETUP_LINK_LIBRARIES)
|
|||||||
ENDIF(TO_INSERT)
|
ENDIF(TO_INSERT)
|
||||||
ENDFOREACH(LINKLIB)
|
ENDFOREACH(LINKLIB)
|
||||||
|
|
||||||
|
SET(ALL_GL_LIBRARIES ${OPENGL_LIBRARIES})
|
||||||
|
IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
|
||||||
|
SET(ALL_GL_LIBRARIES ${ALL_GL_LIBRARIES} ${OPENGL_egl_LIBRARY})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
# FOREACH(LINKLIB ${TARGET_LIBRARIES})
|
||||||
# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||||
# ENDFOREACH(LINKLIB)
|
# ENDFOREACH(LINKLIB)
|
||||||
@ -107,7 +117,7 @@ MACRO(SETUP_LINK_LIBRARIES)
|
|||||||
ENDIF(TARGET_LIBRARIES_VARS)
|
ENDIF(TARGET_LIBRARIES_VARS)
|
||||||
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||||
#when using full path name to specify linkage, it seems that already linked libs must be specified
|
#when using full path name to specify linkage, it seems that already linked libs must be specified
|
||||||
LINK_EXTERNAL(${TARGET_TARGETNAME} ${OPENGL_LIBRARIES})
|
LINK_EXTERNAL(${TARGET_TARGETNAME} ${ALL_GL_LIBRARIES})
|
||||||
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
|
||||||
|
|
||||||
ENDMACRO(SETUP_LINK_LIBRARIES)
|
ENDMACRO(SETUP_LINK_LIBRARIES)
|
||||||
|
@ -20,6 +20,11 @@
|
|||||||
|
|
||||||
#ifndef GL_CLIP_PLANE0
|
#ifndef GL_CLIP_PLANE0
|
||||||
#define GL_CLIP_PLANE0 0x3000
|
#define GL_CLIP_PLANE0 0x3000
|
||||||
|
#define GL_CLIP_PLANE1 0x3001
|
||||||
|
#define GL_CLIP_PLANE2 0x3002
|
||||||
|
#define GL_CLIP_PLANE3 0x3003
|
||||||
|
#define GL_CLIP_PLANE4 0x3004
|
||||||
|
#define GL_CLIP_PLANE5 0x3005
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
typedef char GLchar;
|
typedef char GLchar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(GL_VERSION_2_0)
|
||||||
|
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
|
||||||
|
#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(GL_VERSION_2_0) && !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_VERSION_2_0) && !defined(GL_ES_VERSION_2_0)
|
||||||
#define GL_VERSION_2_0 1
|
#define GL_VERSION_2_0 1
|
||||||
#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
|
#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
|
||||||
@ -44,8 +49,6 @@ typedef char GLchar;
|
|||||||
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
|
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
|
||||||
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
|
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
|
||||||
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
|
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
|
||||||
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
|
|
||||||
#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
|
|
||||||
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
|
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
|
||||||
#define GL_STENCIL_BACK_FUNC 0x8800
|
#define GL_STENCIL_BACK_FUNC 0x8800
|
||||||
#define GL_STENCIL_BACK_FAIL 0x8801
|
#define GL_STENCIL_BACK_FAIL 0x8801
|
||||||
|
@ -20,6 +20,13 @@
|
|||||||
|
|
||||||
#ifndef GL_LIGHT0
|
#ifndef GL_LIGHT0
|
||||||
#define GL_LIGHT0 0x4000
|
#define GL_LIGHT0 0x4000
|
||||||
|
#define GL_LIGHT1 0x4001
|
||||||
|
#define GL_LIGHT2 0x4002
|
||||||
|
#define GL_LIGHT3 0x4003
|
||||||
|
#define GL_LIGHT4 0x4004
|
||||||
|
#define GL_LIGHT5 0x4005
|
||||||
|
#define GL_LIGHT6 0x4006
|
||||||
|
#define GL_LIGHT7 0x4007
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_LIGHTING
|
#ifndef GL_LIGHTING
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#define GL_RESCALE_NORMAL 0x803A
|
#define GL_RESCALE_NORMAL 0x803A
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_NORMALIZE
|
||||||
|
#define GL_NORMALIZE 0x0BA1
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,17 @@
|
|||||||
#define GLX_GLXEXT_PROTOTYPES 1
|
#define GLX_GLXEXT_PROTOTYPES 1
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <GL/glx.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||||
|
#define OSG_USE_EGL
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#else
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osgViewer
|
||||||
@ -41,7 +51,10 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
|||||||
_parent(0),
|
_parent(0),
|
||||||
_window(0),
|
_window(0),
|
||||||
_visualInfo(0),
|
_visualInfo(0),
|
||||||
_glxContext(0),
|
_context(0),
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
_surface(0),
|
||||||
|
#endif
|
||||||
_currentCursor(0),
|
_currentCursor(0),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
_realized(false),
|
_realized(false),
|
||||||
@ -144,7 +157,15 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
|||||||
|
|
||||||
Window& getParent() { return _parent; }
|
Window& getParent() { return _parent; }
|
||||||
Window& getWindow() { return _window; }
|
Window& getWindow() { return _window; }
|
||||||
GLXContext& getGLXContext() { return _glxContext; }
|
|
||||||
|
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
typedef EGLContext Context;
|
||||||
|
#else
|
||||||
|
typedef GLXContext Context;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Context& getContext() { return _context; }
|
||||||
|
|
||||||
Cursor getCurrentCursor() { return _currentCursor; }
|
Cursor getCurrentCursor() { return _currentCursor; }
|
||||||
|
|
||||||
@ -180,7 +201,11 @@ class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow
|
|||||||
Window _parent;
|
Window _parent;
|
||||||
Window _window;
|
Window _window;
|
||||||
XVisualInfo* _visualInfo;
|
XVisualInfo* _visualInfo;
|
||||||
GLXContext _glxContext;
|
Context _context;
|
||||||
|
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
EGLSurface _surface;
|
||||||
|
#endif
|
||||||
|
|
||||||
Cursor _currentCursor;
|
Cursor _currentCursor;
|
||||||
|
|
||||||
|
@ -19,19 +19,14 @@
|
|||||||
#ifndef OSGVIEWER_PIXELBUFFERX11
|
#ifndef OSGVIEWER_PIXELBUFFERX11
|
||||||
#define OSGVIEWER_PIXELBUFFERX11 1
|
#define OSGVIEWER_PIXELBUFFERX11 1
|
||||||
|
|
||||||
#include <osg/GraphicsContext>
|
#include <osgViewer/api/X11/GraphicsWindowX11>
|
||||||
#include <osgViewer/Export>
|
|
||||||
|
|
||||||
#define GLX_GLXEXT_PROTOTYPES 1
|
#ifndef OSG_USE_EGL
|
||||||
|
#ifndef GLX_VERSION_1_3
|
||||||
#include <X11/X.h>
|
|
||||||
#include <GL/glx.h>
|
|
||||||
|
|
||||||
#ifndef GLX_VERSION_1_3
|
|
||||||
typedef XID GLXPbuffer;
|
typedef XID GLXPbuffer;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osgViewer
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -77,8 +72,16 @@ class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext
|
|||||||
|
|
||||||
Display* getDisplay() const { return _display; }
|
Display* getDisplay() const { return _display; }
|
||||||
|
|
||||||
GLXPbuffer& getPbuffer() { return _pbuffer; }
|
#ifdef OSG_USE_EGL
|
||||||
GLXContext& getGLXContext() { return _glxContext; }
|
typedef EGLContext Context;
|
||||||
|
typedef EGLSurface Pbuffer;
|
||||||
|
#else
|
||||||
|
typedef GLXContext Context;
|
||||||
|
typedef GLXPbuffer Pbuffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Pbuffer& getPbuffer() { return _pbuffer; }
|
||||||
|
Context& getContext() { return _context; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -90,9 +93,9 @@ class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext
|
|||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
Display* _display;
|
Display* _display;
|
||||||
GLXPbuffer _pbuffer;
|
Pbuffer _pbuffer;
|
||||||
XVisualInfo* _visualInfo;
|
XVisualInfo* _visualInfo;
|
||||||
GLXContext _glxContext;
|
Context _context;
|
||||||
|
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
bool _realized;
|
bool _realized;
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#include <osg/TexGen>
|
#include <osg/TexGen>
|
||||||
#include <osg/PolygonOffset>
|
#include <osg/PolygonOffset>
|
||||||
#include <osg/LineStipple>
|
#include <osg/LineStipple>
|
||||||
|
#include <osg/Light>
|
||||||
|
#include <osg/ClipPlane>
|
||||||
|
#include <osg/AlphaFunc>
|
||||||
|
#include <osg/Point>
|
||||||
|
#include <osg/Material>
|
||||||
|
#include <osg/Fog>
|
||||||
|
#include <osg/GL2Extensions>
|
||||||
|
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
#include <osgDB/Input>
|
#include <osgDB/Input>
|
||||||
|
@ -165,9 +165,11 @@ public:
|
|||||||
xform->setMatrix( osg::Matrix::scale( sx, sy, sz ) );
|
xform->setMatrix( osg::Matrix::scale( sx, sy, sz ) );
|
||||||
xform->addChild( node );
|
xform->addChild( node );
|
||||||
|
|
||||||
|
#ifndef OSG_GLES2_AVAILABLE
|
||||||
// turn on GL_NORMALIZE to prevent problems with scaled normals
|
// turn on GL_NORMALIZE to prevent problems with scaled normals
|
||||||
osg::StateSet* ss = xform->getOrCreateStateSet();
|
osg::StateSet* ss = xform->getOrCreateStateSet();
|
||||||
ss->setMode( GL_NORMALIZE, osg::StateAttribute::ON );
|
ss->setMode( GL_NORMALIZE, osg::StateAttribute::ON );
|
||||||
|
#endif
|
||||||
|
|
||||||
return xform;
|
return xform;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,6 @@ ELSE()
|
|||||||
SET(OSGVIEWER_USE_XRANDR OFF)
|
SET(OSGVIEWER_USE_XRANDR OFF)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
|
|
||||||
ELSE()
|
|
||||||
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
||||||
${HEADER_PATH}/api/X11/GraphicsWindowX11
|
${HEADER_PATH}/api/X11/GraphicsWindowX11
|
||||||
${HEADER_PATH}/api/X11/PixelBufferX11
|
${HEADER_PATH}/api/X11/PixelBufferX11
|
||||||
@ -119,7 +117,6 @@ ELSE()
|
|||||||
GraphicsWindowX11.cpp
|
GraphicsWindowX11.cpp
|
||||||
PixelBufferX11.cpp
|
PixelBufferX11.cpp
|
||||||
)
|
)
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(OSGVIEWER_USE_XRANDR)
|
IF(OSGVIEWER_USE_XRANDR)
|
||||||
ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
|
ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
|
||||||
|
@ -276,6 +276,17 @@ bool GraphicsWindowX11::createVisualInfo()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
|
||||||
|
_visualInfo = new XVisualInfo;
|
||||||
|
int depth = DefaultDepth( _display, _traits->screenNum );
|
||||||
|
if (XMatchVisualInfo( _display, _traits->screenNum, depth, TrueColor, _visualInfo )==0)
|
||||||
|
{
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::createVisualInfo() failed."<<std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
typedef std::vector<int> Attributes;
|
typedef std::vector<int> Attributes;
|
||||||
Attributes attributes;
|
Attributes attributes;
|
||||||
@ -313,6 +324,7 @@ bool GraphicsWindowX11::createVisualInfo()
|
|||||||
attributes.push_back(None);
|
attributes.push_back(None);
|
||||||
|
|
||||||
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
|
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return _visualInfo != 0;
|
return _visualInfo != 0;
|
||||||
@ -602,8 +614,6 @@ void GraphicsWindowX11::init()
|
|||||||
|
|
||||||
_ownsWindow = windowHandle == 0;
|
_ownsWindow = windowHandle == 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_display = XOpenDisplay(_traits->displayName().c_str());
|
_display = XOpenDisplay(_traits->displayName().c_str());
|
||||||
|
|
||||||
if (!_display)
|
if (!_display)
|
||||||
@ -613,6 +623,24 @@ void GraphicsWindowX11::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
|
||||||
|
EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)_display);
|
||||||
|
|
||||||
|
EGLint eglMajorVersion, eglMinorVersion;
|
||||||
|
if (!eglInitialize(eglDisplay, &eglMajorVersion, &eglMinorVersion))
|
||||||
|
{
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - eglInitialize() failed."<<std::endl;
|
||||||
|
|
||||||
|
XCloseDisplay( _display );
|
||||||
|
_display = 0;
|
||||||
|
_valid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - eglInitialize() succeded eglMajorVersion="<<eglMajorVersion<<" iMinorVersion="<<eglMinorVersion<<std::endl;
|
||||||
|
|
||||||
|
#else
|
||||||
// Query for GLX extension
|
// Query for GLX extension
|
||||||
int errorBase, eventBase;
|
int errorBase, eventBase;
|
||||||
if( glXQueryExtension( _display, &errorBase, &eventBase) == False )
|
if( glXQueryExtension( _display, &errorBase, &eventBase) == False )
|
||||||
@ -624,6 +652,7 @@ void GraphicsWindowX11::init()
|
|||||||
_valid = false;
|
_valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"GLX extension, errorBase="<<errorBase<<" eventBase="<<eventBase<<std::endl;
|
// osg::notify(osg::NOTICE)<<"GLX extension, errorBase="<<errorBase<<" eventBase="<<eventBase<<std::endl;
|
||||||
|
|
||||||
@ -647,26 +676,98 @@ void GraphicsWindowX11::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLXContext sharedContextGLX = NULL;
|
Context sharedContextGLX = NULL;
|
||||||
|
|
||||||
// get any shared GLX contexts
|
// get any shared GLX contexts
|
||||||
GraphicsWindowX11* graphicsWindowX11 = dynamic_cast<GraphicsWindowX11*>(_traits->sharedContext);
|
GraphicsWindowX11* graphicsWindowX11 = dynamic_cast<GraphicsWindowX11*>(_traits->sharedContext);
|
||||||
if (graphicsWindowX11)
|
if (graphicsWindowX11)
|
||||||
{
|
{
|
||||||
sharedContextGLX = graphicsWindowX11->getGLXContext();
|
sharedContextGLX = graphicsWindowX11->getContext();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PixelBufferX11* pixelBufferX11 = dynamic_cast<PixelBufferX11*>(_traits->sharedContext);
|
PixelBufferX11* pixelBufferX11 = dynamic_cast<PixelBufferX11*>(_traits->sharedContext);
|
||||||
if (pixelBufferX11 && pixelBufferX11->valid())
|
if (pixelBufferX11 && pixelBufferX11->valid())
|
||||||
{
|
{
|
||||||
sharedContextGLX = pixelBufferX11->getGLXContext();
|
sharedContextGLX = pixelBufferX11->getContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glxContext = glXCreateContext( _display, _visualInfo, sharedContextGLX, True );
|
#ifdef OSG_USE_EGL
|
||||||
|
|
||||||
if (!_glxContext)
|
_valid = _ownsWindow ? createWindow() : setWindow(windowHandle);
|
||||||
|
|
||||||
|
if (!_valid)
|
||||||
|
{
|
||||||
|
XCloseDisplay( _display );
|
||||||
|
_display = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - window created ="<<_valid<<std::endl;
|
||||||
|
|
||||||
|
EGLConfig eglConfig = 0;
|
||||||
|
|
||||||
|
#if defined(OSG_GLES1_AVAILABLE)
|
||||||
|
EGLint configAttribs[3];
|
||||||
|
configAttribs[0] = EGL_SURFACE_TYPE;
|
||||||
|
configAttribs[1] = EGL_WINDOW_BIT;
|
||||||
|
configAttribs[2] = EGL_NONE;
|
||||||
|
#else
|
||||||
|
EGLint configAttribs[5];
|
||||||
|
configAttribs[0] = EGL_SURFACE_TYPE;
|
||||||
|
configAttribs[1] = EGL_WINDOW_BIT;
|
||||||
|
configAttribs[2] = EGL_RENDERABLE_TYPE;
|
||||||
|
configAttribs[3] = EGL_OPENGL_ES2_BIT;
|
||||||
|
configAttribs[4] = EGL_NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int numConfigs;
|
||||||
|
if (!eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1, &numConfigs) || (numConfigs != 1))
|
||||||
|
{
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - eglChooseConfig() failed."<<std::endl;
|
||||||
|
XCloseDisplay( _display );
|
||||||
|
_valid = false;
|
||||||
|
_display = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_surface = eglCreateWindowSurface(eglDisplay, eglConfig, (EGLNativeWindowType)_window, NULL);
|
||||||
|
if (_surface == EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - eglCreateWindowSurface(..) failed."<<std::endl;
|
||||||
|
XCloseDisplay( _display );
|
||||||
|
_valid = false;
|
||||||
|
_display = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(OSG_GLES1_AVAILABLE)
|
||||||
|
EGLint* contextAttribs = 0;
|
||||||
|
#else
|
||||||
|
EGLint contextAttribs[3];
|
||||||
|
pi32ContextAttribs[0] = EGL_CONTEXT_CLIENT_VERSION;
|
||||||
|
pi32ContextAttribs[1] = 2;
|
||||||
|
pi32ContextAttribs[2] = EGL_NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_context = eglCreateContext(eglDisplay, eglConfig, NULL, contextAttribs);
|
||||||
|
if (_context == EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::init() - eglCreateContext(..) failed."<<std::endl;
|
||||||
|
XCloseDisplay( _display );
|
||||||
|
_valid = false;
|
||||||
|
_display = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
_context = glXCreateContext( _display, _visualInfo, sharedContextGLX, True );
|
||||||
|
|
||||||
|
if (!_context)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"Error: Unable to create OpenGL graphics context."<<std::endl;
|
osg::notify(osg::NOTICE)<<"Error: Unable to create OpenGL graphics context."<<std::endl;
|
||||||
XCloseDisplay( _display );
|
XCloseDisplay( _display );
|
||||||
@ -678,6 +779,8 @@ void GraphicsWindowX11::init()
|
|||||||
_initialized = _ownsWindow ? createWindow() : setWindow(windowHandle);
|
_initialized = _ownsWindow ? createWindow() : setWindow(windowHandle);
|
||||||
_valid = _initialized;
|
_valid = _initialized;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_valid == false)
|
if (_valid == false)
|
||||||
{
|
{
|
||||||
XCloseDisplay( _display );
|
XCloseDisplay( _display );
|
||||||
@ -723,7 +826,7 @@ bool GraphicsWindowX11::createWindow()
|
|||||||
if (!_window)
|
if (!_window)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"Error: Unable to create Window."<<std::endl;
|
osg::notify(osg::NOTICE)<<"Error: Unable to create Window."<<std::endl;
|
||||||
_glxContext = 0;
|
_context = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,10 +952,16 @@ bool GraphicsWindowX11::makeCurrentImplementation()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"GraphicsWindowX11::makeCurrentImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
#ifdef OSG_USE_EGL
|
||||||
// osg::notify(osg::NOTICE)<<" glXMakeCurrent ("<<_display<<","<<_window<<","<<_glxContext<<std::endl;
|
EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)_display);
|
||||||
|
bool result = eglMakeCurrent(eglDisplay, _surface, _surface, _context)==EGL_TRUE;
|
||||||
|
|
||||||
return glXMakeCurrent( _display, _window, _glxContext )==True;
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::makeCurrentImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<" _surface="<<_surface<<" _context="<<_context<<" result="<<result<<std::endl;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
|
return glXMakeCurrent( _display, _window, _context )==True;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsWindowX11::releaseContextImplementation()
|
bool GraphicsWindowX11::releaseContextImplementation()
|
||||||
@ -863,10 +972,14 @@ bool GraphicsWindowX11::releaseContextImplementation()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"GraphicsWindowX11::releaseContextImplementation() "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
osg::notify(osg::NOTICE)<<"GraphicsWindowX11::releaseContextImplementation() "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||||
// osg::notify(osg::NOTICE)<<" glXMakeCurrent ("<<_display<<std::endl;
|
|
||||||
|
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)_display);
|
||||||
|
return eglMakeCurrent( eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )==EGL_TRUE;
|
||||||
|
#else
|
||||||
return glXMakeCurrent( _display, None, NULL )==True;
|
return glXMakeCurrent( _display, None, NULL )==True;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -882,9 +995,14 @@ void GraphicsWindowX11::closeImplementation()
|
|||||||
|
|
||||||
if (_display)
|
if (_display)
|
||||||
{
|
{
|
||||||
if (_glxContext)
|
if (_context)
|
||||||
{
|
{
|
||||||
glXDestroyContext(_display, _glxContext );
|
#ifdef OSG_USE_EGL
|
||||||
|
EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)_display);
|
||||||
|
eglDestroyContext( eglDisplay, _context );
|
||||||
|
#else
|
||||||
|
glXDestroyContext( _display, _context );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_window && _ownsWindow)
|
if (_window && _ownsWindow)
|
||||||
@ -898,11 +1016,15 @@ void GraphicsWindowX11::closeImplementation()
|
|||||||
|
|
||||||
_window = 0;
|
_window = 0;
|
||||||
_parent = 0;
|
_parent = 0;
|
||||||
_glxContext = 0;
|
_context = 0;
|
||||||
|
|
||||||
if (_visualInfo)
|
if (_visualInfo)
|
||||||
{
|
{
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
delete _visualInfo;
|
||||||
|
#else
|
||||||
XFree(_visualInfo);
|
XFree(_visualInfo);
|
||||||
|
#endif
|
||||||
_visualInfo = 0;
|
_visualInfo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,7 +1046,12 @@ void GraphicsWindowX11::swapBuffersImplementation()
|
|||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"swapBuffersImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
// osg::notify(osg::NOTICE)<<"swapBuffersImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||||
|
|
||||||
glXSwapBuffers(_display, _window);
|
#ifdef OSG_USE_EGL
|
||||||
|
EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)_display);
|
||||||
|
eglSwapBuffers( eglDisplay, _surface );
|
||||||
|
#else
|
||||||
|
glXSwapBuffers( _display, _window );
|
||||||
|
#endif
|
||||||
|
|
||||||
while( XPending(_display) )
|
while( XPending(_display) )
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits)
|
|||||||
_display(0),
|
_display(0),
|
||||||
_pbuffer(0),
|
_pbuffer(0),
|
||||||
_visualInfo(0),
|
_visualInfo(0),
|
||||||
_glxContext(0),
|
_context(0),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
_realized(false),
|
_realized(false),
|
||||||
_useGLX1_3(false)
|
_useGLX1_3(false)
|
||||||
@ -234,9 +234,9 @@ void PixelBufferX11::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glxContext = glXCreateContext( _display, _visualInfo, sharedContextGLX, True );
|
_context = glXCreateContext( _display, _visualInfo, sharedContextGLX, True );
|
||||||
|
|
||||||
if (!_glxContext)
|
if (!_context)
|
||||||
{
|
{
|
||||||
osg::notify(osg::NOTICE)<<"Error: Unable to create OpenGL graphics context."<<std::endl;
|
osg::notify(osg::NOTICE)<<"Error: Unable to create OpenGL graphics context."<<std::endl;
|
||||||
XCloseDisplay( _display );
|
XCloseDisplay( _display );
|
||||||
@ -294,7 +294,7 @@ void PixelBufferX11::init()
|
|||||||
osg::notify(osg::NOTICE)<<"Error: Unable to create pbuffer."<<std::endl;
|
osg::notify(osg::NOTICE)<<"Error: Unable to create pbuffer."<<std::endl;
|
||||||
XCloseDisplay( _display );
|
XCloseDisplay( _display );
|
||||||
_display = 0;
|
_display = 0;
|
||||||
_glxContext = 0;
|
_context = 0;
|
||||||
_valid = false;
|
_valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -312,9 +312,9 @@ void PixelBufferX11::closeImplementation()
|
|||||||
// osg::notify(osg::NOTICE)<<"Closing PixelBufferX11"<<std::endl;
|
// osg::notify(osg::NOTICE)<<"Closing PixelBufferX11"<<std::endl;
|
||||||
if (_display)
|
if (_display)
|
||||||
{
|
{
|
||||||
if (_glxContext)
|
if (_context)
|
||||||
{
|
{
|
||||||
glXDestroyContext(_display, _glxContext );
|
glXDestroyContext(_display, _context );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pbuffer)
|
if (_pbuffer)
|
||||||
@ -338,7 +338,7 @@ void PixelBufferX11::closeImplementation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_pbuffer = 0;
|
_pbuffer = 0;
|
||||||
_glxContext = 0;
|
_context = 0;
|
||||||
|
|
||||||
if (_visualInfo)
|
if (_visualInfo)
|
||||||
{
|
{
|
||||||
@ -374,7 +374,7 @@ void PixelBufferX11::closeImplementation()
|
|||||||
{
|
{
|
||||||
// osg::notify(osg::NOTICE)<<"Closing PixelBufferX11"<<std::endl;
|
// osg::notify(osg::NOTICE)<<"Closing PixelBufferX11"<<std::endl;
|
||||||
_pbuffer = 0;
|
_pbuffer = 0;
|
||||||
_glxContext = 0;
|
_context = 0;
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
_realized = false;
|
_realized = false;
|
||||||
_valid = false;
|
_valid = false;
|
||||||
@ -408,9 +408,12 @@ bool PixelBufferX11::makeCurrentImplementation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"PixelBufferX11::makeCurrentImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
// osg::notify(osg::NOTICE)<<"PixelBufferX11::makeCurrentImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||||
// osg::notify(osg::NOTICE)<<" glXMakeCurrent ("<<_display<<","<<_pbuffer<<","<<_glxContext<<std::endl;
|
|
||||||
|
|
||||||
return glXMakeCurrent( _display, _pbuffer, _glxContext )==True;
|
#ifdef OSG_USE_EGL
|
||||||
|
return eglMakeCurrent(_display, _pbuffer, _pbuffer, _context)==EGL_TRUE;
|
||||||
|
#else
|
||||||
|
return glXMakeCurrent( _display, _pbuffer, _context )==True;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PixelBufferX11::makeContextCurrentImplementation(osg::GraphicsContext* readContext)
|
bool PixelBufferX11::makeContextCurrentImplementation(osg::GraphicsContext* readContext)
|
||||||
@ -429,9 +432,12 @@ bool PixelBufferX11::releaseContextImplementation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"PixelBufferX11::releaseContextImplementation() "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
// osg::notify(osg::NOTICE)<<"PixelBufferX11::releaseContextImplementation() "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||||
// osg::notify(osg::NOTICE)<<" glXMakeCurrent ("<<_display<<std::endl;
|
|
||||||
|
|
||||||
|
#ifdef OSG_USE_EGL
|
||||||
|
return eglMakeCurrent( _display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )==EGL_TRUE;
|
||||||
|
#else
|
||||||
return glXMakeCurrent( _display, None, NULL )==True;
|
return glXMakeCurrent( _display, None, NULL )==True;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -446,5 +452,9 @@ void PixelBufferX11::swapBuffersImplementation()
|
|||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"PixelBufferX11::swapBuffersImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
// osg::notify(osg::NOTICE)<<"PixelBufferX11::swapBuffersImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||||
|
|
||||||
glXSwapBuffers(_display, _pbuffer);
|
#ifdef OSG_USE_EGL
|
||||||
|
eglSwapBuffers( _display, _pbuffer );
|
||||||
|
#else
|
||||||
|
glXSwapBuffers( _display, _pbuffer );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user