Esempio n. 1
0
bool grLoadPngTexture (const char *fname, ssgTextureInfo* info)
{
	GLubyte *tex;
	int w, h;
	int mipmap = 1;

	TRACE_GL("Load: grLoadPngTexture start");

	tex = (GLubyte*)GfImgReadPng(fname, &w, &h, 2.0);
	if (!tex) {
		return false;
    }

	if (info) {
		info -> width  = w;
		info -> height = h;
		info -> depth  = 4;
		info -> alpha  = true;
    }

	TRACE_GL("Load: grLoadPngTexture stop");

	// TODO: Check if tex is freed.
	// 		 Check/fix potential problems related to malloc/delete mixture
	//       (instead of malloc/free or new/delete).

	mipmap = doMipMap(fname, mipmap);

	GLubyte* tex2 = new GLubyte[w*h*4];
	memcpy(tex2, tex, w*h*4);
	free(tex);
	tex = tex2;
	
	return grMakeMipMaps(tex, w, h, 4, mipmap);
}
Esempio n. 2
0
void cgrSimpleState::setTexture(const char *fname, int wrapu, int wrapv, int mipmap)
{
	mipmap = doMipMap(fname, mipmap);
	
	ssgSimpleState::setTexture(fname, wrapu, wrapv, mipmap);
}