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


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

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


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

示例1: main

int main()
{
	
	//OpenGL Setup
	if (!glfwInit())
	{
		std::cout << "GLFW failed to initialize!\n";
		return 1;
	}
	glfwOpenWindow(Width,Height,0,0,0,0,0,0,GLFW_WINDOW);
	if (glewInit() != GLEW_OK)
	{
		std::cout << "GLEW failed to initialize!\n";
		return 1;
	}
	glfwSetWindowTitle("it's done.");
	glViewport(0,0,Width, Height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0,0,0,0,0,100);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClearColor(1,0,0,1);
	//OpenGL Setup end
	
	Texture tex;

	while (true)
	{
		
		glClear (GL_COLOR_BUFFER_BIT);

		tex.Draw();
	
		glfwSwapBuffers();

		if (glfwGetKey (GLFW_KEY_ESC))
		{
			return 0;
		}
	}
}
开发者ID:Bumrang,项目名称:Animation,代码行数:42,代码来源:main.cpp

示例2: Draw

	void Draw() const
	{
		if(t)
		{
			Texture::Enable();
			tex.Draw();
			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
			
			glTexCoordPointer(2, GL_FLOAT, 0, t);
		}
		glVertexPointer(3, GL_FLOAT, 0, v);
		glNormalPointer(GL_FLOAT, 0, n);
		
		glDrawArrays(mode, 0, s);
		if(t)
		{
			Texture::Disable();
			glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		}
	}
开发者ID:aLaix,项目名称:RadicalEngine,代码行数:20,代码来源:Poly.cpp

示例3: Draw

void Smoke::Draw()
{
	Texture* tx = TextureManager::GetInstance().GetTexture("smoke");
	tx->color = 0xffdddddd;
	tx->Draw(vPos, &vScale, 0, 0, fAlpha);
}
开发者ID:Rinirihiriro,项目名称:SmallPlanet,代码行数:6,代码来源:Smoke.cpp

示例4: main

int main()
{
	
	//OpenGL Setup
	if (!glfwInit())
	{
		std::cout << "GLFW failed to initialize!\n";
		return 1;
	}
	glfwOpenWindow(Width,Height,0,0,0,0,0,0,GLFW_WINDOW);
	if (glewInit() != GLEW_OK)
	{
		std::cout << "GLEW failed to initialize!\n";
		return 1;
	}
	glfwSetWindowTitle("it's done.");
	glViewport(0,0,Width, Height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0,0,0,0,0,100);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClearColor(1,0,0,1);
	//OpenGL Setup end
	
	Texture tex;
	
	/*// If you had a class, this would be in the contructor.
	GLuint programID = LoadShaders ("tex.vert" , "tex.frag"); std::cout << programID << std::flush;
	
	GLuint img = SOIL_load_OGL_texture("runner_01.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS);

	std::vector <glm::vec2> Verts;
	Verts.push_back (glm::vec2 (-1.0f , -1.0f));
	Verts.push_back (glm::vec2 (-1.0f , 1.0f));
	Verts.push_back (glm::vec2 (1.0f , 1.0f));
	Verts.push_back (glm::vec2 (1.0f , -1.0f));

	std::vector <glm::vec2> UV;
	UV.push_back (glm::vec2 (0.0f , 1.0f));
	UV.push_back (glm::vec2 (0.0f , 0.0f));
	UV.push_back (glm::vec2 (1.0f , 0.0f));
	UV.push_back (glm::vec2 (1.0f , 1.0f));


	GLuint VertBuffer;
	glGenBuffers (1 , &VertBuffer);
	glBindBuffer (GL_ARRAY_BUFFER, VertBuffer);
	glBufferData (GL_ARRAY_BUFFER , Verts.size()*sizeof(glm::vec2) , &Verts[0] , GL_STATIC_DRAW);

	GLuint UVBuffer;
	glGenBuffers (1 , &UVBuffer);
	glBindBuffer (GL_ARRAY_BUFFER , UVBuffer);
	glBufferData (GL_ARRAY_BUFFER , UV.size()*sizeof(glm::vec2) , &UV[0] , GL_STATIC_DRAW);
	// Constructor end. */

	while (true)
	{
		
		glClear (GL_COLOR_BUFFER_BIT);

		tex.Draw();
	
		// This would be in the classes Draw() function.
		// Shader failure/success added.
		
		/*if (programID == NULL) // Was not able to compile, fallback.
		{
		glEnableClientState (GL_VERTEX_ARRAY);
		glBindBuffer (GL_ARRAY_BUFFER , VertBuffer);
		glVertexPointer (2 , GL_FLOAT , 0 , NULL);

		glEnableClientState (GL_TEXTURE_COORD_ARRAY);
		glBindBuffer (GL_ARRAY_BUFFER , UVBuffer);
		glTexCoordPointer (2 , GL_FLOAT , 0 , NULL);

		glEnable (GL_TEXTURE_2D);
		glBindTexture (GL_TEXTURE_2D , img);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		glColor4f(1,1,1,1);
		glDrawArrays (GL_QUADS , 0 , Verts.size());

		glDisable (GL_TEXTURE_2D);
		glDisable(GL_BLEND);

		glDisableClientState (GL_VERTEX_ARRAY);
		glDisableClientState (GL_TEXTURE_COORD_ARRAY);
		}
		
		else // Is able to compile.
		{
			glUseProgram (ProgramID);
			
					   glActiveTexture (GL_TEXTURE0);
	   glBindTexture (GL_TEXTURE_2D , TextureID);
	   glUniform1i (TextureID , 0);

	   glEnableVertexAttribArray (0);
//.........这里部分代码省略.........
开发者ID:Bumrang,项目名称:Common,代码行数:101,代码来源:main.cpp


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