MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / cmdScreenshot

Function cmdScreenshot

src/clientbase/clientCommands.cpp:825–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823
824
825static std::string cmdScreenshot(const std::string&, const CmdArgList& args, bool*) {
826 if (args.size() != 0) {
827 return "usage: screenshot";
828 }
829
830 ScreenshotData* ssdata = new ScreenshotData;
831 ssdata->renderer += (const char*)(glGetString(GL_VENDOR));
832 ssdata->renderer += ": ";
833 ssdata->renderer += (const char*)(glGetString(GL_RENDERER));
834 ssdata->renderer += " (OpenGL ";
835 ssdata->renderer += (const char*)(glGetString(GL_VERSION));
836 ssdata->renderer += ")";
837 int w = mainWindow->getWidth();
838 int h = mainWindow->getHeight();
839 ssdata->xsize = w;
840 ssdata->ysize = h;
841 ssdata->channels = 3; // GL_RGB
842 ssdata->pixels = new unsigned char[h * w * 3];
843 glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, ssdata->pixels);
844
845#if defined(HAVE_PTHREADS)
846 pthread_t thread;
847 pthread_create(&thread, NULL, writeScreenshot, (void*) ssdata);
848#elif defined(_WIN32)
849 CreateThread(
850 NULL, // Security attributes
851 0, // Stack size (0 -> default)
852 writeScreenshot,
853 ssdata,
854 0, // creation flags (0 -> run immediately)
855 NULL); // thread id return value (NULL -> don't care)
856#else
857 // no threads? sucks to be you, but we'll still write the screenshot
858 writeScreenshot(&ssdata);
859#endif
860
861 return std::string();
862}
863
864
865static std::string cmdShotStats(const std::string&, const CmdArgList& args, bool*) {

Callers

nothing calls this directly

Calls 4

writeScreenshotFunction · 0.85
sizeMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected