Example #1
0
/***********************************************************
process function
***********************************************************/
void GuiHandler::Process(void)
{
   inject_time_pulse();

	std::vector<GUI *>::iterator it = _guis.begin();
	std::vector<GUI *>::iterator end = _guis.end();
	for(; it != end; ++it)
		(*it)->Process();
}
bool Renderer::Render()
{
	// send deltaT to SDL 
	inject_time_pulse();

	//inject SDL input into cegui
	bool must_quit = false;
	inject_input(must_quit);

	// clear the colour buffer
	glClear( GL_COLOR_BUFFER_BIT );
 
	// render the GUI :)
	CEGUI::System::getSingleton().renderGUI();
 
	// Update the screen 
	SDL_GL_SwapBuffers();

	return must_quit;
}
Example #3
0
void handle_input_events(bool *pmustquit, Cappdata *app)
{
  t_shared            *pshared_data = (t_shared*)&app->m_shared_data;
  SDL_Event           e;
  SDL_MouseWheelEvent w;
  int                 x, y;
  double              last_time_pulse;
  int                 width;
  int                 height;
  bool                bmousemove;

  inject_time_pulse(last_time_pulse);
  app->setlooptime(last_time_pulse);
  bmousemove = false;
  //SDL_WaitEvent(&event);
  while (SDL_PollEvent(&e))
    {
      if ((int)e.type == app->m_pserver->get_sdl_dialog_user_event_code())
	{
	  // Messages from the netowrk external dialogs
	  app->process_network_messages();
	}
      if ((int)e.type == app->m_shared_data.audio_cmd_sdlevent)
	{
	  app->process_audio_events();
	}
      switch (e.window.event)
	{
/*
        case SDL_WINDOWEVENT_RESIZED:
	  {
	    width  = e.window.data1;
	    height = e.window.data2;
	    printf("window resized to: %d, %d\n", width, height);
	  }
	  break;
        case SDL_WINDOWEVENT_MINIMIZED:
	  printf("window minimised.\n");
	  break;
        case SDL_WINDOWEVENT_MAXIMIZED:
	  printf("window maxiimised.\n");
	  break;
*/
	case SDL_WINDOWEVENT_SIZE_CHANGED:
	  {
	    width  = e.window.data1;
	    height = e.window.data2;
	    app->change_window_size(width, height);
	    //printf("window size changed to: %d, %d\n", width, height);
	    app->m_gfxprimitives->SetLogicalSize(width, height);
	    //SDL_RenderSetLogicalSize( sdlRenderer, width, height);
	    //SDL_RenderGetLogicalSize(app->m_sdlRenderer, &width, &height); // Coordinate bug when maximising on gnome
	    //printf("new size is %d %d\n", width, height);
	  }
	  break;
	default:
	  break;
	};
      switch (e.type)
	{
	case SDL_MOUSEWHEEL:
	  // Find if it is on a window
	  SDL_GetMouseState(&x, &y);
	  memcpy(&w, &e, sizeof(w));
	  //printf("mousewheel x=%d y=%d px %d py %d\n", w.x, w.y, x, y);
	  app->handle_weel(x, y, w.y);
	  bmousemove = true;
	  break;
	case SDL_FINGERMOTION:
	  printf("fingermotion\n");
	  break;
	  // mouse motion handler 
	case SDL_MOUSEMOTION:
	  SDL_GetMouseState(&x, &y);
	  app->mousemove(x, y);
	  bmousemove = true;
	  break;
	  // mouse down handler
	case SDL_MOUSEBUTTONDOWN:
	  SDL_GetMouseState(&x, &y);
	  switch (e.button.button)
	    {
	    case SDL_BUTTON_RIGHT:
	      app->mouseclickright(x, y);
	      break;
	    case SDL_BUTTON_LEFT:
	      app->mouseclickleft(x, y);
	      break;
	    default:
	      break;
	    }
	  bmousemove = true;
	  break;
	  // mouse up handler
	case SDL_MOUSEBUTTONUP:
	  SDL_GetMouseState(&x, &y);
	  switch (e.button.button)
	    {
	    case SDL_BUTTON_RIGHT:
	      app->mouseupright(x, y);
	      break;
	    case SDL_BUTTON_LEFT:
	      app->mouseupleft(x, y);
	      break;
	    default:
	      break;
	    }
	  bmousemove = true;
	  break;
	  // key down
	case SDL_KEYDOWN:
	  //printf("%c %c\n", e.key.keysym.sym, SDL_GetScancodeFromKey(e.key.keysym.sym));
	  //switch (e.key.keysym.scancode)
	  app->key_on(e.key.keysym.sym);
	  break;
	  // key up
	case SDL_KEYUP:
	  app->key_off(e.key.keysym.sym);
	  break;
	  // WM quit event occured
	case SDL_QUIT:
	  printf("Quit event received\n");
	  LOCK;
	  pshared_data->bquit = true;
	  *pmustquit = pshared_data->bquit;
	  UNLOCK;
	  break;
	/*
	case SDL_VIDEORESIZE:
	  printf("Resize video input\n");
	  break;*/
	}
    }
  // Non moving mouse detection
  app->mousedidnotmove(bmousemove);
}