Ejemplo n.º 1
0
bool gs_texrender_begin(gs_texrender_t texrender, uint32_t cx, uint32_t cy)
{
	if (!texrender || texrender->rendered)
		return false;

	if (cx == 0)
		cx = gs_get_width();
	if (cy == 0)
		cy = gs_get_height();

	assert(cx && cy);
	if (!cx || !cy)
		return false;

	if (texrender->cx != cx || texrender->cy != cy)
		if (!texrender_resetbuffer(texrender, cx, cy))
			return false;

	gs_viewport_push();
	gs_projection_push();
	gs_matrix_push();
	gs_matrix_identity();

	texrender->prev_target = gs_get_render_target();
	texrender->prev_zs     = gs_get_zstencil_target();
	gs_set_render_target(texrender->target, texrender->zs);

	gs_set_viewport(0, 0, texrender->cx, texrender->cy);

	return true;
}
Ejemplo n.º 2
0
static inline void render_display_begin(struct obs_display *display)
{
	struct vec4 clear_color;

	gs_load_swapchain(display ? display->swap : NULL);

	if (display->size_changed) {
		gs_resize(display->cx, display->cy);
		display->size_changed = false;
	}

	gs_begin_scene();

	vec4_from_rgba(&clear_color, display->background_color);
	clear_color.w = 1.0f;

	gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL,
			&clear_color, 1.0f, 0);

	gs_enable_depth_test(false);
	/* gs_enable_blending(false); */
	gs_set_cull_mode(GS_NEITHER);

	gs_ortho(0.0f, (float)display->cx,
			0.0f, (float)display->cy, -100.0f, 100.0f);
	gs_set_viewport(0, 0, display->cx, display->cy);
}
Ejemplo n.º 3
0
static inline void set_render_size(uint32_t width, uint32_t height)
{
	gs_enable_depth_test(false);
	gs_set_cull_mode(GS_NEITHER);

	gs_ortho(0.0f, (float)width, 0.0f, (float)height, -100.0f, 100.0f);
	gs_set_viewport(0, 0, width, height);
}
Ejemplo n.º 4
0
static inline void startRegion(int vX, int vY, int vCX, int vCY, float oL,
		float oR, float oT, float oB)
{
	gs_projection_push();
	gs_viewport_push();
	gs_set_viewport(vX, vY, vCX, vCY);
	gs_ortho(oL, oR, oT, oB, -100.0f, 100.0f);
}
Ejemplo n.º 5
0
void OBSProjector::OBSRender(void *data, uint32_t cx, uint32_t cy)
{
	OBSProjector *window = reinterpret_cast<OBSProjector*>(data);

	uint32_t targetCX;
	uint32_t targetCY;
	int      x, y;
	int      newCX, newCY;
	float    scale;

	if (window->source) {
		targetCX = std::max(obs_source_get_width(window->source), 1u);
		targetCY = std::max(obs_source_get_height(window->source), 1u);
	} else {
		struct obs_video_info ovi;
		obs_get_video_info(&ovi);
		targetCX = ovi.base_width;
		targetCY = ovi.base_height;
	}

	GetScaleAndCenterPos(targetCX, targetCY, cx, cy, x, y, scale);

	newCX = int(scale * float(targetCX));
	newCY = int(scale * float(targetCY));

	gs_viewport_push();
	gs_projection_push();
	gs_ortho(0.0f, float(targetCX), 0.0f, float(targetCY), -100.0f, 100.0f);
	gs_set_viewport(x, y, newCX, newCY);

	if (window->source)
		obs_source_video_render(window->source);
	else
		obs_render_main_view();

	gs_projection_pop();
	gs_viewport_pop();
}