Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FullScreen and Escape keyboard shortcuts #80

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/BraynsViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, const char **argv)
const brayns::Vector2ui& size =
brayns.getParametersManager().getApplicationParameters().getWindowSize();

braynsViewer.create( "Brayns Viewer", size.x(), size.y(), false );
braynsViewer.create( "Brayns Viewer", size.x(), size.y( ));
brayns::runGLUT();
}
catch( const std::runtime_error& e )
Expand Down
38 changes: 21 additions & 17 deletions apps/ui/BaseWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ BaseWindow::BaseWindow( Brayns& brayns, const FrameBufferMode frameBufferMode)
, _windowID(-1)
, _windowSize(-1,-1)
, _displayHelp( false )
, _fullScreen( false )
{
const auto motionSpeed = _brayns.getCameraManipulator().getMotionSpeed();
BRAYNS_INFO << "Camera :" << _brayns.getEngine().getCamera() << std::endl;
Expand Down Expand Up @@ -350,8 +351,7 @@ void BaseWindow::setTitle(const char *title)
}

void BaseWindow::create(const char *title,
const size_t width, const size_t height,
bool fullScreen)
const size_t width, const size_t height)
{
glutInitWindowSize(width, height);
_windowID = glutCreateWindow(title);
Expand All @@ -365,9 +365,6 @@ void BaseWindow::create(const char *title,
glutPassiveMotionFunc(glut3dPassiveMouseFunc);
glutIdleFunc(glut3dIdle);

if(fullScreen)
glutFullScreen( );

_screenSpaceProcessor.init( width, height );
}

Expand All @@ -378,6 +375,14 @@ void BaseWindow::keypress( const char key, const Vector2f& )
case 'h':
_displayHelp = !_displayHelp;
break;
case 27:
case 'Q':
#ifdef __APPLE__
exit(0);
#else
glutLeaveMainLoop();
#endif
break;
default:
_brayns.getKeyboardHandler().handleKeyboardShortcut( key );
}
Expand All @@ -401,6 +406,17 @@ void BaseWindow::specialkey( const int key, const Vector2f& )
case GLUT_KEY_DOWN:
_brayns.getKeyboardHandler().handle( SpecialKey::DOWN );
break;
case GLUT_KEY_F11:
if( _fullScreen )
glutPositionWindow( _windowPosition.x(), _windowPosition.y( ));
else
{
_windowPosition.x() = glutGet((GLenum)GLUT_WINDOW_X);
_windowPosition.y() = glutGet((GLenum)GLUT_WINDOW_Y);
glutFullScreen();
}
_fullScreen = !_fullScreen;
break;
}
}

Expand All @@ -419,9 +435,6 @@ void BaseWindow::_registerKeyboardShortcuts()
keyHandler.registerKeyboardShortcut(
'c', "Display current camera information",
std::bind( &BaseWindow::_displayCameraInformation, this ));
keyHandler.registerKeyboardShortcut(
'Q', "Quit application",
std::bind( &BaseWindow::_exitApplication, this ));
keyHandler.registerKeyboardShortcut(
'z', "Switch between depth and color buffers",
std::bind( &BaseWindow::_toggleFrameBuffer, this ));
Expand Down Expand Up @@ -464,15 +477,6 @@ void BaseWindow::_displayCameraInformation()
BRAYNS_INFO << _brayns.getEngine().getCamera() << std::endl;
}

void BaseWindow::_exitApplication()
{
#ifdef __APPLE__
exit(0);
#else
glutLeaveMainLoop();
#endif
}

void BaseWindow::_toggleFrameBuffer()
{
if( _frameBufferMode == FrameBufferMode::DEPTH )
Expand Down
7 changes: 4 additions & 3 deletions apps/ui/BaseWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ class BaseWindow
virtual void activate();

void create(const char *title,
size_t width, size_t height,
bool fullScreen = false);
size_t width, size_t height);

/*! clear the frame buffer color and depth bits */
void clearPixels();
Expand Down Expand Up @@ -174,7 +173,7 @@ class BaseWindow
FrameBufferMode _frameBufferMode;

int _windowID;
Vector2i _windowSize;
Vector2ui _windowSize;

FPSCounter _fps;

Expand All @@ -183,6 +182,8 @@ class BaseWindow
uint64_t _gid;

bool _displayHelp;
bool _fullScreen;
Vector2ui _windowPosition;

private:

Expand Down