Ejemplo n.º 1
0
void Player::render(int x, int y, SDL_Surface* screen) {
	if(shipState) {
		renderSea(x,y,screen);
	} else {
		renderLand(x,y,screen);
	}
}
Ejemplo n.º 2
0
void renderFn()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



	g_program.use();
	setPerspective();
	glActiveTexture(GL_TEXTURE9);
	glBindTexture(GL_TEXTURE_2D, omap2);

	g_program.setUniform("MaxTessLevel", max_tess);
	g_program.setUniform("ModelView", g_modelview);
	g_program.setUniform("Projection", g_projection);
	g_program.setUniform("MVP", g_projection * g_modelview);
	g_program.setUniform("NormalMatrix", 
			glm::inverseTranspose(mat3(g_modelview)));
	g_program.setUniform("MousePosition", mouse);
	
	g_program.setUniform("Time", elapsed);
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	renderLand();

	d_program.use();
	
	glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &plv); 
	glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &plf); 

	glActiveTexture(GL_TEXTURE9);
	glBindTexture(GL_TEXTURE_2D, plane);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	renderPlane(scene->mRootNode);

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

	d_program.setUniform("FrameTime", clockdiff);
	d_program.setUniform("Elapsed", elapsed);
	glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &pav); 
	glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &paf); 
	renderParticles();

	glEnable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);
}
Ejemplo n.º 3
0
void LandRenderer::render(const glm::mat4& projectionMat, const glm::mat4& viewMat)
{
    program_.use();

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D_ARRAY, terrainTexture_);

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D_ARRAY, blendTexture_);

    LandcellManager& landcellManager = Core::get().landcellManager();

    glm::vec3 cameraPosition = Core::get().camera().position();
    glUniform4f(program_.getUniform("cameraPosition"),
        static_cast<GLfloat>(cameraPosition.x),
        static_cast<GLfloat>(cameraPosition.y),
        static_cast<GLfloat>(cameraPosition.z), 1.0f);

    glm::vec4 viewLightPosition = viewMat * glm::vec4{lightPosition_.x, lightPosition_.y, lightPosition_.z, 1.0};
    glUniform3f(program_.getUniform("lightPosition"),
        static_cast<GLfloat>(viewLightPosition.x),
        static_cast<GLfloat>(viewLightPosition.y),
        static_cast<GLfloat>(viewLightPosition.z));

    for(auto& pair : landcellManager)
    {
        if(pair.first.isStructure())
        {
            continue;
        }

        int dx = pair.first.x() - landcellManager.center().x();
        int dy = pair.first.y() - landcellManager.center().y();

        glm::vec3 blockPosition{dx * 192.0, dy * 192.0, 0.0};

        const Land& land = static_cast<const Land&>(*pair.second);

        renderLand(land, projectionMat, viewMat, blockPosition);
    }
}