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


C++ Mat3::GetRightScale方法代码示例

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


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

示例1: DrawSprite

void SpriteBatch::DrawSprite(unsigned int VBO, unsigned int IBO, unsigned int programID, unsigned int textureID , unsigned int projectionLoc, float *projectionMat, Mat3 &matrix, float a_width, float a_height, int rotatePoint, Vec2 a_pivot)
{
	//make sure we are drawing the current width of the object multiplied against the scale
	//otherwise changing the scale of the Mat3 isn't taken into account when drawing.
	float width = a_width * matrix.GetRightScale();
	float height = a_height * matrix.GetUpScale();

	Vec2 tl = Vec2(0,				 0)		+ a_pivot;
	Vec2 tr = Vec2(width,			 0)		+ a_pivot;
	Vec2 br = Vec2(0,			height)		+ a_pivot;
	Vec2 bl = Vec2(width,		height)		+ a_pivot;

	//set the 4 vert points to correct rotation
	tl = matrix.TransformPoint(tl);
	tr = matrix.TransformPoint(tr);
	br = matrix.TransformPoint(br);
	bl = matrix.TransformPoint(bl);


	Vertex vertexData[4] = 
	{
		Vertex(tl.x, tl.y,   1.0f, 1.0f, 1.0f, 1.0f,		 0.0f, 0.0f),
		Vertex(tr.x, tr.y,   1.0f, 1.0f, 1.0f, 1.0f,		 1.0f, 0.0f),
		Vertex(bl.x, bl.y,   1.0f, 1.0f, 1.0f, 1.0f,		 1.0f, 1.0f),
		Vertex(br.x, br.y,   1.0f, 1.0f, 1.0f, 1.0f,		 0.0f, 1.0f)
	};
	

	GLubyte indices[6] = 
	{
		0, 1, 2,	// first triangle
		0, 2, 3		// second triangle
	};

	glUseProgram(programID);

	//std::cout << glGetError() << std::endl;

	// bind our texture to active texture 0...
	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, textureID);
	int textureLocation = glGetUniformLocation(programID, "myTextureSampler");
	glUniform1i(textureLocation , 1 );
	
	//send our orthographic projection info to the shader
	glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, projectionMat);
	

	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);
	
	//allocate space for vertices on the graphics card
	glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex)*4, vertexData, GL_STREAM_DRAW);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte)*6, indices, GL_STREAM_DRAW);

	//enable the vertex array state, since we're sending in an array of vertices
	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);
	glEnableVertexAttribArray(2);

	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); 
	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)16);
	glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)32);
	//glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(sizeof(float)*8));
		
	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, NULL);
//	glDrawArrays(GL_QUADS, 0, 4);
	

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	glBindTexture(GL_TEXTURE_2D, 0);
	
	glUseProgram(0);
	

	//debug collision circles by displaying them
	//note that collision code should match this method for positions collision circles to be correct
	
	//create a posiiton around the world 0 point for the centre of the object to transform from
//	Vec2 drawPos = Vec2((width / 2) + a_pivot.x, (height / 2) + a_pivot.y);
//
//	//transform the circle point to where it needs to go
//	drawPos = matrix.TransformPoint(drawPos);
//
//	float radius = getRadius(width, height, matrix.GetRightScale());
//	//draw the circle
//	DrawCircle(drawPos.x, drawPos.y,  radius, 12, projectionLoc, projectionMat);
	
//	
}
开发者ID:cazBlue,项目名称:AIEYearOneProjects,代码行数:91,代码来源:SpriteBatch.cpp


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