示例#1
0
文件: texture.c 项目: JCGit/ejoy2d
const char * 
texture_load(int id, enum TEXTURE_FORMAT pixel_format, int pixel_width, int pixel_height, void *data, int reduce) {
	if (id >= MAX_TEXTURE) {
		return "Too many texture";
	}
	struct texture * tex = &POOL.tex[id];
	if (id >= POOL.count) {
		POOL.count = id + 1;
	} 
	tex->fb = 0;
	tex->width = pixel_width;
	tex->height = pixel_height;
	tex->invw = 1.0f / (float)pixel_width;
	tex->invh = 1.0f / (float)pixel_height;
	if (tex->id == 0) {
		tex->id = render_texture_create(R, pixel_width, pixel_height, pixel_format, TEXTURE_2D, 0);
	}
	if (data == NULL) {
		// empty texture
		return NULL;
	}

	if (reduce) {
		texture_reduce(pixel_format, &pixel_width, &pixel_height, data);
	}
	render_texture_update(R, tex->id, pixel_width, pixel_height, data, 0, 0);

	return NULL;
}
示例#2
0
文件: label.c 项目: 1414648814/ejoy2d
void
label_load() {
	if (Dfont) return;

	Dfont = dfont_create(TEX_WIDTH, TEX_HEIGHT);

	Tex = render_texture_create(R, TEX_WIDTH, TEX_HEIGHT, TEX_FMT, TEXTURE_2D, 0);
	render_texture_update(R, Tex, TEX_WIDTH, TEX_HEIGHT ,NULL, 0, 0);
}
示例#3
0
文件: render.c 项目: suzuren/ejoy2d
RID 
render_target_create(struct render *R, int width, int height, enum TEXTURE_FORMAT format) {
	RID tex = render_texture_create(R, width, height, format, TEXTURE_2D, 0);
	if (tex == 0)
		return 0;
	render_texture_update(R, tex, width, height, NULL, 0, 0);
	RID rt = create_rt(R, tex);
	glBindFramebuffer(GL_FRAMEBUFFER, R->default_framebuffer);
	R->last.target = 0;
	R->changeflag |= CHANGE_TARGET;

	if (rt == 0) {
		render_release(R, TEXTURE, tex);
	}
	CHECK_GL_ERROR
	return rt;
}
示例#4
0
文件: ej_dtex.c 项目: xzrunner/ejoy2d
static int 
_texture_create(int type, int width, int height, const void* data, int channel, unsigned int id) {
	enum TEXTURE_FORMAT t = TEXTURE_RGBA8;
	switch (type) {
	case DTEX_TF_RGBA8:
		t = TEXTURE_RGBA8;
		break;
	case DTEX_TF_PVR4:
		t = TEXTURE_PVR4;
        break;
	default:
		assert(0);
	}

	struct render* r = sl_shader_get_render();
	int texid = render_texture_create(r, width, height, t, TEXTURE_2D, 0);
	render_texture_update(r, texid, width, height, data, 0, 0);
	return texid;
}