Skip to content

Commit

Permalink
add an option to disable AA
Browse files Browse the repository at this point in the history
  • Loading branch information
wjwwood committed Dec 9, 2015
1 parent 2a3aa26 commit 5aa8f42
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/rviz/ogre_helpers/render_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace rviz

RenderSystem* RenderSystem::instance_ = 0;
int RenderSystem::force_gl_version_ = 0;
bool RenderSystem::use_anti_aliasing_ = true;
bool RenderSystem::force_no_stereo_ = false;

RenderSystem* RenderSystem::get()
Expand All @@ -81,6 +82,12 @@ void RenderSystem::forceGlVersion( int version )
ROS_INFO_STREAM( "Forcing OpenGl version " << (float)version / 100.0 << "." );
}

void RenderSystem::disableAntiAliasing()
{
use_anti_aliasing_ = false;
ROS_INFO("Disabling Anti-Aliasing");
}

void RenderSystem::forceNoStereo()
{
force_no_stereo_ = true;
Expand Down Expand Up @@ -231,15 +238,17 @@ void RenderSystem::setupRenderSystem()
// We operate in windowed mode
renderSys->setConfigOption("Full Screen","No");

/// We used to allow the user to set the RTT mode to PBuffer, FBO, or Copy.
/// We used to allow the user to set the RTT mode to PBuffer, FBO, or Copy.
/// Copy is slow, and there doesn't seem to be a good reason to use it
/// PBuffer limits the size of the renderable area of the RTT to the
/// size of the first window created.
/// FBO seem to be the only good option
// renderSys->setConfigOption("RTT Preferred Mode", "FBO");

// Set the Full Screen Anti-Aliasing factor.
renderSys->setConfigOption("FSAA", "4");
if (use_anti_aliasing_) {
renderSys->setConfigOption("FSAA", "4");
}

ogre_root_->setRenderSystem(renderSys);
}
Expand Down Expand Up @@ -350,7 +359,9 @@ Ogre::RenderWindow* RenderSystem::makeRenderWindow( intptr_t window_id, unsigned
params["externalGLControl"] = true;

// Enable antialiasing
params["FSAA"] = "4";
if (use_anti_aliasing_) {
params["FSAA"] = "4";
}

// Set the macAPI for Ogre based on the Qt implementation
#ifdef QT_MAC_USE_COCOA
Expand Down
4 changes: 4 additions & 0 deletions src/rviz/ogre_helpers/render_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class RenderSystem
// @brief return GLSL Version as integer, e.g. 150 for GLSL 1.50
int getGlslVersion() { return glsl_version_; }

// @brief Disables the use of Anti Aliasing
static void disableAntiAliasing();

// @brief Force to use the provided OpenGL version on startup
static void forceGlVersion( int version );

Expand Down Expand Up @@ -96,6 +99,7 @@ class RenderSystem

int gl_version_;
int glsl_version_;
static bool use_anti_aliasing_;
static int force_gl_version_;
bool stereo_supported_;
static bool force_no_stereo_;
Expand Down
12 changes: 12 additions & 0 deletions src/rviz/visualizer_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ bool VisualizerApp::init( int argc, char** argv )
("ogre-log,l", "Enable the Ogre.log file (output in cwd) and console output.")
("in-mc-wrapper", "Signal that this is running inside a master-chooser wrapper")
("opengl", po::value<int>(), "Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)")
("disable-anti-aliasing", "Prevent rviz from trying to use anti-aliasing when rendering.")
("no-stereo", "Disable the use of stereo rendering.")
("verbose,v", "Enable debug visualizations")
("log-level-debug", "Sets the ROS logger level to debug.");
Expand All @@ -143,6 +144,7 @@ bool VisualizerApp::init( int argc, char** argv )
bool in_mc_wrapper = false;
bool verbose = false;
int force_gl_version = 0;
bool disable_anti_aliasing = false;
bool disable_stereo = false;
try
{
Expand Down Expand Up @@ -203,6 +205,11 @@ bool VisualizerApp::init( int argc, char** argv )
force_gl_version = vm["opengl"].as<int>();
}

if (vm.count("disable-anti-aliasing"))
{
disable_anti_aliasing = true;
}

if (vm.count("verbose"))
{
verbose = true;
Expand Down Expand Up @@ -243,6 +250,11 @@ bool VisualizerApp::init( int argc, char** argv )
RenderSystem::forceGlVersion( force_gl_version );
}

if (disable_anti_aliasing)
{
RenderSystem::disableAntiAliasing();
}

if ( disable_stereo )
{
RenderSystem::forceNoStereo();
Expand Down

0 comments on commit 5aa8f42

Please sign in to comment.