|
From: Tapio V. <aa...@us...> - 2010-11-07 20:32:00
|
Module: performous
Branch: opengl2
Commit: d3a18ed135513665931440d787cce409a443b2ac
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 7 22:30:42 2010 +0200
Vertex shader now handles dance note positioning instead of glTranslatef.
---
game/dancegraph.cc | 14 ++++----------
themes/default/shaders/dancenote.vert | 4 +++-
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 7488dc0..2afc030 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -433,12 +433,9 @@ void DanceGraph::draw(double time) {
.setUniform("noteType", 0)
.setUniform("scale", getScale());
for (int arrow_i = 0; arrow_i < m_pads; ++arrow_i) {
- float x = panel2x(arrow_i);
- float y = time2y(0.0);
float l = m_pressed_anim[arrow_i].get();
- us().setUniform("hitAnim", float(l));
- glutil::PushMatrix pm;
- glTranslatef(x, y, 0.0f);
+ us().setUniform("hitAnim", l)
+ .setUniform("position", panel2x(arrow_i), time2y(0.0));
drawArrow(arrow_i, m_arrows_cursor);
}
}
@@ -494,7 +491,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
double glow = note.hitAnim.get();
{
- glutil::PushMatrix pm;
UseShader us(*DanceGraph::shader_note);
us().setUniform("hitAnim", float(glow))
.setUniform("clock", float(time))
@@ -502,13 +498,12 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
if (yEnd - yBeg > arrowSize) {
// Draw holds
- us().setUniform("noteType", 2);
if (note.isHit && note.releaseTime <= 0) { // The note is being held down
yBeg = std::max(time2y(0.0), yBeg);
yEnd = std::max(time2y(0.0), yEnd);
}
if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time); // Oh noes, it got released!
- glTranslatef(x, yBeg, 0.0f); // Move to place
+ us().setUniform("noteType", 2).setUniform("position", x, yBeg);
// Draw begin
drawArrow(arrow_i, m_arrows_hold, 0.0f, 1.0f/3.0f);
if (yEnd - yBeg > 0) {
@@ -525,9 +520,8 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
}
} else {
// Draw short note
- us().setUniform("noteType", (mine ? 3 : 1));
if (mine && note.isHit) yBeg = time2y(0.0);
- glTranslatef(x, yBeg, 0.0f); // Move to place
+ us().setUniform("noteType", (mine ? 3 : 1)).setUniform("position", x, yBeg);
drawArrow((mine ? -1 : arrow_i), (mine ? m_mine : m_arrows));
}
}
diff --git a/themes/default/shaders/dancenote.vert b/themes/default/shaders/dancenote.vert
index 0b1be7c..60a4d61 100644
--- a/themes/default/shaders/dancenote.vert
+++ b/themes/default/shaders/dancenote.vert
@@ -2,6 +2,7 @@ uniform int noteType;
uniform float hitAnim;
uniform float clock;
uniform float scale;
+uniform vec2 position;
#define deg2rad 0.0174532925
@@ -45,10 +46,11 @@ void main()
// Mines
} else if (noteType == 3) {
trans *= scaleMat(1.0 + hitAnim);
- float r = (int(clock*360) % 360) * deg2rad; // They rotate!
+ float r = float(mod(int(clock*360), 360)) * deg2rad; // They rotate!
trans *= rotMat(r);
}
gl_Position = gl_ModelViewProjectionMatrix * trans * gl_Vertex;
+ gl_Position += gl_ModelViewProjectionMatrix * vec4(position.xy, 0, 0);
}
|