Skip to content

Commit 998ae3f

Browse files
committed
Update FIndpanda3d.
- Change to target based. - Update interfaces of render_pipeline target.
1 parent e635e63 commit 998ae3f

File tree

22 files changed

+221
-249
lines changed

22 files changed

+221
-249
lines changed

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,26 @@ target_include_directories(${PROJECT_NAME}
7474
$<INSTALL_INTERFACE:share>
7575

7676
PRIVATE "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src"
77-
${Panda3d_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${YAML_CPP_INCLUDE_DIR}
77+
${FREETYPE_INCLUDE_DIRS} ${YAML_CPP_INCLUDE_DIR}
7878
)
7979

8080
target_link_libraries(${PROJECT_NAME}
81+
PUBLIC Boost::boost panda3d::panda3d
82+
8183
PRIVATE $<$<NOT:$<BOOL:Boost_USE_STATIC_LIBS>>:Boost::dynamic_linking>
8284
Boost::filesystem Boost::system
83-
${FREETYPE_LIBRARIES} ${Panda3d_LIBRARIES} yaml-cpp spdlog::spdlog
85+
${FREETYPE_LIBRARIES} yaml-cpp spdlog::spdlog
8486
)
8587

8688
set_target_properties(${PROJECT_NAME} PROPERTIES DEFINE_SYMBOL "RPCPP_BUILD")
8789
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
8890

91+
# configure package
8992
set(PACKAGE_VERSION_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake")
9093
set(PACKAGE_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake")
9194
set(TARGET_EXPORT_NAME "${PROJECT_NAME}-targets")
9295
set(PACKAGE_CMAKE_INSTALL_DIR "lib/${PROJECT_NAME}/cmake")
9396

94-
# configure package
9597
include(CMakePackageConfigHelpers)
9698
write_basic_package_version_file(${PACKAGE_VERSION_CONFIG_FILE}
9799
VERSION ${PROJECT_VERSION}
@@ -108,10 +110,13 @@ install(TARGETS ${PROJECT_NAME}
108110
EXPORT ${TARGET_EXPORT_NAME}
109111
RUNTIME DESTINATION "bin"
110112
LIBRARY DESTINATION "lib"
111-
ARCHIVE DESTINATION "lib")
113+
ARCHIVE DESTINATION "lib"
114+
)
115+
112116
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pdb"
113117
DESTINATION "bin"
114-
CONFIGURATIONS Debug RelWithDebInfo)
118+
CONFIGURATIONS Debug RelWithDebInfo
119+
)
115120

116121
install(DIRECTORY "${PROJECT_SOURCE_DIR}/${PROJECT_NAME}" DESTINATION "include/")
117122
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/config/" DESTINATION "etc/${PROJECT_NAME}/")

cmake/FindPackages.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ find_package(Boost 1.62.0 REQUIRED COMPONENTS filesystem system)
1313

1414
# find panda3d
1515
set(PANDA3D_ROOT "" CACHE PATH "Hint for finding panda3d root directory")
16-
find_package(Panda3d REQUIRED COMPONENTS libp3framework libpanda libpandaexpress libp3dtool libp3dtoolconfig libp3direct libp3interrogatedb)
16+
#find_package(panda3d REQUIRED COMPONENTS libp3framework libpanda libpandaexpress libp3dtool libp3dtoolconfig libp3direct libp3interrogatedb)
17+
find_package(panda3d REQUIRED)
1718

1819
# find doxygen
1920
option(RPCPP_BUILD_DOCUMENTS "Build doxygen documents" OFF)

cmake/FindPanda3d.cmake

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#.rst:
2-
# FindPanda3d
2+
# Findpanda3d
33
# --------------
44
#
5-
# FindPanda3d.cmake
5+
# Findpanda3d.cmake
66
#
77
# Author: Younguk Kim (bluekyu)
88
# Date : 2016-08-02
@@ -12,69 +12,83 @@
1212
#
1313
# This module defines the following variables::
1414
#
15-
# Panda3d_INCLUDE_DIRS - Include directories for Panda3D
16-
# Panda3d_LIBRARIES - Libraries to link against Panda3D
17-
# Panda3d_FOUND - True if Panda3D has been found and can be used
18-
# Panda3d_VERSION - Library version for Panda3D
19-
# Panda3d_VERSION_STRING - Library version for Panda3D
20-
# Panda3d_VERSION_MAJOR - Library major version for Panda3D
21-
# Panda3d_VERSION_MINOR - Library minor version for Panda3D
22-
# Panda3d_VERSION_PATCH - Library patch version for Panda3D
15+
# panda3d_FOUND - True if panda3d has been found and can be used
16+
# panda3d_VERSION - Library version for panda3d
17+
# panda3d_VERSION_STRING - Library version for panda3d
18+
# panda3d_VERSION_MAJOR - Library major version for panda3d
19+
# panda3d_VERSION_MINOR - Library minor version for panda3d
20+
# panda3d_VERSION_PATCH - Library patch version for panda3d
2321
#
24-
# and the following imported targets::
22+
# The following `IMPORTED` targets are also defined::
2523
#
26-
# Panda3d::Panda3d - The Panda3D library
24+
# panda3d::panda3d - Target for the Panda3D necessary libraries.
25+
# panda3d::<C> - Target for specific Panda3D component.
2726

2827
cmake_minimum_required(VERSION 3.2)
2928

30-
find_path(Panda3d_INCLUDE_DIR
29+
find_path(panda3d_INCLUDE_DIR
3130
NAMES "pandaFramework.h"
3231
HINTS "${PANDA3D_ROOT}/include"
3332
)
3433

35-
foreach(COMPONENT_NAME ${Panda3d_FIND_COMPONENTS})
36-
find_library(PANDA3D_${COMPONENT_NAME}_LIBRARY
37-
NAMES ${COMPONENT_NAME}
34+
set(panda3d_DEFAULT_COMPONENTS p3framework panda pandaexpress p3dtool p3dtoolconfig p3direct p3interrogatedb)
35+
36+
list(APPEND panda3d_FIND_COMPONENTS ${panda3d_DEFAULT_COMPONENTS})
37+
list(REMOVE_DUPLICATES panda3d_FIND_COMPONENTS)
38+
39+
set(panda3d_NON_DEFAULT_COMPONENTS ${panda3d_FIND_COMPONENTS})
40+
list(REMOVE_ITEM panda3d_NON_DEFAULT_COMPONENTS ${panda3d_DEFAULT_COMPONENTS})
41+
42+
foreach(COMPONENT_NAME ${panda3d_FIND_COMPONENTS})
43+
find_library(panda3d_${COMPONENT_NAME}_LIBRARY
44+
NAMES lib${COMPONENT_NAME}
3845
HINTS "${PANDA3D_ROOT}/lib"
3946
)
40-
list(APPEND Panda3d_LIBRARY ${PANDA3D_${COMPONENT_NAME}_LIBRARY})
47+
list(APPEND panda3d_LIBRARY ${panda3d_${COMPONENT_NAME}_LIBRARY})
4148
endforeach()
42-
#find_library(Panda3d_LIBRARY_DEBUG
43-
# NAMES ${Panda3d_FIND_COMPONENTS}
44-
# HINTS ${PANDA3D_LIBRARYDIR}
49+
#find_library(panda3d_LIBRARY_DEBUG
50+
# NAMES ${panda3d_FIND_COMPONENTS}
51+
# HINTS ${panda3d_LIBRARYDIR}
4552
# PATH_SUFFIXES lib64 lib
4653
#)
4754

48-
# Set Panda3d_FOUND
55+
# Set panda3d_FOUND
4956
include(FindPackageHandleStandardArgs)
50-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Panda3d
51-
FOUND_VAR Panda3d_FOUND
52-
REQUIRED_VARS Panda3d_LIBRARY Panda3d_INCLUDE_DIR
53-
VERSION_VAR Panda3d_VERSION
57+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(panda3d
58+
FOUND_VAR panda3d_FOUND
59+
REQUIRED_VARS panda3d_LIBRARY panda3d_INCLUDE_DIR
60+
VERSION_VAR panda3d_VERSION
5461
)
5562

56-
if(Panda3d_FOUND)
57-
message(STATUS "Found the following Panda3D libraries:")
58-
foreach(COMPONENT ${Panda3d_FIND_COMPONENTS})
63+
if(panda3d_FOUND)
64+
message(STATUS "Found the following panda3d libraries:")
65+
foreach(COMPONENT ${panda3d_FIND_COMPONENTS})
5966
message (STATUS " ${COMPONENT}")
6067
endforeach()
6168

62-
# found both
63-
if(Panda3d_LIBRARY AND Panda3d_LIBRARY_DEBUG)
64-
set(Panda3d_LIBRARIES
65-
optimized ${Panda3d_LIBRARY}
66-
debug ${Panda3d_LIBRARY_DEBUG})
67-
# found only release
68-
elseif(Panda3d_LIBRARY)
69-
set(Panda3d_LIBRARIES ${Panda3d_LIBRARY})
70-
# found only debug
71-
elseif(Panda3d_LIBRARY_DEBUG)
72-
set(Panda3d_LIBRARIES ${Panda3d_LIBRARY_DEBUG})
69+
# create targets of found components
70+
foreach(COMPONENT_NAME ${panda3d_FIND_COMPONENTS})
71+
if(NOT TARGET panda3d::${COMPONENT_NAME})
72+
add_library(panda3d::${COMPONENT_NAME} UNKNOWN IMPORTED)
73+
set_target_properties(panda3d::${COMPONENT_NAME} PROPERTIES
74+
INTERFACE_INCLUDE_DIRECTORIES "${panda3d_INCLUDE_DIR}"
75+
IMPORTED_LOCATION "${panda3d_${COMPONENT_NAME}_LIBRARY}"
76+
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
77+
)
78+
endif()
79+
endforeach()
80+
81+
# create default target
82+
if(NOT TARGET panda3d::panda3d)
83+
add_library(panda3d::panda3d INTERFACE IMPORTED)
84+
85+
foreach(COMPONENT_NAME ${panda3d_DEFAULT_COMPONENTS})
86+
list(APPEND _panda3d_DEFAULT_TARGET_DEPENDENCIES panda3d::${COMPONENT_NAME})
87+
endforeach()
88+
89+
set_target_properties(panda3d::panda3d PROPERTIES
90+
INTERFACE_INCLUDE_DIRECTORIES "${panda3d_INCLUDE_DIR}"
91+
INTERFACE_LINK_LIBRARIES "${_panda3d_DEFAULT_TARGET_DEPENDENCIES}"
92+
)
7393
endif()
74-
set(Panda3d_INCLUDE_DIRS ${Panda3d_INCLUDE_DIR})
7594
endif()
76-
77-
mark_as_advanced(
78-
Panda3d_INCLUDE_DIRS
79-
Panda3d_LIBRARIES
80-
)
Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#pragma once
22

3-
#include <render_pipeline/rpcore/rpobject.h>
3+
#include <memory>
4+
#include <vector>
45

5-
#include <render_pipeline/rpcore/image.h>
6+
#include <render_pipeline/rpcore/rpobject.h>
67

78
namespace rpcore {
89

910
class RenderStage;
1011
class RenderTarget;
12+
class Image;
1113

1214
/**
1315
* Util class for filtering cubemaps, provides funcionality to generate
@@ -16,87 +18,87 @@ class RenderTarget;
1618
class RPCPP_DECL CubemapFilter: public RPObject
1719
{
1820
public:
19-
// Fixed size for the diffuse cubemap, since it does not contain much detail
20-
static const int DIFFUSE_CUBEMAP_SIZE = 10;
21-
static const int PREFILTER_CUBEMAP_SIZE = 32;
21+
// Fixed size for the diffuse cubemap, since it does not contain much detail
22+
static const int DIFFUSE_CUBEMAP_SIZE = 10;
23+
static const int PREFILTER_CUBEMAP_SIZE = 32;
2224

23-
CubemapFilter(RenderStage* stage, const std::string& name="Cubemap", int size=128);
25+
CubemapFilter(RenderStage* stage, const std::string& name="Cubemap", int size=128);
2426

25-
/**
26-
* Returns the generated specular cubemap. The specular cubemap is
27-
* mipmapped and provides the specular IBL components of the input cubemap.
28-
*/
27+
/**
28+
* Returns the generated specular cubemap. The specular cubemap is
29+
* mipmapped and provides the specular IBL components of the input cubemap.
30+
*/
2931
std::shared_ptr<Image> get_specular_cubemap(void) const;
3032

31-
/**
32-
* Returns the generated diffuse cubemap. The diffuse cubemap has no
33-
* mipmaps and contains the filtered diffuse component of the input cubemap.
34-
*/
33+
/**
34+
* Returns the generated diffuse cubemap. The diffuse cubemap has no
35+
* mipmaps and contains the filtered diffuse component of the input cubemap.
36+
*/
3537
std::shared_ptr<Image> get_diffuse_cubemap(void) const;
3638

37-
/** Returns the target where the caller should write the initial cubemap data to. */
39+
/** Returns the target where the caller should write the initial cubemap data to. */
3840
std::shared_ptr<Image> get_target_cubemap(void) const;
3941

40-
/**
41-
* Returns the size of the created cubemap, previously passed to the
42-
* constructor of the filter.
43-
*/
44-
int get_size(void) const;
42+
/**
43+
* Returns the size of the created cubemap, previously passed to the
44+
* constructor of the filter.
45+
*/
46+
int get_size(void) const;
4547

46-
/**
47-
* Creates the filter. The input cubemap should be mipmapped, and will
48-
* get reused for the specular cubemap.
49-
*/
50-
void create(void);
48+
/**
49+
* Creates the filter. The input cubemap should be mipmapped, and will
50+
* get reused for the specular cubemap.
51+
*/
52+
void create(void);
5153

52-
/** Sets all required shaders on the filter. */
53-
void reload_shaders(void);
54+
/** Sets all required shaders on the filter. */
55+
void reload_shaders(void);
5456

5557
private:
56-
/** Internal method to create the cubemap storage. */
57-
void make_maps(void);
58+
/** Internal method to create the cubemap storage. */
59+
void make_maps(void);
5860

59-
/** Internal method to create the specular mip chain. */
60-
void make_specular_targets();
61+
/** Internal method to create the specular mip chain. */
62+
void make_specular_targets();
6163

62-
/** Internal method to create the diffuse cubemap. */
63-
void make_diffuse_target();
64+
/** Internal method to create the diffuse cubemap. */
65+
void make_diffuse_target();
6466

65-
RenderStage* _stage;
66-
const std::string _name;
67-
int _size;
67+
RenderStage* _stage;
68+
const std::string _name;
69+
int _size;
6870

69-
std::shared_ptr<Image> _prefilter_map;
70-
std::shared_ptr<Image> _diffuse_map;
71-
std::shared_ptr<Image> _spec_pref_map;
72-
std::shared_ptr<Image> _specular_map;
71+
std::shared_ptr<Image> _prefilter_map;
72+
std::shared_ptr<Image> _diffuse_map;
73+
std::shared_ptr<Image> _spec_pref_map;
74+
std::shared_ptr<Image> _specular_map;
7375

74-
std::vector<std::shared_ptr<RenderTarget>> _targets_spec;
75-
std::vector<std::shared_ptr<RenderTarget>> _targets_spec_filter;
76+
std::vector<std::shared_ptr<RenderTarget>> _targets_spec;
77+
std::vector<std::shared_ptr<RenderTarget>> _targets_spec_filter;
7678

7779
std::shared_ptr<RenderTarget> _diffuse_target;
7880
std::shared_ptr<RenderTarget> _diff_filter_target;
7981
};
8082

8183
// ************************************************************************************************
82-
std::shared_ptr<Image> CubemapFilter::get_specular_cubemap(void) const
84+
inline std::shared_ptr<Image> CubemapFilter::get_specular_cubemap(void) const
8385
{
84-
return _specular_map;
86+
return _specular_map;
8587
}
8688

87-
std::shared_ptr<Image> CubemapFilter::get_diffuse_cubemap(void) const
89+
inline std::shared_ptr<Image> CubemapFilter::get_diffuse_cubemap(void) const
8890
{
89-
return _diffuse_map;
91+
return _diffuse_map;
9092
}
9193

92-
std::shared_ptr<Image> CubemapFilter::get_target_cubemap(void) const
94+
inline std::shared_ptr<Image> CubemapFilter::get_target_cubemap(void) const
9395
{
94-
return _specular_map;
96+
return _specular_map;
9597
}
9698

97-
int CubemapFilter::get_size(void) const
99+
inline int CubemapFilter::get_size(void) const
98100
{
99-
return _size;
101+
return _size;
100102
}
101103

102-
} // namespace rpcore
104+
}

0 commit comments

Comments
 (0)