MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / RenderBuffer

Method RenderBuffer

Source/VisualizerScope.cpp:63–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void CVisualizerScope::RenderBuffer()
64{
65 const float SAMPLE_SCALING = 1200.0f;
66
67 const COLORREF LINE_COL1 = 0xFFFFFF;
68 const COLORREF LINE_COL2 = 0x808080;
69
70 const int BLUR_COLORS[] = {3, 12, 12};
71
72 const float HALF_HEIGHT = float(m_iHeight) / 2.0f;
73
74 if (m_bBlur)
75 BlurBuffer(m_pBlitBuffer.get(), m_iWidth, m_iHeight, BLUR_COLORS);
76 else
77 ClearBackground();
78
79 float Sample = -float(m_pWindowBuf[0]) / SAMPLE_SCALING;
80
81 for (float x = 0.0f; x < float(m_iWidth); ++x) {
82 float LastSample = Sample;
83 Sample = -float(m_pWindowBuf[int(x)]) / SAMPLE_SCALING;
84
85 if (Sample < -HALF_HEIGHT + 1)
86 Sample = -HALF_HEIGHT + 1;
87 if (Sample > HALF_HEIGHT - 1)
88 Sample = HALF_HEIGHT - 1;
89
90 PutPixel(m_pBlitBuffer.get(), m_iWidth, m_iHeight, x, Sample + HALF_HEIGHT - 0.5f, LINE_COL2);
91 PutPixel(m_pBlitBuffer.get(), m_iWidth, m_iHeight, x, Sample + HALF_HEIGHT + 0.5f, LINE_COL2);
92 PutPixel(m_pBlitBuffer.get(), m_iWidth, m_iHeight, x, Sample + HALF_HEIGHT + 0.0f, LINE_COL1);
93
94 if ((Sample - LastSample) > 1.0f) {
95 float frac = LastSample - floor(LastSample);
96 for (float y = LastSample; y < Sample; ++y) {
97 float Offset = (y - LastSample) / (Sample - LastSample);
98 PutPixel(m_pBlitBuffer.get(), m_iWidth, m_iHeight, x + Offset - 1.0f, y + HALF_HEIGHT + frac, LINE_COL1);
99 }
100 }
101 else if ((LastSample - Sample) > 1.0f) {
102 float frac = Sample - floor(Sample);
103 for (float y = Sample; y < LastSample; ++y) {
104 float Offset = (y - Sample) / (LastSample - Sample);
105 PutPixel(m_pBlitBuffer.get(), m_iWidth, m_iHeight, x - Offset, y + HALF_HEIGHT + frac, LINE_COL1);
106 }
107 }
108 }
109}
110
111void CVisualizerScope::Draw()
112{

Callers

nothing calls this directly

Calls 3

BlurBufferFunction · 0.85
PutPixelFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected