You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include <stdio.h>
  2. #include <GL/freeglut.h>
  3. #include <gtk/gtk.h>
  4. #include <gdk/gdkx.h>
  5. #include <obs/obs.h>
  6. const int window_width = 1280;
  7. const int window_height = 720;
  8. Window xw;
  9. void
  10. print_obs_version_string()
  11. {
  12. const char* version = obs_get_version_string();
  13. printf("OBS version: %s\n", version);
  14. }
  15. void
  16. obs_render (void* param,
  17. uint32_t cx,
  18. uint32_t cy)
  19. {
  20. obs_render_main_texture ();
  21. }
  22. static void
  23. activate (GtkApplication* app,
  24. gpointer user_data)
  25. {
  26. GtkWidget* window = gtk_application_window_new (app);
  27. gtk_window_set_title (GTK_WINDOW(window), "OBS");
  28. gtk_window_set_default_size (GTK_WINDOW(window), window_width, window_height);
  29. gtk_window_present (GTK_WINDOW(window));
  30. xw = gdk_x11_window_get_xid (gtk_widget_get_window(window));
  31. }
  32. void
  33. render_sources(GtkApplication* app)
  34. {
  35. GtkWidget* window = gtk_application_window_new (app);
  36. gtk_window_set_title (GTK_WINDOW(window), "OBS - Sources");
  37. gtk_window_set_default_size (GTK_WINDOW(window), 500, 500);
  38. gtk_window_present (GTK_WINDOW(window));
  39. }
  40. int
  41. main(int argc, char** argv)
  42. {
  43. GtkApplication* app;
  44. obs_display_t* display;
  45. int status;
  46. app = gtk_application_new("xyz.dwayne.obs", G_APPLICATION_FLAGS_NONE);
  47. g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
  48. print_obs_version_string();
  49. if (!obs_initialized())
  50. {
  51. if (!obs_startup("en-US", NULL, NULL))
  52. {
  53. printf("Failed to start OBS...\n");
  54. return 1;
  55. }
  56. glutInit(&argc, argv);
  57. struct obs_video_info v;
  58. struct obs_audio_info a;
  59. v.graphics_module = "libobs-opengl.so.0";
  60. v.fps_num = 30000;
  61. v.fps_den = 1001;
  62. v.base_width = window_width;
  63. v.base_height = window_height;
  64. v.output_width = window_width;
  65. v.output_height = window_height;
  66. v.output_format = VIDEO_FORMAT_NV12;
  67. v.adapter = 0;
  68. v.gpu_conversion = true;
  69. v.colorspace = VIDEO_CS_601;
  70. v.range = VIDEO_RANGE_PARTIAL;
  71. v.scale_type = OBS_SCALE_BICUBIC;
  72. a.samples_per_sec = 44100;
  73. a.speakers = SPEAKERS_STEREO;
  74. obs_reset_video (&v);
  75. obs_reset_audio (&a);
  76. }
  77. // struct gs_init_data info;
  78. // info.cx = window_width;
  79. // info.cy = window_height;
  80. // info.window = NULL; // xw??
  81. // info.format = GS_BGRA;
  82. // info.zsformat = GS_ZS_NONE;
  83. // display = obs_display_create (&info, 0);
  84. // if (display == NULL)
  85. // {
  86. // printf("error creating display!\n");
  87. // }
  88. // obs_display_add_draw_callback (display, obs_render, NULL);
  89. status = g_application_run (G_APPLICATION (app), argc, argv);
  90. // obs_display_destroy (display);
  91. obs_shutdown ();
  92. g_object_unref (app);
  93. return status;
  94. }