UI: Draw cropped scene item edges as green in preview
parent
eb1ee87f38
commit
02661843de
|
@ -862,6 +862,26 @@ void OBSBasic::InitPrimitives()
|
|||
gs_vertex2f(0.0f, 0.0f);
|
||||
box = gs_render_save();
|
||||
|
||||
gs_render_start(true);
|
||||
gs_vertex2f(0.0f, 0.0f);
|
||||
gs_vertex2f(0.0f, 1.0f);
|
||||
boxLeft = gs_render_save();
|
||||
|
||||
gs_render_start(true);
|
||||
gs_vertex2f(0.0f, 0.0f);
|
||||
gs_vertex2f(1.0f, 0.0f);
|
||||
boxTop = gs_render_save();
|
||||
|
||||
gs_render_start(true);
|
||||
gs_vertex2f(1.0f, 0.0f);
|
||||
gs_vertex2f(1.0f, 1.0f);
|
||||
boxRight = gs_render_save();
|
||||
|
||||
gs_render_start(true);
|
||||
gs_vertex2f(0.0f, 1.0f);
|
||||
gs_vertex2f(1.0f, 1.0f);
|
||||
boxBottom = gs_render_save();
|
||||
|
||||
gs_render_start(true);
|
||||
for (int i = 0; i <= 360; i += (360/20)) {
|
||||
float pos = RAD(float(i));
|
||||
|
@ -1279,6 +1299,10 @@ OBSBasic::~OBSBasic()
|
|||
|
||||
obs_enter_graphics();
|
||||
gs_vertexbuffer_destroy(box);
|
||||
gs_vertexbuffer_destroy(boxLeft);
|
||||
gs_vertexbuffer_destroy(boxTop);
|
||||
gs_vertexbuffer_destroy(boxRight);
|
||||
gs_vertexbuffer_destroy(boxBottom);
|
||||
gs_vertexbuffer_destroy(circle);
|
||||
obs_leave_graphics();
|
||||
|
||||
|
|
|
@ -113,6 +113,10 @@ private:
|
|||
std::unique_ptr<BasicOutputHandler> outputHandler;
|
||||
|
||||
gs_vertbuffer_t *box = nullptr;
|
||||
gs_vertbuffer_t *boxLeft = nullptr;
|
||||
gs_vertbuffer_t *boxTop = nullptr;
|
||||
gs_vertbuffer_t *boxRight = nullptr;
|
||||
gs_vertbuffer_t *boxBottom = nullptr;
|
||||
gs_vertbuffer_t *circle = nullptr;
|
||||
|
||||
bool sceneChanging = false;
|
||||
|
|
|
@ -747,13 +747,37 @@ bool OBSBasicPreview::DrawSelectedItem(obs_scene_t *scene,
|
|||
DrawCircleAtPos(0.5f, 1.0f, boxTransform, main->previewScale);
|
||||
DrawCircleAtPos(1.0f, 0.5f, boxTransform, main->previewScale);
|
||||
|
||||
gs_load_vertexbuffer(main->box);
|
||||
|
||||
gs_matrix_push();
|
||||
gs_matrix_scale3f(main->previewScale, main->previewScale, 1.0f);
|
||||
gs_matrix_mul(&boxTransform);
|
||||
|
||||
obs_sceneitem_crop crop;
|
||||
obs_sceneitem_get_crop(item, &crop);
|
||||
|
||||
if (info.bounds_type == OBS_BOUNDS_NONE && crop_enabled(&crop)) {
|
||||
vec4 color;
|
||||
gs_effect_t *eff = gs_get_effect();
|
||||
gs_eparam_t *param = gs_effect_get_param_by_name(eff, "color");
|
||||
|
||||
#define DRAW_SIDE(side, vb) \
|
||||
if (crop.side > 0) \
|
||||
vec4_set(&color, 0.0f, 1.0f, 0.0f, 1.0f); \
|
||||
else \
|
||||
vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f); \
|
||||
gs_effect_set_vec4(param, &color); \
|
||||
gs_load_vertexbuffer(main->vb); \
|
||||
gs_draw(GS_LINESTRIP, 0, 0);
|
||||
|
||||
DRAW_SIDE(left, boxLeft);
|
||||
DRAW_SIDE(top, boxTop);
|
||||
DRAW_SIDE(right, boxRight);
|
||||
DRAW_SIDE(bottom, boxBottom);
|
||||
#undef DRAW_SIDE
|
||||
} else {
|
||||
gs_load_vertexbuffer(main->box);
|
||||
gs_draw(GS_LINESTRIP, 0, 0);
|
||||
}
|
||||
|
||||
gs_matrix_pop();
|
||||
|
||||
UNUSED_PARAMETER(scene);
|
||||
|
|
Loading…
Reference in New Issue