コード例 #1
0
void set_texture()
{
	alloc_tex();

	int height_delta = BLOCK_SIZE / tex_w / 3;
	int i;

	/* Since the pcie hybrid version reuses the same memory to compute different portions of the image,
	the SW_ONLY executable should use a non-zero OFFSET*/
#ifdef SW_ONLY
#define OFFSET (i*tex_w)
#else
#define OFFSET (0)
#endif
	for (i = 0; i < height; i += height_delta) {
		calc_mandel(scale, cx, cy, SHARED_tex+OFFSET, tex_w, max_iter, width, i, MIN(i+height_delta,height), height);
		memcpy_from_shared(tex[i], SHARED_tex, height_delta * tex_w * 3);
	}
 
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture);
	glTexImage2D(GL_TEXTURE_2D, 0, 3, tex_w, tex_h,
		0, GL_RGB, GL_UNSIGNED_BYTE, tex[0]);
 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	render();
}
コード例 #2
0
void TexPacket::alloc(unsigned int _width, unsigned int _height) {
	width = _width;
	height = _height;
	if (tex || fb) {
		WARNING("WARNING: TexPacket::alloc on non-zero tex/fb: " << tex << "/" << fb);
	}
	if (width > 10000 || height > 10000) {
		assert(0);
	}
	alloc_tex(width, height, tex);
	alloc_fb(tex, fb);
	Graphics::gl_errors("TexPacket::alloc");
}