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


C++ Texture::GetSizeY方法代码示例

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


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

示例1: DebugInfoRender

void TextureManager::DebugInfoRender(const float &fRatio, const PosQuat &pq)
{
	Texture *pCurrent = 0;

	//render currently selected texture for debug display
	if (m_dwSelectedIndex < m_vTextures.size())
	{
		pCurrent = m_vTextures.at(m_dwSelectedIndex);
	}

	if (!pCurrent)
	{
		return;
	}

	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	GLboolean bLightingWasOn = glIsEnabled(GL_LIGHTING);
	if (bLightingWasOn)
	{ //turn off lighting
		glDisable(GL_LIGHTING);
	}
	
	GLboolean bTextureWasOn = glIsEnabled(GL_TEXTURE_2D);
	if (!bTextureWasOn)
	{ //turn textures on if it wasn't already on
		glEnable(GL_TEXTURE_2D);
	}

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glBindTexture(GL_TEXTURE_2D, pCurrent->GetTexture());

	glMultMatrixf(pq.quat.ToMatrix().m);

	float fScale = 0.33f;
	float fBorder = fScale * 1.05f;
	float fBorderSize = fBorder - fScale;

	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f);  glVertex3f(-fScale, -fScale, 0.0f);
	glTexCoord2f(0.0f, 1.0f);  glVertex3f(-fScale, fScale, 0.0f);
	glTexCoord2f(1.0f, 1.0f);  glVertex3f(fScale, fScale, 0.0f);
	glTexCoord2f(1.0f, 0.0f);  glVertex3f(fScale, -fScale, 0.0f);
	glEnd();

	glDisable(GL_TEXTURE_2D);

	glBegin(GL_QUADS);
	glColor3f(1.0f, 0.0f, 1.0f);
	glNormal3f(0.0f, 0.0f, 1.0f);
	glVertex3f(-fBorder, -fBorder, 0.0f);
	glVertex3f(-fBorder, fBorder, 0.0f);
	glVertex3f(-fBorder + fBorderSize, fBorder, 0.0f);
	glVertex3f(-fBorder + fBorderSize, -fBorder, 0.0f);

	glVertex3f(fBorder, -fBorder, 0.0f);
	glVertex3f(fBorder, fBorder, 0.0f);
	glVertex3f(fBorder - fBorderSize, fBorder, 0.0f);
	glVertex3f(fBorder - fBorderSize, -fBorder, 0.0f);

	glVertex3f(-fBorder, -fBorder, 0.0f);
	glVertex3f(-fBorder, -fBorder + fBorderSize, 0.0f);
	glVertex3f(fBorder, -fBorder + fBorderSize, 0.0f);
	glVertex3f(fBorder, -fBorder, 0.0f);

	glVertex3f(-fBorder, fBorder, 0.0f);
	glVertex3f(-fBorder, fBorder - fBorderSize, 0.0f);
	glVertex3f(fBorder, fBorder - fBorderSize, 0.0f);
	glVertex3f(fBorder, fBorder, 0.0f);

	glEnd();
	glColor3f(1.0f, 1.0f, 1.0f);

	//reset matrices so text is always in the correct spot
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, fRatio, 0.1, 50.0); //update this so we dont get crappy distortion
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(0.0, 0.0, 1.75, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

	size_t size = 50 + strlen(pCurrent->GetName());
	char *pDetails = (char *)malloc(sizeof(char) * size);
	memset(pDetails, 0, size);
	sprintf_s(pDetails, size, "%dx%d, %u bytes, %s", pCurrent->GetSizeX(), pCurrent->GetSizeY(), pCurrent->GetSizeInBytes(), pCurrent->GetName());

	glRasterPos2f(-fRatio, 0.97f);
	for (const char *c = pDetails; *c != '\0'; c++)
	{
		glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *c);
	}
	free(pDetails);

	this->RenderHelpText(fRatio);

	glEnable(GL_TEXTURE_2D);

	if (!bTextureWasOn)
	{ //disable textures if it wasn't on initially
		glDisable(GL_TEXTURE_2D);
//.........这里部分代码省略.........
开发者ID:scottrick,项目名称:dgame,代码行数:101,代码来源:TextureManager.cpp


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