2018-02-14 20:33:33 +01:00
|
|
|
#!/usr/bin/env python3
|
2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2018-2022 Blender Authors
|
2023-06-15 13:09:04 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2018-02-14 20:33:33 +01:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2018-07-03 06:47:49 +02:00
|
|
|
|
2018-02-14 20:33:33 +01:00
|
|
|
def screenshot():
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
output_path = sys.argv[-1]
|
|
|
|
|
|
|
|
# Force redraw and take screenshot.
|
|
|
|
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
2025-01-30 18:44:23 +01:00
|
|
|
bpy.ops.screen.screenshot(filepath=output_path)
|
2018-02-14 20:33:33 +01:00
|
|
|
|
|
|
|
bpy.ops.wm.quit_blender()
|
|
|
|
|
2018-07-03 06:47:49 +02:00
|
|
|
|
2018-02-14 20:33:33 +01:00
|
|
|
# When run from inside Blender, take screenshot and exit.
|
|
|
|
try:
|
|
|
|
import bpy
|
|
|
|
inside_blender = True
|
|
|
|
except ImportError:
|
|
|
|
inside_blender = False
|
|
|
|
|
|
|
|
if inside_blender:
|
|
|
|
screenshot()
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
2019-05-10 23:00:35 +02:00
|
|
|
def get_arguments(filepath, output_filepath):
|
|
|
|
return [
|
2019-05-16 15:48:30 +02:00
|
|
|
"--no-window-focus",
|
|
|
|
"--window-geometry",
|
|
|
|
"0", "0", "1024", "768",
|
|
|
|
"-noaudio",
|
|
|
|
"--factory-startup",
|
|
|
|
"--enable-autoexec",
|
2020-08-26 22:02:02 +02:00
|
|
|
"--debug-memory",
|
|
|
|
"--debug-exit-on-error",
|
2019-05-16 15:48:30 +02:00
|
|
|
filepath,
|
|
|
|
"-P",
|
|
|
|
os.path.realpath(__file__),
|
|
|
|
"--",
|
2019-05-10 23:00:35 +02:00
|
|
|
output_filepath + '0001.png']
|
2018-02-14 20:33:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
def create_argparse():
|
2024-12-10 14:52:34 +01:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="Run test script for each blend file in TESTDIR, comparing the render result with known output."
|
|
|
|
)
|
|
|
|
parser.add_argument("--blender", required=True)
|
|
|
|
parser.add_argument("--testdir", required=True)
|
|
|
|
parser.add_argument("--outdir", required=True)
|
|
|
|
parser.add_argument("--oiiotool", required=True)
|
2025-01-30 18:44:23 +01:00
|
|
|
parser.add_argument('--batch', default=False, action='store_true')
|
2018-02-14 20:33:33 +01:00
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = create_argparse()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
from modules import render_report
|
2025-01-30 18:44:23 +01:00
|
|
|
report = render_report.Report("Screenshot", args.outdir, args.oiiotool)
|
2024-12-10 14:52:34 +01:00
|
|
|
ok = report.run(args.testdir, args.blender, get_arguments)
|
2018-02-14 20:33:33 +01:00
|
|
|
|
|
|
|
sys.exit(not ok)
|
|
|
|
|
2018-07-03 06:47:49 +02:00
|
|
|
|
2018-02-14 20:33:33 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|