-
-
Notifications
You must be signed in to change notification settings - Fork 639
Add module interface file #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| cmake_minimum_required(VERSION 4.0.0) | ||
|
|
||
| project(CppmExample LANGUAGES CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20) | ||
|
|
||
| add_executable(main main.cc) | ||
|
|
||
| # The module interface file requires the tiny_obj_loader header file | ||
| target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../..") | ||
|
|
||
| # Add the tiny_obj_loader module interface file | ||
| target_sources(main PRIVATE | ||
| FILE_SET cxx_modules | ||
| TYPE CXX_MODULES | ||
| BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../.." | ||
| FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../tiny_obj_loader.cppm" | ||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #include <string> | ||
| #include <vector> | ||
| #include <iostream> | ||
|
|
||
| // import std; | ||
| import tinyobj; | ||
|
|
||
|
|
||
| int main() { | ||
| // Equivalent to doing everything that #include <tiny_obj_loader.h> would do | ||
|
|
||
| const std::string filename = "../../models/cornell_box.obj"; | ||
| tinyobj::attrib_t attrib; | ||
| std::vector<tinyobj::shape_t> shapes; | ||
| std::vector<tinyobj::material_t> materials; | ||
| std::string warn, err; | ||
| if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, filename.c_str())) { | ||
| throw std::runtime_error(warn + err); | ||
| } | ||
|
|
||
| std::cout << "shapes.size() = " << shapes.size() << std::endl; | ||
| for (const auto& shape : shapes) { | ||
| std::cout << "shape.mesh.indices.size() = " << shape.mesh.indices.size() << std::endl; | ||
| } | ||
|
|
||
| // ...... | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| module; | ||
|
|
||
| #define TINYOBJLOADER_IMPLEMENTATION // optional | ||
Mysvac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include <tiny_obj_loader.h> | ||
|
|
||
| export module tinyobj; | ||
Mysvac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| export namespace tinyobj { | ||
| using tinyobj::real_t; | ||
| using tinyobj::texture_type_t; | ||
| using tinyobj::texture_option_t; | ||
| using tinyobj::material_t; | ||
|
|
||
| #ifdef TINY_OBJ_LOADER_PYTHON_BINDING | ||
| using tinyobj::GetDiffuse; | ||
| using tinyobj::GetSpecular; | ||
| using tinyobj::GetTransmittance; | ||
| using tinyobj::GetEmission; | ||
| using tinyobj::GetAmbient; | ||
| using tinyobj::SetDiffuse; | ||
| using tinyobj::SetAmbient; | ||
| using tinyobj::SetSpecular; | ||
| using tinyobj::SetTransmittance; | ||
| using tinyobj::GetCustomParameter; | ||
| #endif // TINY_OBJ_LOADER_PYTHON_BINDING | ||
|
|
||
| using tinyobj::tag_t; | ||
| using tinyobj::joint_and_weight_t; | ||
| using tinyobj::skin_weight_t; | ||
| using tinyobj::index_t; | ||
| using tinyobj::mesh_t; | ||
| using tinyobj::lines_t; | ||
| using tinyobj::points_t; | ||
| using tinyobj::shape_t; | ||
| using tinyobj::attrib_t; | ||
| using tinyobj::callback_t; | ||
| using tinyobj::MaterialReader; | ||
| using tinyobj::MaterialFileReader; | ||
| using tinyobj::MaterialStreamReader; | ||
| using tinyobj::ObjReaderConfig; | ||
| using tinyobj::ObjReader; | ||
| using tinyobj::LoadObj; | ||
| using tinyobj::LoadObjWithCallback; | ||
| using tinyobj::LoadMtl; | ||
| using tinyobj::ParseTextureNameAndOption; | ||
|
|
||
|
|
||
| using tinyobj::vertex_index_t; | ||
| using tinyobj::face_t; | ||
| using tinyobj::__line_t; | ||
| using tinyobj::__points_t; | ||
| using tinyobj::tag_sizes; | ||
| using tinyobj::obj_shape; | ||
| using tinyobj::PrimGroup; | ||
|
|
||
| using tinyobj::warning_context; | ||
|
|
||
| using tinyobj::TinyObjPoint; | ||
| using tinyobj::cross; | ||
| using tinyobj::dot; | ||
| using tinyobj::GetLength; | ||
| using tinyobj::Normalize; | ||
| using tinyobj::WorldToLocal; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.