Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Binaries
build/

# Generated cmake files
CMakeFiles/
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# http://www.linux-magazin.de/Heft-Abo/Ausgaben/2007/02/Mal-ausspannen

cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.0)

SET ( LIBNOISE_VERSION "1.0.0-cmake" )

OPTION(BUILD_LIBNOISE_DOCUMENTATION "Create doxygen documentation for developers" OFF)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(noiseutils)
ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(doc)

#ADD_SUBDIRECTORY(samples)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
> My personal fork was to use this alongside a native plugin for the Unity game engine. It is still licensed under the LGPL as before. Primarily, I made some modifications to allow compiling to a Windows x64 DLL.

libnoise
========

This is a fork of libnoise which includes noiseutils in the building and installing process.
It also contains FindLibNoise.cmake

> This is a fork of libnoise which changes the build system from static Makefiles to cmake.

A portable, open-source, coherent noise-generating library for C++
Expand Down Expand Up @@ -47,6 +52,10 @@ see examples for details but in general:
1. you need to supply the library `-lnoise` to the linker
2. the includes to the compile with `-I /usr/include/noise`

OR

Use provided FindLibNoise.cmake

A comment on performance
------------------------

Expand Down
69 changes: 69 additions & 0 deletions cmake/Modules/FindLibNoise.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Locate libnoise.
# This module defines
# LIBNOISE_LIBRARIES
# LIBNOISE_FOUND, if false, do not try to link to libnoise
# LIBNOISE_INCLUDE_DIR, where to find the headers

FIND_PATH(LIBNOISE_INCLUDE_DIR noise.h
$ENV{LIBNOISE_DIR}
NO_DEFAULT_PATH
PATH_SUFFIXES include
)

FIND_PATH(LIBNOISE_INCLUDE_DIR "noise.h"
PATHS
${CMAKE_SOURCE_DIR}/include
~/Library/Frameworks/noise/Headers
/Library/Frameworks/noise/Headers
/usr/local/include/noise
/usr/local/include/noise
/usr/local/include
/usr/include/noise
/usr/include/noise
/usr/include
/sw/include/noise
/sw/include/noise
/sw/include # Fink
/opt/local/include/noise
/opt/local/include/noise
/opt/local/include # DarwinPorts
/opt/csw/include/noise
/opt/csw/include/noise
/opt/csw/include # Blastwave
/opt/include/noise
/opt/include/noise
/opt/include
PATH_SUFFIXES noise
)

FIND_LIBRARY(LIBNOISE_LIBRARIES
NAMES libnoise noise libnoiseutils noiseutils
PATHS
$ENV{LIBNOISE_DIR}
NO_DEFAULT_PATH
PATH_SUFFIXES lib64 lib so
)

FIND_LIBRARY(LIBNOISE_LIBRARIES
NAMES libnoise noise libnoiseutils noiseutils
PATHS
${CMAKE_SOURCE_DIR}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/usr/freeware
PATH_SUFFIXES lib64 lib so
)

message("LIBNOISE_INCLUDE_DIR: ${LIBNOISE_INCLUDE_DIR}")

SET(LIBNOISE_FOUND "NO")
IF(LIBNOISE_LIBRARY AND LIBNOISE_INCLUDE_DIR)
SET(LIBNOISE_FOUND "YES")
ENDIF(LIBNOISE_LIBRARY AND LIBNOISE_INCLUDE_DIR)

6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET(PROJECT_NAME examples)

add_executable(complexplanet complexplanet.cpp)
ADD_DEFINITIONS( "-I${PROJECT_SOURCE_DIR}/src" )
ADD_DEFINITIONS( "-I${PROJECT_SOURCE_DIR}/noiseutils" )
target_link_libraries(complexplanet noiseutils-static noise-static)
26 changes: 26 additions & 0 deletions noiseutils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SET(PROJECT_NAME libnoiseutils)

add_library(noiseutils SHARED noiseutils.cpp )
add_library(noiseutils-static STATIC noiseutils.cpp )

SET_TARGET_PROPERTIES( noiseutils PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION} )
SET_TARGET_PROPERTIES( noiseutils-static PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION} )

target_link_libraries(noiseutils noise)
target_link_libraries(noiseutils-static noise-static)

# I would like to see more projects using these defaults
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
ADD_DEFINITIONS( "-Wall -ansi -pedantic -O3" )
endif()

# Where to look for noise headers
ADD_DEFINITIONS( "-I${PROJECT_SOURCE_DIR}/src" )

# install include files into /usr/include
INSTALL( FILES "${PROJECT_SOURCE_DIR}/noiseutils/noiseutils.h" DESTINATION
"${CMAKE_INSTALL_PREFIX}/include/noise" )

# install libraries into /lib
INSTALL( TARGETS noiseutils DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
INSTALL( TARGETS noiseutils-static DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
4 changes: 2 additions & 2 deletions noiseutils/noiseutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ RendererImage::RendererImage ():
m_recalcLightValues (true)
{
BuildGrayscaleGradient ();
};
}

void RendererImage::AddGradientPoint (double gradientPos,
const Color& gradientColor)
Expand Down Expand Up @@ -1211,7 +1211,7 @@ RendererNormalMap::RendererNormalMap ():
m_pDestImage (NULL),
m_pSourceNoiseMap (NULL)
{
};
}

Color RendererNormalMap::CalcNormalColor (double nc, double nr, double nu,
double bumpHeight) const
Expand Down
6 changes: 3 additions & 3 deletions noiseutils/noiseutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace noise
/// @param a Value of the alpha (transparency) channel.
Color (noise::uint8 r, noise::uint8 g, noise::uint8 b,
noise::uint8 a):
red (r), green (g), blue (b), alpha (a)
alpha (a), blue (b), green (g), red (r)
{
}

Expand Down Expand Up @@ -1212,8 +1212,8 @@ namespace noise

/// Constructor.
WriterTER ():
m_pSourceNoiseMap (NULL),
m_metersPerPoint (DEFAULT_METERS_PER_POINT)
m_metersPerPoint (DEFAULT_METERS_PER_POINT),
m_pSourceNoiseMap (NULL)
{
}

Expand Down
14 changes: 11 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,29 @@ set(libSrcs ${libSrcs}
module/translatepoint.cpp
module/turbulence.cpp
module/voronoi.cpp

# win32/dllmain.cpp
)

IF (WIN32)
add_library( noise SHARED ${libSrcs} win32/dllmain.cpp)
ELSE()
add_library( noise SHARED ${libSrcs} )
ENDIF()

add_library( noise-static STATIC ${libSrcs} )

# this value is set in the root CMakeLists.txt
SET_TARGET_PROPERTIES( noise PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION} )
SET_TARGET_PROPERTIES( noise-static PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION} )

target_compile_definitions( noise PRIVATE NOISE_BUILD_DLL)
target_compile_definitions( noise-static PUBLIC NOISE_STATIC)

SET_TARGET_PROPERTIES( noise-static PROPERTIES OUTPUT_NAME "noise" )

# i would like to see more projects using these defaults
ADD_DEFINITIONS( "-Wall -ansi -pedantic -O3" )
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
ADD_DEFINITIONS( "-Wall -ansi -pedantic -O3" )
endif()

# install include files into /usr/include
INSTALL( DIRECTORY "${PROJECT_SOURCE_DIR}/src/noise" DESTINATION
Expand Down
2 changes: 1 addition & 1 deletion src/noise/model/cylinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace noise
///
/// This cylinder has a radius of 1.0 unit and has infinite height. It is
/// oriented along the @a y axis. Its center is located at the origin.
class Cylinder
class NOISE_EXPORT Cylinder
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/model/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace noise
/// To generate an output value, pass an input value between 0.0 and 1.0
/// to the GetValue() method. 0.0 represents the start position of the
/// line segment and 1.0 represents the end position of the line segment.
class Line
class NOISE_EXPORT Line
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/model/plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace noise
/// - terrain height maps for local areas
///
/// This plane extends infinitely in both directions.
class Plane
class NOISE_EXPORT Plane
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/model/sphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace noise
///
/// This sphere has a radius of 1.0 unit and its center is located at
/// the origin.
class Sphere
class NOISE_EXPORT Sphere
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/abs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace noise
/// @image html moduleabs.png
///
/// This noise module requires one source module.
class Abs: public Module
class NOISE_EXPORT Abs: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/add.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace noise
/// @image html moduleadd.png
///
/// This noise module requires two source modules.
class Add: public Module
class NOISE_EXPORT Add: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/billow.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace noise
/// this noise module modifies each octave with an absolute-value
/// function. See the documentation of noise::module::Perlin for more
/// information.
class Billow: public Module
class NOISE_EXPORT Billow : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/blend.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace noise
/// operation.
///
/// This noise module requires three source modules.
class Blend: public Module
class NOISE_EXPORT Blend: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace noise
/// noise module in which it is included.
///
/// This noise module requires one source module.
class Cache: public Module
class NOISE_EXPORT Cache: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/checkerboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace noise
/// for debugging purposes.
///
/// This noise module does not require any source modules.
class Checkerboard: public Module
class NOISE_EXPORT Checkerboard: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/clamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace noise
/// SetBounds() method.
///
/// This noise module requires one source module.
class Clamp: public Module
class NOISE_EXPORT Clamp : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace noise
/// source module for other noise modules.
///
/// This noise module does not require any source modules.
class Const: public Module
class NOISE_EXPORT Const : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace noise
/// added to the curve.
///
/// This noise module requires one source module.
class Curve: public Module
class NOISE_EXPORT Curve : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/cylinders.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace noise
/// turbulence, is useful for generating wood-like textures.
///
/// This noise module does not require any source modules.
class Cylinders: public Module
class NOISE_EXPORT Cylinders : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/displace.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace noise
/// that perform the displacement operation.
///
/// This noise module requires four source modules.
class Displace: public Module
class NOISE_EXPORT Displace: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/exponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace noise
/// rescales that value back to the original range.
///
/// This noise module requires one source module.
class Exponent: public Module
class NOISE_EXPORT Exponent : public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/invert.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace noise
/// @image html moduleinvert.png
///
/// This noise module requires one source module.
class Invert: public Module
class NOISE_EXPORT Invert: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/max.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace noise
/// @image html modulemax.png
///
/// This noise module requires two source modules.
class Max: public Module
class NOISE_EXPORT Max: public Module
{

public:
Expand Down
2 changes: 1 addition & 1 deletion src/noise/module/min.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace noise
/// @image html modulemin.png
///
/// This noise module requires two source modules.
class Min: public Module
class NOISE_EXPORT Min: public Module
{

public:
Expand Down
Loading