コード例 #1
0
//-----------------------------------------------------------------------------------
void Renderer::DrawPoint(const Vector3& point, const RGBA& color /*= RGBA::WHITE*/, float pointSize /*= 1.0f*/)
{
	glPointSize(pointSize);
	Vertex_PCT vertex;
	vertex.pos = point;
	vertex.color = color;
	DrawVertexArray(&vertex, 1, DrawMode::POINTS);
}
コード例 #2
0
//-----------------------------------------------------------------------------------
void Renderer::DrawLine(const Vector3& start, const Vector3& end, const RGBA& color /*= RGBA::WHITE*/, float lineThickness /*= 1.0f*/)
{
	glLineWidth(lineThickness);
	Vertex_PCT vertexes[2];
	vertexes[0].pos = start;
	vertexes[1].pos = end;
	vertexes[0].color = color;
	vertexes[1].color = color;
	DrawVertexArray(vertexes, 2, DrawMode::LINES);
}
コード例 #3
0
ファイル: Renderer.cpp プロジェクト: jimmychenn/Games
void Renderer::DrawSprite(TexturePtr texture, const Matrix4& worldTransform)
{
	mSpriteShader->SetActive();
	mSpriteShader->BindWorldTransform(worldTransform);
	mSpriteShader->UploadUniformsToGPU();

	mSpriteShader->BindTexture("uTexture", texture, 0);

	DrawVertexArray(mSpriteVerts);
}
コード例 #4
0
ファイル: Renderer.cpp プロジェクト: caioteixeira/GameEngines
void Renderer::DrawSprite(TexturePtr texture, const Matrix4& worldTransform)
{
	mSpriteShader->SetActive();
	mSpriteShader->GetPerObjectConstants().worldMatrix = worldTransform;
	mSpriteShader->UploadPerObjectConstants();

	mSpriteShader->BindTexture(texture, 0);

	DrawVertexArray(mSpriteVerts);
}
コード例 #5
0
ファイル: Renderer.cpp プロジェクト: caioteixeira/GameEngines
void Renderer::DrawSkeletalMesh(VertexArrayPtr vertArray, TexturePtr texture, const Matrix4& worldTransform, const struct MatrixPalette& palette)
{
	auto & shader = mMeshShaders[EMS_Skinned];

	shader->SetActive();
	shader->GetPerObjectConstants().worldMatrix = worldTransform;
	shader->UploadPerObjectConstants();
	shader->BindTexture(texture, 0);
	shader->UploadMatrixPalette(palette);

	DrawVertexArray(vertArray);
}
コード例 #6
0
ファイル: Renderer.cpp プロジェクト: caioteixeira/GameEngines
void Renderer::DrawMesh(VertexArrayPtr vertArray, TexturePtr texture, const Matrix4& worldTransform, EMeshShader type /*= EMS_Basic*/)
{
	auto & shader = mMeshShaders[type];
	
	shader->SetActive();
	shader->GetPerObjectConstants().worldMatrix = worldTransform;
	shader->UploadPerObjectConstants();
	shader->BindTexture(texture, 0);

	DrawVertexArray(vertArray);
	
}
コード例 #7
0
ファイル: Renderer.cpp プロジェクト: jimmychenn/Games
void Renderer::DrawBasicMesh(VertexArrayPtr vertArray, TexturePtr texture, const Matrix4 &worldTransform)
{
    // We want to draw with the basic mesh shader
    mBasicMeshShader->SetActive();
    // Save the value of the world transform we want to use
    mBasicMeshShader->BindWorldTransform(worldTransform);
    // Send the shader data (matrices, in this case) to the GPU
    mBasicMeshShader->UploadUniformsToGPU();
    // We need to specify which texture is active
    mBasicMeshShader->BindTexture("uTexture", texture, 0);
    // Now draw the triangles!
    DrawVertexArray(vertArray);
}
コード例 #8
0
//-----------------------------------------------------------------------------------
void Renderer::DrawAABB(const AABB2& bounds, const RGBA& color)
{
	const int NUM_VERTS = 4;
	SetColor(color);
	Vertex_PCT vertexes[NUM_VERTS];
	vertexes[0].color = color;
	vertexes[1].color = color;
	vertexes[2].color = color;
	vertexes[3].color = color;
	vertexes[0].pos = Vector3(bounds.mins.x, bounds.mins.y, 0.0f);
	vertexes[1].pos = Vector3(bounds.maxs.x, bounds.mins.y, 0.0f);
	vertexes[2].pos = Vector3(bounds.maxs.x, bounds.maxs.y, 0.0f);
	vertexes[3].pos = Vector3(bounds.mins.x, bounds.maxs.y, 0.0f);
	DrawVertexArray(vertexes, NUM_VERTS, DrawMode::QUADS);
}
コード例 #9
0
//-----------------------------------------------------------------------------------
void Renderer::DrawAABB(const AABB3& bounds, const RGBA& color)
{
	const int NUM_VERTS = 24;
	SetColor(color);
	Vertex_PCT vertexes[NUM_VERTS];
	for (int i = 0; i < NUM_VERTS; i++)
	{
		vertexes[i].color = color;
	}
	//Bottom
	vertexes[0].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[1].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);
	vertexes[2].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);
	vertexes[3].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);

	//Top
	vertexes[4].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.maxs.z);
	vertexes[5].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.maxs.z);
	vertexes[6].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[7].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.maxs.z);

	//North
	vertexes[8].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);
	vertexes[9].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[10].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[11].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);

	//South
	vertexes[12].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[13].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);
	vertexes[14].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.maxs.z);
	vertexes[15].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.maxs.z);

	//East
	vertexes[16].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);
	vertexes[17].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);
	vertexes[18].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[19].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.maxs.z);

	//West
	vertexes[20].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[21].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.maxs.z);
	vertexes[22].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[23].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);

	DrawVertexArray(vertexes, NUM_VERTS, DrawMode::QUADS);
}
コード例 #10
0
//-----------------------------------------------------------------------------------
void Renderer::DrawPolygon(const Vector2& center, float radius, int numSides, float radianOffset, const RGBA& color)
{
	Vertex_PCT* vertexes = new Vertex_PCT[numSides];
	const float radiansTotal = 2.0f * MathUtils::PI;
	const float radiansPerSide = radiansTotal / numSides;
	int index = 0;

	for (float radians = 0.0f; radians < radiansTotal; radians += radiansPerSide)
	{
		float adjustedRadians = radians + radianOffset;
		float x = center.x + (radius * cos(adjustedRadians));
		float y = center.y + (radius * sin(adjustedRadians));

		vertexes[index].color = color;
		vertexes[index].pos = Vector2(x, y);
	}
	DrawVertexArray(vertexes, numSides, DrawMode::POLYGON);
}
コード例 #11
0
void RenderInputScene::Draw(GraphicsState & glstate, const std::vector <Drawable*> & drawlist, bool preculled)
{
	for (std::vector <Drawable*>::const_iterator ptr = drawlist.begin(); ptr != drawlist.end(); ++ptr)
	{
		const Drawable & d = **ptr;
		if (preculled || !FrustumCull(d))
		{
			SetFlags(d, glstate);

			SetTextures(d, glstate);

			SetTransform(d, glstate);

			if (d.GetDrawList())
			{
				glCallList(d.GetDrawList());
			}
			else if (d.GetVertArray())
			{
				DrawVertexArray(*d.GetVertArray(), d.GetLineSize());
			}
		}
	}
}
コード例 #12
0
//-----------------------------------------------------------------------------------
void Renderer::DrawTexturedAABB3(const AABB3& bounds, const RGBA& color, const Vector2& texCoordMins, const Vector2& texCoordMaxs, Texture* texture)
{
	if (texture == nullptr)
	{
		texture = m_defaultTexture;
	}
	const int NUM_VERTS = 20;
	SetColor(color);
	Vertex_PCT vertexes[NUM_VERTS];
	for (int i = 0; i < NUM_VERTS; i++)
	{
		vertexes[i].color = color;
	}
	//Bottom
	vertexes[0].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[1].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);
	vertexes[2].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);
	vertexes[3].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);
	vertexes[0].texCoords = texCoordMins;
	vertexes[1].texCoords = Vector2(texCoordMaxs.x, texCoordMins.y);
	vertexes[2].texCoords = texCoordMaxs;
	vertexes[3].texCoords = Vector2(texCoordMins.x, texCoordMaxs.y);

	//West
	vertexes[4].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[5].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.maxs.z);
	vertexes[6].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[7].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);
	vertexes[4].texCoords = texCoordMins;
	vertexes[5].texCoords = Vector2(texCoordMaxs.x, texCoordMins.y);
	vertexes[6].texCoords = texCoordMaxs;
	vertexes[7].texCoords = Vector2(texCoordMins.x, texCoordMaxs.y);

	//North
	vertexes[8].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.mins.z);
	vertexes[9].pos = Vector3(bounds.mins.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[10].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[11].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);
	vertexes[8].texCoords = texCoordMins;
	vertexes[9].texCoords = Vector2(texCoordMaxs.x, texCoordMins.y);
	vertexes[10].texCoords = texCoordMaxs;
	vertexes[11].texCoords = Vector2(texCoordMins.x, texCoordMaxs.y);

	//East
	vertexes[12].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);
	vertexes[13].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.mins.z);
	vertexes[14].pos = Vector3(bounds.maxs.x, bounds.maxs.y, bounds.maxs.z);
	vertexes[15].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.maxs.z);
	vertexes[12].texCoords = texCoordMins;
	vertexes[13].texCoords = Vector2(texCoordMaxs.x, texCoordMins.y);
	vertexes[14].texCoords = texCoordMaxs;
	vertexes[15].texCoords = Vector2(texCoordMins.x, texCoordMaxs.y);

	//South
	vertexes[16].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.mins.z);
	vertexes[17].pos = Vector3(bounds.maxs.x, bounds.mins.y, bounds.maxs.z);
	vertexes[18].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.maxs.z);
	vertexes[19].pos = Vector3(bounds.mins.x, bounds.mins.y, bounds.mins.z);
	vertexes[16].texCoords = texCoordMins;
	vertexes[17].texCoords = Vector2(texCoordMaxs.x, texCoordMins.y);
	vertexes[18].texCoords = texCoordMaxs;
	vertexes[19].texCoords = Vector2(texCoordMins.x, texCoordMaxs.y);

	DrawVertexArray(vertexes, NUM_VERTS, DrawMode::QUADS);
}