Я пытаюсь реализовать SFML API в своем проекте, который касается процедурной генерации местности с использованием алгоритма шума Перлина. С помощью превосходной библиотеки с открытым исходным кодом libnoise создается файл карты высот в формате .bmp.
Я хочу показать это изображение пользователю для его утверждения, прежде чем продолжить выполнение программы.
Все необходимые заголовочные файлы и библиотеки были связаны в свойствах проекта Eclipse, я могу без проблем использовать большинство функций SFML, кроме метода LoadFromFile из класса Image.
Однако независимо от того, что я делаю, LoadFromFile выдает неразрешенную ошибку метода.
На самом деле рву на себе волосы в этот момент. Хотелось бы несколько предложений. Спасибо!
Вот код:
#include <iostream>
#include <stdio.h>
#include <noise.h>
#include <noiseutils.h>
#include <zeolite.h>
#include <System.hpp>
#include <Graphics.hpp>
#include <Main.hpp>
#include <Image.hpp>
using namespace noise; // Sets reference for usage of the the noise class objects
using namespace std;
void main()
{
// CREATION OF THE NOISE MAP
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
sf::Image img;
module::Perlin Module; // Instantiates the Perlin class object to be used as the source for the noise generation.
utils::NoiseMap heightMap; // Creation of the 2D empty noise map.
utils::NoiseMapBuilderPlane heightMapBuilder; // Used to fill the noise map with the noise values taken from an (x,y) plane.
int size; // Holds the size of the output bitmap file.
int lx, ly, ux, uy; // Holds the coordinates of the bounding rectangle to pass to the heightMapBuilder function.
tag1:
cout<<"Enter the size of the heightmap to generate (must be a multiple of 2) : ";
cin>>size;
if( size%2 != 0 )
{
cout<<"Incorrect input! Please try again.\n";
goto tag1;
}
heightMapBuilder.SetSourceModule (Module); // Sets the Perlin module as the source for noise generation.
heightMapBuilder.SetDestNoiseMap (heightMap); // Sets the empty noise map as the target for the output of the planar noise map builder.
heightMapBuilder.SetDestSize(size,size); // Sets the size of the output noise map.
heightMapBuilder.SetBounds (2.0, 9.0, 6.0, 12.0); // Defines the vertices of the bounding rectangle from which the noise values are produced. lower x, upper x, lower y, upper y.
heightMapBuilder.Build (); // Builds the noise map.
// RENDERING THE TERRAIN HEIGHT MAP
utils::RendererImage renderer;
utils::Image image;
renderer.SetSourceNoiseMap(heightMap);
renderer.SetDestImage(image);
renderer.Render();
// WRITING THE HEIGHT MAP IMAGE TO AN OUTPUT FILE
utils::WriterBMP writer;
writer.SetSourceImage(image);
writer.SetDestFilename("output.bmp");
writer.WriteDestFile ();
system("pause");
img.LoadFromFile("output.bmp");
}