Skip to content

Commit

Permalink
Fixed|ClientWindow|Windows: No need to recreate GL Canvas for FSAA/vs…
Browse files Browse the repository at this point in the history
…ync changes

FSAA is handled by multisampling the GLTarget renderbuffers, so there
is no need to touch the window surface. Also, changing vsync is done
via a WGL extension API.

Fixes the issue with weird GL behavior when FSAA or vsync is toggled.
  • Loading branch information
skyjake committed Nov 18, 2014
1 parent 5aa2439 commit 4255ec2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/src/gl/dgl_common.cpp
Expand Up @@ -323,6 +323,8 @@ void GL_ModulateTexture(int mode)

void GL_SetVSync(dd_bool on)
{
if(CommandLine_Exists("-novsync")) on = false;

// Outside the main thread we'll need to defer the call.
if(!Sys_InMainThread())
{
Expand Down
31 changes: 24 additions & 7 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -522,19 +522,32 @@ DENG2_PIMPL(ClientWindow)
{
if(variable.name() == "fsaa")
{
self.updateCanvasFormat();
updateFSAAMode();
}
else if(variable.name() == "vsync")
{
#ifdef WIN32
self.updateCanvasFormat();
DENG2_UNUSED(newValue);
#else
GL_SetVSync(newValue.isTrue());
#endif
}
}

void updateFSAAMode()
{
int sampleCount = 1;
bool configured = App::config().getb(self.configName("fsaa"));
if(CommandLine_Exists("-nofsaa") || !configured)
{
LOG_GL_VERBOSE("Multisampling off");
}
else
{
sampleCount = 4; // four samples is fine?
LOG_GL_VERBOSE("Multisampling on (%i samples)") << sampleCount;
}
// All GLFramebuffer instances using default multisampling will automatically
// switch to the new setting.
GLFramebuffer::setDefaultMultisampling(sampleCount);
}

void installSidebar(SidebarLocation location, GuiWidget *widget)
{
// Get rid of the old sidebar.
Expand Down Expand Up @@ -860,8 +873,10 @@ void ClientWindow::closeEvent(QCloseEvent *ev)

void ClientWindow::canvasGLReady(Canvas &canvas)
{
d->updateFSAAMode();

// Update the capability flags.
GL_state.features.multisample = canvas.format().sampleBuffers();
GL_state.features.multisample = GLFramebuffer::defaultMultisampling();// canvas.format().sampleBuffers();
LOGDEV_GL_MSG("GL feature: Multisampling: %b") << GL_state.features.multisample;

if(vrCfg().needsStereoGLFormat() && !canvas.format().stereo())
Expand Down Expand Up @@ -971,6 +986,7 @@ bool ClientWindow::setDefaultGLFormat() // static
fmt.setStereo(true);
}

/*
#ifdef WIN32
if(CommandLine_Exists("-novsync") || !App::config().getb("window.main.vsync"))
{
Expand All @@ -994,6 +1010,7 @@ bool ClientWindow::setDefaultGLFormat() // static
LOG_GL_VERBOSE("Multisampling on (%i samples)") << sampleCount;
}
GLFramebuffer::setDefaultMultisampling(sampleCount);
*/

if(fmt != QGLFormat::defaultFormat())
{
Expand Down
2 changes: 0 additions & 2 deletions doomsday/libgui/src/canvaswindow.cpp
Expand Up @@ -315,6 +315,4 @@ void CanvasWindow::setMain(CanvasWindow *window)
mainWindow = window;
}



} // namespace de

0 comments on commit 4255ec2

Please sign in to comment.