GUI: new osc renderer, part 32
This commit is contained in:
parent
f1005afbeb
commit
656107f5ae
|
@ -23,7 +23,26 @@
|
||||||
#include "IconsFontAwesome4.h"
|
#include "IconsFontAwesome4.h"
|
||||||
#include <SDL_timer.h>
|
#include <SDL_timer.h>
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
#include <imgui.h>
|
#include "imgui.h"
|
||||||
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
|
PendingDrawOsc _debugDo;
|
||||||
|
static float oscDebugData[2048];
|
||||||
|
static int oscDebugLen=800;
|
||||||
|
static int oscDebugHeight=400;
|
||||||
|
static float oscDebugLineSize=1.0;
|
||||||
|
static float oscDebugMin=-1.0;
|
||||||
|
static float oscDebugMax=1.0;
|
||||||
|
static float oscDebugPower=1.0;
|
||||||
|
static int oscDebugRepeat=1;
|
||||||
|
|
||||||
|
static void _drawOsc(const ImDrawList* drawList, const ImDrawCmd* cmd) {
|
||||||
|
if (cmd!=NULL) {
|
||||||
|
if (cmd->UserCallbackData!=NULL) {
|
||||||
|
((FurnaceGUI*)(((PendingDrawOsc*)cmd->UserCallbackData)->gui))->runPendingDrawOsc((PendingDrawOsc*)cmd->UserCallbackData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawDebug() {
|
void FurnaceGUI::drawDebug() {
|
||||||
static int bpOrder;
|
static int bpOrder;
|
||||||
|
@ -591,6 +610,56 @@ void FurnaceGUI::drawDebug() {
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
if (ImGui::TreeNode("Osc Render Test")) {
|
||||||
|
ImGui::InputInt("Length",&oscDebugLen);
|
||||||
|
ImGui::InputInt("Height",&oscDebugHeight);
|
||||||
|
ImGui::InputFloat("Line Size",&oscDebugLineSize);
|
||||||
|
ImGui::InputFloat("Min",&oscDebugMin);
|
||||||
|
ImGui::InputFloat("Max",&oscDebugMax);
|
||||||
|
ImGui::InputFloat("Power",&oscDebugPower);
|
||||||
|
ImGui::InputInt("Repeat",&oscDebugRepeat);
|
||||||
|
|
||||||
|
if (oscDebugLen<1) oscDebugLen=1;
|
||||||
|
if (oscDebugLen>2048) oscDebugLen=2048;
|
||||||
|
|
||||||
|
if (oscDebugHeight<1) oscDebugHeight=1;
|
||||||
|
if (oscDebugHeight>2048) oscDebugHeight=2048;
|
||||||
|
|
||||||
|
memset(oscDebugData,0,2048*sizeof(float));
|
||||||
|
for (int i=0; i<oscDebugLen; i++) {
|
||||||
|
oscDebugData[i]=oscDebugMin+(oscDebugMax-oscDebugMin)*pow((float)((i*oscDebugRepeat)%oscDebugLen)/(float)oscDebugLen,oscDebugPower);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rend->supportsDrawOsc()) {
|
||||||
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
||||||
|
|
||||||
|
ImVec2 size=ImVec2(oscDebugLen,oscDebugHeight);
|
||||||
|
ImVec2 minArea=window->DC.CursorPos;
|
||||||
|
ImVec2 maxArea=ImVec2(
|
||||||
|
minArea.x+size.x,
|
||||||
|
minArea.y+size.y
|
||||||
|
);
|
||||||
|
ImRect rect=ImRect(minArea,maxArea);
|
||||||
|
ImGuiStyle& style=ImGui::GetStyle();
|
||||||
|
ImGui::ItemSize(size,style.FramePadding.y);
|
||||||
|
if (ImGui::ItemAdd(rect,ImGui::GetID("debugOsc"))) {
|
||||||
|
_debugDo.gui=this;
|
||||||
|
_debugDo.data=oscDebugData;
|
||||||
|
_debugDo.len=oscDebugLen;
|
||||||
|
_debugDo.pos0=rect.Min;
|
||||||
|
_debugDo.pos1=rect.Max;
|
||||||
|
_debugDo.color=ImVec4(1.0,1.0,1.0,1.0);
|
||||||
|
_debugDo.lineSize=dpiScale*oscDebugLineSize;
|
||||||
|
|
||||||
|
dl->AddCallback(_drawOsc,&_debugDo);
|
||||||
|
dl->AddCallback(ImDrawCallback_ResetRenderState,NULL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::Text("Render Backend does not support osc rendering.");
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
if (ImGui::TreeNode("User Interface")) {
|
if (ImGui::TreeNode("User Interface")) {
|
||||||
if (ImGui::Button("Inspect")) {
|
if (ImGui::Button("Inspect")) {
|
||||||
inspectorOpen=!inspectorOpen;
|
inspectorOpen=!inspectorOpen;
|
||||||
|
|
|
@ -116,7 +116,7 @@ const char* sh_oscRender_srcF=
|
||||||
" }\n"
|
" }\n"
|
||||||
" if ((fur_fragCoord.y-uLineWidth)>valmax*uResolution.y) discard;\n"
|
" if ((fur_fragCoord.y-uLineWidth)>valmax*uResolution.y) discard;\n"
|
||||||
" if ((fur_fragCoord.y+uLineWidth)<valmin*uResolution.y) discard;\n"
|
" if ((fur_fragCoord.y+uLineWidth)<valmin*uResolution.y) discard;\n"
|
||||||
" float slope=sqrt(abs(valmax-valmin)*uResolution.y);\n"
|
" float slope=abs(valmax-valmin)*uResolution.y;\n"
|
||||||
" float slopeDiv=min(1.0,1.0/ceil(slope));\n"
|
" float slopeDiv=min(1.0,1.0/ceil(slope));\n"
|
||||||
" float xRight=ceil(fur_fragCoord.x+uLineWidth);\n"
|
" float xRight=ceil(fur_fragCoord.x+uLineWidth);\n"
|
||||||
" for (float x=max(0.0,floor(fur_fragCoord.x-uLineWidth)); x<=xRight; x+=slopeDiv) {\n"
|
" for (float x=max(0.0,floor(fur_fragCoord.x-uLineWidth)); x<=xRight; x+=slopeDiv) {\n"
|
||||||
|
@ -605,13 +605,13 @@ bool FurnaceGUIRenderGL::init(SDL_Window* win) {
|
||||||
C(glGenTextures(1,&oscDataTex));
|
C(glGenTextures(1,&oscDataTex));
|
||||||
#ifdef USE_GLES
|
#ifdef USE_GLES
|
||||||
C(glBindTexture(GL_TEXTURE_2D,oscDataTex));
|
C(glBindTexture(GL_TEXTURE_2D,oscDataTex));
|
||||||
C(glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR));
|
C(glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST));
|
||||||
C(glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR));
|
C(glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST));
|
||||||
C(glTexImage2D(GL_TEXTURE_2D,0,GL_RED_EXT,2048,1,0,GL_RED_EXT,GL_FLOAT,NULL));
|
C(glTexImage2D(GL_TEXTURE_2D,0,GL_RED_EXT,2048,1,0,GL_RED_EXT,GL_FLOAT,NULL));
|
||||||
#else
|
#else
|
||||||
C(glBindTexture(GL_TEXTURE_1D,oscDataTex));
|
C(glBindTexture(GL_TEXTURE_1D,oscDataTex));
|
||||||
C(glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,GL_LINEAR));
|
C(glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,GL_NEAREST));
|
||||||
C(glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,GL_LINEAR));
|
C(glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,GL_NEAREST));
|
||||||
C(glTexImage1D(GL_TEXTURE_1D,0,GL_RED,2048,0,GL_RED,GL_FLOAT,NULL));
|
C(glTexImage1D(GL_TEXTURE_1D,0,GL_RED,2048,0,GL_RED,GL_FLOAT,NULL));
|
||||||
#endif
|
#endif
|
||||||
C(furActiveTexture(GL_TEXTURE0));
|
C(furActiveTexture(GL_TEXTURE0));
|
||||||
|
|
Loading…
Reference in a new issue