Commit Graph

36 Commits (master)

Author SHA1 Message Date
jpark37 2c7ef7d682 libobs-opengl: Fix Mac projector color space
Use sRGB instead of native display color space for correctness.
2022-08-24 05:08:26 -07:00
jpark37 4fe6803fe4 libobs: Prevent D3D11 projectors from tearing
Some users stream projectors, so don't let them tear. Use the waitable
object to check the flip queue, and only flip if there's space.

Metal and Vulkan can probably perform similar flip throttling once OBS
starts using them.
2022-08-06 16:16:20 -07:00
PatTheMav 4edb034790 libobs-opengl: Fix error message for invalid IOSurface buffers
Syphon relies on global IOSurfaces which are not officially supported
by macOS anymore. While the core functionality is still available,
`IOSurfaceGetPixelFormat` will not return a valid pixel format.
2022-07-31 12:21:35 +02:00
Developer-Ecosystem-Engineering 9ed5062e59 mac-capture: Add support for improved window capture in macOS 12.3
Add a new capture plugin called General Capture that allows for capture
of an entire desktop, a single window, or all windows of an application
2022-07-24 13:59:09 +02:00
mvji c6029ac658 libobs-opengl: Fix compiler warning
Fix unused parameter warning.
2022-04-23 16:12:45 -07:00
jpark37 eccde48926 libobs/graphics: Add gs_is_monitor_hdr
Only Windows is implemented for now. Mac/Linux return false for now.
2022-03-23 22:35:26 -07:00
PatTheMav 61ea6e0247
libobs: Add texture sharing support for macOS/OpenGL 2020-12-18 17:44:03 +01:00
jpark37 0a296bb12f libobs-opengl: Lock Mac parent context during present
Parent context lock keeps GL commands serialized.

Fixes race that causes crash when resizing multiview.
2020-05-02 12:00:11 -07:00
jpark37 1733705070 libobs-opengl: Fix Mac VAO created without context 2020-02-24 22:08:28 -08:00
jpark37 9f330050ef libobs-opengl: OpenGL thread-safety on Mac
Attempt to fix threading issues that cause OBS to force-crash when
compiled with latest Xcode. There are two places where the new SDK
introduces a force-crash because operations are not happening on the
main thread: when we modify the context view to switch swap chains, and
when we resize a swap chain.

Instead of using just one context for all rendering, we create an
additional context for each swap chain, set each view once on
initialization, and switch contexts only in present to blit the final
framebuffer. This is an extra copy, but it's pretty hairy to optimize
away, and it's not worth potential regressions just to speed up Mac.

For resizing, we schedule the update code to run on the main thread from
the render thread. Ideally, we wouldn't have to round trip the logic
from main thread to graphics thread and back, but I don't think we want
to hack up the interface for this, especially since OpenGL will give way
to Metal soon enough.
2019-12-26 01:45:48 -08:00
jp9000 bf41fd5a6b libobs: Add graphics API to get graphics object pointer 2019-08-29 12:43:10 -07:00
Colin Edwards ad85a9fa25 Apply clang-format to objective c code 2019-07-09 13:39:13 -05:00
jp9000 4494e927f7 libobs-opengl: Disable v-sync on mac
Sets the swap interval to 0 to prevent v-sync from affecting any of the
preview panes on mac.
2017-10-06 06:35:56 -07:00
jp9000 ce1014c417 libobs-opengl: Use windowless context (cocoa)
(Non-compiling commit: windowless-context branch)

On cocoa, windowless contexts appear to be no problem.  You just don't
set a view or just clear the view.
2015-08-05 01:07:18 -07:00
jp9000 41fad2d1a4 (API Change) Use const params where applicable
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.

Functions that do not modify the fundamental underlying data of a
structure should be marked as constant, both for safety and to signify
that the parameter is input only and will not be modified by the
function using it.
2014-09-26 17:23:07 -07:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 5780f3f177 (API Change) Improve graphics API consistency
Summary:
- Prefix all graphics subsystem names with gs_ or GS_
- Unsquish funciton names (for example _setfloat to _set_float)
- Changed create functions to be more consistent with the rest of the
  API elsewhere.  For exmaple, instead of
  gs_create_texture/gs_texture_destroy, it's now
  gs_texture_create/gs_texture_destroy
- Renamed gs_stencil_op enum to gs_stencil_op_type

From:                            To:
-----------------------------------------------------------
tvertarray                       gs_tvertarray
vb_data                          gs_vb_data
vbdata_create                    gs_vbdata_create
vbdata_destroy                   gs_vbdata_destroy
shader_param                     gs_shader_param
gs_effect                        gs_effect
effect_technique                 gs_effect_technique
effect_pass                      gs_effect_pass
effect_param                     gs_effect_param
texture_t                        gs_texture_t
stagesurf_t                      gs_stagesurf_t
zstencil_t                       gs_zstencil_t
vertbuffer_t                     gs_vertbuffer_t
indexbuffer_t                    gs_indexbuffer_t
samplerstate_t                   gs_samplerstate_t
swapchain_t                      gs_swapchain_t
texrender_t                      gs_texrender_t
shader_t                         gs_shader_t
sparam_t                         gs_sparam_t
effect_t                         gs_effect_t
technique_t                      gs_technique_t
eparam_t                         gs_eparam_t
device_t                         gs_device_t
graphics_t                       graphics_t
shader_param_type                gs_shader_param_type
SHADER_PARAM_UNKNOWN             GS_SHADER_PARAM_UNKNOWN
SHADER_PARAM_BOOL                GS_SHADER_PARAM_BOOL
SHADER_PARAM_FLOAT               GS_SHADER_PARAM_FLOAT
SHADER_PARAM_INT                 GS_SHADER_PARAM_INT
SHADER_PARAM_STRING              GS_SHADER_PARAM_STRING
SHADER_PARAM_VEC2                GS_SHADER_PARAM_VEC2
SHADER_PARAM_VEC3                GS_SHADER_PARAM_VEC3
SHADER_PARAM_VEC4                GS_SHADER_PARAM_VEC4
SHADER_PARAM_MATRIX4X4           GS_SHADER_PARAM_MATRIX4X4
SHADER_PARAM_TEXTURE             GS_SHADER_PARAM_TEXTURE
shader_param_info                gs_shader_param_info
shader_type                      gs_shader_type
SHADER_VERTEX                    GS_SHADER_VERTEX
SHADER_PIXEL                     GS_SHADER_PIXEL
shader_destroy                   gs_shader_destroy
shader_numparams                 gs_shader_get_num_params
shader_getparambyidx             gs_shader_get_param_by_idx
shader_getparambyname            gs_shader_get_param_by_name
shader_getviewprojmatrix         gs_shader_get_viewproj_matrix
shader_getworldmatrix            gs_shader_get_world_matrix
shader_getparaminfo              gs_shader_get_param_info
shader_setbool                   gs_shader_set_bool
shader_setfloat                  gs_shader_set_float
shader_setint                    gs_shader_set_int
shader_setmatrix3                gs_shader_setmatrix3
shader_setmatrix4                gs_shader_set_matrix4
shader_setvec2                   gs_shader_set_vec2
shader_setvec3                   gs_shader_set_vec3
shader_setvec4                   gs_shader_set_vec4
shader_settexture                gs_shader_set_texture
shader_setval                    gs_shader_set_val
shader_setdefault                gs_shader_set_default
effect_property_type             gs_effect_property_type
EFFECT_NONE                      GS_EFFECT_NONE
EFFECT_BOOL                      GS_EFFECT_BOOL
EFFECT_FLOAT                     GS_EFFECT_FLOAT
EFFECT_COLOR                     GS_EFFECT_COLOR
EFFECT_TEXTURE                   GS_EFFECT_TEXTURE
effect_param_info                gs_effect_param_info
effect_destroy                   gs_effect_destroy
effect_gettechnique              gs_effect_get_technique
technique_begin                  gs_technique_begin
technique_end                    gs_technique_end
technique_beginpass              gs_technique_begin_pass
technique_beginpassbyname        gs_technique_begin_pass_by_name
technique_endpass                gs_technique_end_pass
effect_numparams                 gs_effect_get_num_params
effect_getparambyidx             gs_effect_get_param_by_idx
effect_getparambyname            gs_effect_get_param_by_name
effect_updateparams              gs_effect_update_params
effect_getviewprojmatrix         gs_effect_get_viewproj_matrix
effect_getworldmatrix            gs_effect_get_world_matrix
effect_getparaminfo              gs_effect_get_param_info
effect_setbool                   gs_effect_set_bool
effect_setfloat                  gs_effect_set_float
effect_setint                    gs_effect_set_int
effect_setmatrix4                gs_effect_set_matrix4
effect_setvec2                   gs_effect_set_vec2
effect_setvec3                   gs_effect_set_vec3
effect_setvec4                   gs_effect_set_vec4
effect_settexture                gs_effect_set_texture
effect_setval                    gs_effect_set_val
effect_setdefault                gs_effect_set_default
texrender_create                 gs_texrender_create
texrender_destroy                gs_texrender_destroy
texrender_begin                  gs_texrender_begin
texrender_end                    gs_texrender_end
texrender_reset                  gs_texrender_reset
texrender_gettexture             gs_texrender_get_texture
GS_BUILDMIPMAPS                  GS_BUILD_MIPMAPS
GS_RENDERTARGET                  GS_RENDER_TARGET
gs_device_name                   gs_get_device_name
gs_device_type                   gs_get_device_type
gs_entercontext                  gs_enter_context
gs_leavecontext                  gs_leave_context
gs_getcontext                    gs_get_context
gs_renderstart                   gs_render_start
gs_renderstop                    gs_render_stop
gs_rendersave                    gs_render_save
gs_getinput                      gs_get_input
gs_geteffect                     gs_get_effect
gs_create_effect_from_file       gs_effect_create_from_file
gs_create_effect                 gs_effect_create
gs_create_vertexshader_from_file gs_vertexshader_create_from_file
gs_create_pixelshader_from_file  gs_pixelshader_create_from_file
gs_create_texture_from_file      gs_texture_create_from_file
gs_resetviewport                 gs_reset_viewport
gs_set2dmode                     gs_set_2d_mode
gs_set3dmode                     gs_set_3d_mode
gs_create_swapchain              gs_swapchain_create
gs_getsize                       gs_get_size
gs_getwidth                      gs_get_width
gs_getheight                     gs_get_height
gs_create_texture                gs_texture_create
gs_create_cubetexture            gs_cubetexture_create
gs_create_volumetexture          gs_voltexture_create
gs_create_zstencil               gs_zstencil_create
gs_create_stagesurface           gs_stagesurface_create
gs_create_samplerstate           gs_samplerstate_create
gs_create_vertexshader           gs_vertexshader_create
gs_create_pixelshader            gs_pixelshader_create
gs_create_vertexbuffer           gs_vertexbuffer_create
gs_create_indexbuffer            gs_indexbuffer_create
gs_gettexturetype                gs_get_texture_type
gs_load_defaultsamplerstate      gs_load_default_samplerstate
gs_getvertexshader               gs_get_vertex_shader
gs_getpixelshader                gs_get_pixel_shader
gs_getrendertarget               gs_get_render_target
gs_getzstenciltarget             gs_get_zstencil_target
gs_setrendertarget               gs_set_render_target
gs_setcuberendertarget           gs_set_cube_render_target
gs_beginscene                    gs_begin_scene
gs_draw                          gs_draw
gs_endscene                      gs_end_scene
gs_setcullmode                   gs_set_cull_mode
gs_getcullmode                   gs_get_cull_mode
gs_enable_depthtest              gs_enable_depth_test
gs_enable_stenciltest            gs_enable_stencil_test
gs_enable_stencilwrite           gs_enable_stencil_write
gs_blendfunction                 gs_blend_function
gs_depthfunction                 gs_depth_function
gs_stencilfunction               gs_stencil_function
gs_stencilop                     gs_stencil_op
gs_setviewport                   gs_set_viewport
gs_getviewport                   gs_get_viewport
gs_setscissorrect                gs_set_scissor_rect
gs_create_texture_from_iosurface gs_texture_create_from_iosurface
gs_create_gdi_texture            gs_texture_create_gdi
gs_is_compressed_format          gs_is_compressed_format
gs_num_total_levels              gs_get_total_levels
texture_setimage                 gs_texture_set_image
cubetexture_setimage             gs_cubetexture_set_image
swapchain_destroy                gs_swapchain_destroy
texture_destroy                  gs_texture_destroy
texture_getwidth                 gs_texture_get_width
texture_getheight                gs_texture_get_height
texture_getcolorformat           gs_texture_get_color_format
texture_map                      gs_texture_map
texture_unmap                    gs_texture_unmap
texture_isrect                   gs_texture_is_rect
texture_getobj                   gs_texture_get_obj
cubetexture_destroy              gs_cubetexture_destroy
cubetexture_getsize              gs_cubetexture_get_size
cubetexture_getcolorformat       gs_cubetexture_get_color_format
volumetexture_destroy            gs_voltexture_destroy
volumetexture_getwidth           gs_voltexture_get_width
volumetexture_getheight          gs_voltexture_get_height
volumetexture_getdepth           gs_voltexture_getdepth
volumetexture_getcolorformat     gs_voltexture_get_color_format
stagesurface_destroy             gs_stagesurface_destroy
stagesurface_getwidth            gs_stagesurface_get_width
stagesurface_getheight           gs_stagesurface_get_height
stagesurface_getcolorformat      gs_stagesurface_get_color_format
stagesurface_map                 gs_stagesurface_map
stagesurface_unmap               gs_stagesurface_unmap
zstencil_destroy                 gs_zstencil_destroy
samplerstate_destroy             gs_samplerstate_destroy
vertexbuffer_destroy             gs_vertexbuffer_destroy
vertexbuffer_flush               gs_vertexbuffer_flush
vertexbuffer_getdata             gs_vertexbuffer_get_data
indexbuffer_destroy              gs_indexbuffer_destroy
indexbuffer_flush                gs_indexbuffer_flush
indexbuffer_getdata              gs_indexbuffer_get_data
indexbuffer_numindices           gs_indexbuffer_get_num_indices
indexbuffer_gettype              gs_indexbuffer_get_type
texture_rebind_iosurface         gs_texture_rebind_iosurface
texture_get_dc                   gs_texture_get_dc
texture_release_dc               gs_texture_release_dc
2014-08-09 11:57:38 -07:00
Palana b0237fd581 Use high resolution GL surface when available 2014-04-16 22:39:20 +02:00
BtbN e50201cad1 Move from glLoadGen to GLAD 2014-04-15 22:19:40 +02:00
BtbN 0f9c6e5503 Create sub window for rendering, to avoid visual mismatch issues 2014-04-12 16:24:38 +02:00
Palana c2abb80c9a Use bzalloc instead of bmalloc+memset 2014-04-04 02:00:10 +02:00
Palana 61cf2faad3 Delete per window GL context for Cocoa and just swap the view instead
This unfortunately re-introduces undesirable rendering behaviour for
slow renderers (e.g. first gen Intel HD graphics/Apple software
renderer) when the property window is open, but fixes property window
preview rendering for sufficiently fast renderers
2014-04-04 02:00:08 +02:00
Palana f8b90a5c8f Add per window GL context for Cocoa libobs-opengl implementation
This fixes some problems with multiple swap chains (e.g. flickering
between the render views)
2014-03-24 17:42:45 +01:00
Zachary Lund 74ab96a3ad I removed GLEW, added glLoadGen (renamed to GL here), and added implementations for all platforms. Hopefully this goes better than GLAD did. 2014-01-25 22:26:43 -06:00
Zachary Lund 840c1cfd65 I removed GL-specific extension checking to a platform independent file.
I also fixed autoconf to find wxWidgets 2.9 without user intervention
Removed unused code and added more organization
2014-01-05 23:50:32 -06:00
Palana b70df7607c synchronize opengl context access on osx between threads 2013-12-31 18:46:19 +01:00
jp9000 e2a1186269 one of the problems of doing changes for Objective-C on windows is that you can't actually compile your code and test it before commiting, leading to foolish little errors like 'you forgot to put a semicolen at the end of that call' 2013-12-31 03:13:56 -07:00
jp9000 141b22e76e not sure what was on my mind there but I totally got the variable names wrong in that last commit (for NSOpenGLContext update) 2013-12-31 03:12:31 -07:00
jp9000 969a71d716 call NSOpenGLContext 'update' on opengl context on macos when resizing 2013-12-31 03:09:28 -07:00
Palana d9e1362cce add pixel format check for iosurfaces 2013-12-24 17:07:58 +01:00
Palana 74aa1c466b add osx iosurface opengl integration 2013-12-23 16:35:14 +01:00
jp9000 8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
jp9000 409b011a8e cleaned up main internal data structure design, changed to reference counting for sources to ensure safe destruction of source objects from all parts of the system, added some service-related stuff for testing 2013-11-20 15:00:16 -07:00
Palana 41bef32962 removed global VAO from gl-cocoa 2013-11-15 15:03:35 +01:00
jp9000 041f48b566 make code gl-cocoa.m 80 columns for consistency (I'm probably just being OCD, don't mind me, hopefully didn't break anything) 2013-11-14 10:48:48 -07:00
Palana d7a04aea8c added osx cocoa support files 2013-11-14 18:31:18 +01:00