Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlutWindow::screenshot() doesn't work #395

Closed
jslee02 opened this issue May 26, 2015 · 9 comments · Fixed by #623
Closed

GlutWindow::screenshot() doesn't work #395

jslee02 opened this issue May 26, 2015 · 9 comments · Fixed by #623
Milestone

Comments

@jslee02
Copy link
Member

jslee02 commented May 26, 2015

No description provided.

@olzhas
Copy link
Contributor

olzhas commented Feb 17, 2016

it works for me, and I have some what related question,

is it possible to change in /dart/gui/Win3D.cpp

  if (mCapture)
    screenshot();

to

  if (mCapture)
    std::async(std::launch::async, screenshot);

@mxgrey
Copy link
Member

mxgrey commented Feb 17, 2016

Is there a particular motivation for launching it in a thread? I'd be concerned about race conditions causing problems, such as missing the frame that the user wanted, or worse: capturing a frame which is only partially rendered.

@jslee02
Copy link
Member Author

jslee02 commented Feb 17, 2016

Out of curiosity, which platform are you using? I've never seen this function working on ubuntu.

@olzhas
Copy link
Contributor

olzhas commented Mar 1, 2016

I am using ubuntu as well, I did not check whether it is working on my computer, just saw it while reading more about C++11.

@jslee02
Copy link
Member Author

jslee02 commented Mar 1, 2016

I meant GlutWindow::screenshot() function. I had observed that GlutWindow::screenshot() function doesn't work on my ubuntu (maybe other platforms as well). The console says wrote screenshot frames/CaptureXXXX.png, but the files are actually not created at all. So I wondered if it really worked for you.

@olzhas
Copy link
Contributor

olzhas commented Mar 1, 2016

I guess it works on my computer. When I press 'c', frames/CaptureXXXX.png are getting generated. and I can see those files there. however I don't remember if I created frames/ directory or the library did.

@jslee02
Copy link
Member Author

jslee02 commented Mar 1, 2016

I manually created frames directory, and not it works! It seems lodepng doesn't create necessary directories for the passed-in filename. GlutWindow::screenshot() should be changed to create frames directory when it doesn't exist. Thanks!

Also, I have a similar concern about the race conditions as @mxgrey mentioned. The screen data will be shared by the renderer and the screen-capturing threads.

@olzhas
Copy link
Contributor

olzhas commented Mar 2, 2016

which fix will be better

//...
#include <boost/filesystem.hpp>

//...
void Win3D::keyboard(unsigned char _key, int /*_x*/, int /*_y*/) {
  char directory[8] = "frames";
//...
case 'c':
case 'C':
//...
  if (!boost::filesystem::exists(directory)) {
    boost::filesystem::create_directory(directory);
  }

  if (!boost::filesystem::is_directory(directory)) {
    std::cout << "frames/ is not a directory, cannot write a screenshot\n";
  }

or something without boost::filesystem

@jslee02
Copy link
Member Author

jslee02 commented Mar 2, 2016

I created a pull request for this (#623), which is similar to your suggestion but not using boost::filesystem as we're trying to minimize the dependencies as much as possible.

@jslee02 jslee02 added this to the DART 6.0.0 milestone Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants