How can i draw a line on image-source?

nemo

New Member
i want to write a plugin provide painting feature that shows in the image.
 
Last edited:

nemo

New Member
here is the answer:
Code:
    struct pen_source *context = bzalloc(sizeof(struct pen_source));
    context->source = source;

    if (context->tex)
        gs_texture_destroy(context->tex);

    struct obs_video_info ovi;
    obs_get_video_info(&ovi);
    context->width = (int)ovi.base_width;
    context->height = (int)ovi.base_height;
    size_t len = sizeof(char) * context->width * context->height * 4;
    context->data = bzalloc(len);
    memset(context->data, 0xff, len);

    obs_enter_graphics();
    context->tex = gs_texture_create(context->width, context->height, GS_RGBA, 1,
        &context->data, GS_DYNAMIC);
    obs_leave_graphics();

     .......
   
    obs_enter_graphics();
    gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), context->tex);
    gs_draw_sprite(context->tex, 0, context->width, context->height); 
    obs_leave_graphics();
 
Last edited:

nemo

New Member
a better implementation.
Code:
        obs_enter_graphics();
        gs_render_start(true);
        gs_vertex2f(x2, y2);
        gs_vertex2f(x1, y1);
        gs_vertex2f(x2 + x_offset, y2 + y_offset);
        gs_vertex2f(x1 + x_offset, y1 + y_offset);
        line->buf = gs_render_save();
        obs_leave_graphics();
 

c00lnerd

New Member
This is in Visual c#. Did you create an install for it, or an executable? I can't do that on this computer. Maybe I'll try to do that on my other computer where I do c#.
 
Top