filterview
This commit is contained in:
@@ -32,21 +32,15 @@ CrushView::CrushView()
|
|||||||
backgroundVertices.push_back(VertexTexture{{1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 1.0f}});
|
backgroundVertices.push_back(VertexTexture{{1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 1.0f}});
|
||||||
backgroundIndices = {0,1,2,1,2,3};
|
backgroundIndices = {0,1,2,1,2,3};
|
||||||
|
|
||||||
antialiasing.multisamplingLevel = 3;
|
|
||||||
ctx.setPixelFormat(antialiasing);
|
|
||||||
|
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
ctx.setContinuousRepainting(true);
|
|
||||||
ctx.setRenderer(this);
|
|
||||||
ctx.attachTo(*this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CrushView::~CrushView()
|
CrushView::~CrushView()
|
||||||
{
|
{
|
||||||
|
bgTexture.bind();
|
||||||
bgTexture.release();
|
bgTexture.release();
|
||||||
shaderProgram->release();
|
shaderProgram->release();
|
||||||
shaderProgramBackground->release();
|
shaderProgramBackground->release();
|
||||||
ctx.detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrushView::distortWaveForm(int samplerate){
|
void CrushView::distortWaveForm(int samplerate){
|
||||||
@@ -76,7 +70,13 @@ void CrushView::resized()
|
|||||||
|
|
||||||
void CrushView::newOpenGLContextCreated(){
|
void CrushView::newOpenGLContextCreated(){
|
||||||
|
|
||||||
|
// antialiasing.multisamplingLevel = 3;
|
||||||
|
// ctx.setPixelFormat(antialiasing);
|
||||||
|
|
||||||
background = juce::ImageCache::getFromMemory(BinaryData::panel_png, BinaryData::panel_pngSize);
|
background = juce::ImageCache::getFromMemory(BinaryData::panel_png, BinaryData::panel_pngSize);
|
||||||
|
printf("loaded bg\n");
|
||||||
|
background.duplicateIfShared();
|
||||||
|
printf("duplicatedBackground\n");
|
||||||
bgTexture.loadImage(background);
|
bgTexture.loadImage(background);
|
||||||
|
|
||||||
ctx.extensions.glGenBuffers(1, &vboBackground);
|
ctx.extensions.glGenBuffers(1, &vboBackground);
|
||||||
@@ -138,7 +138,6 @@ void CrushView::renderOpenGL(){
|
|||||||
ctx.extensions.glEnableVertexAttribArray(2);
|
ctx.extensions.glEnableVertexAttribArray(2);
|
||||||
|
|
||||||
juce::gl::glDrawElements(juce::gl::GL_TRIANGLES, backgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
juce::gl::glDrawElements(juce::gl::GL_TRIANGLES, backgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
||||||
bgTexture.unbind();
|
|
||||||
|
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vbo);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vbo);
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, ibo);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, ibo);
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CrushView)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CrushView)
|
||||||
juce::OpenGLContext ctx;
|
juce::OpenGLContext ctx;
|
||||||
juce::OpenGLPixelFormat antialiasing;
|
|
||||||
|
|
||||||
std::vector<Vertex> waveform;
|
std::vector<Vertex> waveform;
|
||||||
std::vector<Vertex> distortedWaveform;
|
std::vector<Vertex> distortedWaveform;
|
||||||
|
|||||||
@@ -8,20 +8,6 @@
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <JuceHeader.h>
|
|
||||||
#include "FilterView.h"
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
/*
|
|
||||||
* ==============================================================================
|
|
||||||
*
|
|
||||||
* FilterView.cpp
|
|
||||||
* Created: 16 Jan 2026 5:05:38pm
|
|
||||||
* Author: esca
|
|
||||||
*
|
|
||||||
* ==============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <JuceHeader.h>
|
#include <JuceHeader.h>
|
||||||
#include "FilterView.h"
|
#include "FilterView.h"
|
||||||
#include "BinaryData.h"
|
#include "BinaryData.h"
|
||||||
@@ -31,32 +17,81 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
FilterView::FilterView()
|
FilterView::FilterView()
|
||||||
{
|
{
|
||||||
float startingColour[4] = {128.0f, 255.0f, 255.0f, 255.0f};
|
cutoff = &tempcutoff;
|
||||||
|
mix = &tempmix;
|
||||||
|
//generate filter arrays for first time
|
||||||
|
for(unsigned int i=0; i<FILTERVIEW_SAMPLECOUNT; i++){
|
||||||
|
filterVertices.push_back(Vertex{{0,0}, COLOUR});
|
||||||
|
filterIndices.push_back(i);
|
||||||
|
|
||||||
|
filterBackgroundVertices.push_back(Vertex{{0,0}, BGCOLOUR});
|
||||||
|
|
||||||
|
//BACKGROUND INDICES
|
||||||
|
if(i!=0&&i%2==0){
|
||||||
|
filterBackgroundIndices.insert(filterBackgroundIndices.end(), { i-2, i-1, i });
|
||||||
|
}
|
||||||
|
|
||||||
backgroundVertices.push_back(VertexTexture{{-1, -1}, {255.0f, 255.0f, 255.0f, 255.0f}, {0.0f, 0.0f}});
|
if(i!=1&&i%2!=0){
|
||||||
backgroundVertices.push_back(VertexTexture{{-1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {0.0f, 1.0f}});
|
filterBackgroundIndices.insert(filterBackgroundIndices.end(), { i-2, i-1, i });
|
||||||
backgroundVertices.push_back(VertexTexture{{1, -1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 0.0f}});
|
}
|
||||||
backgroundVertices.push_back(VertexTexture{{1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 1.0f}});
|
}
|
||||||
backgroundIndices = {0,1,2,1,2,3};
|
genFilterArrays();
|
||||||
|
|
||||||
antialiasing.multisamplingLevel = 3;
|
float startingColour[4] = {128.0f, 255.0f, 255.0f, 255.0f};
|
||||||
ctx.setPixelFormat(antialiasing);
|
backgroundVertices.push_back(VertexTexture{{-1, -1}, {255.0f, 255.0f, 255.0f, 255.0f}, {0.0f, 0.0f}});
|
||||||
|
backgroundVertices.push_back(VertexTexture{{-1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {0.0f, 1.0f}});
|
||||||
|
backgroundVertices.push_back(VertexTexture{{1, -1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 0.0f}});
|
||||||
|
backgroundVertices.push_back(VertexTexture{{1, 1}, {255.0f, 255.0f, 255.0f, 255.0f}, {1.0f, 1.0f}});
|
||||||
|
backgroundIndices = {0,1,2,1,2,3};
|
||||||
|
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
ctx.setContinuousRepainting(true);
|
|
||||||
ctx.setRenderer(this);
|
|
||||||
ctx.attachTo(*this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterView::~FilterView()
|
FilterView::~FilterView()
|
||||||
{
|
{
|
||||||
|
bgTexture.bind();
|
||||||
bgTexture.release();
|
bgTexture.release();
|
||||||
shaderProgramFilter->release();
|
shaderProgramFilter->release();
|
||||||
shaderProgramFilterFill->release();
|
shaderProgramFilterFill->release();
|
||||||
shaderProgramBackground->release();
|
shaderProgramBackground->release();
|
||||||
ctx.detach();
|
// ctx.detach(); //failing here
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilterView::genFilterArrays(){
|
||||||
|
int i = 0;
|
||||||
|
float yposition = *mix;
|
||||||
|
for(Vertex &v : filterVertices){
|
||||||
|
float xposition = (float)i/FILTERVIEW_SAMPLECOUNT;
|
||||||
|
float deltaCutoff = xposition-*cutoff;
|
||||||
|
|
||||||
|
v.position[0] = xposition;
|
||||||
|
|
||||||
|
if(deltaCutoff>0){
|
||||||
|
v.position[1] = yposition-5*(deltaCutoff*deltaCutoff);
|
||||||
|
if(v.position[1]<0){
|
||||||
|
v.position[1]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else v.position[1] = yposition;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
vScale(filterVertices, 2, 2);
|
||||||
|
vTransform(filterVertices, -1, -1);
|
||||||
|
genFilterFillArrays();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilterView::genFilterFillArrays(){
|
||||||
|
for(unsigned int i = 0; i<FILTERVIEW_SAMPLECOUNT; i++){
|
||||||
|
|
||||||
|
if(i%2==0){
|
||||||
|
filterBackgroundVertices.at(i) = filterVertices.at(i);
|
||||||
|
filterBackgroundVertices.at(i).position[1]=-1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
filterBackgroundVertices.at(i) = filterVertices.at(i-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterView::paint (juce::Graphics& g)
|
void FilterView::paint (juce::Graphics& g)
|
||||||
@@ -74,8 +109,8 @@ void FilterView::resized()
|
|||||||
void FilterView::newOpenGLContextCreated(){
|
void FilterView::newOpenGLContextCreated(){
|
||||||
|
|
||||||
background = juce::ImageCache::getFromMemory(BinaryData::panel_png, BinaryData::panel_pngSize);
|
background = juce::ImageCache::getFromMemory(BinaryData::panel_png, BinaryData::panel_pngSize);
|
||||||
|
background.duplicateIfShared();
|
||||||
bgTexture.loadImage(background);
|
bgTexture.loadImage(background);
|
||||||
|
|
||||||
//GENERATE BUFFERS
|
//GENERATE BUFFERS
|
||||||
|
|
||||||
ctx.extensions.glGenBuffers(1, &vboBackground);
|
ctx.extensions.glGenBuffers(1, &vboBackground);
|
||||||
@@ -87,7 +122,6 @@ void FilterView::newOpenGLContextCreated(){
|
|||||||
ctx.extensions.glGenBuffers(1, &vboFilter);
|
ctx.extensions.glGenBuffers(1, &vboFilter);
|
||||||
ctx.extensions.glGenBuffers(1, &iboFilter);
|
ctx.extensions.glGenBuffers(1, &iboFilter);
|
||||||
|
|
||||||
|
|
||||||
//BIND BACKGROUND BUFFERS
|
//BIND BACKGROUND BUFFERS
|
||||||
|
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboBackground);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboBackground);
|
||||||
@@ -99,16 +133,23 @@ void FilterView::newOpenGLContextCreated(){
|
|||||||
//BIND FILTER FILL BUFFERS
|
//BIND FILTER FILL BUFFERS
|
||||||
|
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilterFill);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilterFill);
|
||||||
ctx.extensions.glBufferData(juce::gl::GL_ARRAY_BUFFER, sizeof(Vertex)*filterVertices.size(), filterVertices.data(), juce::gl::GL_STATIC_DRAW);
|
ctx.extensions.glBufferData(juce::gl::GL_ARRAY_BUFFER, sizeof(Vertex)*filterBackgroundVertices.size(), filterBackgroundVertices.data(), juce::gl::GL_STATIC_DRAW);
|
||||||
|
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, iboFilterFill);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, iboFilterFill);
|
||||||
|
ctx.extensions.glBufferData(juce::gl::GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * filterBackgroundIndices.size(), filterBackgroundIndices.data(), juce::gl::GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
//BIND FILTER BUFFERS
|
||||||
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilter);
|
||||||
|
ctx.extensions.glBufferData(juce::gl::GL_ARRAY_BUFFER, sizeof(Vertex)*filterVertices.size(), filterVertices.data(), juce::gl::GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, iboFilter);
|
||||||
ctx.extensions.glBufferData(juce::gl::GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * filterIndices.size(), filterIndices.data(), juce::gl::GL_STATIC_DRAW);
|
ctx.extensions.glBufferData(juce::gl::GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * filterIndices.size(), filterIndices.data(), juce::gl::GL_STATIC_DRAW);
|
||||||
|
|
||||||
//SHADERS
|
//SHADERS
|
||||||
vertexShaderFilter = "placeholder";
|
vertexShaderFilter = VERTEXSHADERFILTER;
|
||||||
fragmentShaderFilter = "placeholder";
|
fragmentShaderFilter = FRAGSHADERFILTER;
|
||||||
vertexShaderFilterFill = "placeholder";
|
vertexShaderFilterFill = VERTEXSHADERFILTERFILL;
|
||||||
fragmentShaderFilterFill = "placeholder";
|
fragmentShaderFilterFill = FRAGSHADERFILTER;
|
||||||
vertexShaderBackground = VERTEXSHADERBACKGROUND;
|
vertexShaderBackground = VERTEXSHADERBACKGROUND;
|
||||||
fragmentShaderBackground = FRAGSHADERBACKGROUND;
|
fragmentShaderBackground = FRAGSHADERBACKGROUND;
|
||||||
|
|
||||||
@@ -130,6 +171,7 @@ void FilterView::newOpenGLContextCreated(){
|
|||||||
shaderProgramFilter->addFragmentShader(fragmentShaderFilter);
|
shaderProgramFilter->addFragmentShader(fragmentShaderFilter);
|
||||||
shaderProgramFilter->link();
|
shaderProgramFilter->link();
|
||||||
shaderProgramFilter->use();
|
shaderProgramFilter->use();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterView::renderOpenGL(){
|
void FilterView::renderOpenGL(){
|
||||||
@@ -139,7 +181,6 @@ void FilterView::renderOpenGL(){
|
|||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboBackground);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboBackground);
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, iboBackground);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ELEMENT_ARRAY_BUFFER, iboBackground);
|
||||||
|
|
||||||
|
|
||||||
//RENDER BACKGROUND
|
//RENDER BACKGROUND
|
||||||
shaderProgramBackground->use();
|
shaderProgramBackground->use();
|
||||||
bgTexture.bind();
|
bgTexture.bind();
|
||||||
@@ -155,7 +196,6 @@ void FilterView::renderOpenGL(){
|
|||||||
ctx.extensions.glEnableVertexAttribArray(2);
|
ctx.extensions.glEnableVertexAttribArray(2);
|
||||||
|
|
||||||
juce::gl::glDrawElements(juce::gl::GL_TRIANGLES, backgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
juce::gl::glDrawElements(juce::gl::GL_TRIANGLES, backgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
||||||
bgTexture.unbind();
|
|
||||||
|
|
||||||
//RENDER FILTER FILL
|
//RENDER FILTER FILL
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilterFill);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilterFill);
|
||||||
@@ -166,7 +206,7 @@ void FilterView::renderOpenGL(){
|
|||||||
ctx.extensions.glEnableVertexAttribArray(2);
|
ctx.extensions.glEnableVertexAttribArray(2);
|
||||||
ctx.extensions.glVertexAttribPointer(1, 4, juce::gl::GL_FLOAT, juce::gl::GL_FALSE, sizeof(Vertex), (GLvoid*)(sizeof(float)*2));
|
ctx.extensions.glVertexAttribPointer(1, 4, juce::gl::GL_FLOAT, juce::gl::GL_FALSE, sizeof(Vertex), (GLvoid*)(sizeof(float)*2));
|
||||||
ctx.extensions.glEnableVertexAttribArray(3);
|
ctx.extensions.glEnableVertexAttribArray(3);
|
||||||
juce::gl::glDrawElements(juce::gl::GL_LINE_STRIP, filterBackgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
juce::gl::glDrawElements(juce::gl::GL_TRIANGLES, filterBackgroundIndices.size(), juce::gl::GL_UNSIGNED_INT, nullptr);
|
||||||
|
|
||||||
//RENDER FILTER
|
//RENDER FILTER
|
||||||
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilter);
|
ctx.extensions.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vboFilter);
|
||||||
@@ -183,4 +223,3 @@ void FilterView::renderOpenGL(){
|
|||||||
void FilterView::openGLContextClosing(){
|
void FilterView::openGLContextClosing(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,76 +16,155 @@
|
|||||||
#include "OpenGLUtils.h"
|
#include "OpenGLUtils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define CRUSHVIEW_SAMPLECOUNT 200
|
#define FILTERVIEW_SAMPLECOUNT 200
|
||||||
|
#define COLOUR {230, 230, 230, 1.0}
|
||||||
|
#define BGCOLOUR {255, 255, 255, 0.3}
|
||||||
|
|
||||||
#define VERTEXSHADERFILTERFILL R"(placeholder)"
|
|
||||||
|
|
||||||
#define FRAGSHADERFILTERFILL R"(placeholder)"
|
#define VERTEXSHADERFILTER R"(#version 330 core
|
||||||
|
in vec2 position;
|
||||||
|
in vec4 colour;
|
||||||
|
out vec4 fragcolour;
|
||||||
|
float bounds = 0.8;
|
||||||
|
float xmult;
|
||||||
|
float ymult;
|
||||||
|
|
||||||
#define VERTEXSHADERFILTER R"(placeholder)"
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(position, 1, 1);
|
||||||
|
fragcolour = colour;
|
||||||
|
if(position.x<-bounds){
|
||||||
|
xmult = (1/(1-bounds))*(position.x+1);
|
||||||
|
}
|
||||||
|
else if(position.x>bounds){
|
||||||
|
xmult= 1-(1/(1-bounds))*(position.x-bounds);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
xmult=1;
|
||||||
|
}
|
||||||
|
if(position.y<-bounds){
|
||||||
|
ymult = (1/(1-bounds))*(position.y+1);
|
||||||
|
}
|
||||||
|
else if(position.y>bounds){
|
||||||
|
ymult= 1-(1/(1-bounds))*(position.y-bounds);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ymult=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragcolour.a = xmult*ymult;
|
||||||
|
}
|
||||||
|
)"
|
||||||
|
|
||||||
|
#define VERTEXSHADERFILTERFILL R"(#version 330 core
|
||||||
|
in vec2 position;
|
||||||
|
in vec4 colour;
|
||||||
|
out vec4 fragcolour;
|
||||||
|
float bounds = 0.8;
|
||||||
|
float xmult;
|
||||||
|
float ymult;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(position, 1, 1);
|
||||||
|
fragcolour = colour;
|
||||||
|
if(position.x<-bounds){
|
||||||
|
xmult = (1/(1-bounds))*(position.x+1);
|
||||||
|
}
|
||||||
|
else if(position.x>bounds){
|
||||||
|
xmult= 1-(1/(1-bounds))*(position.x-bounds);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
xmult=1;
|
||||||
|
}
|
||||||
|
if(position.y<-bounds){
|
||||||
|
ymult = (1/(1-bounds))*(position.y+1);
|
||||||
|
}
|
||||||
|
else if(position.y>bounds){
|
||||||
|
ymult= 1-(1/(1-bounds))*(position.y-bounds);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ymult=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragcolour.a = 0.5*xmult*ymult;
|
||||||
|
}
|
||||||
|
)"
|
||||||
|
|
||||||
|
#define FRAGSHADERFILTER R"(#version 330 core
|
||||||
|
in vec4 fragcolour;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = fragcolour;
|
||||||
|
}
|
||||||
|
)"
|
||||||
|
|
||||||
#define FRAGSHADERFILTER R"(placeholder)"
|
|
||||||
|
|
||||||
|
|
||||||
class FilterView : public juce::Component, public juce::OpenGLRenderer
|
class FilterView : public juce::Component, public juce::OpenGLRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FilterView();
|
FilterView();
|
||||||
~FilterView() override;
|
~FilterView() override;
|
||||||
|
|
||||||
void renderFilter();
|
void renderFilter();
|
||||||
|
|
||||||
void newOpenGLContextCreated() override;
|
void newOpenGLContextCreated() override;
|
||||||
void renderOpenGL() override;
|
void renderOpenGL() override;
|
||||||
void openGLContextClosing() override;
|
void openGLContextClosing() override;
|
||||||
|
|
||||||
void paint (juce::Graphics&) override;
|
void paint (juce::Graphics&) override;
|
||||||
void resized() override;
|
void resized() override;
|
||||||
|
|
||||||
|
void genFilterArrays();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilterView)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilterView)
|
||||||
|
|
||||||
bool isLowPass;
|
void genFilterFillArrays();
|
||||||
float cutoff;
|
|
||||||
float mix;
|
|
||||||
|
|
||||||
juce::OpenGLContext ctx;
|
bool isLowPass;
|
||||||
juce::OpenGLPixelFormat antialiasing;
|
float *cutoff;
|
||||||
|
float *mix;
|
||||||
|
float tempcutoff = 0.5;
|
||||||
|
float tempmix = 0.5;
|
||||||
|
|
||||||
std::vector<Vertex> filterVertices;
|
juce::OpenGLContext ctx;
|
||||||
std::vector<unsigned int> filterIndices;
|
|
||||||
|
|
||||||
std::vector<Vertex> filterBackgroundVertices;
|
std::vector<Vertex> filterVertices;
|
||||||
std::vector<unsigned int> filterBackgroundIndices;
|
std::vector<unsigned int> filterIndices;
|
||||||
|
|
||||||
std::vector<VertexTexture> backgroundVertices;
|
std::vector<Vertex> filterBackgroundVertices;
|
||||||
std::vector<unsigned int> backgroundIndices;
|
std::vector<unsigned int> filterBackgroundIndices;
|
||||||
|
|
||||||
juce::ComponentListener listener;
|
std::vector<VertexTexture> backgroundVertices;
|
||||||
|
std::vector<unsigned int> backgroundIndices;
|
||||||
|
|
||||||
GLuint vboFilter;
|
juce::ComponentListener listener;
|
||||||
GLuint iboFilter;
|
|
||||||
|
|
||||||
GLuint vboFilterFill;
|
GLuint vboFilter;
|
||||||
GLuint iboFilterFill;
|
GLuint iboFilter;
|
||||||
|
|
||||||
GLuint vboBackground;
|
GLuint vboFilterFill;
|
||||||
GLuint iboBackground;
|
GLuint iboFilterFill;
|
||||||
|
|
||||||
std::string vertexShaderFilter;
|
GLuint vboBackground;
|
||||||
std::string fragmentShaderFilter;
|
GLuint iboBackground;
|
||||||
|
|
||||||
std::string vertexShaderFilterFill;
|
std::string vertexShaderFilter;
|
||||||
std::string fragmentShaderFilterFill;
|
std::string fragmentShaderFilter;
|
||||||
|
|
||||||
std::string vertexShaderBackground;
|
std::string vertexShaderFilterFill;
|
||||||
std::string fragmentShaderBackground;
|
std::string fragmentShaderFilterFill;
|
||||||
|
|
||||||
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramFilter;
|
std::string vertexShaderBackground;
|
||||||
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramFilterFill;
|
std::string fragmentShaderBackground;
|
||||||
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramBackground;
|
|
||||||
|
|
||||||
juce::Image background;
|
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramFilter;
|
||||||
juce::OpenGLTexture bgTexture;
|
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramFilterFill;
|
||||||
|
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgramBackground;
|
||||||
|
|
||||||
|
juce::Image background;
|
||||||
|
juce::OpenGLTexture bgTexture;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "OpenGLUtils.h"
|
#include "OpenGLUtils.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void svCol(Vertex &v, float newColour[4]){
|
void svCol(Vertex &v, float newColour[4]){
|
||||||
v.colour[0] = newColour[0];
|
v.colour[0] = newColour[0];
|
||||||
@@ -50,3 +51,13 @@ std::vector<Vertex> generateSineWave(int numVertices, float angle, float startin
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void printBufferData(std::vector<Vertex> vertices){
|
||||||
|
for(Vertex v: vertices){
|
||||||
|
std::cout << "V: ";
|
||||||
|
std::cout << v.position[0] << ", " << v.position[1] << ", ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,3 +64,5 @@ void vTransform(std::vector<Vertex> &verticeList, float x, float y);
|
|||||||
void vScale(std::vector<Vertex> & verticeList, float x, float y);
|
void vScale(std::vector<Vertex> & verticeList, float x, float y);
|
||||||
|
|
||||||
std::vector<Vertex> generateSineWave(int numVertices, float angle, float startingColour[4]);
|
std::vector<Vertex> generateSineWave(int numVertices, float angle, float startingColour[4]);
|
||||||
|
|
||||||
|
void printBufferData(std::vector<Vertex> vertices);
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
This file contains the basic framework code for a JUCE plugin editor.
|
this shit is held together by thoughts and prayers and i dont even pray
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BinaryData.h"
|
#include "BinaryData.h"
|
||||||
#include "FilterButtonLook.h"
|
#include "FilterButtonLook.h"
|
||||||
|
#include "FilterView.h"
|
||||||
#include "PluginProcessor.h"
|
#include "PluginProcessor.h"
|
||||||
#include "juce_gui_basics/juce_gui_basics.h"
|
#include "juce_gui_basics/juce_gui_basics.h"
|
||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
@@ -16,6 +17,17 @@
|
|||||||
CrushFXAudioProcessorEditor::CrushFXAudioProcessorEditor (CrushFXAudioProcessor& p)
|
CrushFXAudioProcessorEditor::CrushFXAudioProcessorEditor (CrushFXAudioProcessor& p)
|
||||||
: AudioProcessorEditor (&p), audioProcessor (p)
|
: AudioProcessorEditor (&p), audioProcessor (p)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ctxC.setRenderer(&crushView);
|
||||||
|
ctxC.attachTo(crushView);
|
||||||
|
|
||||||
|
ctxV.setRenderer(&filterView);
|
||||||
|
ctxV.attachTo(filterView);
|
||||||
|
|
||||||
|
antialiasing.multisamplingLevel = 3;
|
||||||
|
ctxC.setPixelFormat(antialiasing);
|
||||||
|
ctxV.setPixelFormat(antialiasing);
|
||||||
|
|
||||||
//images
|
//images
|
||||||
bg = juce::ImageCache::getFromMemory(BinaryData::BG_png, BinaryData::BG_pngSize);
|
bg = juce::ImageCache::getFromMemory(BinaryData::BG_png, BinaryData::BG_pngSize);
|
||||||
dialLookandFeel.setImage();
|
dialLookandFeel.setImage();
|
||||||
@@ -26,8 +38,10 @@ CrushFXAudioProcessorEditor::CrushFXAudioProcessorEditor (CrushFXAudioProcessor&
|
|||||||
addAndMakeVisible(dial2);
|
addAndMakeVisible(dial2);
|
||||||
addAndMakeVisible(crushSlider);
|
addAndMakeVisible(crushSlider);
|
||||||
addAndMakeVisible(filterButton);
|
addAndMakeVisible(filterButton);
|
||||||
|
addAndMakeVisible(filterView);
|
||||||
addAndMakeVisible(crushView);
|
addAndMakeVisible(crushView);
|
||||||
|
|
||||||
|
|
||||||
//styling
|
//styling
|
||||||
dial1.setLookAndFeel(&dialLookandFeel);
|
dial1.setLookAndFeel(&dialLookandFeel);
|
||||||
dial1.setSliderStyle(juce::Slider::SliderStyle::Rotary);
|
dial1.setSliderStyle(juce::Slider::SliderStyle::Rotary);
|
||||||
@@ -54,17 +68,24 @@ CrushFXAudioProcessorEditor::CrushFXAudioProcessorEditor (CrushFXAudioProcessor&
|
|||||||
|
|
||||||
CrushFXAudioProcessorEditor::~CrushFXAudioProcessorEditor()
|
CrushFXAudioProcessorEditor::~CrushFXAudioProcessorEditor()
|
||||||
{
|
{
|
||||||
|
printf("detaching\n");
|
||||||
|
ctxC.detach();
|
||||||
|
ctxV.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void CrushFXAudioProcessorEditor::paint (juce::Graphics& g)
|
void CrushFXAudioProcessorEditor::paint (juce::Graphics& g)
|
||||||
{
|
{
|
||||||
g.drawImageAt(bg, 0,0);
|
g.drawImageAt(bg, 0,0);
|
||||||
|
ctxC.triggerRepaint();
|
||||||
|
ctxV.triggerRepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrushFXAudioProcessorEditor::resized()
|
void CrushFXAudioProcessorEditor::resized()
|
||||||
{
|
{
|
||||||
crushView.setBounds(408, 11, 393, 273);
|
crushView.setBounds(408, 11, 393, 273);
|
||||||
|
filterView.setBounds(11, 11, 393, 273);
|
||||||
|
|
||||||
dial1.setBounds(269, 287, 55, 56);
|
dial1.setBounds(269, 287, 55, 56);
|
||||||
dial2.setBounds(331, 287, 55, 56);
|
dial2.setBounds(331, 287, 55, 56);
|
||||||
crushSlider.setBounds(578, 293, 205, 43);
|
crushSlider.setBounds(578, 293, 205, 43);
|
||||||
|
|||||||
@@ -11,10 +11,12 @@
|
|||||||
#include <JuceHeader.h>
|
#include <JuceHeader.h>
|
||||||
#include "CrushSliderLook.h"
|
#include "CrushSliderLook.h"
|
||||||
#include "FilterButtonLook.h"
|
#include "FilterButtonLook.h"
|
||||||
|
#include "FilterView.h"
|
||||||
#include "PluginProcessor.h"
|
#include "PluginProcessor.h"
|
||||||
#include "juce_gui_basics/juce_gui_basics.h"
|
#include "juce_gui_basics/juce_gui_basics.h"
|
||||||
#include "DialLook.h"
|
#include "DialLook.h"
|
||||||
#include "CrushView.h"
|
#include "CrushView.h"
|
||||||
|
#include "juce_opengl/juce_opengl.h"
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@@ -29,8 +31,13 @@ public:
|
|||||||
void resized() override;
|
void resized() override;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
FilterView filterView;
|
||||||
CrushView crushView;
|
CrushView crushView;
|
||||||
|
|
||||||
|
juce::OpenGLContext ctxC;
|
||||||
|
juce::OpenGLContext ctxV;
|
||||||
|
juce::OpenGLPixelFormat antialiasing;
|
||||||
|
|
||||||
DialLook dialLookandFeel;
|
DialLook dialLookandFeel;
|
||||||
juce::Slider dial1;
|
juce::Slider dial1;
|
||||||
juce::Slider dial2;
|
juce::Slider dial2;
|
||||||
|
|||||||
Reference in New Issue
Block a user