Fixup glBars, static but working view
This commit is contained in:
parent
e0d6d59ce9
commit
58d54066d3
4 changed files with 45 additions and 96 deletions
|
@ -412,6 +412,9 @@ struct AudioFileListWidget : ImGuiWidget {
|
|||
{
|
||||
module->fileChanged = false;
|
||||
|
||||
currentFiles.clear();
|
||||
selectedFile = (size_t)-1;
|
||||
|
||||
static constexpr const char* const supportedExtensions[] = {
|
||||
#ifdef HAVE_SNDFILE
|
||||
".aif",".aifc",".aiff",".au",".bwf",".flac",".htk",".iff",".mat4",".mat5",".oga",".ogg;"
|
||||
|
@ -422,9 +425,9 @@ struct AudioFileListWidget : ImGuiWidget {
|
|||
|
||||
using namespace ghc::filesystem;
|
||||
currentDirectory = path(module->currentFile).parent_path().string();
|
||||
currentFiles.clear();
|
||||
|
||||
directory_iterator it(currentDirectory);
|
||||
size_t index = 0;
|
||||
for (directory_iterator itb = begin(it), ite=end(it); itb != ite; ++itb)
|
||||
{
|
||||
if (! itb->is_regular_file())
|
||||
|
@ -435,7 +438,10 @@ struct AudioFileListWidget : ImGuiWidget {
|
|||
{
|
||||
if (extension.compare(supportedExtensions[i]) == 0)
|
||||
{
|
||||
if (filepath.compare(module->currentFile) == 0)
|
||||
selectedFile = index;
|
||||
currentFiles.push_back({ filepath.string(), filepath.filename().string() });
|
||||
++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +478,7 @@ struct AudioFileWidget : ModuleWidget {
|
|||
addOutput(createOutput<PJ301MPort>(Vec(box.size.x - RACK_GRID_WIDTH * 5/2,
|
||||
RACK_GRID_HEIGHT - RACK_GRID_WIDTH - padding * 1),
|
||||
module, 1));
|
||||
|
||||
|
||||
if (m != nullptr)
|
||||
{
|
||||
AudioFileListWidget* const listw = new AudioFileListWidget(m);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* DISTRHO Cardinal Plugin
|
||||
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
|
||||
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
|
@ -69,17 +69,25 @@ struct glBarsRendererWidget : OpenGlWidget {
|
|||
|
||||
void drawFramebuffer() override {
|
||||
math::Vec fbSize = getFramebufferSize();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, fbSize.x, fbSize.y, 0.0, 0.0, 1.0);
|
||||
glViewport(0.0, 0.0, fbSize.x, fbSize.y);
|
||||
glFrustum(-1, 1, -1, 1, 1.5, 10);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
// glDisable(GL_CULL_FACE);
|
||||
// glDisable(GL_STENCIL_TEST);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBars->state.Render();
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
|
||||
* Copyright (C) 2000 Christian Zander <phoenix@minion.de>
|
||||
* Copyright (C) 2015 Nedko Arnaudov
|
||||
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
|
||||
* Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -48,53 +48,29 @@ void draw_rectangle(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2,
|
|||
}
|
||||
|
||||
static inline
|
||||
void draw_bar(GLenum mode, GLfloat x_offset, GLfloat z_offset, GLfloat height, GLfloat red, GLfloat green, GLfloat blue)
|
||||
void draw_bar(GLfloat x_offset, GLfloat z_offset, GLfloat height, GLfloat red, GLfloat green, GLfloat blue)
|
||||
{
|
||||
const GLfloat width = 0.1;
|
||||
static constexpr const GLfloat width = 0.1;
|
||||
|
||||
if (mode == GL_POINT)
|
||||
glColor3f(0.2, 1.0, 0.2);
|
||||
// left
|
||||
glColor3f(0.25 * red, 0.25 * green, 0.25 * blue);
|
||||
draw_rectangle(x_offset, 0.0, z_offset , x_offset, height, z_offset + 0.1);
|
||||
|
||||
if (mode != GL_POINT)
|
||||
{
|
||||
glColor3f(red,green,blue);
|
||||
draw_rectangle(x_offset, height, z_offset, x_offset + width, height, z_offset + 0.1);
|
||||
}
|
||||
draw_rectangle(x_offset, 0, z_offset, x_offset + width, 0, z_offset + 0.1);
|
||||
// right
|
||||
glColor3f(0.5 * red, 0.5 * green, 0.5 * blue);
|
||||
draw_rectangle(x_offset, 0.0, z_offset + 0.1, x_offset + width, height, z_offset + 0.1);
|
||||
|
||||
if (mode != GL_POINT)
|
||||
{
|
||||
glColor3f(0.5 * red, 0.5 * green, 0.5 * blue);
|
||||
draw_rectangle(x_offset, 0.0, z_offset + 0.1, x_offset + width, height, z_offset + 0.1);
|
||||
}
|
||||
draw_rectangle(x_offset, 0.0, z_offset, x_offset + width, height, z_offset );
|
||||
|
||||
if (mode != GL_POINT)
|
||||
{
|
||||
glColor3f(0.25 * red, 0.25 * green, 0.25 * blue);
|
||||
draw_rectangle(x_offset, 0.0, z_offset , x_offset, height, z_offset + 0.1);
|
||||
}
|
||||
draw_rectangle(x_offset + width, 0.0, z_offset , x_offset + width, height, z_offset + 0.1);
|
||||
// top
|
||||
glColor3f(red, green, blue);
|
||||
draw_rectangle(x_offset, height, z_offset, x_offset + width, height, z_offset + 0.1);
|
||||
}
|
||||
|
||||
struct glBarsState {
|
||||
GLenum g_mode;
|
||||
GLfloat x_angle, x_speed;
|
||||
GLfloat y_angle, y_speed;
|
||||
GLfloat z_angle, z_speed;
|
||||
GLfloat heights[16][16], cHeights[16][16], scale;
|
||||
GLfloat hSpeed;
|
||||
|
||||
glBarsState()
|
||||
{
|
||||
g_mode = GL_FILL;
|
||||
x_angle = 20.0;
|
||||
x_speed = 0.0;
|
||||
y_angle = 15.0; // was 45
|
||||
y_speed = 0.5;
|
||||
z_angle = 0.0;
|
||||
z_speed = 0.0;
|
||||
|
||||
// Set "Bar Height"
|
||||
scale = 1.f / log(256.f); // "Default" / standard
|
||||
//scale = 2.f / log(256.f); // "Big"
|
||||
|
@ -109,35 +85,30 @@ struct glBarsState {
|
|||
//hSpeed = 0.2f; // "Very Fast"
|
||||
//hSpeed = 0.05f; // "Very Slow"
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
cHeights[y][x] = heights[y][x] = 0;
|
||||
}
|
||||
std::memset(heights, 0, sizeof(heights));
|
||||
std::memset(cHeights, 0, sizeof(cHeights));
|
||||
}
|
||||
|
||||
void drawBars()
|
||||
void Render()
|
||||
{
|
||||
GLfloat x_offset, z_offset, r_base, b_base;
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glPushMatrix();
|
||||
glTranslatef(0.0,-0.5,-5.0);
|
||||
glRotatef(x_angle,1.0,0.0,0.0);
|
||||
glRotatef(y_angle,0.0,1.0,0.0);
|
||||
glRotatef(z_angle,0.0,0.0,1.0);
|
||||
glTranslatef(0.0,0.25,-4.0);
|
||||
glRotatef(30.0,1.0,0.0,0.0);
|
||||
glRotatef(45,0.0,1.0,0.0);
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, g_mode);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
for (int y = 0; y < 16; y++)
|
||||
for (int y = 16; --y >= 0;)
|
||||
{
|
||||
z_offset = -1.6 + ((15 - y) * 0.2);
|
||||
|
||||
b_base = y * (1.0 / 15);
|
||||
r_base = 1.0 - b_base;
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int x = 16; --x >= 0;)
|
||||
{
|
||||
x_offset = -1.6 + ((float)x * 0.2);
|
||||
if (::fabs(cHeights[y][x]-heights[y][x])>hSpeed)
|
||||
|
@ -147,53 +118,17 @@ struct glBarsState {
|
|||
else
|
||||
cHeights[y][x] -= hSpeed;
|
||||
}
|
||||
draw_bar(g_mode, x_offset, z_offset,
|
||||
|
||||
draw_bar(x_offset, z_offset,
|
||||
cHeights[y][x], r_base - (float(x) * (r_base / 15.0)),
|
||||
(float)x * (1.0 / 15), b_base /*, 16*y+x*/);
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Render()
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glFrustum(-1, 1, -1, 1, 1.5, 10);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
//glPolygonMode(GL_FRONT, GL_FILL);
|
||||
//glPolygonMode(GL_BACK, GL_FILL);
|
||||
|
||||
x_angle += x_speed;
|
||||
if (x_angle >= 360.0)
|
||||
x_angle -= 360.0;
|
||||
|
||||
y_angle += y_speed;
|
||||
if (y_angle >= 360.0)
|
||||
y_angle -= 360.0;
|
||||
|
||||
z_angle += z_speed;
|
||||
if (z_angle >= 360.0)
|
||||
z_angle -= 360.0;
|
||||
|
||||
drawBars();
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
void AudioData(const float* pAudioData, int iAudioDataLength)
|
||||
{
|
||||
const int xscale[] = {0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 101, 137, 187, 255};
|
||||
|
|
|
@ -57,7 +57,7 @@ BASE_FLAGS += -UDEBUG
|
|||
endif
|
||||
|
||||
ifeq ($(HAVE_LIBLO),true)
|
||||
BASE_FLAGS += -DHAVE_LIBLO
|
||||
BASE_FLAGS += -DHAVE_LIBLO $(LIBLO_FLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(HEADLESS),true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue