Working on music cross fade and settings
This commit is contained in:
1 parent
84f9fa37a8
commit
b8d79c7b7b
13 files changed
+779
-332
No files matched your search
+17
-13
@@ -327,16 +327,16 @@ namespace ZL {
|
||||
knobMesh.data.PositionData.clear();
|
||||
knobMesh.data.TexCoordData.clear();
|
||||
|
||||
float kw = vertical ? rect.w * 4.0f : rect.w * 0.5f;
|
||||
float kh = vertical ? rect.w * 4.0f : rect.h * 0.5f;
|
||||
|
||||
float cx = rect.x + rect.w * 0.5f;
|
||||
float cy = rect.y + (vertical ? (value * rect.h) : (rect.h * 0.5f));
|
||||
|
||||
float x0 = cx - kw * 0.5f;
|
||||
float y0 = cy - kh * 0.5f;
|
||||
float x1 = cx + kw * 0.5f;
|
||||
float y1 = cy + kh * 0.5f;
|
||||
// Knob is built centered at the middle of the track rect.
|
||||
// draw() applies a per-frame translation so the knob tracks the current value
|
||||
// without needing to rebuild the VBO on every value change.
|
||||
const float kSize = vertical ? rect.w * 2.0f : rect.h;
|
||||
const float cx = rect.x + rect.w * 0.5f;
|
||||
const float cy = rect.y + rect.h * 0.5f;
|
||||
const float x0 = cx - kSize * 0.5f;
|
||||
const float y0 = cy - kSize * 0.5f;
|
||||
const float x1 = cx + kSize * 0.5f;
|
||||
const float y1 = cy + kSize * 0.5f;
|
||||
|
||||
knobMesh.data.PositionData.push_back({ x0, y0, 0 });
|
||||
knobMesh.data.TexCoordData.push_back({ 0, 0 });
|
||||
@@ -366,8 +366,15 @@ namespace ZL {
|
||||
renderer.DrawVertexRenderStruct(trackMesh);
|
||||
}
|
||||
if (texKnob) {
|
||||
// The knob mesh is built centered at the middle of the track rect.
|
||||
// Translate it so its center lands on the value position along the track.
|
||||
const float offsetX = vertical ? 0.0f : (value - 0.5f) * rect.w;
|
||||
const float offsetY = vertical ? (value - 0.5f) * rect.h : 0.0f;
|
||||
renderer.PushMatrix();
|
||||
renderer.TranslateMatrix({ offsetX, offsetY, 0.0f });
|
||||
glBindTexture(GL_TEXTURE_2D, texKnob->getTexID());
|
||||
renderer.DrawVertexRenderStruct(knobMesh);
|
||||
renderer.PopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1301,7 +1308,6 @@ namespace ZL {
|
||||
if (fabs(s->value - value) < 1e-6f) return true;
|
||||
s->value = value;
|
||||
s->buildTrackMesh();
|
||||
s->buildKnobMesh();
|
||||
if (s->onValueChanged) s->onValueChanged(s->name, s->value);
|
||||
return true;
|
||||
}
|
||||
@@ -1796,7 +1802,6 @@ namespace ZL {
|
||||
if (t > 1.0f) t = 1.0f;
|
||||
s->value = t;
|
||||
s->buildTrackMesh();
|
||||
s->buildKnobMesh();
|
||||
if (s->onValueChanged) s->onValueChanged(s->name, s->value);
|
||||
}
|
||||
}
|
||||
@@ -1843,7 +1848,6 @@ namespace ZL {
|
||||
if (t > 1.0f) t = 1.0f;
|
||||
s->value = t;
|
||||
s->buildTrackMesh();
|
||||
s->buildKnobMesh();
|
||||
if (s->onValueChanged) s->onValueChanged(s->name, s->value);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user