示例#1
0
void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width,
		uint32_t height)
{
	graphics_t graphics = thread_graphics;
	float fcx, fcy;
	struct vb_data *data;

	assert(tex);

	if (gs_gettexturetype(tex) != GS_TEXTURE_2D) {
		blog(LOG_ERROR, "A sprite must be a 2D texture");
		return;
	}

	fcx = width  ? (float)width  : (float)texture_getwidth(tex);
	fcy = height ? (float)height : (float)texture_getheight(tex);

	data = vertexbuffer_getdata(graphics->sprite_buffer);
	build_sprite(data, fcx, fcy, flip);
	vertexbuffer_flush(graphics->sprite_buffer, false);
	gs_load_vertexbuffer(graphics->sprite_buffer);
	gs_load_indexbuffer(NULL);

	gs_draw(GS_TRISTRIP, 0, 0);
}
示例#2
0
static inline void build_sprite_norm(struct vb_data *data, float fcx, float fcy,
		uint32_t flip)
{
	float start_u, end_u;
	float start_v, end_v;

	assign_sprite_uv(&start_u, &end_u, (flip & GS_FLIP_U) != 0);
	assign_sprite_uv(&start_v, &end_v, (flip & GS_FLIP_V) != 0);
	build_sprite(data, fcx, fcy, start_u, end_u, start_v, end_v, flip);
}
示例#3
0
static inline void build_sprite_rect(struct vb_data *data, texture_t tex,
		float fcx, float fcy, uint32_t flip)
{
	float start_u, end_u;
	float start_v, end_v;
	float width  = (float)texture_getwidth(tex);
	float height = (float)texture_getheight(tex);

	assign_sprite_rect(&start_u, &end_u, width,  (flip & GS_FLIP_U) != 0);
	assign_sprite_rect(&start_v, &end_v, height, (flip & GS_FLIP_V) != 0);
	build_sprite(data, fcx, fcy, start_u, end_u, start_v, end_v, flip);
}