Skip to content
Snippets Groups Projects
Commit 71c20caf authored by Oliver Bock's avatar Oliver Bock
Browse files

Code formatting

parent 159971ea
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,11 @@ bool WindowManager::initialize() ...@@ -51,7 +51,11 @@ bool WindowManager::initialize()
m_VideoModeFlags = SDL_OPENGL | SDL_RESIZABLE; m_VideoModeFlags = SDL_OPENGL | SDL_RESIZABLE;
Uint32 bitPerPixel = SDL_VideoModeOK(m_DesktopWidth, m_DesktopHeight, m_DesktopBitsPerPixel, m_VideoModeFlags); Uint32 bitPerPixel = SDL_VideoModeOK(
m_DesktopWidth,
m_DesktopHeight,
m_DesktopBitsPerPixel,
m_VideoModeFlags);
if ( !bitPerPixel) { if ( !bitPerPixel) {
cerr << "Video mode not supported: " << SDL_GetError() << endl; cerr << "Video mode not supported: " << SDL_GetError() << endl;
...@@ -68,13 +72,19 @@ bool WindowManager::initialize() ...@@ -68,13 +72,19 @@ bool WindowManager::initialize()
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); //SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
//SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
// 4x FSAA, way too heavy on many machines :-) // 4x FSAA, way too heavy on some machines :-)
// FIXME: without it polygon fonts look really ugly :-( // FIXME: without it polygon fonts look really ugly :-(
// TODO: should be controlled with config values (coupled to disabling text rendering?)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
m_DisplaySurface = SDL_SetVideoMode(m_DesktopWidth, m_DesktopHeight, m_DesktopBitsPerPixel, m_VideoModeFlags); m_DisplaySurface = SDL_SetVideoMode(
m_DesktopWidth,
m_DesktopHeight,
m_DesktopBitsPerPixel,
m_VideoModeFlags);
if (m_DisplaySurface == NULL) { if (m_DisplaySurface == NULL) {
cerr << "Could not acquire rendering surface: " << SDL_GetError() << endl; cerr << "Could not acquire rendering surface: " << SDL_GetError() << endl;
...@@ -109,10 +119,8 @@ void WindowManager::eventLoop() ...@@ -109,10 +119,8 @@ void WindowManager::eventLoop()
static double i = 0.0; static double i = 0.0;
while ( SDL_WaitEvent(&event) ) while (SDL_WaitEvent(&event) ) {
{ if (event.type == SDL_USEREVENT && event.user.code == RenderEvent) {
if( event.type == SDL_USEREVENT && event.user.code == RenderEvent )
{
#ifdef DEBUG_VALGRIND #ifdef DEBUG_VALGRIND
if(i < 0.25) { if(i < 0.25) {
#endif #endif
...@@ -125,67 +133,92 @@ void WindowManager::eventLoop() ...@@ -125,67 +133,92 @@ void WindowManager::eventLoop()
} }
#endif #endif
} }
else if( event.type == SDL_USEREVENT && event.user.code == BOINCUpdateEvent) else if (event.type == SDL_USEREVENT && event.user.code
{ == BOINCUpdateEvent) {
} }
else if( event.motion.state & (SDL_BUTTON(1) | SDL_BUTTON(3)) && event.type == SDL_MOUSEMOTION ) else if (event.motion.state & (SDL_BUTTON(1) | SDL_BUTTON(3)) &&
{ event.type == SDL_MOUSEMOTION) {
if(event.motion.state & SDL_BUTTON(1))
{ if (event.motion.state & SDL_BUTTON(1)) {
graphics->rotateSphere(event.motion.xrel, event.motion.yrel); graphics->rotateSphere(event.motion.xrel, event.motion.yrel);
} }
else if(event.motion.state & SDL_BUTTON(3)) else if (event.motion.state & SDL_BUTTON(3)) {
{
graphics->zoomSphere(event.motion.yrel); graphics->zoomSphere(event.motion.yrel);
} }
} }
else if (event.type == SDL_VIDEORESIZE) else if (event.type == SDL_VIDEORESIZE) {
{
m_CurrentWidth = event.resize.w; m_CurrentWidth = event.resize.w;
m_CurrentHeight = event.resize.h; m_CurrentHeight = event.resize.h;
m_DisplaySurface = SDL_SetVideoMode( m_CurrentWidth, m_CurrentHeight, m_DesktopBitsPerPixel, m_VideoModeFlags);
m_DisplaySurface = SDL_SetVideoMode(
m_CurrentWidth,
m_CurrentHeight,
m_DesktopBitsPerPixel,
m_VideoModeFlags);
graphics->resize(m_CurrentWidth, m_CurrentHeight); graphics->resize(m_CurrentWidth, m_CurrentHeight);
} }
else if( event.type == SDL_QUIT || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) ) else if (event.type == SDL_QUIT ||
{ (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
if (m_DisplaySurface) SDL_FreeSurface(m_DisplaySurface);
if (m_DisplaySurface) {
SDL_FreeSurface(m_DisplaySurface);
}
exit(0); exit(0);
} }
else if( event.type == SDL_KEYDOWN ) else if (event.type == SDL_KEYDOWN) {
{ switch (event.key.keysym.sym) {
switch(event.key.keysym.sym)
{
case SDLK_s: case SDLK_s:
graphics->setFeature(graphics->STARS, graphics->isFeature(graphics->STARS) ? false : true); graphics->setFeature(
graphics->STARS,
graphics->isFeature(graphics->STARS) ? false : true);
break; break;
case SDLK_c: case SDLK_c:
graphics->setFeature(graphics->CONSTELLATIONS, graphics->isFeature(graphics->CONSTELLATIONS) ? false : true); graphics->setFeature(
graphics->CONSTELLATIONS,
graphics->isFeature(graphics->CONSTELLATIONS) ? false : true);
break; break;
case SDLK_o: case SDLK_o:
graphics->setFeature(graphics->OBSERVATORIES, graphics->isFeature(graphics->OBSERVATORIES) ? false : true); graphics->setFeature(
graphics->OBSERVATORIES,
graphics->isFeature(graphics->OBSERVATORIES) ? false : true);
break; break;
case SDLK_x: case SDLK_x:
graphics->setFeature(graphics->XRAYS, graphics->isFeature(graphics->XRAYS) ? false : true); graphics->setFeature(
graphics->XRAYS,
graphics->isFeature(graphics->XRAYS) ? false : true);
break; break;
case SDLK_p: case SDLK_p:
graphics->setFeature(graphics->PULSARS, graphics->isFeature(graphics->PULSARS) ? false : true); graphics->setFeature(
graphics->PULSARS,
graphics->isFeature(graphics->PULSARS) ? false : true);
break; break;
case SDLK_r: case SDLK_r:
graphics->setFeature(graphics->SNRS, graphics->isFeature(graphics->SNRS) ? false : true); graphics->setFeature(
graphics->SNRS,
graphics->isFeature(graphics->SNRS) ? false : true);
break; break;
case SDLK_g: case SDLK_g:
graphics->setFeature(graphics->GLOBE, graphics->isFeature(graphics->GLOBE) ? false : true); graphics->setFeature(
graphics->GLOBE,
graphics->isFeature(graphics->GLOBE) ? false : true);
break; break;
case SDLK_a: case SDLK_a:
graphics->setFeature(graphics->AXES, graphics->isFeature(graphics->AXES) ? false : true); graphics->setFeature(
graphics->AXES,
graphics->isFeature(graphics->AXES) ? false : true);
break; break;
case SDLK_i: case SDLK_i:
graphics->setFeature(graphics->SEARCHINFO, graphics->isFeature(graphics->SEARCHINFO) ? false : true); graphics->setFeature(
graphics->SEARCHINFO,
graphics->isFeature(graphics->SEARCHINFO) ? false : true);
break; break;
case SDLK_l: case SDLK_l:
graphics->setFeature(graphics->LOGO, graphics->isFeature(graphics->LOGO) ? false : true); graphics->setFeature(
graphics->LOGO,
graphics->isFeature(graphics->LOGO) ? false : true);
break; break;
case SDLK_RETURN: case SDLK_RETURN:
toggleFullscreen(); toggleFullscreen();
...@@ -221,10 +254,11 @@ Uint32 WindowManager::timerCallbackRenderEvent( Uint32 interval, void *param ) ...@@ -221,10 +254,11 @@ Uint32 WindowManager::timerCallbackRenderEvent( Uint32 interval, void *param )
SDL_PushEvent(&event); SDL_PushEvent(&event);
return( interval ); return interval;
} }
Uint32 WindowManager::timerCallbackBOINCUpdateEvent( Uint32 interval, void *param ) Uint32 WindowManager::timerCallbackBOINCUpdateEvent(Uint32 interval,
void *param)
{ {
SDL_Event event; SDL_Event event;
SDL_UserEvent userevent; SDL_UserEvent userevent;
...@@ -239,7 +273,7 @@ Uint32 WindowManager::timerCallbackBOINCUpdateEvent( Uint32 interval, void *para ...@@ -239,7 +273,7 @@ Uint32 WindowManager::timerCallbackBOINCUpdateEvent( Uint32 interval, void *para
SDL_PushEvent(&event); SDL_PushEvent(&event);
return( interval ); return interval;
} }
int WindowManager::windowWidth() const int WindowManager::windowWidth() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment