mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00

This occurs with the multithreaded render pipeline. It's not an issue when using ShowBase because ShowBase also explicitly calls this during shutdown.
74 lines
1.7 KiB
Python
74 lines
1.7 KiB
Python
import pytest
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def graphics_pipe():
|
|
from panda3d.core import GraphicsPipeSelection
|
|
|
|
pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()
|
|
|
|
if pipe is None or not pipe.is_valid():
|
|
pytest.skip("GraphicsPipe is invalid")
|
|
|
|
yield pipe
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def graphics_engine():
|
|
from panda3d.core import GraphicsEngine
|
|
|
|
engine = GraphicsEngine.get_global_ptr()
|
|
yield engine
|
|
|
|
# This causes GraphicsEngine to also terminate the render threads.
|
|
engine.remove_all_windows()
|
|
|
|
|
|
@pytest.fixture
|
|
def window(graphics_pipe, graphics_engine):
|
|
from panda3d.core import GraphicsPipe, FrameBufferProperties, WindowProperties
|
|
|
|
fbprops = FrameBufferProperties.get_default()
|
|
winprops = WindowProperties.get_default()
|
|
|
|
win = graphics_engine.make_output(
|
|
graphics_pipe,
|
|
'window',
|
|
0,
|
|
fbprops,
|
|
winprops,
|
|
GraphicsPipe.BF_require_window
|
|
)
|
|
graphics_engine.open_windows()
|
|
|
|
assert win is not None
|
|
yield win
|
|
|
|
if win is not None:
|
|
graphics_engine.remove_window(win)
|
|
|
|
|
|
@pytest.fixture(scope='module')
|
|
def gsg(graphics_pipe, graphics_engine):
|
|
"Returns a windowless GSG that can be used for offscreen rendering."
|
|
from panda3d.core import GraphicsPipe, FrameBufferProperties, WindowProperties
|
|
|
|
fbprops = FrameBufferProperties()
|
|
fbprops.force_hardware = True
|
|
|
|
buffer = graphics_engine.make_output(
|
|
graphics_pipe,
|
|
'buffer',
|
|
0,
|
|
fbprops,
|
|
WindowProperties.size(32, 32),
|
|
GraphicsPipe.BF_refuse_window
|
|
)
|
|
graphics_engine.open_windows()
|
|
|
|
assert buffer is not None
|
|
yield buffer.gsg
|
|
|
|
if buffer is not None:
|
|
graphics_engine.remove_window(buffer)
|