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


C++ AnimatedSprite::SetAnimation方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........



	//new object
	float Spoints[] = {
		-0.25f, -0.5f, 0.0f,
		-0.25f, -0.75f, 0.0f,
		0.25f, -0.5f, 0.0f,
		0.25f, -0.75f, 0.0f
	};

	GLuint VBO2 = 0;
	glGenBuffers(1, &VBO2);
	glBindBuffer(GL_ARRAY_BUFFER, VBO2);
	glBufferData(GL_ARRAY_BUFFER, 12 * sizeof (float), Spoints, GL_STATIC_DRAW);
	GLuint VAO2 = 0;
	glGenVertexArrays(1, &VAO2);
	glBindVertexArray(VAO2);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte*)NULL);

	const char* vertex_shader2 =
		"#version 330\n"
		"in vec3 vp;\n"
		"void main() {"
		"gl_position = vec4(vp, 2.0);\n"
		"}";
	const char* fragment_shader2 =
		"#version 330\n"
		"out vec4 frag_colour;\n"
		"void main() {"
		"frag_colour = vec4(0.5, 0.0, 0.0, 1.0);\n"
		"}";

	//create a shader
	GLuint vs2 = glCreateShader(GL_VERTEX_SHADER);
	//put the actual char* in the shader
	glShaderSource(vs2, 1, &vertex_shader2, NULL);
	//compile the shader
	glCompileShader(vs2);
	PrintShaderInfoLog(vs2);
	GLuint fs2 = glCreateShader(GL_FRAGMENT_SHADER);
	glShaderSource(fs2, 1, &fragment_shader2, NULL);
	glCompileShader(fs2);
	PrintShaderInfoLog(fs2);
	//create the container that holds the shaders
	GLuint secondProgram = glCreateProgram();
	//attach the shaders
	glAttachShader(secondProgram, fs2);
	glAttachShader(secondProgram, vs2);
	//this inks the shaders together, its kinda like a compile
	glLinkProgram(secondProgram);
	PrintProgramInfoLog(secondProgram);
	*/

	Ortho = new Matrix4();
	Orthographic(0, g_gl_width, g_gl_height, 0, 0, -1, Ortho);

	//Quad * tester1 = new Quad();

	AnimatedSprite * tester = new AnimatedSprite("../resources/MegamanXSheet.xml", window);

	tester->SetAnimation("teleport", ONCE);
	

	while (!glfwWindowShouldClose(window)) {
		//_update_fps_counter(window);
		glEnable(GL_ALPHA_TEST);
		glAlphaFunc(GL_GREATER, 0.5);
		glEnable(GL_ALPHA);
		glEnable(GL_CULL_FACE);
		glCullFace(GL_BACK);
		glFrontFace(GL_CW);

		//wipe the drawing surface
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		//resize window
		glViewport (0, 0, g_gl_width, g_gl_height);
		
		tester->Update();
		//tester->Draw();
		//tester->Input();
		
		//update other events like input handling
		glfwPollEvents();
		//put the stuff we've been drawing into the display
		glfwSwapBuffers(window);
		
		resetDeltaTime();
		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE)) {
			glfwSetWindowShouldClose(window, 1);
		}
	}

	//close GL context and any other GLFW resources
	//delete Ortho;
	//delete tester;
	glfwTerminate();
	return 0;
}
开发者ID:BrendanHurt,项目名称:SimpleSpriteAnimations,代码行数:101,代码来源:OO_OpenGL.cpp


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