当前位置: 首页>>代码示例>>C++>>正文


C++ TRaster32P::extract方法代码示例

本文整理汇总了C++中TRaster32P::extract方法的典型用法代码示例。如果您正苦于以下问题:C++ TRaster32P::extract方法的具体用法?C++ TRaster32P::extract怎么用?C++ TRaster32P::extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TRaster32P的用法示例。


在下文中一共展示了TRaster32P::extract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clearMatte

GLuint MeshTexturizer::Imp::textureAlloc(const TRaster32P &ras, const TRaster32P &aux,
										 int x, int y, int textureLx, int textureLy,
										 bool premultiplied)
{
	struct locals {
		static void clearMatte(const TRaster32P &ras, int xBegin, int yBegin, int xEnd, int yEnd)
		{
			for (int y = yBegin; y != yEnd; ++y) {
				TPixel32 *line = ras->pixels(y), *pixEnd = line + xEnd;

				for (TPixel32 *pix = line + xBegin; pix != pixEnd; ++pix)
					pix->m = 0;
			}
		}

		static void clearMatte_border(const TRaster32P &ras, int border0, int border1)
		{
			assert(border0 < border1);

			// Horizontal
			clearMatte(ras, border0, border0, ras->getLx() - border0, border1);
			clearMatte(ras, border0, ras->getLy() - border1, ras->getLx() - border0, ras->getLy() - border0);

			// Vertical
			clearMatte(ras, border0, border1, border1, ras->getLy() - border1);
			clearMatte(ras, ras->getLx() - border1, border1, ras->getLx() - border0, ras->getLy() - border1);
		}
	}; // locals

	// Prepare the texture tile
	assert(aux->getLx() >= textureLx + TOTAL_BORDER_2 && aux->getLy() >= textureLy + TOTAL_BORDER_2);

	TRect rasRect(x, y, x + textureLx - 1, y + textureLy - 1);
	rasRect = rasRect.enlarge(premultiplied ? COPIED_BORDER : COPIED_BORDER + NONPREM_BORDER);
	rasRect = rasRect * ras->getBounds();

	TRect auxRect(rasRect - TPoint(x - TOTAL_BORDER, y - TOTAL_BORDER));

	// An auxiliary raster must be used to supply the transparent border
	TRaster32P tex(aux->extract(0, 0, textureLx + TOTAL_BORDER_2 - 1, textureLy + TOTAL_BORDER_2 - 1));
	tex->clear();
	aux->extract(auxRect)->copy(ras->extract(rasRect));

	if (!premultiplied && NONPREM_BORDER > 0)
		locals::clearMatte_border(aux, TRANSP_BORDER - NONPREM_BORDER, TRANSP_BORDER);

	// Pass the raster into VRAM
	GLuint texId;
	glGenTextures(1, &texId);
	glBindTexture(GL_TEXTURE_2D, texId);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);	  // These must be used on a bound texture,
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);	  // and are remembered in the OpenGL context.
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // They can be set here, no need for
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // the user to do it.

	glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->getWrap());
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	glTexImage2D(GL_TEXTURE_2D,
				 0,				   // one level only
				 GL_RGBA,		   // pixel channels count
				 tex->getLx(),	 // width
				 tex->getLy(),	 // height
				 0,				   // border size
				 TGL_FMT,		   // pixel format
				 GL_UNSIGNED_BYTE, // pixel data type
				 (GLvoid *)tex->getRawData());

	return texId;
}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:71,代码来源:meshtexturizer.cpp


注:本文中的TRaster32P::extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。