MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / getScreenPixels

Method getScreenPixels

examples/OpenGLWindow/SimpleOpenGL3App.cpp:991–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989}
990
991void SimpleOpenGL3App::getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes)
992{
993 int width = m_data->m_customViewPortWidth >= 0 ? m_data->m_customViewPortWidth : (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenWidth();
994 int height = m_data->m_customViewPortHeight >= 0 ? m_data->m_customViewPortHeight : (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenHeight();
995
996 b3Assert((width * height * 4) == bufferSizeInBytes);
997 if ((width * height * 4) == bufferSizeInBytes)
998 {
999 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, rgbaBuffer);
1000 int glstat;
1001 glstat = glGetError();
1002 b3Assert(glstat == GL_NO_ERROR);
1003 }
1004 b3Assert((width * height * sizeof(float)) == depthBufferSizeInBytes);
1005 if ((width * height * sizeof(float)) == depthBufferSizeInBytes)
1006 {
1007 glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, depthBuffer);
1008 int glstat;
1009 glstat = glGetError();
1010 b3Assert(glstat == GL_NO_ERROR);
1011 }
1012}
1013
1014//#define STB_IMAGE_WRITE_IMPLEMENTATION
1015#include "stb_image/stb_image_write.h"

Callers 1

copyCameraImageDataMethod · 0.45

Calls 3

getRetinaScaleMethod · 0.45
getScreenWidthMethod · 0.45
getScreenHeightMethod · 0.45

Tested by

no test coverage detected