From 8743203dfc7e640373443bd2f2a0715dbf34ea30 Mon Sep 17 00:00:00 2001 From: Cary Phillips Date: Fri, 2 Feb 2024 11:38:03 -0800 Subject: [PATCH] Make 'Hello, World' example reader/writer downloadable (#1620) Signed-off-by: Cary Phillips --- README.md | 10 +++---- website/HelloWorld.rst | 29 ++++++++++++------- .../src/{reader => exrreader}/CMakeLists.txt | 2 +- website/src/exrreader/build.sh | 3 ++ .../reader.cpp => exrreader/exrreader.cpp} | 0 .../src/{writer => exrwriter}/CMakeLists.txt | 2 +- website/src/exrwriter/build.sh | 3 ++ .../writer.cpp => exrwriter/exrwriter.cpp} | 0 website/src/reader/build.sh | 3 -- website/src/writer/build.sh | 3 -- 10 files changed, 31 insertions(+), 24 deletions(-) rename website/src/{reader => exrreader}/CMakeLists.txt (75%) create mode 100755 website/src/exrreader/build.sh rename website/src/{reader/reader.cpp => exrreader/exrreader.cpp} (100%) rename website/src/{writer => exrwriter}/CMakeLists.txt (75%) create mode 100755 website/src/exrwriter/build.sh rename website/src/{writer/writer.cpp => exrwriter/exrwriter.cpp} (100%) delete mode 100755 website/src/reader/build.sh delete mode 100755 website/src/writer/build.sh diff --git a/README.md b/README.md index d41b6a19d7..b3bcd1237a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ for more information. # Quick Start See the [technical documentation](https://openexr.readthedocs.io) for -complete details, but to get started, the "hello, world" `.exr` writer program is: +complete details, but to get started, the "Hello, world" [`exrwriter.cpp`](https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr/main/website/src/exrwriter/exrwriter.cpp) writer program is: #include #include @@ -87,18 +87,18 @@ complete details, but to get started, the "hello, world" `.exr` writer program i return 0; } -The `CMakeLists.txt` to build: +The [`CMakeLists.txt`](https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr/main/website/src/exrwriter/CMakeLists.txt) to build: - cmake_minimum_required(VERSION 3.10) + cmake_minimum_required(VERSION 3.12) project(exrwriter) find_package(OpenEXR REQUIRED) - add_executable(${PROJECT_NAME} writer.cpp) + add_executable(${PROJECT_NAME} exrwriter.cpp) target_link_libraries(${PROJECT_NAME} OpenEXR::OpenEXR) To build: - $ cmake -S . -B _build + $ cmake -S . -B _build -DCMAKE_PREFIX_PATH= $ cmake --build _build For more details, see [The OpenEXR diff --git a/website/HelloWorld.rst b/website/HelloWorld.rst index bb5846bedb..d2ef782148 100644 --- a/website/HelloWorld.rst +++ b/website/HelloWorld.rst @@ -11,33 +11,40 @@ Hello, World :caption: Hello, World :maxdepth: 1 -A simple program to write a simple ``.exr`` file of an image of 10x10 -pixels with values that are a ramp in green and blue: +Write an Image +============== -.. literalinclude:: src/writer/writer.cpp +This example :download:`exrwriter.cpp ` +program writes a simple ``hello.exr`` file of an image of 10x10 pixels with +values that are a ramp in green and blue: -And the ``CMakeLists.txt`` file to build: +.. literalinclude:: src/exrwriter/exrwriter.cpp + +And the :download:`CMakeLists.txt ` file to build: -.. literalinclude:: src/writer/CMakeLists.txt +.. literalinclude:: src/exrwriter/CMakeLists.txt To build: -.. literalinclude:: src/writer/build.sh +.. literalinclude:: src/exrwriter/build.sh For more details, see :ref:`The OpenEXR API`. -And a simple program to read an ``.exr`` file: +Read an Image +============= -.. literalinclude:: src/reader/reader.cpp +This companion example :download:`exrreader.cpp ` +program reads the ``hello.exr`` file written by the writer program above: +.. literalinclude:: src/exrreader/exrreader.cpp -And the ``CMakeLists.txt`` file to build: +And the :download:`CMakeLists.txt ` file to build: -.. literalinclude:: src/reader/CMakeLists.txt +.. literalinclude:: src/exrreader/CMakeLists.txt To build: -.. literalinclude:: src/reader/build.sh +.. literalinclude:: src/exrreader/build.sh diff --git a/website/src/reader/CMakeLists.txt b/website/src/exrreader/CMakeLists.txt similarity index 75% rename from website/src/reader/CMakeLists.txt rename to website/src/exrreader/CMakeLists.txt index f33f3df026..17356928fe 100644 --- a/website/src/reader/CMakeLists.txt +++ b/website/src/exrreader/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.12) project(exrreader) find_package(OpenEXR REQUIRED) -add_executable(${PROJECT_NAME} reader.cpp) +add_executable(${PROJECT_NAME} exrreader.cpp) target_link_libraries(${PROJECT_NAME} OpenEXR::OpenEXR) diff --git a/website/src/exrreader/build.sh b/website/src/exrreader/build.sh new file mode 100755 index 0000000000..a93f250f6c --- /dev/null +++ b/website/src/exrreader/build.sh @@ -0,0 +1,3 @@ +$ mkdir _build +$ cmake -S . -B _build -DCMAKE_PREFIX_PATH= +$ cmake --build _build diff --git a/website/src/reader/reader.cpp b/website/src/exrreader/exrreader.cpp similarity index 100% rename from website/src/reader/reader.cpp rename to website/src/exrreader/exrreader.cpp diff --git a/website/src/writer/CMakeLists.txt b/website/src/exrwriter/CMakeLists.txt similarity index 75% rename from website/src/writer/CMakeLists.txt rename to website/src/exrwriter/CMakeLists.txt index 79052a6ac7..ceefb2b4f0 100644 --- a/website/src/writer/CMakeLists.txt +++ b/website/src/exrwriter/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.12) project(exrwriter) find_package(OpenEXR REQUIRED) -add_executable(${PROJECT_NAME} writer.cpp) +add_executable(${PROJECT_NAME} exrwriter.cpp) target_link_libraries(${PROJECT_NAME} OpenEXR::OpenEXR) diff --git a/website/src/exrwriter/build.sh b/website/src/exrwriter/build.sh new file mode 100755 index 0000000000..a93f250f6c --- /dev/null +++ b/website/src/exrwriter/build.sh @@ -0,0 +1,3 @@ +$ mkdir _build +$ cmake -S . -B _build -DCMAKE_PREFIX_PATH= +$ cmake --build _build diff --git a/website/src/writer/writer.cpp b/website/src/exrwriter/exrwriter.cpp similarity index 100% rename from website/src/writer/writer.cpp rename to website/src/exrwriter/exrwriter.cpp diff --git a/website/src/reader/build.sh b/website/src/reader/build.sh deleted file mode 100755 index 7cd8c5801a..0000000000 --- a/website/src/reader/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -$ mkdir _build -$ cmake -S . -B _build -$ cmake --build _build diff --git a/website/src/writer/build.sh b/website/src/writer/build.sh deleted file mode 100755 index 7cd8c5801a..0000000000 --- a/website/src/writer/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -$ mkdir _build -$ cmake -S . -B _build -$ cmake --build _build