GUI: new osc renderer, part 8

only update waveform[] when using old code
This commit is contained in:
tildearrow 2024-02-11 17:57:50 -05:00
parent 9ed7364cff
commit b9a6a83798
2 changed files with 14 additions and 12 deletions

View file

@ -293,16 +293,6 @@ void FurnaceGUI::drawOsc() {
if ((oscWidth-24)>0) { if ((oscWidth-24)>0) {
if (settings.oscMono) { if (settings.oscMono) {
for (int i=0; i<oscWidth-24; i++) {
float x=(float)i/(float)(oscWidth-24);
float y=oscValuesAverage[i+12]*oscZoom;
if (!settings.oscEscapesBoundary) {
if (y<-0.5f) y=-0.5f;
if (y>0.5f) y=0.5f;
}
waveform[i]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
}
if (rend->supportsDrawOsc()) { if (rend->supportsDrawOsc()) {
_do.gui=this; _do.gui=this;
_do.data=&oscValuesAverage[12]; _do.data=&oscValuesAverage[12];
@ -314,6 +304,16 @@ void FurnaceGUI::drawOsc() {
dl->AddCallback(_drawOsc,&_do); dl->AddCallback(_drawOsc,&_do);
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL); dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
} else { } else {
for (int i=0; i<oscWidth-24; i++) {
float x=(float)i/(float)(oscWidth-24);
float y=oscValuesAverage[i+12]*oscZoom;
if (!settings.oscEscapesBoundary) {
if (y<-0.5f) y=-0.5f;
if (y>0.5f) y=0.5f;
}
waveform[i]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
}
if (settings.oscEscapesBoundary) { if (settings.oscEscapesBoundary) {
dl->PushClipRectFullScreen(); dl->PushClipRectFullScreen();
dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale); dl->AddPolyline(waveform,oscWidth-24,color,ImDrawFlags_None,dpiScale);

View file

@ -104,12 +104,14 @@ const char* sh_oscRender_srcF=
"void main() {\n" "void main() {\n"
" vec2 uv = fur_fragCoord/uResolution;\n" " vec2 uv = fur_fragCoord/uResolution;\n"
" vec2 tresh = vec2(uLineWidth)/uResolution;\n" " vec2 tresh = vec2(uLineWidth)/uResolution;\n"
" float x1 = uv.x-uAdvance;\n"
" float x2 = uv.x;\n" " float x2 = uv.x;\n"
" float x3 = uv.x+uAdvance;\n" " float x3 = uv.x+uAdvance;\n"
" float val1 = texture2D(oscVal,vec2(x2,1.0)).x;\n"
" float val2 = texture2D(oscVal,vec2(x2,1.0)).x;\n" " float val2 = texture2D(oscVal,vec2(x2,1.0)).x;\n"
" float val3 = texture2D(oscVal,vec2(x3,1.0)).x;\n" " float val3 = texture2D(oscVal,vec2(x3,1.0)).x;\n"
" float valmax = max(val2,val3);\n" " float valmax = max(max(val1,val2),val3);\n"
" float valmin = min(val2,val3);\n" " float valmin = min(min(val1,val2),val3);\n"
" float vald = abs(valmax-valmin);\n" " float vald = abs(valmax-valmin);\n"
" float alpha = 1.0-abs(uv.y-val2)/max(tresh.y,vald);\n" " float alpha = 1.0-abs(uv.y-val2)/max(tresh.y,vald);\n"
" if (vald>(1.0/uResolution.y)) {\n" " if (vald>(1.0/uResolution.y)) {\n"