Index: uppsrc/GLCtrl/GLCtrl.cpp =================================================================== --- uppsrc/GLCtrl/GLCtrl.cpp (revision 8885) +++ uppsrc/GLCtrl/GLCtrl.cpp (working copy) @@ -4,11 +4,14 @@ void GLCtrl::GLResize(int w, int h) { + #ifndef flagOPENGL_NEW glViewport(0, 0, (GLsizei)w, (GLsizei)h); + #endif } void GLCtrl::StdView() { + #ifndef flagOPENGL_NEW glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); @@ -23,6 +26,7 @@ gluPerspective(45.0f, (GLfloat)(sz.cx)/(GLfloat)(sz.cy), 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + #endif } #ifndef GUI_GTK @@ -41,4 +45,9 @@ #endif +#ifdef flagOPENGL_NEW +int GLCtrl::OPENGL_NEW_VERSION_MAJOR = 4; +int GLCtrl::OPENGL_NEW_VERSION_MINOR = 1; +#endif + END_UPP_NAMESPACE Index: uppsrc/GLCtrl/GLCtrl.h =================================================================== --- uppsrc/GLCtrl/GLCtrl.h (revision 8885) +++ uppsrc/GLCtrl/GLCtrl.h (working copy) @@ -25,6 +25,16 @@ #undef Display #endif +#ifdef flagOPENGL_NEW +#ifdef _WIN32 +#include "wglext.h" +#define OPENGL_OBTAIN(f, PROTOPTR) if (!f) f = reinterpret_cast(wglGetProcAddress(#f)) +#else +#define OPENGL_OBTAIN(f, PROTOPTR) +#endif +#include "glext.h" +#endif + NAMESPACE_UPP #ifdef GUI_GTK @@ -40,6 +50,12 @@ virtual void GLResize(int w, int h); void StdView(); + +public: + #ifdef flagOPENGL_NEW + static int OPENGL_NEW_VERSION_MAJOR; + static int OPENGL_NEW_VERSION_MINOR; + #endif }; #else @@ -140,6 +156,8 @@ // Called on paint events virtual void GLPaint() { WhenGLPaint(); } virtual void GLPickingPaint() {} + + public: Callback WhenGLPaint; @@ -164,6 +182,12 @@ void Refresh() { pane.Refresh(); } Vector Pick(int x, int y); + +public: + #ifdef flagOPENGL_NEW + static int OPENGL_NEW_VERSION_MAJOR; + static int OPENGL_NEW_VERSION_MINOR; + #endif }; #endif Index: uppsrc/GLCtrl/Win32GLCtrl.cpp =================================================================== --- uppsrc/GLCtrl/Win32GLCtrl.cpp (revision 8885) +++ uppsrc/GLCtrl/Win32GLCtrl.cpp (working copy) @@ -9,6 +9,7 @@ void GLCtrl::GLPane::Init() { + RLOG("GLCtrl::GLPane::Init"); HWND hwnd = GetHWND(); if(!hwnd) return; @@ -42,6 +43,32 @@ return; ActivateContext(); + + #ifdef flagOPENGL_NEW + RLOG("GLCtrl::GLPane::Init + OpenGL NEW..."); + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; + wglCreateContextAttribsARB = reinterpret_cast(wglGetProcAddress("wglCreateContextAttribsARB")); + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC); + if (!wglCreateContextAttribsARB) + return; + + int attribs[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, GLCtrl::OPENGL_NEW_VERSION_MAJOR, + WGL_CONTEXT_MINOR_VERSION_ARB, GLCtrl::OPENGL_NEW_VERSION_MINOR, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + hRC = wglCreateContextAttribsARB(hDC, 0, attribs); + if (!hRC || !wglMakeCurrent(hDC, hRC)) + return; + + glEnable(GL_DEBUG_OUTPUT); + RLOG("GLCtrl::GLPane::Init + OpenGL NEW + initialized"); + #endif + ctrl->GLInit(); ctrl->GLResize(GetSize().cx, GetSize().cy); ctrl->GLPaint();