예제 #1
0
파일: glshared.c 프로젝트: jeoerl/arcan
void agp_resize_rendertarget(
	struct agp_rendertarget* tgt, size_t neww, size_t newh)
{
	if (!tgt || !tgt->store){
		arcan_warning("attempted resize on broken rendertarget\n");
		return;
	}

/* same dimensions, no need to resize */
	if (tgt->store->w == neww && tgt->store->h == newh)
		return;

	struct storage_info_t* os = tgt->store;

/* we inplace- modify, want the refcounter intact */
	agp_null_vstore(os);
	arcan_mem_free(os->vinf.text.raw);
	os->vinf.text.raw = NULL;
	os->vinf.text.s_raw = 0;
	agp_empty_vstore(os, neww, newh);

	glDeleteFramebuffers(1,&tgt->fbo);
	glDeleteRenderbuffers(1,&tgt->depth);
	tgt->fbo = GL_NONE;
	tgt->depth = GL_NONE;
	alloc_fbo(tgt, tgt->mode);
}
예제 #2
0
파일: glshared.c 프로젝트: mewbak/arcan
static void erase_store(struct storage_info_t* os)
{
	if (!os)
		return;

	agp_null_vstore(os);
	arcan_mem_free(os->vinf.text.raw);
	os->vinf.text.raw = NULL;
	os->vinf.text.s_raw = 0;
}
예제 #3
0
파일: gl21.c 프로젝트: mewbak/arcan
struct stream_meta agp_stream_prepare(struct storage_info_t* s,
		struct stream_meta meta, enum stream_type type)
{
	struct agp_fenv* env = agp_env();
	struct stream_meta res = meta;
	res.state = true;
	res.type = type;

	switch (type){
	case STREAM_RAW:
		if (!s->vinf.text.wid)
			setup_unpack_pbo(s, NULL);

		alloc_buffer(s);

		res.buf = s->vinf.text.raw;
		res.state = res.buf != NULL;
	break;

	case STREAM_RAW_DIRECT_COPY:
		alloc_buffer(s);
	case STREAM_RAW_DIRECT:
		if (!s->vinf.text.wid)
			setup_unpack_pbo(s, meta.buf);

		if (meta.dirty)
			pbo_stream_sub(s, meta.buf, &meta, type == STREAM_RAW_DIRECT_COPY);
		else
			pbo_stream(s, meta.buf, &meta, type == STREAM_RAW_DIRECT_COPY);
	break;

/* resynch: drop PBOs and GLid, alloc / upload and rebuild possible PBOs */
	case STREAM_EXT_RESYNCH:
		agp_null_vstore(s);
		agp_update_vstore(s, true);
		rebuild_pbo(s);
	break;

	case STREAM_RAW_DIRECT_SYNCHRONOUS:
		agp_activate_vstore(s);

		if (meta.dirty){
			set_pixel_store(s->w, meta);
			env->tex_subimage_2d(GL_TEXTURE_2D, 0, meta.x1, meta.y1, meta.w, meta.h,
				s->vinf.text.s_fmt ? s->vinf.text.s_fmt : GL_PIXEL_FORMAT,
				GL_UNSIGNED_BYTE, meta.buf
			);
			reset_pixel_store();
		}
		else
			env->tex_subimage_2d(GL_TEXTURE_2D, 0, 0, 0, s->w, s->h,
				s->vinf.text.s_fmt ? s->vinf.text.s_fmt : GL_PIXEL_FORMAT,
				GL_UNSIGNED_BYTE, meta.buf
			);
		agp_deactivate_vstore();
	break;

	case STREAM_HANDLE:
/* if platform_video_map_handle fails here, prepare an empty vstore and attempt
 * again, if that succeeds it means that we had to go through a RTT
 * indirection, if that fails we should convey back to the client that
	we can't accept this kind of transfer */
	res.state = platform_video_map_handle(s, meta.handle);
	break;
	}

	return res;
}