Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [APPROVED] GLCtrl flickering on Win32
[APPROVED] GLCtrl flickering on Win32 [message #42441] Fri, 14 March 2014 18:44 Go to next message
Klugier is currently offline  Klugier
Messages: 1085
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

It seems that GLCtrl flickers when window is resized on M$ Windows. The main problem with current implementation is that "WindowProc" method does not support resizing events like "WM_SIZE" and "WM_ERASEBKGND". The other thing that was wrong is calling glFinish() (We should only use "glFlush" in case when doubleBuffering is off).

So, below is the corrected implementation "WindowProc" method(GLCtrl/Win32GLCtrl.cpp - line 87):

LRESULT GLCtrl::GLPane::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if((message == WM_PAINT || message == WM_SIZE || message == WM_ERASEBKGND) && hDC && hRC) 
	{
		PAINTSTRUCT ps;
		BeginPaint(GetHWND(), &ps);
		ActivateContext();
		ctrl->GLPaint();
		ctrl->doubleBuffering ? SwapBuffers(hDC) : glFlush();
		EndPaint(GetHWND(), &ps);
		return 0;
	}
	
	return DHCtrl::WindowProc(message, wParam, lParam);
}


// **********

The second less important thing is that GLDraw dosen't support resizing by default. The first solution is improve virtual method GLResize(int w, int h) part of GLCtrl class. Implementation: (GLCtrl.h - several header changes, GLCtrl.cpp - GLResize implementation)

void GLCtrl::GLResize(int w, int h)
{
	glViewport(0, 0, (GLsizei)w, (GLsizei)h);
}


The second option is writting documentation for GLDraw for instance: "If you want to have GLDraw resizing you should override GLResize method with following code: glViewport(0, 0, (GLsizei)w, (GLsizei)h);.".

// **********

At the end I have one question: can we move "GLEW" from GLDraw to separate module or plugin. It would help a lot...

P.S.
Tested on NVIDIA & Intel GPU.

Sincerely,
Klugier
  • Attachment: GLCtrl.cpp
    (Size: 1.03KB, Downloaded 260 times)
  • Attachment: GLCtrl.h
    (Size: 3.33KB, Downloaded 258 times)
  • Attachment: Win32GLCtrl.cpp
    (Size: 2.27KB, Downloaded 507 times)


U++ - one framework to rule them all.

[Updated on: Sat, 22 March 2014 03:01]

Report message to a moderator

Re: [BUG] GLCtrl flickering on Win32 [message #42494 is a reply to message #42441] Wed, 19 March 2014 19:01 Go to previous message
mirek is currently offline  mirek
Messages: 14162
Registered: November 2005
Ultimate Member
Thanks, applied.
Previous Topic: [DEPRECTED] GLDrawDemo - Resizing dosen't work.
Next Topic: [APPROVED] GLEW as plugin
Goto Forum:
  


Current Time: Fri Dec 13 23:16:23 CET 2024

Total time taken to generate the page: 0.02487 seconds