MCPcopy Create free account
hub / github.com/dfranx/SHADERed / Process

Method Process

src/SHADERed/UI/FrameAnalysisUI.cpp:5–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4namespace ed {
5 void FrameAnalysisUI::Process()
6 {
7 for (int i = 0; i < 256; i++) {
8 m_histogramR[i] = m_histogramG[i] = m_histogramB[i] = 0.0f;
9 m_histogramRGB[i] = 0.0f;
10 }
11
12 // get texture data
13 glm::ivec2 rendererSize = m_data->Renderer.GetLastRenderSize();
14 uint8_t* pixels = (uint8_t*)malloc(rendererSize.x * rendererSize.y * 4);
15 glBindTexture(GL_TEXTURE_2D, m_data->Renderer.GetTexture());
16 glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
17 glBindTexture(GL_TEXTURE_2D, 0);
18
19 // build histogram
20 for (int x = 0; x < rendererSize.x; x++) {
21 for (int y = 0; y < rendererSize.y; y++) {
22 uint8_t* px = &pixels[(y * rendererSize.x + x) * 4];
23
24 m_histogramR[px[0]]++;
25 m_histogramG[px[1]]++;
26 m_histogramB[px[2]]++;
27
28 // TODO: is this even how RGB histogram works? I just did this by my logic idk tho, compare with Photoshop
29 m_histogramRGB[px[0]]++;
30 m_histogramRGB[px[1]]++;
31 m_histogramRGB[px[2]]++;
32 }
33 }
34
35 // free memory
36 free(pixels);
37 }
38 void FrameAnalysisUI::OnEvent(const SDL_Event& e)
39 {
40 }

Callers 1

m_runFrameAnalysisMethod · 0.80

Calls 2

GetLastRenderSizeMethod · 0.80
GetTextureMethod · 0.45

Tested by

no test coverage detected