Skip to content

Commit

Permalink
Got rid of the textureless shader program finally.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Dec 12, 2024
1 parent 96d94a5 commit 86d5591
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 514 deletions.
31 changes: 15 additions & 16 deletions FinModelUtility/Fin/Fin.Ui/src/rendering/gl/AotWaveformRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
using fin.math;
using fin.model;
using fin.model.impl;
using fin.ui.rendering.gl.model;

using OpenTK.Graphics.OpenGL;

using LogicOp = fin.model.LogicOp;
using PrimitiveType = fin.model.PrimitiveType;

namespace fin.ui.rendering.gl;

public class AotWaveformRenderer {
private IReadOnlyList<NormalTangentMultiColorMultiUvVertexImpl> vertices_;
private IDynamicGlBufferManager bufferManager_;
private IGlBufferRenderer bufferRenderer_;
private IDynamicModelRenderer renderer_;

public IAotAudioPlayback<short>? ActivePlayback { get; set; }

Expand All @@ -29,14 +30,15 @@ public void Render() {

if (this.vertices_ == null) {
var model = ModelImpl.CreateForViewer(1000);

var material = model.MaterialManager.AddColorMaterial(Color.Red);

var skin = model.Skin;

this.vertices_ = skin.TypedVertices;
skin.AddMesh().AddLineStrip(this.vertices_).SetMaterial(material);

this.bufferManager_ = GlBufferManager.CreateDynamic(model);
this.bufferRenderer_
= this.bufferManager_.CreateRenderer(PrimitiveType.LINE_STRIP,
this.vertices_);
this.renderer_ = ModelRendererV2.CreateDynamic(model);
}

var source = this.ActivePlayback.TypedSource;
Expand Down Expand Up @@ -87,9 +89,11 @@ var baseSampleOffset
floatMin + normalizedShortSample * (floatMax - floatMin);

var x = i * xPerPoint;
var y = this.MiddleY + this.Amplitude * fraction *
MathF.Sign(floatSample) *
MathF.Pow(MathF.Abs(floatSample), .8f);
var y = this.MiddleY +
this.Amplitude *
fraction *
MathF.Sign(floatSample) *
MathF.Pow(MathF.Abs(floatSample), .8f);
this.vertices_[i].SetLocalPosition(x, y, 0);
}

Expand All @@ -101,13 +105,8 @@ var baseSampleOffset
}
}

GlTransform.PassMatricesIntoGl();

GL.LineWidth(1);
GlUtil.SetBlendColor(Color.Red);
GlUtil.SetBlending(BlendEquation.ADD, BlendFactor.CONST_COLOR, BlendFactor.SRC_ALPHA);

this.bufferManager_.UpdateBuffer();
this.bufferRenderer_.Render();
this.renderer_.UpdateBuffer();
this.renderer_.Render();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ namespace fin.ui.rendering.gl.model;
public interface IModelRenderer : IRenderable, IDisposable {
IReadOnlyModel Model { get; }
IReadOnlySet<IReadOnlyMesh>? HiddenMeshes { get; set; }
}

public interface IDynamicModelRenderer : IModelRenderer {
void UpdateBuffer();
}

This file was deleted.

Loading

0 comments on commit 86d5591

Please sign in to comment.