diff --git a/docs/reference/changelog-r2024.md b/docs/reference/changelog-r2024.md index 54add51c1ef..91cf19d8809 100644 --- a/docs/reference/changelog-r2024.md +++ b/docs/reference/changelog-r2024.md @@ -22,3 +22,4 @@ Released on December **th, 2023. - Fixed the bug that when the language is Python, getTargets() cannot correctly obtain the multi-target data detected by the radar ([#6606](https://github.com/cyberbotics/webots/pull/6606)) - Fixed incomplete loading while minimized under some windowing systems ([#6617](https://github.com/cyberbotics/webots/pull/6617)). - Fixed unitialized sliding friction when using asymmetric rolling friction ([#6618](https://github.com/cyberbotics/webots/pull/6618)). + - Made `supervisor_export_image` work even if using the `--minimize --no-rendering` options ([#6622](https://github.com/cyberbotics/webots/pull/6622)). diff --git a/include/wren/scene.h b/include/wren/scene.h index ea0d7fc1d0d..ec9fd2e4f27 100644 --- a/include/wren/scene.h +++ b/include/wren/scene.h @@ -68,8 +68,7 @@ void wr_scene_enable_depth_reset(WrScene *scene, bool enable); void wr_scene_add_frame_listener(WrScene *scene, void (*listener)()); void wr_scene_remove_frame_listener(WrScene *scene, void (*listener)()); -void wr_scene_get_main_buffer(WrScene *scene, int width, int height, unsigned int format, unsigned int data_type, - unsigned int buffer_type, void *buffer); +void wr_scene_get_main_buffer(int width, int height, unsigned int format, unsigned int data_type, void *buffer); void wr_scene_init_frame_capture(WrScene *scene, int pixel_buffer_count, unsigned int *pixel_buffer_ids, int frame_size); void wr_scene_bind_pixel_buffer(WrScene *scene, int buffer); diff --git a/src/webots/gui/WbView3D.cpp b/src/webots/gui/WbView3D.cpp index b60cc9bd591..5728028f55e 100644 --- a/src/webots/gui/WbView3D.cpp +++ b/src/webots/gui/WbView3D.cpp @@ -332,7 +332,7 @@ void WbView3D::refresh() { const WbSimulationState *const sim = WbSimulationState::instance(); mPhysicsRefresh = true; if (mScreenshotRequested) - renderNow(); + renderNow(true, true); else if (sim->isPaused()) renderLater(); else if (WbVideoRecorder::instance()->isRecording()) { diff --git a/src/webots/gui/WbWrenWindow.cpp b/src/webots/gui/WbWrenWindow.cpp index 44960f92495..dba767bb7e8 100644 --- a/src/webots/gui/WbWrenWindow.cpp +++ b/src/webots/gui/WbWrenWindow.cpp @@ -446,15 +446,5 @@ void WbWrenWindow::feedMultimediaStreamer() { } void WbWrenWindow::readPixels(int width, int height, unsigned int format, void *buffer) { -#ifdef __linux__ - if (WbSysInfo::isVirtualMachine()) { - // Reading the front buffer is not supported by all OpenGL implementations (especially on Linux running in a VM). - // In that case, to read the front buffer, we need to swap the buffers, read the back buffer and swap the buffers again. - // However, doing this may cause flickering on platforms where reading the front buffer is supported (including macOS). - WbWrenOpenGlContext::instance()->swapBuffers(this); - wr_scene_get_main_buffer(wr_scene_get_instance(), width, height, format, GL_UNSIGNED_BYTE, GL_BACK, buffer); - WbWrenOpenGlContext::instance()->swapBuffers(this); - } else -#endif - wr_scene_get_main_buffer(wr_scene_get_instance(), width, height, format, GL_UNSIGNED_BYTE, GL_FRONT, buffer); + wr_scene_get_main_buffer(width, height, format, GL_UNSIGNED_BYTE, buffer); } diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 87258a3e4dc..913277bb3a5 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -101,11 +101,10 @@ namespace wren { assert(!Texture2d::cachedItemCount()); } - void Scene::getMainBuffer(int width, int height, unsigned int format, unsigned int data_type, unsigned int buffer_type, - void *buffer) { - assert(buffer_type == GL_FRONT || buffer_type == GL_BACK); - glstate::bindFrameBuffer(0); - glReadBuffer(buffer_type); + void Scene::getMainBuffer(int width, int height, unsigned int format, unsigned int data_type, void *buffer) { + glstate::bindFrameBuffer(instance()->mMainViewport->frameBuffer()->glName()); + glReadBuffer(GL_COLOR_ATTACHMENT0); + glFinish(); glReadPixels(0, 0, width, height, format, data_type, buffer); } @@ -884,9 +883,8 @@ void wr_scene_apply_pending_updates(WrScene *scene) { reinterpret_cast(scene)->applyPendingUpdates(); } -void wr_scene_get_main_buffer(WrScene *scene, int width, int height, unsigned int format, unsigned int data_type, - unsigned int buffer_type, void *buffer) { - reinterpret_cast(scene)->getMainBuffer(width, height, format, data_type, buffer_type, buffer); +void wr_scene_get_main_buffer(int width, int height, unsigned int format, unsigned int data_type, void *buffer) { + wren::Scene::getMainBuffer(width, height, format, data_type, buffer); } void wr_scene_init_frame_capture(WrScene *scene, int pixel_buffer_count, unsigned int *pixel_buffer_ids, int frame_size) { diff --git a/src/wren/Scene.hpp b/src/wren/Scene.hpp index 9f68654b77e..5e8b4ea032b 100644 --- a/src/wren/Scene.hpp +++ b/src/wren/Scene.hpp @@ -53,8 +53,7 @@ namespace wren { void reset(); static void applyPendingUpdates(); - static void getMainBuffer(int width, int height, unsigned int format, unsigned int data_type, unsigned int buffer_type, - void *buffer); + static void getMainBuffer(int width, int height, unsigned int format, unsigned int data_type, void *buffer); void initFrameCapture(int pixelBufferCount, unsigned int *pixelBufferIds, int frameSize); static void bindPixelBuffer(int buffer); void *mapPixelBuffer(unsigned int accessMode); diff --git a/tests/Makefile b/tests/Makefile index 3f5ddfafe0f..523b2988eb4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: api cache other_api parser physics protos rendering with_rendering +.PHONY: api cache other_api parser physics protos rendering -release debug profile: api cache other_api parser physics protos rendering with_rendering +release debug profile: api cache other_api parser physics protos rendering clean: api cache parser physics protos rendering @-rm -rf *.txt \ @@ -56,6 +56,3 @@ protos: rendering: +@make -s -C rendering $(MAKECMDGOALS) - -with_rendering: - +@make -s -C with_rendering $(MAKECMDGOALS) diff --git a/tests/with_rendering/controllers/billboard/.gitignore b/tests/api/controllers/billboard/.gitignore similarity index 100% rename from tests/with_rendering/controllers/billboard/.gitignore rename to tests/api/controllers/billboard/.gitignore diff --git a/tests/with_rendering/controllers/billboard/Makefile b/tests/api/controllers/billboard/Makefile similarity index 100% rename from tests/with_rendering/controllers/billboard/Makefile rename to tests/api/controllers/billboard/Makefile diff --git a/tests/with_rendering/controllers/billboard/billboard.c b/tests/api/controllers/billboard/billboard.c similarity index 100% rename from tests/with_rendering/controllers/billboard/billboard.c rename to tests/api/controllers/billboard/billboard.c diff --git a/tests/with_rendering/controllers/supervisor_export_image/.gitignore b/tests/api/controllers/supervisor_export_image/.gitignore similarity index 100% rename from tests/with_rendering/controllers/supervisor_export_image/.gitignore rename to tests/api/controllers/supervisor_export_image/.gitignore diff --git a/tests/with_rendering/controllers/supervisor_export_image/Makefile b/tests/api/controllers/supervisor_export_image/Makefile similarity index 100% rename from tests/with_rendering/controllers/supervisor_export_image/Makefile rename to tests/api/controllers/supervisor_export_image/Makefile diff --git a/tests/with_rendering/controllers/supervisor_export_image/supervisor_export_image.c b/tests/api/controllers/supervisor_export_image/supervisor_export_image.c similarity index 100% rename from tests/with_rendering/controllers/supervisor_export_image/supervisor_export_image.c rename to tests/api/controllers/supervisor_export_image/supervisor_export_image.c diff --git a/tests/with_rendering/worlds/billboard.wbt b/tests/api/worlds/billboard.wbt similarity index 100% rename from tests/with_rendering/worlds/billboard.wbt rename to tests/api/worlds/billboard.wbt diff --git a/tests/with_rendering/worlds/supervisor_export_image.wbt b/tests/api/worlds/supervisor_export_image.wbt similarity index 100% rename from tests/with_rendering/worlds/supervisor_export_image.wbt rename to tests/api/worlds/supervisor_export_image.wbt diff --git a/tests/test_suite.py b/tests/test_suite.py index 42ba6cc73aa..582466ff666 100755 --- a/tests/test_suite.py +++ b/tests/test_suite.py @@ -50,7 +50,7 @@ parser.add_argument('--nomake', dest='nomake', default=False, action='store_true', help='The controllers are not re-compiled.') parser.add_argument('--no-ansi-escape', dest='ansi_escape', default=True, action='store_false', help='Disables ansi escape.') parser.add_argument('--group', '-g', type=str, dest='group', default=[], help='Specifies which group of tests should be run.', - choices=['api', 'cache', 'other_api', 'physics', 'protos', 'parser', 'rendering', 'with_rendering']) + choices=['api', 'cache', 'other_api', 'physics', 'protos', 'parser', 'rendering']) parser.add_argument('--performance-log', '-p', type=str, dest='performance_log', default="", help='The name of the performance log file to use if you want to log performance.') parser.add_argument('worlds', nargs='*', default=[]) @@ -236,11 +236,9 @@ def runGroupTest(groupName, firstSimulation, worldsCount, failures): # command.run(silent = False) webotsArguments = [webotsFullPath, firstSimulation] - webotsArguments += ['--mode=fast', '--stdout', '--stderr', '--batch'] + webotsArguments += ['--mode=fast', '--stdout', '--stderr', '--batch', '--no-rendering', '--minimize'] if args.performance_log: webotsArguments += [f'--log-performance={args.performance_log}'] - if groupName != 'with_rendering': - webotsArguments += ['--no-rendering', '--minimize'] if groupName == 'cache': webotsArguments += ['--clear-cache'] command = Command(webotsArguments) @@ -332,7 +330,7 @@ def runGroupTest(groupName, firstSimulation, worldsCount, failures): if args.group: testGroups = [str(args.group)] else: - testGroups = ['api', 'cache', 'other_api', 'physics', 'protos', 'parser', 'rendering', 'with_rendering'] + testGroups = ['api', 'cache', 'other_api', 'physics', 'protos', 'parser', 'rendering'] if sys.platform == 'win32' and 'parser' in testGroups: testGroups.remove('parser') # this one doesn't work on Windows diff --git a/tests/with_rendering/.gitignore b/tests/with_rendering/.gitignore deleted file mode 100644 index 2ced1307bbc..00000000000 --- a/tests/with_rendering/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/worlds_index.txt -/worlds.txt diff --git a/tests/with_rendering/Makefile b/tests/with_rendering/Makefile deleted file mode 100644 index d9b5df50fe7..00000000000 --- a/tests/with_rendering/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 1996-2023 Cyberbotics Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -release debug profile clean: - +@make -s -C controllers $(MAKECMDGOALS) diff --git a/tests/with_rendering/controllers/.gitignore b/tests/with_rendering/controllers/.gitignore deleted file mode 100644 index caa17cad8e7..00000000000 --- a/tests/with_rendering/controllers/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/test_suite_supervisor - diff --git a/tests/with_rendering/controllers/Makefile b/tests/with_rendering/controllers/Makefile deleted file mode 100644 index 3149288896d..00000000000 --- a/tests/with_rendering/controllers/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 1996-2023 Cyberbotics Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -DIRECTORIES=$(subst test_suite_supervisor,,$(subst Makefile,,$(shell ls))) -TARGETS = $(DIRECTORIES:=.Makefile) - -.PHONY: release debug profile clean - -release debug profile clean: $(TARGETS) - -%.Makefile: - +@echo "# make" $(MAKECMDGOALS) $(@:.Makefile=) - +@make -s -C $(@:.Makefile=) $(MAKECMDGOALS) diff --git a/tests/with_rendering/worlds/.gitignore b/tests/with_rendering/worlds/.gitignore deleted file mode 100644 index 267c479acec..00000000000 --- a/tests/with_rendering/worlds/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.*.wbproj -!/.supervisor_export_image.wbproj diff --git a/tests/with_rendering/worlds/.supervisor_export_image.wbproj b/tests/with_rendering/worlds/.supervisor_export_image.wbproj deleted file mode 100644 index e078696581c..00000000000 --- a/tests/with_rendering/worlds/.supervisor_export_image.wbproj +++ /dev/null @@ -1,12 +0,0 @@ -Webots Project File version R2024a -perspectives: 000000ff00000000fd000000020000000100000393000002eafc0200000001fb0000001400540065007800740045006400690074006f00720100000017000002ea0000008900ffffff0000000300000780000000d9fc0100000001fb0000001a0043006f006e0073006f006c00650041006c006c0041006c006c0100000000000007800000006900ffffff000003eb000002ea00000001000000020000000100000008fc00000000 -simulationViewPerspectives: 000000ff000000010000000200000100000005620100000002010000000100 -sceneTreePerspectives: 000000ff00000001000000030000001d000000c0000000fa0100000002010000000200 -maximizedDockId: -1 -centralWidgetVisible: 1 -projectionMode: PERSPECTIVE -userInteractions: selectionDisabled -orthographicViewHeight: 1.75385 -textFiles: 0 "controllers/supervisor_export_image/supervisor_export_image.c" -consoles: Console:All:All -renderingDevicePerspectives: robot:camera;0;1;0;0