Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [Proposal] Adding a GLLock struct to GLCtrl
Re: [Proposal] Adding a GLLock struct to GLCtrl [message #54714 is a reply to message #54713] |
Thu, 03 September 2020 02:30 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello Klugier, You are right about adding method in addition to struct:
Here is the code I got:
GLCtrl.h
//Class GLCtrl : public Ctrl{
void ActivateContext();
void SwapBuffer();
void DesactivateContext();
struct ContextLock {
private:
GLCtrl& parent;
public:
ContextLock(GLCtrl& ctrl);
~ContextLock();
};
struct ContextLockWithSwapBuffers{
private:
GLCtrl& parent;
public:
ContextLockWithSwapBuffers(GLCtrl& ctrl);
~ContextLockWithSwapBuffers();
};
//};
Win32GLCtrl.cpp :
void GLCtrl::ActivateContext(){
HWND hwnd = pane.GetHWND();
GLCtrl::CreateContext();
HDC hDC = GetDC(hwnd);
wglMakeCurrent(hDC, s_openGLContext);
}
void GLCtrl::SwapBuffer(){
HWND hwnd = GetHWND();
HDC hDC = GetDC(hwnd);
SwapBuffers(hDC);
}
void GLCtrl::DesactivateContext(){
HWND hwnd = GetHWND();
HDC hDC = GetDC(hwnd);
wglMakeCurrent(NULL, NULL);
ReleaseDC(hwnd, hDC);
}
GLCtrl::ContextLock::ContextLock(GLCtrl& ctrl) : parent(ctrl){
HWND hwnd = parent.pane.GetHWND();
GLCtrl::CreateContext();
HDC hDC = GetDC(hwnd);
wglMakeCurrent(hDC, s_openGLContext);
}
GLCtrl::ContextLock::~ContextLock(){
HWND hwnd = parent.pane.GetHWND();
HDC hDC = GetDC(hwnd);
wglMakeCurrent(NULL, NULL);
ReleaseDC(hwnd, hDC);
}
GLCtrl::ContextLockWithSwapBuffers::ContextLockWithSwapBuffers(GLCtrl& ctrl) : parent(ctrl){
HWND hwnd = parent.pane.GetHWND();
GLCtrl::CreateContext();
HDC hDC = GetDC(hwnd);
wglMakeCurrent(hDC, s_openGLContext);
}
GLCtrl::ContextLockWithSwapBuffers::~ContextLockWithSwapBuffers(){
HWND hwnd = parent.pane.GetHWND();
HDC hDC = GetDC(hwnd);
SwapBuffers(hDC);
wglMakeCurrent(NULL, NULL);
ReleaseDC(hwnd, hDC);
}
XGLCtrl.cpp :
void GLCtrl::ActivateContext(){
glXMakeCurrent(s_Display, win, s_GLXContext);
}
void GLCtrl::SwapBuffer(){
glXSwapBuffers(s_Display, win);
}
void GLCtrl::DesactivateContext(){
glXMakeCurrent(s_Display, None, NULL);
}
GLCtrl::ContextLock::ContextLock(GLCtrl& ctrl) : parent(ctrl){
glXMakeCurrent(s_Display, parent.win, s_GLXContext);
}
GLCtrl::ContextLock::~ContextLock(){
glXMakeCurrent(s_Display, None, NULL);
}
GLCtrl::ContextLockWithSwapBuffers::ContextLockWithSwapBuffers(GLCtrl& ctrl) : parent(ctrl){
glXMakeCurrent(s_Display, parent.win, s_GLXContext);
}
GLCtrl::ContextLockWithSwapBuffers::~ContextLockWithSwapBuffers(){
glXSwapBuffers(s_Display, parent.win);
glXMakeCurrent(s_Display, None, NULL);
}
[Updated on: Thu, 03 September 2020 03:35] Report message to a moderator
|
|
|
|
|
[Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Wed, 02 September 2020 18:55
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Klugier on Thu, 03 September 2020 00:37
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Thu, 03 September 2020 02:30
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: mirek on Thu, 03 September 2020 09:51
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Thu, 03 September 2020 17:21
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Klugier on Thu, 03 September 2020 23:46
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Fri, 04 September 2020 16:34
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Klugier on Fri, 04 September 2020 22:28
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Sat, 05 September 2020 15:39
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: koldo on Wed, 09 September 2020 08:15
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: koldo on Wed, 09 September 2020 20:41
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Klugier on Wed, 09 September 2020 21:25
|
|
|
Re: [Proposal] Adding a GLLock struct to GLCtrl
By: Xemuth on Thu, 10 September 2020 16:52
|
Goto Forum:
Current Time: Mon Apr 29 15:33:43 CEST 2024
Total time taken to generate the page: 0.02847 seconds
|