Commit ca65662f authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot
Browse files

Merge topic 'try_more_recent_opengl_add_getversion'

8d0daf13

 improve opengl context version handling
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !1233
parents d9b08c54 8d0daf13
......@@ -31,6 +31,8 @@
#include "vtkRenderWindowInteractor.h"
#include "vtkOpenGLRenderWindow.h"
//----------------------------------------------------------------------------
int TestVBOPLYMapper(int argc, char *argv[])
{
......@@ -86,6 +88,9 @@ int TestVBOPLYMapper(int argc, char *argv[])
timer->StopTimer();
double firstRender = timer->GetElapsedTime();
cerr << "first render time: " << firstRender << endl;
int major, minor;
vtkOpenGLRenderWindow::SafeDownCast(renderWindow.Get())->GetOpenGLVersion(major,minor);
cerr << "opengl version " << major << "." << minor << "\n";
timer->StartTimer();
int numRenders = 8;
......
......@@ -563,6 +563,21 @@ void vtkOpenGLRenderWindow::InitializeTextureInternalFormats()
}
}
void vtkOpenGLRenderWindow::GetOpenGLVersion(int &major, int &minor)
{
int glMajorVersion = 0;
int glMinorVersion = 0;
if (this->Initialized)
{
glGetIntegerv(GL_MAJOR_VERSION, & glMajorVersion);
glGetIntegerv(GL_MINOR_VERSION, & glMinorVersion);
}
major = glMinorVersion;
minor = glMinorVersion;
}
void vtkOpenGLRenderWindow::OpenGLInitContext()
{
this->ContextCreationTime.Modified();
......
......@@ -140,11 +140,17 @@ public:
// Initialize VTK for rendering in a new OpenGL context
virtual void OpenGLInitContext();
// Description::
// Description:
// Get if the context includes opengl core profile 3.2 support
static bool GetContextSupportsOpenGL32();
void SetContextSupportsOpenGL32(bool val);
// Description:
// Get the major and minor version numbers of the OpenGL context we are using
// ala 3.2, 3.3, 4.0, etc... returns 0,0 if opengl has not been initialized
// yet
void GetOpenGLVersion(int &major, int &minor);
// Description:
// Return the OpenGL name of the back left buffer.
// It is GL_BACK_LEFT if GL is bound to the window-system-provided
......
......@@ -706,6 +706,12 @@ void vtkWin32OpenGLRenderWindow::SetupPixelFormatPaletteAndContext(
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB =
reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
if (wglCreateContextAttribsARB)
{
this->ContextId = 0;
// we believe that these later versions are all compatible with
// OpenGL 3.2 so get a more recent context if we can.
int attemptedVersions[] = {4,5, 4,4, 4,3, 4,2, 4,1, 4,0, 3,3, 3,2};
for (int i = 0; i < 8 && !this->ContextId; i++)
{
int iContextAttribs[] =
{
......@@ -717,9 +723,12 @@ void vtkWin32OpenGLRenderWindow::SetupPixelFormatPaletteAndContext(
// WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
0 // End of attributes list
};
iContextAttribs[1] = attemptedVersions[i*2];
iContextAttribs[3] = attemptedVersions[i*2+1];
this->ContextId = wglCreateContextAttribsARB(hDC, 0, iContextAttribs);
}
}
if (this->ContextId)
{
this->SetContextSupportsOpenGL32(true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment