I'm attempting to implement the SFML API in my project which is about procedural generation of terrain using the Perlin noise algorithm. Using the excellent open source library 'libnoise', a heightmap file is generated in .bmp format.
I want to display this image to the user for their approval, before continuing with the program execution.
All the necessary headerfiles and libraries have been linked in the Eclipse project properties, I'm able to use the majority of the SFML functions with no issue, except the method LoadFromFile from the Image class.
However, no matter what I seem to do, LoadFromFile throws an unresolved method error.
Really tearing my hair out at this point. Would love some suggestions. Thanks!
Here's the code:
#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");
}
Aucun commentaire:
Enregistrer un commentaire