Dwayne Harris
3 years ago
4 changed files with 203 additions and 49 deletions
-
88.gitignore
-
2Makefile
-
11README.md
-
151main.c
@ -0,0 +1,88 @@ |
|||
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/macos,c |
|||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,c |
|||
|
|||
### C ### |
|||
# Prerequisites |
|||
*.d |
|||
|
|||
# Object files |
|||
*.o |
|||
*.ko |
|||
*.obj |
|||
*.elf |
|||
|
|||
# Linker output |
|||
*.ilk |
|||
*.map |
|||
*.exp |
|||
|
|||
# Precompiled Headers |
|||
*.gch |
|||
*.pch |
|||
|
|||
# Libraries |
|||
*.lib |
|||
*.a |
|||
*.la |
|||
*.lo |
|||
|
|||
# Shared objects (inc. Windows DLLs) |
|||
*.dll |
|||
*.so |
|||
*.so.* |
|||
*.dylib |
|||
|
|||
# Executables |
|||
*.exe |
|||
*.out |
|||
*.app |
|||
*.i*86 |
|||
*.x86_64 |
|||
*.hex |
|||
|
|||
# Debug files |
|||
*.dSYM/ |
|||
*.su |
|||
*.idb |
|||
*.pdb |
|||
|
|||
# Kernel Module Compile Results |
|||
*.mod* |
|||
*.cmd |
|||
.tmp_versions/ |
|||
modules.order |
|||
Module.symvers |
|||
Mkfile.old |
|||
dkms.conf |
|||
|
|||
### macOS ### |
|||
# General |
|||
.DS_Store |
|||
.AppleDouble |
|||
.LSOverride |
|||
|
|||
# Icon must end with two \r |
|||
Icon |
|||
|
|||
|
|||
# Thumbnails |
|||
._* |
|||
|
|||
# Files that might appear in the root of a volume |
|||
.DocumentRevisions-V100 |
|||
.fseventsd |
|||
.Spotlight-V100 |
|||
.TemporaryItems |
|||
.Trashes |
|||
.VolumeIcon.icns |
|||
.com.apple.timemachine.donotpresent |
|||
|
|||
# Directories potentially created on remote AFP share |
|||
.AppleDB |
|||
.AppleDesktop |
|||
Network Trash Folder |
|||
Temporary Items |
|||
.apdisk |
|||
|
|||
# End of https://www.toptal.com/developers/gitignore/api/macos,c |
@ -0,0 +1,11 @@ |
|||
# obs-sample |
|||
|
|||
|
|||
### Install Dependencies |
|||
|
|||
`apt install libobs-dev libgtk-3-dev libsimde-dev mesa-common-dev freeglut3-dev` |
|||
|
|||
|
|||
### Build and Run |
|||
|
|||
`make run` |
@ -1,59 +1,114 @@ |
|||
#include <stdio.h> |
|||
#include <GL/freeglut.h> |
|||
#include <gtk/gtk.h> |
|||
#include <gdk/gdkx.h> |
|||
#include <obs/obs.h> |
|||
|
|||
void render() { |
|||
glClearColor(0.0, 0.0, 0.0, 0.0); |
|||
glClear(GL_COLOR_BUFFER_BIT); |
|||
glFlush(); |
|||
const int window_width = 1280; |
|||
const int window_height = 720; |
|||
Window xw; |
|||
|
|||
void |
|||
print_obs_version_string() |
|||
{ |
|||
const char* version = obs_get_version_string(); |
|||
printf("OBS version: %s\n", version); |
|||
} |
|||
|
|||
int main(int argc, char** argv) { |
|||
const char* version; |
|||
void |
|||
obs_render (void* param, |
|||
uint32_t cx, |
|||
uint32_t cy) |
|||
{ |
|||
obs_render_main_texture (); |
|||
} |
|||
|
|||
version = obs_get_version_string(); |
|||
printf("OBS version: %s\n", version); |
|||
static void |
|||
activate (GtkApplication* app, |
|||
gpointer user_data) |
|||
{ |
|||
GtkWidget* window = gtk_application_window_new (app); |
|||
gtk_window_set_title (GTK_WINDOW(window), "OBS"); |
|||
gtk_window_set_default_size (GTK_WINDOW(window), window_width, window_height); |
|||
gtk_window_present (GTK_WINDOW(window)); |
|||
xw = gdk_x11_window_get_xid (gtk_widget_get_window(window)); |
|||
} |
|||
|
|||
void |
|||
render_sources(GtkApplication* app) |
|||
{ |
|||
GtkWidget* window = gtk_application_window_new (app); |
|||
gtk_window_set_title (GTK_WINDOW(window), "OBS - Sources"); |
|||
gtk_window_set_default_size (GTK_WINDOW(window), 500, 500); |
|||
gtk_window_present (GTK_WINDOW(window)); |
|||
} |
|||
|
|||
int |
|||
main(int argc, char** argv) |
|||
{ |
|||
GtkApplication* app; |
|||
obs_display_t* display; |
|||
int status; |
|||
|
|||
app = gtk_application_new("xyz.dwayne.obs", G_APPLICATION_FLAGS_NONE); |
|||
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); |
|||
|
|||
print_obs_version_string(); |
|||
|
|||
if (!obs_initialized()) { |
|||
if (!obs_startup("en-US", NULL, NULL)) { |
|||
printf("Failed to start OBS...\n"); |
|||
return 1; |
|||
if (!obs_initialized()) |
|||
{ |
|||
if (!obs_startup("en-US", NULL, NULL)) |
|||
{ |
|||
printf("Failed to start OBS...\n"); |
|||
return 1; |
|||
} |
|||
|
|||
glutInit(&argc, argv); |
|||
|
|||
struct obs_video_info v; |
|||
struct obs_audio_info a; |
|||
|
|||
v.graphics_module = "libobs-opengl.so.0"; |
|||
v.fps_num = 30000; |
|||
v.fps_den = 1001; |
|||
v.base_width = window_width; |
|||
v.base_height = window_height; |
|||
v.output_width = window_width; |
|||
v.output_height = window_height; |
|||
v.output_format = VIDEO_FORMAT_NV12; |
|||
v.adapter = 0; |
|||
v.gpu_conversion = true; |
|||
v.colorspace = VIDEO_CS_601; |
|||
v.range = VIDEO_RANGE_PARTIAL; |
|||
v.scale_type = OBS_SCALE_BICUBIC; |
|||
|
|||
a.samples_per_sec = 44100; |
|||
a.speakers = SPEAKERS_STEREO; |
|||
|
|||
obs_reset_video (&v); |
|||
obs_reset_audio (&a); |
|||
} |
|||
|
|||
glutInit(&argc, argv); |
|||
|
|||
struct obs_video_info v; |
|||
struct obs_audio_info a; |
|||
|
|||
v.graphics_module = "libobs-opengl.so.0"; |
|||
v.fps_num = 30000; |
|||
v.fps_den = 1001; |
|||
v.base_width = 1280; |
|||
v.base_height = 720; |
|||
v.output_width = 1280; |
|||
v.output_height = 720; |
|||
v.output_format = VIDEO_FORMAT_NV12; |
|||
v.adapter = 0; |
|||
v.gpu_conversion = true; |
|||
v.colorspace = VIDEO_CS_601; |
|||
v.range = VIDEO_RANGE_PARTIAL; |
|||
v.scale_type = OBS_SCALE_BICUBIC; |
|||
|
|||
a.samples_per_sec = 44100; |
|||
a.speakers = SPEAKERS_STEREO; |
|||
|
|||
obs_reset_video(&v); |
|||
obs_reset_audio(&a); |
|||
} |
|||
|
|||
glutInitDisplayMode(GLUT_SINGLE); |
|||
glutInitWindowSize(500, 500); |
|||
glutInitWindowPosition(100, 100); |
|||
glutCreateWindow("OBS Window"); |
|||
glutDisplayFunc(render); |
|||
glutMainLoop(); |
|||
|
|||
obs_shutdown(); |
|||
|
|||
return 0; |
|||
// struct gs_init_data info; |
|||
// info.cx = window_width; |
|||
// info.cy = window_height; |
|||
// info.window = NULL; // xw?? |
|||
// info.format = GS_BGRA; |
|||
// info.zsformat = GS_ZS_NONE; |
|||
|
|||
// display = obs_display_create (&info, 0); |
|||
// if (display == NULL) |
|||
// { |
|||
// printf("error creating display!\n"); |
|||
// } |
|||
|
|||
// obs_display_add_draw_callback (display, obs_render, NULL); |
|||
|
|||
status = g_application_run (G_APPLICATION (app), argc, argv); |
|||
|
|||
// obs_display_destroy (display); |
|||
obs_shutdown (); |
|||
g_object_unref (app); |
|||
|
|||
return status; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue