LepidopterasRevenge
New Member
I'm creating an image source plugin using image data that is being rendered externally to the OBS graphic system
I'm having some difficulty getting the pixel data to render to OBS. Currently I'm just getting a black source with nothing being drawn
I have a dynamic array
that's being populated and then set to a texture by an async thread thusly
then in the source's render function I'm drawing like
the render function never enters into the if(textureA) test, it seems like because the texture isn't being set
I figure I'm doing something wrong in setting the texture data?
perhaps it's that the colour data array is a dynamic array and not const like the gs_texture_set_image function appears to expect? the data array is coming from video and might change size so I'm struggling to see a way around that
my c++ is pretty rusty so perhaps I'm confused on exactly what that means
or maybe I'm abusing the use of an async thread here?
in case it's relevant I'm creating and initialising the texture as such at the top of the updating async thread
what would be the best way to throw a dynamic raw colour array at the screen? thanks for your help
I'm having some difficulty getting the pixel data to render to OBS. Currently I'm just getting a black source with nothing being drawn
I have a dynamic array
C++:
uint8_t *data = new uint8_t[length * 4];
C++:
Monitor::Enter(bridge->textureLockA);
obs_enter_graphics();
width = tempWidth;
height = tempHeight;
gs_texture_set_image(textureA, tempData, width * 4, false);
obs_leave_graphics();
Monitor::Exit(bridge->textureLockA);
then in the source's render function I'm drawing like
C++:
Monitor::Enter(bridge->textureLockA);
if (textureA)
{
gs_effect_t *effect = obs_get_base_effect(OBS_EFFECT_PREMULTIPLIED_ALPHA);
while (gs_effect_loop(effect, "Draw"))
obs_source_draw(textureA, 0, 0, width, height, 0);
}
Monitor::Exit(bridge->textureLockA);
the render function never enters into the if(textureA) test, it seems like because the texture isn't being set
I figure I'm doing something wrong in setting the texture data?
perhaps it's that the colour data array is a dynamic array and not const like the gs_texture_set_image function appears to expect? the data array is coming from video and might change size so I'm struggling to see a way around that
my c++ is pretty rusty so perhaps I'm confused on exactly what that means
or maybe I'm abusing the use of an async thread here?
in case it's relevant I'm creating and initialising the texture as such at the top of the updating async thread
C++:
Monitor::Enter(bridge->lifeCycleLock);
const uint8_t *data[4]{ 0, 0, 0, 0 };
obs_enter_graphics();
width = 1;
height = 1;
textureA = gs_texture_create(1, 1, gs_color_format::GS_BGRA, 1, data, GS_DYNAMIC);
obs_leave_graphics();
Monitor::Exit(bridge->lifeCycleLock);
what would be the best way to throw a dynamic raw colour array at the screen? thanks for your help
Last edited: