mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 07:03:36 -04:00
display: properly prioritize preferred pipe
Previously, load-display of a module with more than one pipe would cause the first available pipe to be loaded, rather than the one returned by `get_pipe_type_<module>()`
This commit is contained in:
parent
e3ea397665
commit
deb24afe18
@ -49,6 +49,7 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") {
|
||||
|
||||
_default_display_module = load_display.get_word(0);
|
||||
_default_pipe_name = load_display.get_word(1);
|
||||
_default_pipe_type = TypeHandle::none();
|
||||
|
||||
if (_default_display_module == "*") {
|
||||
// '*' or empty string is the key for all display modules.
|
||||
@ -124,7 +125,11 @@ print_pipe_types() const {
|
||||
LightMutexHolder holder(_lock);
|
||||
nout << "Known pipe types:" << std::endl;
|
||||
for (const PipeType &pipe_type : _pipe_types) {
|
||||
nout << " " << pipe_type._type << "\n";
|
||||
nout << " " << pipe_type._type;
|
||||
if (_pipe_types.size() > 1 && pipe_type._type == _default_pipe_type) {
|
||||
nout << " (default)";
|
||||
}
|
||||
nout << "\n";
|
||||
}
|
||||
if (_display_modules.empty()) {
|
||||
nout << "(all display modules loaded.)\n";
|
||||
@ -256,7 +261,7 @@ make_default_pipe() {
|
||||
|
||||
if (!_default_pipe_name.empty()) {
|
||||
// First, look for an exact match of the default type name from the
|
||||
// Configrc file (excepting case and hyphenunderscore).
|
||||
// Config.prc file (excepting case and hyphen / underscore).
|
||||
for (const PipeType &ptype : _pipe_types) {
|
||||
if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) {
|
||||
// Here's an exact match.
|
||||
@ -281,6 +286,18 @@ make_default_pipe() {
|
||||
}
|
||||
}
|
||||
|
||||
// Look for the preferred type of the default display module.
|
||||
if (_default_pipe_type != TypeHandle::none()) {
|
||||
for (const PipeType &ptype : _pipe_types) {
|
||||
if (ptype._type == _default_pipe_type) {
|
||||
PT(GraphicsPipe) pipe = (*ptype._constructor)();
|
||||
if (pipe != nullptr) {
|
||||
return pipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find a matching pipe type; choose the first one on the list.
|
||||
for (const PipeType &ptype : _pipe_types) {
|
||||
PT(GraphicsPipe) pipe = (*ptype._constructor)();
|
||||
@ -358,7 +375,7 @@ do_load_default_module() {
|
||||
return;
|
||||
}
|
||||
|
||||
load_named_module(_default_display_module);
|
||||
_default_pipe_type = load_named_module(_default_display_module);
|
||||
|
||||
DisplayModules::iterator di =
|
||||
std::find(_display_modules.begin(), _display_modules.end(),
|
||||
|
@ -87,6 +87,7 @@ private:
|
||||
DisplayModules _display_modules;
|
||||
std::string _default_display_module;
|
||||
std::string _default_pipe_name;
|
||||
TypeHandle _default_pipe_type;
|
||||
bool _default_module_loaded;
|
||||
|
||||
static GraphicsPipeSelection *_global_ptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user