Ejemplo n.º 1
0
static void draw_shadow_volume_to_stencil(const BoardData3d* bd3d)
{
	/* First clear the stencil buffer */
	glClear(GL_STENCIL_BUFFER_BIT);

	/* Disable drawing to colour buffer, lighting and don't update depth buffer */
	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
	glDisable(GL_LIGHTING);
	glDepthMask(GL_FALSE);

	/* Z-pass approach */
	glStencilFunc(GL_ALWAYS, midStencilVal, (GLuint)~0);

	glCullFace(GL_FRONT);
	glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);

	DrawShadows(bd3d);

	glCullFace(GL_BACK);
	glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);

	DrawShadows(bd3d);

	/* Enable colour buffer, lighting and depth buffer */
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	glEnable(GL_LIGHTING);
	glDepthMask(GL_TRUE);
}
Ejemplo n.º 2
0
void World::DrawScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    camera_.Apply();
    
    glLoadIdentity();

    DrawReflections();
    DrawShadows();

    // ¹Ù´Ú ±×¸®±â
	glDisable(GL_STENCIL_TEST);
	glEnable(GL_BLEND);
	glDisable(GL_LIGHTING);
	glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	DrawFloor();
	glEnable(GL_LIGHTING);
	glDisable(GL_BLEND);

    // ½Ç¹° ½ºÇÁ¶óÀÌÆ® ±×¸®±â
    //glTranslatef(0.0f, 0.0f, 1.5f);
    DrawSprites();

    DrawOrigin();
    DrawCollisionInfo();
}
Ejemplo n.º 3
0
	void Vessel::DrawWorld()
	{
		if (myPlayer)
		{
			camera.position = myPlayer->pos;

			glm::mat4 viewMat(1.0f);
			camera.GenerateView(viewMat);

			glUseProgram(floorProgram.program);
			glActiveTexture(GL_TEXTURE0);
			glBindTexture(GL_TEXTURE_2D, floorProgram.texture);
			glUniformMatrix4fv(floorProgram.viewMat, 1, false, glm::value_ptr(viewMat));
			glUniform1i(floorProgram.textureLoc, 0);

			DrawFloor();

			glUseProgram(coloredVertexProgram.program);
			glm::vec4 color(0.5f, 0.5f, 0.5f, 1.0f);
			glUniform4fv(coloredVertexProgram.color, 1, glm::value_ptr(color));
			glUniformMatrix4fv(coloredVertexProgram.viewMat, 1, false, glm::value_ptr(viewMat));

			DrawWalls();

			glDisable(GL_CULL_FACE);
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			glUseProgram(shadowProgram.program);
			glUniform2fv(shadowProgram.playerPos, 1, glm::value_ptr(camera.position));
			glUniformMatrix4fv(shadowProgram.viewMat, 1, false, glm::value_ptr(viewMat));

			DrawShadows();

			glEnable(GL_CULL_FACE);
			glDisable(GL_BLEND);
		}
	}