How to using "obs.gs_samplerstate_create" in lua script?

myso

New Member
nice to meet you.

I am currently working on a filter that stitches a dual-fisheye using Lua Script.
Help me solve this problem.

References
https://github.com/jp9000/obs-studio/blob/master/plugins/obs-filters/scroll-filter.c
https://github.com/jp9000/obs-studi.../frontend-tools/data/scripts/clock-source.lua

Error Log
Code:
[obs-video-filter-insta360.lua] Failed to call create for Insta360: .../obs-video-filter-insta360/obs-video-filter-insta360.lua:67: Error in gs_samplerstate_create (arg 1), expected 'struct gs_sampler_info const *' got 'table'

Filter Create Code
Code:
function Filter:create(settings, context)
    local filter = {}
    local effect_path = script_path() .. "crop_filter.effect"
    local sampler_info = {}
    sampler_info.filter = obs.GS_FILTER_LINEAR
    sampler_info.address_u = obs.GS_ADDRESS_WRAP
    sampler_info.address_v = obs.GS_ADDRESS_WRAP

  filter.context = context

  obs.obs_enter_graphics();
  filter.effect = obs.gs_effect_create_from_file(effect_path, nil)
  filter.sampler = obs.gs_samplerstate_create(sampler_info) -- This Line Error
  obs.obs_leave_graphics();

  if filter.effect then
      return;
  end

  filter.param_add   = obs.gs_effect_get_param_by_name(filter.effect, "add_val")
  filter.param_mul   = obs.gs_effect_get_param_by_name(filter.effect, "mul_val")
  filter.param_image = obs.gs_effect_get_param_by_name(filter.effect, "image")
   
    -- obs.obs_source_update(context, settings);

    return filter
end
 
Last edited:

myso

New Member
I tried using it with ffi, but I get another error.

Error Log
Code:
[obs-video-filter-insta360.lua] Failed to call create for Insta360: .../obs-video-filter-insta360/obs-video-filter-insta360.lua:67: declaration specifier expected near 'gs_sampler_info'

Source Code
Code:
local sampler_info = ffi.new("gs_sampler_info")
 

myso

New Member
i tried...

References
https://github.com/jp9000/obs-studi...00b160414eca9299d2/libobs/graphics/graphics.h

Error Log
Code:
[obs-video-filter-insta360.lua] Error running file: .../obs-video-filter-insta360/obs-video-filter-insta360.lua:46: size of C type is unknown or too large at line 8

Source Code
Code:
ffi.cdef[[
typedef struct {
    enum gs_sample_filter filter;
    enum gs_address_mode address_u;
    enum gs_address_mode address_v;
    enum gs_address_mode address_w;
    int max_anisotropy;
    uint32_t border_color;
}  gs_sampler_info;
]]
 
Top