<bdo id='aI6LY'></bdo><ul id='aI6LY'></ul>

  • <small id='aI6LY'></small><noframes id='aI6LY'>

    1. <legend id='aI6LY'><style id='aI6LY'><dir id='aI6LY'><q id='aI6LY'></q></dir></style></legend>

        <i id='aI6LY'><tr id='aI6LY'><dt id='aI6LY'><q id='aI6LY'><span id='aI6LY'><b id='aI6LY'><form id='aI6LY'><ins id='aI6LY'></ins><ul id='aI6LY'></ul><sub id='aI6LY'></sub></form><legend id='aI6LY'></legend><bdo id='aI6LY'><pre id='aI6LY'><center id='aI6LY'></center></pre></bdo></b><th id='aI6LY'></th></span></q></dt></tr></i><div id='aI6LY'><tfoot id='aI6LY'></tfoot><dl id='aI6LY'><fieldset id='aI6LY'></fieldset></dl></div>

      1. <tfoot id='aI6LY'></tfoot>

        如何在OpenGL中截取屏幕截图

        时间:2023-09-18
      2. <small id='NfcwA'></small><noframes id='NfcwA'>

        • <legend id='NfcwA'><style id='NfcwA'><dir id='NfcwA'><q id='NfcwA'></q></dir></style></legend>
        • <i id='NfcwA'><tr id='NfcwA'><dt id='NfcwA'><q id='NfcwA'><span id='NfcwA'><b id='NfcwA'><form id='NfcwA'><ins id='NfcwA'></ins><ul id='NfcwA'></ul><sub id='NfcwA'></sub></form><legend id='NfcwA'></legend><bdo id='NfcwA'><pre id='NfcwA'><center id='NfcwA'></center></pre></bdo></b><th id='NfcwA'></th></span></q></dt></tr></i><div id='NfcwA'><tfoot id='NfcwA'></tfoot><dl id='NfcwA'><fieldset id='NfcwA'></fieldset></dl></div>
            <bdo id='NfcwA'></bdo><ul id='NfcwA'></ul>
              <tfoot id='NfcwA'></tfoot>

                <tbody id='NfcwA'></tbody>

                  本文介绍了如何在OpenGL中截取屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何在 C++ 中截取 OpenGL 窗口的屏幕截图并将其保存到文件中.

                  How to take a screenshot of an OpenGL window in C++ and save it to file.

                  我找到了 glReadPixels() 功能,但我不知道接下来要做什么.例如,我可以在哪里设置文件路径?

                  I found the glReadPixels() function, but I don't know what to do next. Where I can set path to a file, for example?

                  如果不难,请写代码.

                  推荐答案

                  这段代码捕获 OpenGL 窗口并导出到 BMP 文件.您必须有 FreeImage 库才能运行它.

                  This piece of code captures the OpenGL window and export to a BMP file. You must have FreeImage library to run it.

                  // Make the BYTE array, factor of 3 because it's RBG.
                  BYTE* pixels = new BYTE[3 * width * height];
                  
                  glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
                  
                  // Convert to FreeImage format & save to file
                  FIBITMAP* image = FreeImage_ConvertFromRawBits(pixels, width, height, 3 * width, 24, 0x0000FF, 0xFF0000, 0x00FF00, false);
                  FreeImage_Save(FIF_BMP, image, "C:/test.bmp", 0);
                  
                  // Free resources
                  FreeImage_Unload(image);
                  delete [] pixels;
                  

                  这篇关于如何在OpenGL中截取屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 C++ 中使用 GLUT/OpenGL 绘制文本? 下一篇:使用 opengl 进行真正的等距投影

                  相关文章

                  最新文章

                1. <legend id='8CXIZ'><style id='8CXIZ'><dir id='8CXIZ'><q id='8CXIZ'></q></dir></style></legend>

                2. <small id='8CXIZ'></small><noframes id='8CXIZ'>

                      <bdo id='8CXIZ'></bdo><ul id='8CXIZ'></ul>
                    <i id='8CXIZ'><tr id='8CXIZ'><dt id='8CXIZ'><q id='8CXIZ'><span id='8CXIZ'><b id='8CXIZ'><form id='8CXIZ'><ins id='8CXIZ'></ins><ul id='8CXIZ'></ul><sub id='8CXIZ'></sub></form><legend id='8CXIZ'></legend><bdo id='8CXIZ'><pre id='8CXIZ'><center id='8CXIZ'></center></pre></bdo></b><th id='8CXIZ'></th></span></q></dt></tr></i><div id='8CXIZ'><tfoot id='8CXIZ'></tfoot><dl id='8CXIZ'><fieldset id='8CXIZ'></fieldset></dl></div>

                    1. <tfoot id='8CXIZ'></tfoot>