You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 01:45:19
|
Module: performous Branch: opengl2 Commit: a136b2ee85144bed84ee983860dce0ba3b398022 Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Mon Feb 7 02:43:12 2011 +0100 Better diagnostics for shader compile errors. --- game/glshader.cc | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/game/glshader.cc b/game/glshader.cc index 9c30e5b..fe6bd3b 100644 --- a/game/glshader.cc +++ b/game/glshader.cc @@ -62,7 +62,11 @@ Shader& Shader::compileFile(std::string const& filename, std::string const& defi if (pos == std::string::npos) throw std::runtime_error("Shader " + filename + " missing //DEFINES (needed for injected code)"); srccode = srccode.substr(0, pos) + defines + srccode.substr(pos + 9); } - return compileCode(srccode, type); + try { + compileCode(srccode, type); + } catch (std::runtime_error& e) { + throw std::runtime_error(filename + ": " + e.what()); + } } @@ -75,10 +79,11 @@ Shader& Shader::compileCode(std::string const& srccode, GLenum type) { ec.check("glShaderSource"); glCompileShader(new_shader); + ec.check("glCompileShader"); glGetShaderiv(new_shader, GL_COMPILE_STATUS, &gl_response); if (gl_response != GL_TRUE) { dumpInfoLog(new_shader); - throw std::runtime_error("Something went wrong compiling the shader."); + throw std::runtime_error("Shader compile error"); } shader_ids.push_back(new_shader); |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 00:45:24
|
Module: performous Branch: opengl2 Commit: 9d7608e901302824c2f812e2ea03889633a5ce39 Author: Lasse Karkkainen <tro...@tr...> Date: Mon Feb 7 01:44:25 2011 +0100 Three-layered song browser theme, rotated cover images. --- game/screen_songs.cc | 19 ++- game/screen_songs.hh | 3 +- themes/default/songs_bg.svg | 23 ++-- themes/default/songs_bg_default.svg | 47 +++++-- themes/default/songs_bg_ground.svg | 260 +++++++++++++++++++++++++++++++++++ 5 files changed, 319 insertions(+), 33 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 00:45:21
|
Module: performous Branch: opengl2 Commit: 0608e9eee182e78178fd3f06bb933aa6529ec5ca Author: Lasse Karkkainen <tro...@tr...> Date: Mon Feb 7 00:19:48 2011 +0100 Make Surface::load only adjust dimensions when the aspect ratio hasn't been defined before. --- game/surface.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/game/surface.cc b/game/surface.cc index 77da12b..674cf22 100644 --- a/game/surface.cc +++ b/game/surface.cc @@ -125,7 +125,7 @@ void Surface::load(unsigned int width, unsigned int height, pix::Format format, using namespace pix; // Initialize dimensions m_width = width; m_height = height; - dimensions = Dimensions(ar != 0.0f ? ar : float(width) / height).fixedWidth(1.0f); + if (dimensions.ar() == 0.0) dimensions = Dimensions(ar != 0.0f ? ar : float(width) / height).fixedWidth(1.0f); // Load the data into texture UseTexture texture(m_texture); PixFmt const& f = getPixFmt(format); |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 00:45:19
|
Module: performous
Branch: opengl2
Commit: 86c8a3df624212a038776e064f0bddcf4b5801cb
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Feb 7 00:18:56 2011 +0100
Fix view setup so that non-stereo doesn't render left eye.
---
game/video_driver.cc | 23 +++++++++--------------
game/video_driver.hh | 7 +++----
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 3c8a3fc..0e1b458 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -123,7 +123,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
for (unsigned i = 0; i < 2; ++i) {
UseFBO user(*fbo[i]);
glViewport(0, 0, w, h); // Full FBO
- view(i);
+ view(i + 1);
drawFunc();
}
// Render to actual framebuffer from FBOs
@@ -177,7 +177,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
}
}
-bool Window::view(unsigned num) {
+void Window::view(unsigned num) {
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
@@ -202,18 +202,13 @@ bool Window::view(unsigned num) {
* translate(Vec3(0.0, 0.0, -z0))
);
// Setup views
- bool stereo = config["graphic/stereo3d"].b();
- if (stereo) {
- if (num > 1) return false;
- double separation = (num == 0 ? -1 : 1) * getSeparation();
- glMatrixMode(GL_PROJECTION);
- glTranslatef(separation, 0.0f, 0.0f);
- glMatrixMode(GL_MODELVIEW);
- glTranslatef(-separation, 0.0f, 0.0f);
- } else {
- if (num != 0) return false;
- }
- return true;
+ if (num == 0) return; // Center (non-stereo)
+ // Stereo separation
+ double separation = (num == 1 ? -1 : 1) * getSeparation();
+ glMatrixMode(GL_PROJECTION);
+ glTranslatef(separation, 0.0f, 0.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(-separation, 0.0f, 0.0f);
}
void Window::swap() {
diff --git a/game/video_driver.hh b/game/video_driver.hh
index d9e4209..3546219 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -27,10 +27,6 @@ public:
/// destructor
~Window();
void render(boost::function<void (void)> drawFunc);
- /// Setup everything for drawing a view.
- /// @param num should be 0 the first time each frame then incremented for each additional view
- /// @returns true if the view should be rendered, false if no more views are available
- bool view(unsigned num);
/// clears window
void blank();
/// swaps buffers
@@ -57,6 +53,9 @@ public:
/// Construct a new shader or return an existing one by name
Shader& shader(std::string const& name) { return m_shaders[name]; }
private:
+ /// Setup everything for drawing a view.
+ /// @param num 0 = no stereo, 1 = left eye, 2 = right eye
+ void view(unsigned num);
SDL_Surface* screen;
unsigned int m_windowW, m_windowH;
unsigned int m_fsW, m_fsH;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-07 00:45:16
|
Module: performous
Branch: opengl2
Commit: 9602a1c9fd54a8d586c491ec483d08e45cebb37b
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 22:37:10 2011 +0100
Perspective-correct curvy cover browser.
* Still b0rked z ordering between covers and song info window
---
game/screen_songs.cc | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 458d32d..17b38d1 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -252,13 +252,13 @@ void ScreenSongs::drawCovers() {
Song& song = m_songs[baseidx + i];
Surface& s = getCover(song);
// Calculate dimensions for cover and instrument markers
- double diff = (i == 0 ? 2.0 * (0.5 - fabs(shift)) : 0.0); // 0..1 for current cover hilight level
- double y = 0.26;
+ double diff = 0.5 * (1.0 + std::cos(std::min(M_PI, std::abs(i - shift)))); // 0..1 for current cover hilight level
+ double y = 0.5 * virtH();
glutil::PushMatrix pm;
- glTranslatef(0.0f, 0.0f, -0.05 * (1.0 - diff)); // Move other covers further back
- double c = 0.6 + 0.4 * diff;
- glColor3f(c, c, c);
- s.dimensions.middle(-0.2 + 0.17 * (i - shift)).bottom(y - 0.01 * diff).fitInside(0.15, 0.15);
+ glTranslatef(0.0f, 0.0f, -0.2 - 0.2 * (1.0 - diff)); // Move other covers further back
+ double c = 0.4 + 0.6 * diff;
+ glutil::Color c1(Color(c, c, c));
+ s.dimensions.middle(-0.2 + 0.20 * (i - shift)).bottom(y - 0.0 * diff).fitInside(0.17, 0.17);
// Draw the cover normally
s.draw();
// Draw the reflection
@@ -266,7 +266,7 @@ void ScreenSongs::drawCovers() {
glTranslatef(0.0f, 2.0 * y, 0.0f);
glScalef(1.0f, -1.0f, 1.0f);
{
- glutil::Color c(Color(1.0f, 1.0f, 1.0f, 0.4f));
+ glutil::Color c2(Color(1.0f, 1.0f, 1.0f, 0.4f));
s.draw();
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 21:24:03
|
Module: performous
Branch: opengl2
Commit: 3bb222da91892f1e188680242f2f5f7f45ab05fd
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 22:23:52 2011 +0100
Fix intro screen color effect.
---
game/screen_intro.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 2eff166..90735bb 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -117,6 +117,7 @@ void ScreenIntro::draw() {
{
float anim = SDL_GetTicks() % 20000 / 20000.0;
Shader& sh = theme->bg.shader();
+ sh.bind();
sh.setUniformMatrix("colorMatrix", glmath::rotate(2.0 * M_PI * anim, glmath::Vec3(1.0, 1.0, 1.0)));
theme->bg.draw();
sh.setUniformMatrix("colorMatrix", glmath::Matrix());
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 21:02:17
|
Module: performous
Branch: opengl2
Commit: 7045ca120773edff9e494dc08637675a70abef15
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 22:02:05 2011 +0100
Fix dance mode. Shader slightly optimized.
---
game/dancegraph.cc | 19 ++++++++++-
game/video_driver.cc | 4 ++
themes/default/shaders/dancenote.frag | 30 +++++++++++++++++
themes/default/shaders/dancenote.vert | 56 +++++++++++++++++++++++++++++++++
4 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 2cf3d9f..ee29f98 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -392,7 +392,8 @@ namespace {
/// Draw a dance pad icon using the given texture
void DanceGraph::drawArrow(int arrow_i, Texture& tex, float ty1, float ty2) {
- UseTexture tblock(tex);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(tex.type(), tex.id());
glutil::VertexArray va;
vertexPair(va, arrow_i, -arrowSize, ty1);
vertexPair(va, arrow_i, arrowSize, ty2);
@@ -426,8 +427,14 @@ void DanceGraph::draw(double time) {
// Arrows on cursor
{
+ UseShader us(getShader("dancenote"));
+ us().setUniform("clock", float(time))
+ .setUniform("noteType", 0)
+ .setUniform("scale", getScale());
for (int arrow_i = 0; arrow_i < m_pads; ++arrow_i) {
float l = m_pressed_anim[arrow_i].get();
+ us().setUniform("hitAnim", l)
+ .setUniform("position", panel2x(arrow_i), time2y(0.0));
drawArrow(arrow_i, m_arrows_cursor);
}
}
@@ -483,6 +490,11 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
double glow = note.hitAnim.get();
{
+ UseShader us(getShader("dancenote"));
+ us().setUniform("hitAnim", float(glow))
+ .setUniform("clock", float(time))
+ .setUniform("scale", getScale());
+
if (yEnd - yBeg > arrowSize) {
// Draw holds
if (note.isHit && note.releaseTime <= 0) { // The note is being held down
@@ -490,10 +502,12 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
yEnd = std::max(time2y(0.0), yEnd);
}
if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time); // Oh noes, it got released!
+ 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) {
- UseTexture tblock(m_arrows_hold);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(m_arrows_hold.type(), m_arrows_hold.id());
glutil::VertexArray va;
// Middle
vertexPair(va, arrow_i, arrowSize, 1.0f/3.0f);
@@ -507,6 +521,7 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
} else {
// Draw short note
if (mine && note.isHit) yBeg = time2y(0.0);
+ us().setUniform("noteType", (mine ? 3 : 1)).setUniform("position", x, yBeg);
drawArrow((mine ? -1 : arrow_i), (mine ? m_mine : m_arrows));
}
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index ea238da..3c8a3fc 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -87,6 +87,10 @@ Window::Window(unsigned int width, unsigned int height, bool fs): m_windowW(widt
.compileFile(getThemePath("shaders/3dobject.vert"))
.compileFile(getThemePath("shaders/3dobject.frag"))
.link();
+ shader("dancenote")
+ .compileFile(getThemePath("shaders/dancenote.vert"))
+ .compileFile(getThemePath("shaders/dancenote.frag"))
+ .link();
}
Window::~Window() { }
diff --git a/themes/default/shaders/dancenote.frag b/themes/default/shaders/dancenote.frag
new file mode 100644
index 0000000..d60579d
--- /dev/null
+++ b/themes/default/shaders/dancenote.frag
@@ -0,0 +1,30 @@
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2D tex;
+uniform int noteType;
+uniform float hitAnim;
+uniform float clock;
+uniform float scale;
+
+
+void colorGlow(inout vec4 c) {
+ c = vec4(
+ min(c.r + hitAnim *.5, 1.0),
+ min(c.g + hitAnim *.5, 1.0),
+ min(c.b + hitAnim *.5, 1.0),
+ max(c.a - hitAnim, 0.0));
+}
+
+
+void main()
+{
+ vec4 texel;
+
+ texel = texture2D(tex, gl_TexCoord[0].st).rgba;
+
+ // Regular arrows or holds
+ if (noteType == 1 || noteType == 2) colorGlow(texel);
+
+ gl_FragColor = texel;
+}
+
diff --git a/themes/default/shaders/dancenote.vert b/themes/default/shaders/dancenote.vert
new file mode 100644
index 0000000..3573391
--- /dev/null
+++ b/themes/default/shaders/dancenote.vert
@@ -0,0 +1,56 @@
+uniform int noteType;
+uniform float hitAnim;
+uniform float clock;
+uniform float scale;
+uniform vec2 position;
+
+#define deg2rad 0.0174532925
+
+mat4 scaleMat(in float sc) {
+ return mat4(sc, 0, 0, 0,
+ 0, sc, 0, 0,
+ 0, 0, sc, 0,
+ 0, 0, 0, 1);
+}
+
+mat4 rotMat(in float ang) {
+ float ca = cos(ang);
+ float sa = sin(ang);
+ return mat4(ca, -sa, 0, 0,
+ sa, ca, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+}
+
+
+void main()
+{
+ gl_FrontColor = gl_Color;
+ gl_BackColor = gl_Color;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ mat4 trans = scaleMat(scale);
+
+ // Cursor arrows
+ if (noteType == 0) {
+ trans *= scaleMat(1.0 - hitAnim * .5);
+
+ // Regular arrows
+ } else if (noteType == 1) {
+ trans *= scaleMat(1.0 + hitAnim);
+
+ // Holds
+ } else if (noteType == 2) {
+ trans *= scaleMat(1.0 + hitAnim);
+
+ // Mines
+ } else if (noteType == 3) {
+ trans *= scaleMat(1.0 + hitAnim);
+ float r = float(mod(int(clock*360.0), 360)) * deg2rad; // They rotate!
+ trans *= rotMat(r);
+ }
+
+ gl_Position = gl_ModelViewProjectionMatrix * trans * gl_Vertex;
+ gl_Position += gl_ModelViewProjectionMatrix * vec4(position.xy, 0, 0);
+}
+
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 20:38:51
|
Module: performous
Branch: opengl2
Commit: 2296fe1e6c97d0566647af3c3b13bffbffc5dd61
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 21:35:36 2011 +0100
Fix all shaders.
* 3dobject shader is now in Window & 3dobject
* Removed unused shader files
* Removed all mention of shaders in guitar/dancegraph
Regression: dance note effects removed
* Can be done with colorMatrix (much faster)
* Quite possibly moving to 3d objects instead of flat arrows
---
game/3dobject.hh | 1 +
game/dancegraph.cc | 15 ---------
game/guitargraph.cc | 6 ---
game/instrumentgraph.hh | 4 --
game/video_driver.cc | 4 ++
themes/default/shaders/3dobject.frag | 2 -
themes/default/shaders/dancenote.frag | 55 --------------------------------
themes/default/shaders/dancenote.vert | 56 ---------------------------------
themes/default/shaders/intro.frag | 28 ----------------
themes/default/shaders/intro.vert | 7 ----
10 files changed, 5 insertions(+), 173 deletions(-)
diff --git a/game/3dobject.hh b/game/3dobject.hh
index ef99f11..bef24e5 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -67,6 +67,7 @@ class Object3d: boost::noncopyable {
void drawVBO();
/// draws the object
void draw(float x = 0, float y = 0, float z = 0, float s = 1.0) {
+ UseShader us(getShader("3dobject"));
glutil::PushMatrix pm;
glTranslatef(x, y, z); // Move to position
if (s != 1.0) glScalef(s,s,s); // Scale if needed
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index f3393dc..2cf3d9f 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -90,8 +90,6 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_flow_direction(1),
m_insideStop()
{
- m_shader_note.reset(new Shader);
- m_shader_note->compileFile(getThemePath("shaders/dancenote.vert")).compileFile(getThemePath("shaders/dancenote.frag")).link();
// Initialize some arrays
for (size_t i = 0; i < max_panels; i++) {
m_activeNotes[i] = m_notes.end();
@@ -428,14 +426,8 @@ void DanceGraph::draw(double time) {
// Arrows on cursor
{
- UseShader us(*m_shader_note);
- us().setUniform("clock", float(time))
- .setUniform("noteType", 0)
- .setUniform("scale", getScale());
for (int arrow_i = 0; arrow_i < m_pads; ++arrow_i) {
float l = m_pressed_anim[arrow_i].get();
- us().setUniform("hitAnim", l)
- .setUniform("position", panel2x(arrow_i), time2y(0.0));
drawArrow(arrow_i, m_arrows_cursor);
}
}
@@ -491,11 +483,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
double glow = note.hitAnim.get();
{
- UseShader us(*m_shader_note);
- us().setUniform("hitAnim", float(glow))
- .setUniform("clock", float(time))
- .setUniform("scale", getScale());
-
if (yEnd - yBeg > arrowSize) {
// Draw holds
if (note.isHit && note.releaseTime <= 0) { // The note is being held down
@@ -503,7 +490,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
yEnd = std::max(time2y(0.0), yEnd);
}
if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time); // Oh noes, it got released!
- 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) {
@@ -521,7 +507,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
} else {
// Draw short note
if (mine && note.isHit) yBeg = time2y(0.0);
- us().setUniform("noteType", (mine ? 3 : 1)).setUniform("position", x, yBeg);
drawArrow((mine ? -1 : arrow_i), (mine ? m_mine : m_arrows));
}
}
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 72d6cdc..e1d2175 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -127,8 +127,6 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number)
} else {
initGuitar();
}
- m_shader_note.reset(new Shader);
- m_shader_note->compileFile(getThemePath("shaders/3dobject.vert")).compileFile(getThemePath("shaders/3dobject.frag"));
// Load 3D fret objects
m_fretObj.load(getThemePath("fret.obj"));
m_tappableObj.load(getThemePath("fret_tap.obj"));
@@ -1060,7 +1058,6 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
color.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f);
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, y, 0.0f);
}
y -= fretWid;
@@ -1099,14 +1096,12 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
color.a = s;
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, yBeg, 0.0f, s);
}
} else {
color.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f);
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, yBeg, 0.0f);
}
}
@@ -1125,7 +1120,6 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
if (m_use3d) { // 3D
float s = 1.0 - hitAnim;
glutil::Color c(Color(l, l, l, s));
- UseShader us(*m_shader_note); // Switch shader
m_tappableObj.draw(x, yBeg, 0.0f, s);
} else { // 2D
glutil::Color c(Color(l, l, l));
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index 0c6e050..7b6fd77 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -13,7 +13,6 @@
#include "screen.hh"
#include "fs.hh"
#include "theme.hh"
-#include "glshader.hh"
/// Represents popup messages
@@ -136,9 +135,6 @@ class InstrumentGraph {
boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
boost::scoped_ptr<ThemeInstrumentMenu> m_menuTheme;
- // Shaders
- boost::scoped_ptr<Shader> m_shader_note;
-
// Dynamic stuff for join menu
ConfigItem m_selectedTrack; /// menu modifies this to select track
ConfigItem m_selectedDifficulty; /// menu modifies this to select difficulty
diff --git a/game/video_driver.cc b/game/video_driver.cc
index a766a49..ea238da 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -83,6 +83,10 @@ Window::Window(unsigned int width, unsigned int height, bool fs): m_windowW(widt
.link()
.bind()
.setUniformMatrix("colorMatrix", glmath::Matrix());
+ shader("3dobject")
+ .compileFile(getThemePath("shaders/3dobject.vert"))
+ .compileFile(getThemePath("shaders/3dobject.frag"))
+ .link();
}
Window::~Window() { }
diff --git a/themes/default/shaders/3dobject.frag b/themes/default/shaders/3dobject.frag
index bade8b1..9bc1d80 100644
--- a/themes/default/shaders/3dobject.frag
+++ b/themes/default/shaders/3dobject.frag
@@ -1,5 +1,3 @@
-#extension GL_ARB_texture_rectangle : enable
-
varying vec3 normal;
void main()
diff --git a/themes/default/shaders/dancenote.frag b/themes/default/shaders/dancenote.frag
deleted file mode 100644
index 8be9c5c..0000000
--- a/themes/default/shaders/dancenote.frag
+++ /dev/null
@@ -1,55 +0,0 @@
-#extension GL_ARB_texture_rectangle : enable
-
-uniform int texMode;
-uniform sampler2D tex;
-uniform sampler2DRect texRect;
-uniform int noteType;
-uniform float hitAnim;
-uniform float clock;
-uniform float scale;
-
-
-void colorGlow(inout vec4 c) {
- c = vec4(
- min(c.r + hitAnim *.5, 1.0),
- min(c.g + hitAnim *.5, 1.0),
- min(c.b + hitAnim *.5, 1.0),
- max(c.a - hitAnim, 0.0));
-}
-
-
-void main()
-{
- vec4 texel;
-
- if (texMode == 1) {
- texel = texture2D(tex, gl_TexCoord[0].st).rgba;
- } else if (texMode == 2) {
- texel = texture2DRect(texRect, gl_TexCoord[0].st).rgba;
- } else if (texMode == 0) {
- texel = vec4(1.0, 1.0, 1.0, 1.0);
- } else {
- texel = vec4(1.0, 0.0, 1.0, 1.0); // Magenta to highlight
- }
-
- // Cursor arrows
- if (noteType == 0) {
- /* no op */
-
- // Regular arrows
- } else if (noteType == 1) {
- colorGlow(texel);
-
- // Holds
- } else if (noteType == 2) {
- colorGlow(texel);
-
- // Mines
- } else if (noteType == 3) {
- /* no op */
-
- }
-
- gl_FragColor = texel;
-}
-
diff --git a/themes/default/shaders/dancenote.vert b/themes/default/shaders/dancenote.vert
deleted file mode 100644
index 3573391..0000000
--- a/themes/default/shaders/dancenote.vert
+++ /dev/null
@@ -1,56 +0,0 @@
-uniform int noteType;
-uniform float hitAnim;
-uniform float clock;
-uniform float scale;
-uniform vec2 position;
-
-#define deg2rad 0.0174532925
-
-mat4 scaleMat(in float sc) {
- return mat4(sc, 0, 0, 0,
- 0, sc, 0, 0,
- 0, 0, sc, 0,
- 0, 0, 0, 1);
-}
-
-mat4 rotMat(in float ang) {
- float ca = cos(ang);
- float sa = sin(ang);
- return mat4(ca, -sa, 0, 0,
- sa, ca, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1);
-}
-
-
-void main()
-{
- gl_FrontColor = gl_Color;
- gl_BackColor = gl_Color;
- gl_TexCoord[0] = gl_MultiTexCoord0;
-
- mat4 trans = scaleMat(scale);
-
- // Cursor arrows
- if (noteType == 0) {
- trans *= scaleMat(1.0 - hitAnim * .5);
-
- // Regular arrows
- } else if (noteType == 1) {
- trans *= scaleMat(1.0 + hitAnim);
-
- // Holds
- } else if (noteType == 2) {
- trans *= scaleMat(1.0 + hitAnim);
-
- // Mines
- } else if (noteType == 3) {
- trans *= scaleMat(1.0 + hitAnim);
- float r = float(mod(int(clock*360.0), 360)) * deg2rad; // They rotate!
- trans *= rotMat(r);
- }
-
- gl_Position = gl_ModelViewProjectionMatrix * trans * gl_Vertex;
- gl_Position += gl_ModelViewProjectionMatrix * vec4(position.xy, 0, 0);
-}
-
diff --git a/themes/default/shaders/intro.frag b/themes/default/shaders/intro.frag
deleted file mode 100644
index f4665b3..0000000
--- a/themes/default/shaders/intro.frag
+++ /dev/null
@@ -1,28 +0,0 @@
-#extension GL_ARB_texture_rectangle : enable
-
-uniform int texMode;
-uniform sampler2D tex;
-uniform sampler2DRect texRect;
-
-uniform float anim;
-
-void main()
-{
- vec4 texel;
-
- if (texMode == 1) {
- texel = texture2D(tex, gl_TexCoord[0].st).rgba;
- } else if (texMode == 2) {
- texel = texture2DRect(texRect, gl_TexCoord[0].st).rgba;
- } else if (texMode == 0) {
- texel = gl_Color;
- } else {
- texel = vec4(1.0, 0.0, 1.0, 1.0); // Magenta to highlight
- }
-
- float r = anim * 0.5;
- float g = anim * 0.5 + 0.5;
- float b = anim * 0.3 + 0.7;
-
- gl_FragColor = vec4(texel.r * r, texel.g * g, texel.b * b, texel.a);
-}
diff --git a/themes/default/shaders/intro.vert b/themes/default/shaders/intro.vert
deleted file mode 100644
index 48bf7e9..0000000
--- a/themes/default/shaders/intro.vert
+++ /dev/null
@@ -1,7 +0,0 @@
-void main()
-{
- gl_FrontColor = gl_Color;
- gl_BackColor = gl_Color;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 20:14:12
|
Module: performous
Branch: opengl2
Commit: 8186733b5fdd1f1c925634cb338ec66a6ba16c17
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 21:12:35 2011 +0100
3D composition optimization and fixes
* Viewports now properly positioned in cropped (overwide/overtall) modes too
* FBOs rendered in final resolution (1:1 pixel mapping)
* FBOs have depth buffers
---
game/fbo.hh | 14 ++++++++++----
game/video_driver.cc | 38 ++++++++++++++++++++++++++------------
2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/game/fbo.hh b/game/fbo.hh
index f511a99..f980faa 100644
--- a/game/fbo.hh
+++ b/game/fbo.hh
@@ -5,19 +5,24 @@
#include "video_driver.hh"
/// Frame Buffer Object class
-class FBO: public boost::noncopyable {
+class FBO: boost::noncopyable {
public:
/// Generate the FBO and attach a fresh texture to it
- FBO(): m_texture() {
+ FBO(unsigned w, unsigned h) {
{
UseTexture tex(m_texture);
- glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, screenW(), screenH(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+ {
+ UseTexture tex(m_depth);
+ glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_DEPTH_COMPONENT24, w, h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
}
// Create FBO
glGenFramebuffersEXT(1, &m_fbo);
// Bind texture as COLOR_ATTACHMENT0
bind();
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE, m_texture.id(), 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, m_texture.id(), 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_RECTANGLE, m_depth.id(), 0);
unbind();
}
/// Handle clean-up
@@ -40,6 +45,7 @@ class FBO: public boost::noncopyable {
private:
GLuint m_fbo;
OpenGLTexture<GL_TEXTURE_RECTANGLE> m_texture;
+ OpenGLTexture<GL_TEXTURE_RECTANGLE> m_depth;
};
/// RAII FBO binder
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 5585ccc..a766a49 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -92,28 +92,42 @@ void Window::blank() {
}
void Window::render(boost::function<void (void)> drawFunc) {
+ if (s_width < screen->w || s_height < screen->h) glClear(GL_COLOR_BUFFER_BIT); // Black bars
bool stereo = config["graphic/stereo3d"].b();
int type = config["graphic/stereo3dtype"].i();
if (type == 2 && !m_fullscreen) stereo = false; // Over/under only in full screen mode
- // Viewport parameters (defaults)
- double vx = 0.5f * (screen->w - s_width);
- double vy = 0.5f * (screen->h - s_height);
- double vw = s_width, vh = s_height;
- glViewport(vx, vy, vw, vh);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (!stereo) {
+ double vx = 0.5f * (screen->w - s_width);
+ double vy = 0.5f * (screen->h - s_height);
+ double vw = s_width, vh = s_height;
+ glViewport(vx, vy, vw, vh); // Drawable area of the window (excluding black bars)
view(0);
drawFunc();
return;
}
// Render each eye to FBO
- FBO fbo[2];
+ unsigned w = s_width;
+ unsigned h = s_height;
+ if (type == 2) h /= 2; // Half-height mode
+ FBO fboleft(w, h), fboright(w, h);
+ FBO* fbo[] = { &fboleft, &fboright };
for (unsigned i = 0; i < 2; ++i) {
- UseFBO user(fbo[i]);
+ UseFBO user(*fbo[i]);
+ glViewport(0, 0, w, h); // Full FBO
view(i);
drawFunc();
}
// Render to actual framebuffer from FBOs
+ glViewport(0, 0, screen->w, screen->h); // Entire window
+ {
+ // Use normalized eye coordinates for composition
+ using namespace glmath;
+ glMatrixMode(GL_PROJECTION);
+ upload(Matrix());
+ glMatrixMode(GL_MODELVIEW);
+ upload(Matrix());
+ }
glDisable(GL_BLEND);
Shader& sh = shader("surface");
glmath::Matrix colorMatrix;
@@ -142,14 +156,14 @@ void Window::render(boost::function<void (void)> drawFunc) {
glBlendFunc(GL_ONE, GL_ONE);
}
sh.bind();
- } else if (type == 2) { // Over/under
- double margin = screen->h - s_height;
- glViewport(vx, 0.25 * margin + (num ? 0.0 : 0.5 * screen->h), vw, 0.5 * vh);
}
{
- UseTexture use(fbo[num].getTexture());
+ // Render FBO with 1:1 pixels, properly filtered/positioned for 3d
+ UseTexture use(fbo[num]->getTexture());
sh.setUniformMatrix("colorMatrix", colorMatrix);
- fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, screenH(), screenW(), 0.0));
+ Dimensions dim = Dimensions().stretch(2.0 * w / screen->w, 2.0 * h / screen->h);
+ if (type == 2) dim.center(num == 0 ? 0.5 : -0.5);
+ fbo[num]->getTexture().draw(dim, TexCoords(0.0, 0.0, w, h));
sh.setUniformMatrix("colorMatrix", glmath::Matrix());
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 17:44:51
|
Module: performous
Branch: opengl2
Commit: 14a4e47fc529c32d8c933043f3092026db3e9d77
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 18:44:30 2011 +0100
Revert the earlier fix for window resizing as it doesn't seem to be necessary (anymore?).
---
game/main.cc | 2 +-
game/video_driver.cc | 1 -
2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 5171e8d..8fbb531 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -66,7 +66,7 @@ static void checkEvents_SDL(ScreenManager& sm) {
sm.finished();
break;
case SDL_VIDEORESIZE:
- //sm.window().resize(event.resize.w, event.resize.h);
+ sm.window().resize(event.resize.w, event.resize.h);
break;
case SDL_KEYDOWN:
int keypressed = event.key.keysym.sym;
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 2536349..5585ccc 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -244,7 +244,6 @@ void Window::resize() {
screen = SDL_SetVideoMode(width, height, 0, SDL_OPENGL | SDL_RESIZABLE | (m_fullscreen ? SDL_FULLSCREEN : 0));
if (!screen) throw std::runtime_error(std::string("SDL_SetVideoMode failed: ") + SDL_GetError());
}
- glerror.check("SetVideoMode");
s_width = screen->w;
s_height = screen->h;
if (!m_fullscreen) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 17:06:23
|
Module: performous Branch: opengl2 Commit: f21fe8a9e3218d1cb7bf3cc73aa85d784514deb0 Author: Lasse Karkkainen <tro...@tr...> Date: Sun Feb 6 18:06:12 2011 +0100 Fixed stereo3d config description --- data/schema.xml | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/data/schema.xml b/data/schema.xml index c1a1b0b..ca06961 100644 --- a/data/schema.xml +++ b/data/schema.xml @@ -135,7 +135,7 @@ to save the current settings to XML. <limits min="0" max="2" step="1" /> <locale name="C"> <short>Stereo3D type</short> - <long>Some modes may only be activated in FullHD mode. 0 = red/cyan, 1 = green/magenta, 2 = over/under.</long> + <long>Some modes may only be activated in fullscreen mode. 0 = red/cyan, 1 = green/magenta, 2 = over/under.</long> </locale> </entry> <entry name="graphic/stereo3dseparation" type="float" value="50"> |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 16:59:51
|
Module: performous
Branch: opengl2
Commit: bb963d7e6b4b9dc1c451d467540df213b02ed412
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 17:59:39 2011 +0100
Implement green-magenta anaglyph and fix the stereo rendering.
---
data/schema.xml | 4 ++--
game/video_driver.cc | 48 +++++++++++++++++++++++++++---------------------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index 0bebc88..c1a1b0b 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -132,10 +132,10 @@ to save the current settings to XML.
</locale>
</entry>
<entry name="graphic/stereo3dtype" type="int" value="0">
- <limits min="0" max="1" step="1" />
+ <limits min="0" max="2" step="1" />
<locale name="C">
<short>Stereo3D type</short>
- <long>Some modes may only be activated in FullHD mode. 0 = red/cyan, 1 = over/under.</long>
+ <long>Some modes may only be activated in FullHD mode. 0 = red/cyan, 1 = green/magenta, 2 = over/under.</long>
</locale>
</entry>
<entry name="graphic/stereo3dseparation" type="float" value="50">
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 9f42452..2536349 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -94,7 +94,7 @@ void Window::blank() {
void Window::render(boost::function<void (void)> drawFunc) {
bool stereo = config["graphic/stereo3d"].b();
int type = config["graphic/stereo3dtype"].i();
- if (type == 1 && !m_fullscreen) stereo = false; // Over/under only in full screen mode
+ if (type == 2 && !m_fullscreen) stereo = false; // Over/under only in full screen mode
// Viewport parameters (defaults)
double vx = 0.5f * (screen->w - s_width);
double vy = 0.5f * (screen->h - s_height);
@@ -116,36 +116,42 @@ void Window::render(boost::function<void (void)> drawFunc) {
// Render to actual framebuffer from FBOs
glDisable(GL_BLEND);
Shader& sh = shader("surface");
+ glmath::Matrix colorMatrix;
for (int num = 0; num < 2; ++num) {
- if (type == 0) {
- using namespace glmath;
- Matrix colorMatrix;
- float saturation = 0.6; // (0..1)
- float col = (1.0 + 2.0 * saturation) / 3.0;
- float gry = 0.5 * (1.0 - col);
- if (num == 0) {
- // Left eye
- colorMatrix.cols[0] = Vec4(col, 0.0, 0.0); // Red in original becomes
- colorMatrix.cols[1] = Vec4(gry, 0.0, 0.0); // Green in original becomes
- colorMatrix.cols[2] = Vec4(gry, 0.0, 0.0); // Blue in original becomes
- } else {
- // Right eye
+ if (type == 0 || type == 1) { // Anaglyph
+ {
+ float saturation = 0.6; // (0..1)
+ float col = (1.0 + 2.0 * saturation) / 3.0;
+ float gry = 0.5 * (1.0 - col);
+ bool out[3] = {}; // Which colors to output
+ if (type == 0 && num == 0) { out[0] = true; } // Red
+ if (type == 0 && num == 1) { out[1] = out[2] = true; } // Cyan
+ if (type == 1 && num == 0) { out[1] = true; } // Green
+ if (type == 1 && num == 1) { out[0] = out[2] = true; } // Magenta
+ for (unsigned i = 0; i < 3; ++i) {
+ for (unsigned j = 0; j < 3; ++j) {
+ double val = 0.0;
+ if (out[i]) val = (i == j ? col : gry);
+ colorMatrix(i, j) = val;
+ }
+ }
+ }
+ if (num == 1) {
+ // Right eye blends over the left eye
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- colorMatrix.cols[0] = Vec4(0.0, gry, gry); // Red in original becomes
- colorMatrix.cols[1] = Vec4(0.0, col, gry); // Green in original becomes
- colorMatrix.cols[2] = Vec4(0.0, gry, col); // Blue in original becomes
+ glBlendFunc(GL_ONE, GL_ONE);
}
- sh.setUniformMatrix("colorMatrix", colorMatrix);
- } else {
+ sh.bind();
+ } else if (type == 2) { // Over/under
double margin = screen->h - s_height;
glViewport(vx, 0.25 * margin + (num ? 0.0 : 0.5 * screen->h), vw, 0.5 * vh);
}
{
UseTexture use(fbo[num].getTexture());
+ sh.setUniformMatrix("colorMatrix", colorMatrix);
fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, screenH(), screenW(), 0.0));
+ sh.setUniformMatrix("colorMatrix", glmath::Matrix());
}
- sh.setUniformMatrix("colorMatrix", glmath::Matrix());
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 16:23:59
|
Module: performous
Branch: opengl2
Commit: 18626cdf84b8c77df817b17fc95520e3a550e47f
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 17:21:09 2011 +0100
Shader refactoring.
* Shaders now owned by Window
* UseTexture sets the proper shader for texture rendering
* GL_TEXTURE_RECTANGLE used instead of ~_ARB
---
game/glshader.cc | 4 ----
game/glshader.hh | 9 ---------
game/screen_intro.cc | 5 +++--
game/surface.cc | 5 +++++
game/surface.hh | 33 ++++++++++++++++-----------------
game/video_driver.cc | 19 +++++++++++++++----
game/video_driver.hh | 7 +++++--
themes/default/shaders/core.frag | 25 +++++++++++++++----------
8 files changed, 59 insertions(+), 48 deletions(-)
diff --git a/game/glshader.cc b/game/glshader.cc
index ffad283..9c30e5b 100644
--- a/game/glshader.cc
+++ b/game/glshader.cc
@@ -40,12 +40,9 @@ namespace {
}
}
-Shader::ShaderMap Shader::shader_progs;
-
Shader::Shader(): program(0) {}
Shader::~Shader() {
- shader_progs[program] = NULL;
glDeleteProgram(program);
std::for_each(shader_ids.begin(), shader_ids.end(), glDeleteShader);
//std::clog << "shader/info: Shader program " << (unsigned)program << " deleted." << std::endl;
@@ -109,7 +106,6 @@ Shader& Shader::link() {
}
ec.check("glLinkProgram");
- shader_progs[program] = this;
return *this;
}
diff --git a/game/glshader.hh b/game/glshader.hh
index 0bf934b..61039ca 100644
--- a/game/glshader.hh
+++ b/game/glshader.hh
@@ -65,13 +65,6 @@ struct Shader: public boost::noncopyable {
bool operator==(const Shader& rhs) const { return program == rhs.program; }
bool operator!=(const Shader& rhs) const { return program != rhs.program; }
- /** Returns pointer to the currently used shader. */
- static Shader* current() {
- GLint i;
- glGetIntegerv(GL_CURRENT_PROGRAM, &i);
- return shader_progs[i];
- }
-
private:
GLuint program; ///< shader program object id
int gl_response; ///< save last return state
@@ -82,8 +75,6 @@ private:
typedef std::map<std::string, GLint> UniformMap;
UniformMap uniforms; ///< Cached uniform locations, use operator[] to access
- typedef std::map<GLint, Shader*> ShaderMap;
- static ShaderMap shader_progs; ///< Shader objects for reverse look-up by id
};
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 2d60ddf..2eff166 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -116,9 +116,10 @@ void ScreenIntro::draw_menu_options() {
void ScreenIntro::draw() {
{
float anim = SDL_GetTicks() % 20000 / 20000.0;
- Shader::current()->setUniformMatrix("colorMatrix", glmath::rotate(2.0 * M_PI * anim, glmath::Vec3(1.0, 1.0, 1.0)));
+ Shader& sh = theme->bg.shader();
+ sh.setUniformMatrix("colorMatrix", glmath::rotate(2.0 * M_PI * anim, glmath::Vec3(1.0, 1.0, 1.0)));
theme->bg.draw();
- Shader::current()->setUniformMatrix("colorMatrix", glmath::Matrix());
+ sh.setUniformMatrix("colorMatrix", glmath::Matrix());
}
if (m_menu.current().image) m_menu.current().image->draw();
// Comment
diff --git a/game/surface.cc b/game/surface.cc
index 54fb533..77da12b 100644
--- a/game/surface.cc
+++ b/game/surface.cc
@@ -5,6 +5,7 @@
#include "configuration.hh"
#include "video_driver.hh"
#include "image.hh"
+#include "screen.hh"
#include <fstream>
#include <stdexcept>
@@ -17,6 +18,10 @@
#include <boost/format.hpp>
using boost::uint32_t;
+Shader& getShader(std::string const& name) {
+ return ScreenManager::getSingletonPtr()->window().shader(name); // FIXME
+}
+
float Dimensions::screenY() const {
switch (m_screenAnchor) {
case CENTER: return 0.0;
diff --git a/game/surface.hh b/game/surface.hh
index 8d856af..adb394e 100644
--- a/game/surface.hh
+++ b/game/surface.hh
@@ -99,11 +99,21 @@ struct TexCoords {
x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
};
+/// This function hides the ugly global vari-- I mean singleton access to ScreenManager...
+Shader& getShader(std::string const& name);
+
/** @short A RAII wrapper for allocating/deallocating OpenGL texture ID **/
template <GLenum Type> class OpenGLTexture: boost::noncopyable {
public:
/// return Type
static GLenum type() { return Type; };
+ static Shader& shader() {
+ switch (Type) {
+ case GL_TEXTURE_2D: return getShader("texture");
+ case GL_TEXTURE_RECTANGLE: return getShader("surface");
+ }
+ throw std::logic_error("Unknown texture type");
+ }
OpenGLTexture(): m_id() { glGenTextures(1, &m_id); }
~OpenGLTexture() { glDeleteTextures(1, &m_id); }
/// returns id
@@ -120,22 +130,11 @@ template <GLenum Type> class OpenGLTexture: boost::noncopyable {
class UseTexture: boost::noncopyable {
public:
/// constructor
- template <GLenum Type> UseTexture(OpenGLTexture<Type> const& s):
- m_shader(*Shader::current()) {
- switch (Type) {
- //case GL_TEXTURE_2D: glActiveTexture(GL_TEXTURE0); /*m_shader.setUniform("texMode", 1); */break;
- case GL_TEXTURE_RECTANGLE_ARB: glActiveTexture(GL_TEXTURE0); /*m_shader.setUniform("texMode", 2);*/ break;
- //default: m_shader.setUniform("texMode", 3); break;
- }
- glEnable(Type);
- glBindTexture(Type, s.id());
- }
- ~UseTexture() {
- //m_shader.setUniform("texMode", 0);
- }
-
+ template <GLenum Type> UseTexture(OpenGLTexture<Type> const& tex):
+ m_shader(/* hack of the year */ (glutil::GLErrorChecker("UseTexture"), glActiveTexture(GL_TEXTURE0), glBindTexture(Type, tex.id()), tex.shader())) {}
+
private:
- Shader& m_shader;
+ UseShader m_shader;
};
template <GLenum Type> void OpenGLTexture<Type>::draw(Dimensions const& dim, TexCoords const& tex) const {
@@ -200,8 +199,8 @@ class Surface {
void draw() const;
/// loads surface into buffer
void load(unsigned int width, unsigned int height, pix::Format format, unsigned char const* buffer, float ar = 0.0f);
-
+ Shader& shader() { return m_texture.shader(); }
private:
unsigned int m_width, m_height;
- OpenGLTexture<GL_TEXTURE_RECTANGLE_ARB> m_texture;
+ OpenGLTexture<GL_TEXTURE_RECTANGLE> m_texture;
};
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 5fec179..9f42452 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -71,8 +71,18 @@ Window::Window(unsigned int width, unsigned int height, bool fs): m_windowW(widt
//std::clog << "video/info: GL_EXTENSIONS: " << glGetString(GL_EXTENSIONS) << std::endl;
input::SDL::init(); // Joysticks etc.
- m_shader.reset(new Shader);
- m_shader->compileFile(getThemePath("shaders/core.vert")).compileFile(getThemePath("shaders/core.frag"), "#define TEXTURE_RECT\n").link().bind();
+ shader("surface")
+ .compileFile(getThemePath("shaders/core.vert"))
+ .compileFile(getThemePath("shaders/core.frag"), "#define SURFACE\n")
+ .link()
+ .bind()
+ .setUniformMatrix("colorMatrix", glmath::Matrix());
+ shader("texture")
+ .compileFile(getThemePath("shaders/core.vert"))
+ .compileFile(getThemePath("shaders/core.frag"), "#define TEXTURE\n")
+ .link()
+ .bind()
+ .setUniformMatrix("colorMatrix", glmath::Matrix());
}
Window::~Window() { }
@@ -91,7 +101,6 @@ void Window::render(boost::function<void (void)> drawFunc) {
double vw = s_width, vh = s_height;
glViewport(vx, vy, vw, vh);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- m_shader->setUniformMatrix("colorMatrix", glmath::Matrix());
if (!stereo) {
view(0);
drawFunc();
@@ -106,6 +115,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
}
// Render to actual framebuffer from FBOs
glDisable(GL_BLEND);
+ Shader& sh = shader("surface");
for (int num = 0; num < 2; ++num) {
if (type == 0) {
using namespace glmath;
@@ -126,7 +136,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
colorMatrix.cols[1] = Vec4(0.0, col, gry); // Green in original becomes
colorMatrix.cols[2] = Vec4(0.0, gry, col); // Blue in original becomes
}
- m_shader->setUniformMatrix("colorMatrix", colorMatrix);
+ sh.setUniformMatrix("colorMatrix", colorMatrix);
} else {
double margin = screen->h - s_height;
glViewport(vx, 0.25 * margin + (num ? 0.0 : 0.5 * screen->h), vw, 0.5 * vh);
@@ -135,6 +145,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
UseTexture use(fbo[num].getTexture());
fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, screenH(), screenW(), 0.0));
}
+ sh.setUniformMatrix("colorMatrix", glmath::Matrix());
}
}
diff --git a/game/video_driver.hh b/game/video_driver.hh
index 45ecf6b..d9e4209 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -3,7 +3,7 @@
#include "glshader.hh"
#include "glutil.hh"
#include <boost/function.hpp>
-#include <boost/scoped_ptr.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
unsigned int screenW();
unsigned int screenH();
@@ -54,11 +54,14 @@ public:
/// take a screenshot
void screenshot();
+ /// Construct a new shader or return an existing one by name
+ Shader& shader(std::string const& name) { return m_shaders[name]; }
private:
SDL_Surface* screen;
unsigned int m_windowW, m_windowH;
unsigned int m_fsW, m_fsH;
bool m_fullscreen;
- boost::scoped_ptr<Shader> m_shader; ///< core shader used for general drawing
+ typedef boost::ptr_map<std::string, Shader> ShaderMap;
+ ShaderMap m_shaders; ///< Shader programs by name
};
diff --git a/themes/default/shaders/core.frag b/themes/default/shaders/core.frag
index 337c071..97e8222 100644
--- a/themes/default/shaders/core.frag
+++ b/themes/default/shaders/core.frag
@@ -1,19 +1,24 @@
//DEFINES
-#ifdef TEXTURE_RECT
-#extension GL_ARB_texture_rectangle : enable
-#define SAMPLER sampler2DRect
-#define TEXTURE texture2DRect
-#else
-#define SAMPLER sampler2D
-#define TEXTURE texture2D
+uniform mat4 colorMatrix;
+
+#ifdef SURFACE
+#extension GL_ARB_texture_rectangle : require
+uniform sampler2DRect tex;
+#define TFUNC texture2DRect
#endif
-uniform mat4 colorMatrix;
-uniform SAMPLER tex;
+#ifdef TEXTURE
+uniform sampler2D tex;
+#define TFUNC texture2D
+#endif
void main() {
- gl_FragColor = colorMatrix * (gl_Color * TEXTURE(tex, gl_TexCoord[0].st).rgba);
+ gl_FragColor = colorMatrix * (gl_Color
+#ifdef TFUNC
+ * TFUNC(tex, gl_TexCoord[0].st).rgba
+#endif
+ );
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 16:23:57
|
Module: performous
Branch: opengl2
Commit: 8949db85a40c8bb94d6e0d4d53e8edb15aa9d294
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 16:17:12 2011 +0100
Build fix to allow proper linkage of pthreads
---
game/CMakeLists.txt | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index ccf5faf..3a34f6b 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -117,18 +117,15 @@ else()
endif()
-# Set default compile flags for GCC
-if(CMAKE_COMPILER_IS_GNUCXX)
- message(STATUS "GCC detected, adding compile flags")
- # -pedantic cannot be used because ffmpeg headers are b0rked
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers")
- # -pthread is unrecognized on Windows and ansi standard causes errors
- if(NOT WIN32)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -pthread")
- endif(NOT WIN32)
+if(APPLE)
# Needed for ffmpeg.cc to compile cleanly on OSX (it's a (unsigned long) long story)
add_definitions("-D__STDC_CONSTANT_MACROS")
-endif(CMAKE_COMPILER_IS_GNUCXX)
+endif(APPLE)
+
+if(UNIX)
+ list(APPEND CMAKE_CXX_FLAGS -pthread)
+ list(APPEND CMAKE_EXE_LINKER_FLAGS -pthread)
+endif(UNIX)
if(MSVC)
set(SUBSYSTEM_WIN32 WIN32)
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 02:34:03
|
Module: performous Branch: opengl2 Commit: cca89ba981e1fff9ec8d4aebc6cfbdb6eba7e1fb Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Sun Feb 6 03:31:38 2011 +0100 Shader cleanup. * 2x speedup for Intel * Support for geometry shader * Support for reusing same shader with different defines * TEXTURE_2D currently b0rked (needs to use proper shader) --- game/dancegraph.cc | 3 +- game/glshader.cc | 38 ++++++++++++++++++--------------- game/glshader.hh | 11 ++++----- game/guitargraph.cc | 3 +- game/screen_intro.cc | 7 +++-- game/surface.hh | 12 ++++------ game/theme.cc | 3 +- game/theme.hh | 2 - game/video_driver.cc | 3 +- themes/default/shaders/3dobject.frag | 19 +--------------- themes/default/shaders/core.frag | 31 +++++++++++---------------- 11 files changed, 57 insertions(+), 75 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-05 23:12:44
|
Module: performous
Branch: opengl2
Commit: baaf59b8a5247cacaff173de8b04712772b761f4
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 00:12:02 2011 +0100
Huge performance improvement (for Nvidia) by not generating mipmaps for FBO.
---
game/fbo.hh | 14 ++++----------
game/video_driver.cc | 3 +--
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/game/fbo.hh b/game/fbo.hh
index 77a58d2..f511a99 100644
--- a/game/fbo.hh
+++ b/game/fbo.hh
@@ -11,19 +11,13 @@ class FBO: public boost::noncopyable {
FBO(): m_texture() {
{
UseTexture tex(m_texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, screenW(), screenH(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- // When texture area is large, bilinear filter the original
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- // The texture wraps over at the edges (repeat)
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, screenW(), screenH(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
// Create FBO
glGenFramebuffersEXT(1, &m_fbo);
// Bind texture as COLOR_ATTACHMENT0
bind();
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture.id(), 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE, m_texture.id(), 0);
unbind();
}
/// Handle clean-up
@@ -31,7 +25,7 @@ class FBO: public boost::noncopyable {
if (m_fbo) glDeleteFramebuffersEXT(1, &m_fbo);
}
/// Returns a reference to the attached texture
- OpenGLTexture<GL_TEXTURE_2D>& getTexture() {
+ OpenGLTexture<GL_TEXTURE_RECTANGLE>& getTexture() {
return m_texture;
}
/// Bind the FBO into use
@@ -45,7 +39,7 @@ class FBO: public boost::noncopyable {
private:
GLuint m_fbo;
- OpenGLTexture<GL_TEXTURE_2D> m_texture;
+ OpenGLTexture<GL_TEXTURE_RECTANGLE> m_texture;
};
/// RAII FBO binder
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 337c939..97da256 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -132,8 +132,7 @@ void Window::render(boost::function<void (void)> drawFunc) {
}
{
UseTexture use(fbo[num].getTexture());
- glGenerateMipmap(GL_TEXTURE_2D);
- fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, 1.0, 1.0, 0.0));
+ fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, screenH(), screenW(), 0.0));
}
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-05 23:12:42
|
Module: performous
Branch: opengl2
Commit: d1c160bdf25c148b5a4a8f569755509964617d21
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Feb 5 23:46:30 2011 +0100
Better song loader profiler message (profiler-songloader/info)
---
game/songs.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/songs.cc b/game/songs.cc
index 6ce646d..62ab26d 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -39,7 +39,7 @@ void Songs::reload_internal() {
m_songs.clear();
m_dirty = true;
}
- Profiler prof("Song loading took");
+ Profiler prof("songloader");
Paths paths = getPathsConfig("paths/songs");
for (Paths::iterator it = paths.begin(); m_loading && it != paths.end(); ++it) {
try {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-05 15:33:54
|
Module: performous Branch: opengl2 Commit: d856fe4f7ff6b44989119c87767cbf512c018f70 Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Sat Feb 5 16:31:10 2011 +0100 Performance optimization. * Call glFinish in mainloop before profiler checkpoints * No blanking done by mainloop anymore * Screens now responsible for painting cleanly on old buffer (i.e. must have a background) * Window::view now sets the GL flags instead of Window::resize --- game/main.cc | 3 ++- game/video_driver.cc | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/game/main.cc b/game/main.cc index b69a936..5171e8d 100644 --- a/game/main.cc +++ b/game/main.cc @@ -179,11 +179,12 @@ void mainLoop(std::string const& songlist) { prof("misc"); try { // Draw - window.blank(); window.render(boost::bind(&ScreenManager::drawScreen, &sm)); + glFinish(); prof("draw"); // Display (and wait until next frame) window.swap(); + glFinish(); prof("swap"); if (config["graphic/fps"].b()) { ++frames; diff --git a/game/video_driver.cc b/game/video_driver.cc index 2eae46f..337c939 100644 --- a/game/video_driver.cc +++ b/game/video_driver.cc @@ -104,6 +104,7 @@ void Window::render(boost::function<void (void)> drawFunc) { drawFunc(); } // Render to actual framebuffer from FBOs + glDisable(GL_BLEND); for (int num = 0; num < 2; ++num) { if (type == 0) { using namespace glmath; @@ -118,12 +119,13 @@ void Window::render(boost::function<void (void)> drawFunc) { colorMatrix.cols[2] = Vec4(gry, 0.0, 0.0); // Blue in original becomes } else { // Right eye + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); colorMatrix.cols[0] = Vec4(0.0, gry, gry); // Red in original becomes colorMatrix.cols[1] = Vec4(0.0, col, gry); // Green in original becomes colorMatrix.cols[2] = Vec4(0.0, gry, col); // Blue in original becomes } m_shader->setUniformMatrix("colorMatrix", colorMatrix); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); } else { double margin = screen->h - s_height; glViewport(vx, 0.25 * margin + (num ? 0.0 : 0.5 * screen->h), vw, 0.5 * vh); @@ -131,13 +133,20 @@ void Window::render(boost::function<void (void)> drawFunc) { { UseTexture use(fbo[num].getTexture()); glGenerateMipmap(GL_TEXTURE_2D); - //drawFunc(); fbo[num].getTexture().draw(Dimensions().stretch(1.0, virtH()), TexCoords(0.0, 1.0, 1.0, 0.0)); } } } bool Window::view(unsigned num) { + // Set flags + glClearColor (0.0f, 0.0f, 0.0f, 1.0f); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glShadeModel(GL_SMOOTH); + glEnable(GL_BLEND); // Setup the projection matrix for 2D translates using namespace glmath; glMatrixMode(GL_PROJECTION); @@ -227,14 +236,6 @@ void Window::resize() { } if (s_height < 0.56f * s_width) s_width = round(s_height / 0.56f); if (s_height > 0.8f * s_width) s_height = round(0.8f * s_width); - // Set flags - glClearColor (0.0f, 0.0f, 0.0f, 1.0f); - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - glShadeModel(GL_SMOOTH); - glEnable(GL_BLEND); } FarTransform::FarTransform() { |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-05 15:33:50
|
Module: performous Branch: opengl2 Commit: ae4b78f112fd609772dcbef79d481e24abc1622c Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Sat Feb 5 16:30:14 2011 +0100 Allow choosing profilers via logging system: profiler-name/info --- game/profiler.hh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/game/profiler.hh b/game/profiler.hh index 7beec08..f56db2b 100644 --- a/game/profiler.hh +++ b/game/profiler.hh @@ -11,8 +11,8 @@ class Profiler { boost::xtime m_time; public: /// create a new profiler with a given name - Profiler(std::string const& name): m_time(now()) { m_oss << name << ": "; } - ~Profiler() { std::clog << "Profiler/info: " << m_oss.str() << std::endl; } + Profiler(std::string const& name): m_time(now()) { m_oss << "profiler-" << name << "/info: "; } + ~Profiler() { std::clog << m_oss.str() << std::endl; } /// calling the object as a function will return the time since the start void operator()(std::string const& tag) { boost::xtime n = now(); |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-04 15:27:58
|
Module: editor
Branch: master
Commit: 7bd4b0fce3ae9630b30add1947d3bf9fe98c2924
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Feb 4 16:26:13 2011 +0100
Fix issues with analyzing music file
* Would analyze at most processStep samples per audio block (discarding the end of the song)
* Only half of each block was actually output (causing artifacts and discarding half of the audio data)
---
ffmpeg.cc | 4 ++--
ffmpeg.hh | 2 +-
pitch.cc | 2 +-
pitchvis.cc | 35 +++++++++++++++++++----------------
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/ffmpeg.cc b/ffmpeg.cc
index 84a14cf..e533b88 100644
--- a/ffmpeg.cc
+++ b/ffmpeg.cc
@@ -167,8 +167,8 @@ void FFmpeg::decodeNextFrame() {
// Move forward within the packet
packetSize -= decodeSize;
packetData += decodeSize;
- // Convert outsize from bytes into number of frames (samples)
- outsize /= sizeof(qint16) * pAudioCodecCtx->channels;
+ // Convert outsize from bytes into number of samples
+ outsize /= sizeof(qint16);
// Calculate new positions
if (packet.time() == packet.time()) m_position = packet.time();
else m_position += outsize / audioQueue.samplesPerSecond();
diff --git a/ffmpeg.hh b/ffmpeg.hh
index c904471..7763b42 100644
--- a/ffmpeg.hh
+++ b/ffmpeg.hh
@@ -61,7 +61,7 @@ public:
void setRateChannels(unsigned rate, unsigned channels) { m_rate = rate; m_channels = channels; }
unsigned getRate() { return m_rate; }
unsigned getChannels() { return m_channels; }
- AudioQueue(unsigned capacity = (2 << 20)): m_ring(capacity), m_channels(), m_position(), m_size(), m_eof() {}
+ AudioQueue(unsigned capacity = 32768): m_ring(capacity), m_channels(), m_position(), m_size(), m_eof() {}
private:
QMutex m_mutex;
diff --git a/pitch.cc b/pitch.cc
index ec54316..e5dab9e 100644
--- a/pitch.cc
+++ b/pitch.cc
@@ -150,7 +150,7 @@ void Analyzer::temporalMerge(Tones& tones) {
}
}
}
- m_moments.push_back(Moment(m_moments.size() * FFT_STEP / m_rate));
+ m_moments.push_back(Moment(m_moments.size() * processStep() / m_rate));
m_moments.back().stealTones(tones); // No pointers are invalidated
}
diff --git a/pitchvis.cc b/pitchvis.cc
index b275144..34611f3 100644
--- a/pitchvis.cc
+++ b/pitchvis.cc
@@ -28,28 +28,31 @@ void PitchVis::run()
position = 0.0;
duration = mpeg.duration(); // Estimation
}
+ unsigned rate = mpeg.audioQueue.getRate();
unsigned channels = mpeg.audioQueue.getChannels();
if (channels == 0) throw std::runtime_error("No audio channels found");
- std::vector<Analyzer> analyzers(channels, Analyzer(mpeg.audioQueue.getRate(), ""));
+ std::vector<Analyzer> analyzers(channels, Analyzer(rate, ""));
// Process the entire song
std::vector<float> data;
+ data.reserve((duration + 1.0) * rate * channels);
unsigned x = 0;
while (mpeg.audioQueue.output(data)) {
- // Read until enough data is available
- if (data.size() / channels - x < analyzers[0].processSize()) continue;
- // Pitch detection
- for (unsigned ch = 0; ch < channels; ++ch) {
- analyzers[ch].process(da::step_iterator<float>(&data[x * channels + ch], channels));
- }
- x += analyzers[0].processStep();
- // Update progress and check for quit flag
- QMutexLocker locker(&mutex);
- if (cancelled) return;
- Analyzer::Moments const& moments = analyzers[0].getMoments();
- if (!moments.empty()) {
- double t = moments.back().time();
- position = t;
- duration = std::max(duration, t + 0.01);
+ // Process as much as can be processed at this point
+ while (data.size() / channels - x >= analyzers[0].processSize()) {
+ // Pitch detection
+ for (unsigned ch = 0; ch < channels; ++ch) {
+ analyzers[ch].process(da::step_iterator<float>(&data[x * channels + ch], channels));
+ }
+ x += analyzers[0].processStep();
+ // Update progress and check for quit flag
+ QMutexLocker locker(&mutex);
+ if (cancelled) return;
+ Analyzer::Moments const& moments = analyzers[0].getMoments();
+ if (!moments.empty()) {
+ double t = moments.back().time();
+ position = t;
+ duration = std::max(duration, t + 0.01);
+ }
}
}
// Filter the analyzer output data into QPainterPaths.
|
|
From: Tapio V. <aa...@us...> - 2011-02-04 09:34:41
|
Module: editor
Branch: master
Commit: 95c98b8c178a87f893691a79db55c6f609e1e733
Author: Tapio Vierros <tap...@gm...>
Date: Fri Feb 4 11:33:11 2011 +0200
Now note does not jump higher when timing.
---
notegraphwidget.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index ee87d7a..eb5a572 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -225,7 +225,7 @@ void NoteGraphWidget::timeCurrent()
Operation op("MOVE");
op << getNoteLabelId(selectedNote())
<< px2s(m_seekHandle.curx()) << px2s(m_seekHandle.curx() + selectedNote()->width())
- << int(round(px2n(selectedNote()->y() + m_noteHalfHeight))) + 1;
+ << int(round(px2n(selectedNote()->y() + m_noteHalfHeight)));
doOperation(op);
}
}
|
|
From: Tapio V. <aa...@us...> - 2011-02-04 09:09:04
|
Module: editor
Branch: master
Commit: 3f068492f313a4bf9eb3902ccedb5598813c504b
Author: Tapio Vierros <tap...@gm...>
Date: Fri Feb 4 11:08:25 2011 +0200
Line break handling in the new style "NEW" Operation.
---
notegraphwidget.cc | 4 ++--
notelabelmanager.cc | 8 +++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 08d6242..ee87d7a 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -15,7 +15,7 @@
namespace {
static Operation opFromNote(const Note& note, int id, bool floating) {
Operation op("NEW");
- op << id << note.syllable << note.begin << note.end << note.note << floating;
+ op << id << note.syllable << note.begin << note.end << note.note << floating << note.lineBreak;
return op;
}
}
@@ -66,8 +66,8 @@ void NoteGraphWidget::setLyrics(QString lyrics)
ts2 >> word;
if (!word.isEmpty()) {
Note note(word); note.note = 24;
+ if (sentenceStart) note.lineBreak = true;
doOperation(opFromNote(note, m_notes.size(), !firstNote));
- if (sentenceStart) setLineBreak(m_notes.back(), true);
firstNote = false;
sentenceStart = false;
}
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 98514b4..aa67cf7 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -81,8 +81,8 @@ void NoteLabelManager::split(NoteLabel *note, float ratio)
// Create operations for adding the new labels and deleting the old one
int id = getNoteLabelId(note);
Operation new1("NEW"), new2("NEW");
- new1 << id << firstst << n.begin << n.begin + n.length() * ratio << n.note << note->isFloating();
- new2 << id+1 << secondst << n.begin + n.length() * ratio << n.end << n.note << note->isFloating();
+ new1 << id << firstst << n.begin << n.begin + n.length() * ratio << n.note << note->isFloating() << n.lineBreak;
+ new2 << id+1 << secondst << n.begin + n.length() * ratio << n.end << n.note << note->isFloating() << false;
doOperation(new1, Operation::NO_UPDATE);
doOperation(new2, Operation::NO_UPDATE);
doOperation(Operation("DEL", id+2), Operation::NO_UPDATE);
@@ -180,8 +180,10 @@ void NoteLabelManager::doOperation(const Operation& op, Operation::OperationFlag
if (action == "BLOCK" || action == "COMBINER") {
; // No op
} else if (action == "NEW") {
+ Note newnote(op.s(2)); // lyric
+ newnote.lineBreak = op.b(7); // lineBreak
NoteLabel *newLabel = new NoteLabel(
- Note(op.s(2)), // Note(lyric)
+ newnote, // Note(lyric)
this, // parent
QPoint(s2px(op.d(3)), n2px(op.i(5)) - m_noteHalfHeight), // x,y
QSize(s2px(op.d(4) - op.d(3)), 2 * m_noteHalfHeight), // w,h
|
|
From: Tapio V. <aa...@us...> - 2011-02-04 08:58:19
|
Module: editor
Branch: master
Commit: f6954e541e0981582fdd9247dae6a8dba8c8f87b
Author: Tapio Vierros <tap...@gm...>
Date: Fri Feb 4 10:56:48 2011 +0200
Create and use a couple of convenience constructors for Operation.
---
notelabelmanager.cc | 28 +++++++++-------------------
operation.hh | 4 ++--
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 66a850e..98514b4 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -83,12 +83,10 @@ void NoteLabelManager::split(NoteLabel *note, float ratio)
Operation new1("NEW"), new2("NEW");
new1 << id << firstst << n.begin << n.begin + n.length() * ratio << n.note << note->isFloating();
new2 << id+1 << secondst << n.begin + n.length() * ratio << n.end << n.note << note->isFloating();
- Operation del("DEL"); del << id+2;
- Operation combiner("COMBINER"); combiner << 3; // This will combine the previous ones to one undo action
doOperation(new1, Operation::NO_UPDATE);
doOperation(new2, Operation::NO_UPDATE);
- doOperation(del, Operation::NO_UPDATE);
- doOperation(combiner);
+ doOperation(Operation("DEL", id+2), Operation::NO_UPDATE);
+ doOperation(Operation("COMBINER", 3)); // This will combine the previous ones to one undo action
}
void NoteLabelManager::del(NoteLabel *note)
@@ -105,16 +103,14 @@ void NoteLabelManager::del(NoteLabel *note)
}
// Combine to one undo operation
if (i > 1) {
- Operation op("COMBINER"); op << i; doOperation(op);
+ doOperation(Operation("COMBINER", i));
}
// Clear all
m_selectedNotes.clear();
} else {
// Here we have non-selected note up for deletion
- Operation op("DEL");
- op << getNoteLabelId(note);
- doOperation(op);
+ doOperation(Operation("DEL", getNoteLabelId(note)));
}
}
@@ -134,7 +130,7 @@ void NoteLabelManager::move(NoteLabel *note, int value)
// Combine to one undo operation
if (i > 1) {
- Operation op("COMBINER"); op << i; doOperation(op);
+ doOperation(Operation("COMBINER", i));
}
}
@@ -149,20 +145,14 @@ void NoteLabelManager::setType(NoteLabel *note, int index)
void NoteLabelManager::setFloating(NoteLabel *note, bool state)
{
- if (note && note->isFloating() != state) {
- Operation op("FLOATING");
- op << getNoteLabelId(note) << state;
- doOperation(op);
- }
+ if (note && note->isFloating() != state)
+ doOperation(Operation("FLOATING", getNoteLabelId(note), state));
}
void NoteLabelManager::setLineBreak(NoteLabel *note, bool state)
{
- if (note && note->isLineBreak() != state) {
- Operation op("LINEBREAK");
- op << getNoteLabelId(note) << state;
- doOperation(op);
- }
+ if (note && note->isLineBreak() != state)
+ doOperation(Operation("LINEBREAK", getNoteLabelId(note), state));
}
void NoteLabelManager::editLyric(NoteLabel *note) {
diff --git a/operation.hh b/operation.hh
index b00a841..5b9e56f 100644
--- a/operation.hh
+++ b/operation.hh
@@ -12,13 +12,13 @@ struct Operation
Operation() { }
Operation(const QString &opString) { *this << opString; }
+ Operation(const QString &opString, int id) { *this << opString << id; }
+ Operation(const QString &opString, int id, bool state) { *this << opString << id << state; }
// Functions to add parameters to Operation
Operation& operator<<(const QString &str) { m_params.push_back(QVariant(str)); return *this; }
- //Operation& operator<<(char c) { m_params.push_back(QVariant(c)); return *this; }
Operation& operator<<(int i) { m_params.push_back(QVariant(i)); return *this; }
- //Operation& operator<<(unsigned u) { m_params.push_back(QVariant(u)); return *this; }
Operation& operator<<(bool b) { m_params.push_back(QVariant(b)); return *this; }
Operation& operator<<(float f) { m_params.push_back(QVariant(f)); return *this; }
Operation& operator<<(double d) { m_params.push_back(QVariant(d)); return *this; }
|
|
From: Tapio V. <aa...@us...> - 2011-02-04 08:58:16
|
Module: editor
Branch: master
Commit: 5ef73b8807c1f3ee84c8fcf8992f61e1378deb0a
Author: Tapio Vierros <tap...@gm...>
Date: Fri Feb 4 10:48:14 2011 +0200
Fix note splitting.
---
notelabelmanager.cc | 8 ++++++--
operation.hh | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 2783dae..66a850e 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -85,7 +85,10 @@ void NoteLabelManager::split(NoteLabel *note, float ratio)
new2 << id+1 << secondst << n.begin + n.length() * ratio << n.end << n.note << note->isFloating();
Operation del("DEL"); del << id+2;
Operation combiner("COMBINER"); combiner << 3; // This will combine the previous ones to one undo action
- doOperation(new1); doOperation(new2); doOperation(del); doOperation(combiner);
+ doOperation(new1, Operation::NO_UPDATE);
+ doOperation(new2, Operation::NO_UPDATE);
+ doOperation(del, Operation::NO_UPDATE);
+ doOperation(combiner);
}
void NoteLabelManager::del(NoteLabel *note)
@@ -219,7 +222,8 @@ void NoteLabelManager::doOperation(const Operation& op, Operation::OperationFlag
n->createPixmap(n->size());
}
}
- updateNotes();
+ if (!(flags & Operation::NO_UPDATE))
+ updateNotes();
}
if (!(flags & Operation::NO_EMIT)) {
emit operationDone(op);
diff --git a/operation.hh b/operation.hh
index 7b25ff5..b00a841 100644
--- a/operation.hh
+++ b/operation.hh
@@ -8,7 +8,7 @@
struct Operation
{
- enum OperationFlags { NORMAL = 0, NO_EXEC = 1, NO_EMIT = 2 };
+ enum OperationFlags { NORMAL = 0, NO_EXEC = 1, NO_EMIT = 2, NO_UPDATE = 4 };
Operation() { }
Operation(const QString &opString) { *this << opString; }
|
|
From: Tapio V. <aa...@us...> - 2011-02-04 08:35:05
|
Module: editor Branch: master Commit: f8006c7b2a2074b575e1f4d586c69d853774c86a Author: Tapio Vierros <tap...@gm...> Date: Fri Feb 4 10:34:32 2011 +0200 Fix new note y-position. --- notelabelmanager.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/notelabelmanager.cc b/notelabelmanager.cc index 4774957..2783dae 100644 --- a/notelabelmanager.cc +++ b/notelabelmanager.cc @@ -190,7 +190,7 @@ void NoteLabelManager::doOperation(const Operation& op, Operation::OperationFlag NoteLabel *newLabel = new NoteLabel( Note(op.s(2)), // Note(lyric) this, // parent - QPoint(s2px(op.d(3)), n2px(op.i(5))), // x,y + QPoint(s2px(op.d(3)), n2px(op.i(5)) - m_noteHalfHeight), // x,y QSize(s2px(op.d(4) - op.d(3)), 2 * m_noteHalfHeight), // w,h op.b(6) // floating ); |