obs-app.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include <util/bmem.h>
  15. #include "obs-app.hpp"
  16. #include "window-obs-basic.hpp"
  17. #include "obs-wrappers.hpp"
  18. #include "wx-wrappers.hpp"
  19. IMPLEMENT_APP(OBSApp)
  20. bool OBSApp::OnInit()
  21. {
  22. if (!wxApp::OnInit())
  23. return false;
  24. if (!obs_startup())
  25. return false;
  26. wxInitAllImageHandlers();
  27. OBSBasic *mainWindow = new OBSBasic();
  28. const wxPanel *preview = mainWindow->GetPreviewPanel();
  29. wxRect rc = mainWindow->GetPreviewPanel()->GetClientRect();
  30. struct obs_video_info ovi;
  31. ovi.adapter = 0;
  32. ovi.base_width = rc.width;
  33. ovi.base_height = rc.height;
  34. ovi.fps_num = 30000;
  35. ovi.fps_den = 1001;
  36. ovi.graphics_module = "libobs-opengl";
  37. ovi.output_format = VIDEO_FORMAT_RGBA;
  38. ovi.output_width = rc.width;
  39. ovi.output_height = rc.height;
  40. ovi.window = WxToGSWindow(preview);
  41. if (!obs_reset_video(&ovi))
  42. return false;
  43. mainWindow->Show();
  44. return true;
  45. }
  46. int OBSApp::OnExit()
  47. {
  48. obs_shutdown();
  49. blog(LOG_INFO, "Number of memory leaks: %u", bnum_allocs());
  50. wxApp::OnExit();
  51. return 0;
  52. }