Factor out the routine for monitor resolution query, bring up GLFW RAII#194
Factor out the routine for monitor resolution query, bring up GLFW RAII#194hujiajie wants to merge 1 commit into
Conversation
In particular, the design takes in mind GLFW invocations even before main().
|
@gyagp Not see your comments, will you add your input? |
shaoboyan
left a comment
There was a problem hiding this comment.
If stick on a specific monitor will help simplify the code, then do it!(And could provide info/comments to describe this restriction)
| return {}; | ||
| } | ||
|
|
||
| GLFWmonitor *monitor = glfwGetPrimaryMonitor(); |
There was a problem hiding this comment.
Can we cache them? (Assume call glfwGetPrimaryMonitor for the assumption that the user have multiple monitors?)
There was a problem hiding this comment.
This was one of my initial candidate ideas, and I happened to choose the other considering it's only called during initialization. Personally I'd like to avoid introducing too many static variables in the code base, but let's see how others feel about this.
| return {}; | ||
| } | ||
|
|
||
| const GLFWvidmode *mode = glfwGetVideoMode(monitor); |
There was a problem hiding this comment.
Ditto. It's a getter, concerns for so many glfw calls
|
@hujiajie, can you upload and point me the changes to option parser? I'd like to understand more about the motivation for this patch. |
|
The start point is that abseil-cpp has become a hard dependency of googletest, and it provides an option parser, making cxxopts redundant. The typical usage of the Abseil flags library looks like the following: ABSL_FLAG(std::string, window_size, DEFAULT_VALUE, "help message");
// Approximately equivalent with:
// std::string FLAGS_window_size = DEFAULT_VALUE;
int main(int argc, char *argv[]) {
absl::ParseCommandLine(argc, argv);
std::string foobar = absl::GetFlag(FLAGS_window_size);
// ...
return 0;
}The question is how to set ABSL_FLAG(std::string,
window_size,
std::to_string(getMonitorResolution().width) + "," + std::to_string(getMonitorResolution().height),
"help message");Note |
|
Full PoC here: https://github.com/hujiajie/aquarium/tree/abseil-cpp |
|
My most concerns come from the following points:
And in your ABSEIL POC, I also don't think the option parser is a part of Context. Option parser belongs to App (Aquarium in our case), and it parses the options and passes them to Context. |
I don't like either, but unfortunately it's the standard usage of the Abseil flags library. Putting
So call for voting here: a simple command-line user interface (no special case like 0,0) + a complicated implementation, or a complicated command-line user interface + a simple implementation?
This is caused by another strange design of the Abseil flags library. To illustrate the auto-generated --help output: The |
In particular, the design takes in mind GLFW invocations even before main().