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-24 02:48:23
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 03:40:18 2011 +0100 Fix pitch wave color (colorMatrix not updated => use vertex colors instead). --- game/notegraph.cc | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/game/notegraph.cc b/game/notegraph.cc index 322025f..f012ea8 100644 --- a/game/notegraph.cc +++ b/game/notegraph.cc @@ -207,7 +207,7 @@ void NoteGraph::drawWaves(Database const& database) { double oldval = getNaN(); glutil::VertexArray va; Notes::const_iterator noteIt = m_vocal.notes.begin(); - glutil::Color c(Color(p->m_color.r, p->m_color.g, p->m_color.b, m_notealpha)); + Color c(p->m_color.r, p->m_color.g, p->m_color.b, m_notealpha); for (; idx < endIdx; ++idx, t += Engine::TIMESTEP) { double const freq = pitch[idx].first; // If freq is NaN, we have nothing to process @@ -235,10 +235,10 @@ void NoteGraph::drawWaves(Database const& database) { // If there has been a break or if the pitch change is too fast, terminate and begin a new one if (oldval != oldval || std::abs(oldval - val) > 1) strip(va); // Add a point or a pair of points - if (!va.size()) va.TexCoord(tex, 0.5f).Vertex(x, y); + if (!va.size()) va.TexCoord(tex, 0.5f).Color(c).Vertex(x, y); else { - va.TexCoord(tex, 0.0f).Vertex(x, y - thickness); - va.TexCoord(tex, 1.0f).Vertex(x, y + thickness); + va.TexCoord(tex, 0.0f).Color(c).Vertex(x, y - thickness); + va.TexCoord(tex, 1.0f).Color(c).Vertex(x, y + thickness); } oldval = val; } |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:48:17
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 03:39:26 2011 +0100 Shader cleanup, now conditional parts only in fragment shader (where performance matters). --- data/shaders/core.frag | 18 ------------------ data/shaders/core.vert | 16 ---------------- data/shaders/dancenote.vert | 9 ++++----- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/data/shaders/core.frag b/data/shaders/core.frag index ffec65a..3d3353c 100644 --- a/data/shaders/core.frag +++ b/data/shaders/core.frag @@ -3,37 +3,19 @@ //DEFINES -#ifdef ENABLE_BOGUS in float bogus; // Nvidia will overwrite the first in variable with bogus data, so as a workaround we put a bogus variable here -#endif - in mat4 colorMat; - -#ifdef ENABLE_LIGHTING in vec3 normal; -#endif - -#ifdef ENABLE_VERTEX_COLOR in vec4 color; -#endif - -#ifdef SURFACE -#endif #ifdef ENABLE_TEXTURING - in vec4 texCoord; - #if ENABLE_TEXTURING == 1 - uniform sampler2DRect tex; #define TEXFUNC texture2DRect(tex, texCoord.st) - #elif ENABLE_TEXTURING == 2 - uniform sampler2D tex; #define TEXFUNC texture2D(tex, texCoord.st) - #else #error Unknown texturing mode in ENABLE_TEXTURING #endif diff --git a/data/shaders/core.vert b/data/shaders/core.vert index 95934b5..f47515b 100644 --- a/data/shaders/core.vert +++ b/data/shaders/core.vert @@ -2,46 +2,30 @@ //DEFINES -#ifdef ENABLE_BOGUS varying float bogus; -#endif in vec4 vertPos; uniform mat4 colorMatrix; varying mat4 colorMat; -#ifdef ENABLE_TEXTURING in vec4 vertTexCoord; varying vec4 texCoord; varying vec4 vTexCoord; -#endif -#ifdef ENABLE_LIGHTING in vec3 vertNormal; varying vec3 normal; varying vec3 vNormal; -#endif -#ifdef ENABLE_VERTEX_COLOR in vec4 vertColor; varying vec4 color; varying vec4 vColor; -#endif void main() { -#ifdef ENABLE_BOGUS bogus = 0.0; -#endif colorMat = colorMatrix; // In case no geometry shader is used (otherwise it sets this) gl_Position = gl_ModelViewProjectionMatrix * vertPos; -#ifdef ENABLE_TEXTURING vTexCoord = texCoord = vertTexCoord; -#endif -#ifdef ENABLE_LIGHTING vNormal = normal = normalize(gl_NormalMatrix * vertNormal); -#endif -#ifdef ENABLE_VERTEX_COLOR vColor = color = vertColor; -#endif } diff --git a/data/shaders/dancenote.vert b/data/shaders/dancenote.vert index 06c35a7..4919a05 100644 --- a/data/shaders/dancenote.vert +++ b/data/shaders/dancenote.vert @@ -1,10 +1,9 @@ #version 120 -// Input from glVertexAttribPointer -/* layout (location = 0) */ in vec4 vertPos; -/* layout (location = 1) */ in vec4 vertTexCoord; -/* layout (location = 2) */ in vec3 vertNormal; -/* layout (location = 3) */ in vec4 vertColor; +in vec4 vertPos; +in vec4 vertTexCoord; +in vec3 vertNormal; +in vec4 vertColor; varying float bogus; |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:48:10
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 03:16:18 2011 +0100 Rewrite 3dobject for glutil::VertexArray, fix OBJ parser bugs, add glmath::Vec4 support for VA. --- game/3dobject.cc | 111 +++++++++++++----------------------------------------- game/3dobject.hh | 42 ++------------------ game/glshader.hh | 18 +++++++- 3 files changed, 45 insertions(+), 126 deletions(-) diff --git a/game/3dobject.cc b/game/3dobject.cc index 379c28e..8e921c1 100644 --- a/game/3dobject.cc +++ b/game/3dobject.cc @@ -24,41 +24,43 @@ namespace { } } +/// A polygon containing links to required point data +struct Face { + std::vector<int> vertices; + std::vector<int> texcoords; + std::vector<int> normals; +}; + /// Load a Wavefront .obj file and possibly scale it also void Object3d::loadWavefrontObj(std::string filepath, float scale) { int linenumber = 0; std::string row; std::ifstream file(filepath.c_str(), std::ios::binary); if (!file.is_open()) throw std::runtime_error("Couldn't open object file "+filepath); - // Get rid of old data - m_vertices.clear(); - m_faces.clear(); - m_texcoords.clear(); - while (!file.eof()) { - getline(file, row); // Read a line + std::vector<glmath::Vec4> m_vertices, m_normals, m_texcoords; + std::vector<Face> m_faces; + while (getline(file, row)) { ++linenumber; std::istringstream srow(row); float x,y,z; std::string tempst; if (row.substr(0,2) == "v ") { // Vertices srow >> tempst >> x >> y >> z; - m_vertices.push_back(Vertex(x*scale,y*scale,z*scale)); + m_vertices.push_back(glmath::Vec4(x*scale, y*scale, z*scale, 1.0f)); } else if (row.substr(0,2) == "vt") { // Texture Coordinates srow >> tempst >> x >> y; - m_texcoords.push_back(TexCoord(x,y)); + m_texcoords.push_back(glmath::Vec4(x, y, 0.0f, 0.0f)); } else if (row.substr(0,2) == "vn") { // Normals srow >> tempst >> x >> y >> z; double sum = std::abs(x)+std::abs(y)+std::abs(z); if (sum == 0) throw std::runtime_error("Invalid normal in "+filepath+":"+boost::lexical_cast<std::string>(linenumber)); x /= sum; y /= sum; z /= sum; // Normalize components - m_normals.push_back(Vertex(x,y,z)); + m_normals.push_back(glmath::Vec4(x, y, z, 0.0)); } else if (row.substr(0,2) == "f ") { // Faces Face f; srow >> tempst; // Eat away prefix // Parse face point's coordinate references - while (!srow.eof()) { - std::string fpoint; - srow >> fpoint; + for (std::string fpoint; srow >> fpoint; ) { for (size_t i = 1; i <= 3; ++i) { std::string st_id(getWord(fpoint,i,'/')); if (!st_id.empty()) { @@ -86,82 +88,21 @@ void Object3d::loadWavefrontObj(std::string filepath, float scale) { } } } + // Construct a vertex array + for (std::vector<Face>::const_iterator i = m_faces.begin(); i != m_faces.end(); ++i) { + bool hasNormals = !i->normals.empty(); + bool hasTexCoords = !i->texcoords.empty(); + for (size_t j = 0; j < i->vertices.size(); ++j) { + if (hasNormals) m_va.Normal(m_normals[i->normals[j]]); + if (hasTexCoords) m_va.TexCoord(m_texcoords[i->texcoords[j]]); + m_va.Vertex(m_vertices[i->vertices[j]]); + } + } + } void Object3d::drawVBO() { UseShader us(getShader("3dobject")); - int stride = 3*sizeof(GLfloat); - int offset = 0; - if (m_vboStructure & HAS_TEXCOORDS) stride += 2*sizeof(GLfloat); - if (m_vboStructure & HAS_NORMALS) stride += 3*sizeof(GLfloat); - - glBindBuffer(GL_ARRAY_BUFFER, m_vbo); - - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, stride, (const GLvoid *)offset); - offset += 3*sizeof(GLfloat); - - if (m_vboStructure & HAS_NORMALS) { - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, stride, (const GLvoid *)offset); - offset += 3*sizeof(GLfloat); - } - - if (m_vboStructure & HAS_TEXCOORDS) { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, stride, (const GLvoid *)offset); - } - - glDrawArrays(m_polyType, 0, m_numvertices); - - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - glBindBuffer(GL_ARRAY_BUFFER, 0); + m_va.Draw(GL_TRIANGLES); } -void Object3d::generateVBO() { - std::vector<GLfloat> data; - - if (m_vbo != 0) glDeleteBuffers(1, &m_vbo); - glGenBuffers(1, &m_vbo); - glBindBuffer(GL_ARRAY_BUFFER, m_vbo); - - // TODO: We should tessellate everything into triangles somehow - // in order to allow non-triangle based meshes. - m_polyType = GL_TRIANGLES; - m_numvertices = m_faces.size() * 3; // Triangle faces - - m_vboStructure = 0; - if (!m_texcoords.empty()) m_vboStructure |= HAS_TEXCOORDS; - if (!m_normals.empty()) m_vboStructure |= HAS_NORMALS; - - std::vector<Face>::const_iterator i; - for (i = m_faces.begin(); i != m_faces.end(); ++i) { - for (size_t j = 0; j < i->vertices.size(); ++j) { - data.push_back(m_vertices[i->vertices[j]].x); - data.push_back(m_vertices[i->vertices[j]].y); - data.push_back(m_vertices[i->vertices[j]].z); - - if (m_vboStructure & HAS_NORMALS) { - data.push_back(m_normals[i->normals[j]].x); - data.push_back(m_normals[i->normals[j]].y); - data.push_back(m_normals[i->normals[j]].z); - } - - if (m_vboStructure & HAS_TEXCOORDS) { - data.push_back(m_texcoords[i->texcoords[j]].s); - data.push_back(m_texcoords[i->texcoords[j]].t); - } - } - } - - glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*data.size(), &data.front(), GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - data.clear(); - m_vertices.clear(); - m_normals.clear(); - m_texcoords.clear(); - m_faces.clear(); -} diff --git a/game/3dobject.hh b/game/3dobject.hh index ef99f11..1479c3b 100644 --- a/game/3dobject.hh +++ b/game/3dobject.hh @@ -5,64 +5,30 @@ #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> #include "surface.hh" +#include "glshader.hh" #include "glutil.hh" // TODO: Exception handling // TODO: Texture loading -/// Point in 3d space -struct Vertex { - Vertex(float x = 0, float y = 0, float z = 0): x(x), y(y), z(z) {} - float x; - float y; - float z; -}; - -/// 2d texture coordinate -struct TexCoord { - TexCoord(float s = 0, float t = 0): s(s), t(t) {} - float s; - float t; -}; - -/// A polygon containing links to required point data -struct Face { - std::vector<int> vertices; - std::vector<int> texcoords; - std::vector<int> normals; -}; - /// A class representing 3d object /// Non-copyable because of display lists getting messed up class Object3d: boost::noncopyable { private: - std::vector<Vertex> m_vertices; /// vertices - std::vector<TexCoord> m_texcoords; /// texture coordinates - std::vector<Vertex> m_normals; /// normals - std::vector<Face> m_faces; /// faces - GLuint m_vbo; - GLuint m_polyType; - int m_vboStructure; - int m_numvertices; + glutil::VertexArray m_va; boost::scoped_ptr<Texture> m_texture; /// texture /// load a Wavefront .obj 3d object file void loadWavefrontObj(std::string filepath, float scale = 1.0); - void generateVBO(); public: + Object3d() {} /// constructors - Object3d(): m_vbo(0) {}; - Object3d(std::string filepath, std::string texturepath = "", float scale = 1.0): m_vbo(0) { + Object3d(std::string filepath, std::string texturepath = "", float scale = 1.0) { load(filepath, texturepath, scale); } - /// destructor - ~Object3d() { - if (m_vbo != 0) glDeleteBuffers(1, &m_vbo); - } /// load a new object file void load(std::string filepath, std::string texturepath = "", float scale = 1.0) { if (!texturepath.empty()) m_texture.reset(new Texture(texturepath)); loadWavefrontObj(filepath, scale); - generateVBO(); } void drawVBO(); /// draws the object diff --git a/game/glshader.hh b/game/glshader.hh index bfd0d44..4a2ae25 100644 --- a/game/glshader.hh +++ b/game/glshader.hh @@ -121,19 +121,31 @@ namespace glutil { VertexArray() {} VertexArray& Vertex(float x, float y, float z = 0.0f) { - m_vert.position = glmath::Vec4(x, y, z, 1.0f); + return Vertex(glmath::Vec4(x, y, z, 1.0f)); + } + + VertexArray& Vertex(glmath::Vec4 const& v) { + m_vert.position = v; m_vertices.push_back(m_vert); m_vert = VertexInfo(); return *this; } VertexArray& Normal(float x, float y, float z) { - m_vert.normal = glmath::Vec4(x, y, z, 1.0f); + return Normal(glmath::Vec4(x, y, z, 1.0f)); + } + + VertexArray& Normal(glmath::Vec4 const& v) { + m_vert.normal = v; return *this; } VertexArray& TexCoord(float s, float t, float u = 0.0f, float v = 0.0f) { - m_vert.texCoord = glmath::Vec4(s, t, u, v); + return TexCoord(glmath::Vec4(s, t, u, v)); + } + + VertexArray& TexCoord(glmath::Vec4 const& v) { + m_vert.texCoord = v; return *this; } |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:48:04
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 02:34:26 2011 +0100 Fix logo display during loading (again). --- game/screenmanager.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/game/screenmanager.cc b/game/screenmanager.cc index 2c60c2a..460b2b0 100644 --- a/game/screenmanager.cc +++ b/game/screenmanager.cc @@ -50,10 +50,10 @@ void ScreenManager::drawScreen() { void ScreenManager::loading(std::string const& message, float progress) { - drawLogo(); // TODO: Create a better one, this is quite ugly flashMessage(message + " " + boost::lexical_cast<std::string>(int(round(progress*100))) + "%", 0.0f, 1.0f, 1.0f); m_window.blank(); + drawLogo(); drawNotifications(); const int maxi = 20; const float x = 0.3; |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:47:56
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 02:30:58 2011 +0100 Fix loading bar color (colorMatrix upload only occurs on shader bind). --- game/screenmanager.cc | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/game/screenmanager.cc b/game/screenmanager.cc index 5808362..2c60c2a 100644 --- a/game/screenmanager.cc +++ b/game/screenmanager.cc @@ -61,6 +61,7 @@ void ScreenManager::loading(std::string const& message, float progress) { const float sq_size = (2*x - (maxi-1)*spacing) / maxi; for (int i = 0; i <= progress * maxi; ++i) { glutil::Color c(Color(0.2f, 0.7f, 0.7f, (progress + 1)*0.5f)); + UseShader shader(getShader("color")); glutil::Square(-x + i * (sq_size + spacing), 0, sq_size/2, true); } m_window.swap(); |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:47:50
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 01:56:18 2011 +0100 VertexArray simplification/optimization. Be sure the always call .Vertex only after all other attributes from now on. --- game/glshader.cc | 17 +++++++---------- game/glshader.hh | 54 ++++++++++++++++++++++++++---------------------------- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/game/glshader.cc b/game/glshader.cc index fa864d6..c01912f 100644 --- a/game/glshader.cc +++ b/game/glshader.cc @@ -139,33 +139,30 @@ GLint Shader::operator[](const std::string& uniform) { } void VertexArray::Draw(GLint mode) { + if (empty()) return; GLint program; glGetIntegerv(GL_CURRENT_PROGRAM, &program); GLint vertPos = glGetAttribLocation(program, "vertPos"); GLint vertTexCoord = glGetAttribLocation(program, "vertTexCoord"); GLint vertNormal = glGetAttribLocation(program, "vertNormal"); GLint vertColor = glGetAttribLocation(program, "vertColor"); - unsigned vertices = size(); + glmath::Vec4 const* ptr = &m_vertices[0].position; + unsigned stride = sizeof(VertexInfo); if (vertPos != -1) { glEnableVertexAttribArray(vertPos); - glVertexAttribPointer(vertPos, 3, GL_FLOAT, GL_FALSE, 0, &m_vertices.front()); + glVertexAttribPointer(vertPos, 4, GL_FLOAT, GL_FALSE, stride, ptr); } if (vertTexCoord != -1) { - if (m_texcoords.empty()) m_texcoords.resize(4 * vertices, 0.0f); // FIXME: Shouldn't be using a texturing shader if not texturing... - if (m_texcoords.size() != 4 * vertices) throw std::logic_error("Invalid number of vertex texture coordinates"); glEnableVertexAttribArray(vertTexCoord); - glVertexAttribPointer(vertTexCoord, 4, GL_FLOAT, GL_FALSE, 0, &m_texcoords.front()); + glVertexAttribPointer(vertTexCoord, 4, GL_FLOAT, GL_FALSE, stride, ptr + 1); } if (vertNormal != -1) { - if (m_normals.size() != 3 * vertices) throw std::logic_error("Invalid number of vertex normals"); glEnableVertexAttribArray(vertNormal); - glVertexAttribPointer(vertNormal, 3, GL_FLOAT, GL_FALSE, 0, &m_normals.front()); + glVertexAttribPointer(vertNormal, 4, GL_FLOAT, GL_FALSE, stride, ptr + 2); } if (vertColor != 1) { - if (m_colors.empty()) m_colors.resize(4 * vertices, 1.0f); - if (m_colors.size() != 4 * vertices) throw std::logic_error("Invalid number of vertex colors"); glEnableVertexAttribArray(vertColor); - glVertexAttribPointer(vertColor, 4, GL_FLOAT, GL_FALSE, 0, &m_colors.front()); + glVertexAttribPointer(vertColor, 4, GL_FLOAT, GL_FALSE, stride, ptr + 3); } glDrawArrays(mode, 0, size()); diff --git a/game/glshader.hh b/game/glshader.hh index 5ab89d0..bfd0d44 100644 --- a/game/glshader.hh +++ b/game/glshader.hh @@ -99,67 +99,65 @@ struct UseShader { }; namespace glutil { + // Note: if you reorder or otherwise change the contents of this, VertexShader::Draw() must be modified accordingly + struct VertexInfo { + glmath::Vec4 position; + glmath::Vec4 texCoord; + glmath::Vec4 normal; + glmath::Vec4 color; + VertexInfo(): + position(0.0, 0.0, 0.0, 1.0), + texCoord(0.0, 0.0, 0.0, 0.0), + normal(0.0, 0.0, 0.0, 0.0), + color(1.0, 1.0, 1.0, 1.0) + {} + }; /// handy vertex array capable of drawing itself class VertexArray { private: - std::vector<float> m_vertices; - std::vector<float> m_normals; - std::vector<float> m_texcoords; - std::vector<float> m_colors; - + std::vector<VertexInfo> m_vertices; + VertexInfo m_vert; public: VertexArray() {} VertexArray& Vertex(float x, float y, float z = 0.0f) { - m_vertices.push_back(x); - m_vertices.push_back(y); - m_vertices.push_back(z); + m_vert.position = glmath::Vec4(x, y, z, 1.0f); + m_vertices.push_back(m_vert); + m_vert = VertexInfo(); return *this; } VertexArray& Normal(float x, float y, float z) { - m_normals.push_back(x); - m_normals.push_back(y); - m_normals.push_back(z); + m_vert.normal = glmath::Vec4(x, y, z, 1.0f); return *this; } VertexArray& TexCoord(float s, float t, float u = 0.0f, float v = 0.0f) { - m_texcoords.push_back(s); - m_texcoords.push_back(t); - m_texcoords.push_back(u); - m_texcoords.push_back(v); + m_vert.texCoord = glmath::Vec4(s, t, u, v); return *this; } - VertexArray& Color(float r, float g, float b, float a) { - m_colors.push_back(r); - m_colors.push_back(g); - m_colors.push_back(b); - m_colors.push_back(a); + VertexArray& Color(float r, float g, float b, float a = 1.0f) { + m_vert.color = glmath::Vec4(r, g, b, a); return *this; } VertexArray& Color(const glutil::Color& c) { - m_colors.push_back(c.r); - m_colors.push_back(c.g); - m_colors.push_back(c.b); - m_colors.push_back(c.a); - return *this; + return Color(c.r, c.g, c.b, c.a); } void Draw(GLint mode = GL_TRIANGLE_STRIP); bool empty() const { - return m_vertices.empty() && m_normals.empty() && m_texcoords.empty() && m_colors.empty(); + return m_vertices.empty(); } unsigned size() const { - return m_vertices.size() / 3; + return m_vertices.size(); } void clear() { - m_vertices.clear(); m_normals.clear(); m_texcoords.clear(); m_colors.clear(); + m_vertices.clear(); } }; |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:47:43
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 00:32:04 2011 +0100 Layout changes for flash messages so that they do not overlap with the logo --- game/screenmanager.cc | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/game/screenmanager.cc b/game/screenmanager.cc index e8eb6e8..5808362 100644 --- a/game/screenmanager.cc +++ b/game/screenmanager.cc @@ -2,6 +2,7 @@ #include "fs.hh" #include "configuration.hh" #include "glutil.hh" +#include "glmath.hh" #include "util.hh" #include <boost/thread.hpp> @@ -17,7 +18,7 @@ ScreenManager::ScreenManager(Window& _window): m_messagePopup(0.0, 1.0), m_textMessage(getThemePath("message_text.svg"), config["graphic/text_lod"].f()), m_logo(getThemePath("logo.svg")), m_logoAnim(0.0, 0.5) { - m_textMessage.dimensions.middle().screenTop(0.05); + m_textMessage.dimensions.middle().center(-0.05); } void ScreenManager::activateScreen(std::string const& name) { @@ -49,6 +50,7 @@ void ScreenManager::drawScreen() { void ScreenManager::loading(std::string const& message, float progress) { + drawLogo(); // TODO: Create a better one, this is quite ugly flashMessage(message + " " + boost::lexical_cast<std::string>(int(round(progress*100))) + "%", 0.0f, 1.0f, 1.0f); m_window.blank(); @@ -61,7 +63,6 @@ void ScreenManager::loading(std::string const& message, float progress) { glutil::Color c(Color(0.2f, 0.7f, 0.7f, (progress + 1)*0.5f)); glutil::Square(-x + i * (sq_size + spacing), 0, sq_size/2, true); } - drawLogo(); m_window.swap(); } |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 02:47:37
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 00:15:59 2011 +0100 Separated logo from backgrounds and added animations for it. --- game/screen.hh | 5 ++ game/screen_intro.cc | 1 + game/screen_sing.cc | 3 + game/screen_songs.cc | 1 + game/screenmanager.cc | 12 ++++- themes/default/configuration_bg.svg | 17 +------ themes/default/intro_bg.svg | 17 +------ themes/default/logo.svg | 90 +++++++++++++++++++++++++++++++++++ themes/default/practice_bg.svg | 17 +------ themes/default/songs_bg.svg | 21 ++------- 10 files changed, 120 insertions(+), 64 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 22:34:51
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 23:33:51 2011 +0100 Move UseShader to 3dobject.cc instead of the header --- game/3dobject.cc | 1 + game/3dobject.hh | 2 -- 2 files changed, 1 insertions(+), 2 deletions(-) diff --git a/game/3dobject.cc b/game/3dobject.cc index c3b4418..379c28e 100644 --- a/game/3dobject.cc +++ b/game/3dobject.cc @@ -89,6 +89,7 @@ void Object3d::loadWavefrontObj(std::string filepath, float scale) { } void Object3d::drawVBO() { + UseShader us(getShader("3dobject")); int stride = 3*sizeof(GLfloat); int offset = 0; if (m_vboStructure & HAS_TEXCOORDS) stride += 2*sizeof(GLfloat); diff --git a/game/3dobject.hh b/game/3dobject.hh index 8fe4c02..ef99f11 100644 --- a/game/3dobject.hh +++ b/game/3dobject.hh @@ -72,10 +72,8 @@ class Object3d: boost::noncopyable { if (s != 1.0) glScalef(s,s,s); // Scale if needed if (m_texture) { UseTexture tex(*m_texture); - UseShader us(getShader("3dobject")); drawVBO(); } else { - UseShader us(getShader("3dobject")); drawVBO(); } } |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 22:34:44
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 21:36:11 2011 +0100 Merge branch 'master' into opengl2 --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 22:34:38
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 21:27:13 2011 +0100 Add mapping for RockBand guitar with USB adapter --- data/controllers.xml | 15 +++++++++++++++ game/joystick.cc | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/data/controllers.xml b/data/controllers.xml index 6e8560b..23fbca1 100644 --- a/data/controllers.xml +++ b/data/controllers.xml @@ -53,6 +53,21 @@ <button id="7" value="start" /> </mapping> </controller> + <controller type="guitar" name="GUITAR_ROCKBAND_XBOXADAPTER"> + <description>Rock Band guitar Xbox with USB adapter</description> + <regexp match="Generic X-Box pad" /> + <mapping> + <button id="0" value="green" /> + <button id="1" value="red" /> + <button id="2" value="blue" /> + <button id="3" value="yellow" /> + <button id="4" value="orange" /> + <button id="10" value="select" /> + <button id="6" value="start" /> + <axis id="4" range="-32768" value="godmode" /> + <axis id="3" range="-32768:32767" value="whammy" /> + </mapping> + </controller> <controller type="guitar" name="GUITAR_ROCKBAND_PS3"> <description>Rock Band guitar PS3</description> <regexp match="Harmonix Guitar .* PlayStation" /> diff --git a/game/joystick.cc b/game/joystick.cc index 663c12c..e18499a 100644 --- a/game/joystick.cc +++ b/game/joystick.cc @@ -768,7 +768,9 @@ bool input::SDL::pushEvent(SDL_Event _e) { } break; } else if ((dev.name() != "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2 ) - || (dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 4)) { + || (dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 4) + || (dev.name() == "GUITAR_ROCKBAND_XBOXADAPTER" && _e.jaxis.axis == 3)) + { // Whammy bar (special case for XBox RB guitar for( unsigned int i = 0 ; i < BUTTONS ; ++i ) { event.pressed[i] = dev.pressed(i); @@ -784,7 +786,9 @@ bool input::SDL::pushEvent(SDL_Event _e) { dev.addEvent(event); break; } else if ((dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 3) - || (dev.name() == "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2)) { + || (dev.name() == "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2) + || (dev.name() == "GUITAR_ROCKBAND_XBOXADAPTER" && _e.jaxis.axis ==4)) + { // Tilt sensor as an axis on some guitars for( unsigned int i = 0 ; i < BUTTONS ; ++i ) { event.pressed[i] = dev.pressed(i); |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 22:34:32
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 18:25:48 2011 +0100 Default webcam to disabled because it causes crashes on many systems --- data/schema.xml | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/schema.xml b/data/schema.xml index 3f05b12..4bdc3f9 100644 --- a/data/schema.xml +++ b/data/schema.xml @@ -131,10 +131,10 @@ to save the current settings to XML. <long>Allows completely disabling background videos. It is recommended to leave this enabled as Performous will still smoothly fade out the video if your computer is not fast enough.</long> </locale> </entry> - <entry name="graphic/webcam" type="bool" value="true"> + <entry name="graphic/webcam" type="bool" value="false"> <locale name="C"> <short>Webcam background</short> - <long>Performous can try to use webcam as a background video. You can disable it if it annoys you.</long> + <long>Performous can use webcam as a background video. Disable it if Performous crashes while entering a song.</long> </locale> </entry> <entry name="graphic/webcamid" type="int" value="-1"> |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 22:34:27
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 9 21:24:35 2011 +0200
Fix warning.
---
game/notes.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/game/notes.cc b/game/notes.cc
index ed9f4ea..14af3a2 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -80,6 +80,7 @@ double Note::scoreMultiplier() const {
case LIFT:
return 1.0;
}
+ return 0.0;
}
double Note::powerFactor(double note) const {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 20:27:34
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 21:27:13 2011 +0100 Add mapping for RockBand guitar with USB adapter --- data/controllers.xml | 15 +++++++++++++++ game/joystick.cc | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/data/controllers.xml b/data/controllers.xml index 6e8560b..23fbca1 100644 --- a/data/controllers.xml +++ b/data/controllers.xml @@ -53,6 +53,21 @@ <button id="7" value="start" /> </mapping> </controller> + <controller type="guitar" name="GUITAR_ROCKBAND_XBOXADAPTER"> + <description>Rock Band guitar Xbox with USB adapter</description> + <regexp match="Generic X-Box pad" /> + <mapping> + <button id="0" value="green" /> + <button id="1" value="red" /> + <button id="2" value="blue" /> + <button id="3" value="yellow" /> + <button id="4" value="orange" /> + <button id="10" value="select" /> + <button id="6" value="start" /> + <axis id="4" range="-32768" value="godmode" /> + <axis id="3" range="-32768:32767" value="whammy" /> + </mapping> + </controller> <controller type="guitar" name="GUITAR_ROCKBAND_PS3"> <description>Rock Band guitar PS3</description> <regexp match="Harmonix Guitar .* PlayStation" /> diff --git a/game/joystick.cc b/game/joystick.cc index 663c12c..e18499a 100644 --- a/game/joystick.cc +++ b/game/joystick.cc @@ -768,7 +768,9 @@ bool input::SDL::pushEvent(SDL_Event _e) { } break; } else if ((dev.name() != "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2 ) - || (dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 4)) { + || (dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 4) + || (dev.name() == "GUITAR_ROCKBAND_XBOXADAPTER" && _e.jaxis.axis == 3)) + { // Whammy bar (special case for XBox RB guitar for( unsigned int i = 0 ; i < BUTTONS ; ++i ) { event.pressed[i] = dev.pressed(i); @@ -784,7 +786,9 @@ bool input::SDL::pushEvent(SDL_Event _e) { dev.addEvent(event); break; } else if ((dev.name() == "GUITAR_ROCKBAND_XBOX360" && _e.jaxis.axis == 3) - || (dev.name() == "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2)) { + || (dev.name() == "GUITAR_GUITARHERO_XPLORER" && _e.jaxis.axis == 2) + || (dev.name() == "GUITAR_ROCKBAND_XBOXADAPTER" && _e.jaxis.axis ==4)) + { // Tilt sensor as an axis on some guitars for( unsigned int i = 0 ; i < BUTTONS ; ++i ) { event.pressed[i] = dev.pressed(i); |
|
From: Tapio V. <aa...@us...> - 2011-02-23 18:51:58
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 23 20:50:41 2011 +0200
Remove a couple of duplicate "magic numbers".
---
editorapp.cc | 11 +++++++----
notegraphwidget.cc | 5 +++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 2254125..5fa4043 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -954,7 +954,10 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
{
if (!ngw) return;
const int notes = 12 * 4; // Four octaves
+ const QColor borderColor = QColor("#c0c0c0");
+ const QColor selectionColor = QColor("#090");
int noteHeight = ngw->n2px(0) - ngw->n2px(1);
+
QImage image(50, notes * noteHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
setFixedSize(image.width(), image.height());
@@ -970,8 +973,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
int y2 = image.height() - i * noteHeight; // Note center y
y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
- else pen.setColor(QColor("#c0c0c0"));
+ if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ else pen.setColor(borderColor);
painter.setPen(pen);
// Skip the first key because y hasn't been calculated yet
if (i > -1) {
@@ -986,8 +989,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
if (!scale.isSharp(i)) continue;
y = image.height() - i*noteHeight - noteHeight / 2;
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
- else pen.setColor(QColor("#c0c0c0"));
+ if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ else pen.setColor(borderColor);
painter.setPen(pen);
painter.fillRect(0, y, w, noteHeight, QColor("#000000"));
painter.drawRect(0, y, w, noteHeight);
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index e51dc39..ecbc311 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -24,6 +24,7 @@ namespace {
}
static const double endMarginSeconds = 5.0;
+ static const int NoteGraphHeight = 768;
}
@@ -39,7 +40,7 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
// Initially expanding horizontally to fill the space
QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);
setSizePolicy(sp);
- setFixedHeight(768);
+ setFixedHeight(NoteGraphHeight);
setFocusPolicy(Qt::StrongFocus);
setAcceptDrops(true);
@@ -696,7 +697,7 @@ QString NoteGraphWidget::dumpLyrics() const
SeekHandle::SeekHandle(QWidget *parent)
: QLabel(parent)
{
- QImage image(8, 768, QImage::Format_ARGB32_Premultiplied);
+ QImage image(8, NoteGraphHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(128, 128, 128, 128));
setPixmap(QPixmap::fromImage(image));
setMouseTracking(true);
|
|
From: Tapio V. <aa...@us...> - 2011-02-23 18:51:52
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 23 20:34:44 2011 +0200
Narrower SeekHandle.
---
notegraphwidget.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 96f584c..e51dc39 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -696,7 +696,7 @@ QString NoteGraphWidget::dumpLyrics() const
SeekHandle::SeekHandle(QWidget *parent)
: QLabel(parent)
{
- QImage image(16, 768, QImage::Format_ARGB32_Premultiplied);
+ QImage image(8, 768, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(128, 128, 128, 128));
setPixmap(QPixmap::fromImage(image));
setMouseTracking(true);
|
|
From: Tapio V. <aa...@us...> - 2011-02-23 18:15:32
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 18:25:48 2011 +0100 Default webcam to disabled because it causes crashes on many systems --- data/schema.xml | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/schema.xml b/data/schema.xml index 3f05b12..4bdc3f9 100644 --- a/data/schema.xml +++ b/data/schema.xml @@ -131,10 +131,10 @@ to save the current settings to XML. <long>Allows completely disabling background videos. It is recommended to leave this enabled as Performous will still smoothly fade out the video if your computer is not fast enough.</long> </locale> </entry> - <entry name="graphic/webcam" type="bool" value="true"> + <entry name="graphic/webcam" type="bool" value="false"> <locale name="C"> <short>Webcam background</short> - <long>Performous can try to use webcam as a background video. You can disable it if it annoys you.</long> + <long>Performous can use webcam as a background video. Disable it if Performous crashes while entering a song.</long> </locale> </entry> <entry name="graphic/webcamid" type="int" value="-1"> |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 18:12:46
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 19:10:24 2011 +0100 OpenGL cleanup: * Shader compile debug improved * Vertex array handling changed * Conditionally enabled shader features for more generic shading * Works mostly fine on Intel * Still has various issues --- data/shaders/core.frag | 31 ++++++++++-- data/shaders/core.vert | 35 +++++++++---- game/glshader.cc | 50 ++++++++++++++++-- game/glshader.hh | 113 ++++++++++++++++++++++++++++++++++++++-- game/glutil.hh | 133 +----------------------------------------------- game/guitargraph.cc | 24 ++++---- game/notegraph.cc | 12 +---- game/screen_sing.cc | 9 ++-- game/video_driver.cc | 20 ++++++-- 9 files changed, 239 insertions(+), 188 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 18:12:40
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 18:25:48 2011 +0100 Default webcam to disabled because it causes crashes on many systems --- data/schema.xml | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/schema.xml b/data/schema.xml index ca06961..3219b2f 100644 --- a/data/schema.xml +++ b/data/schema.xml @@ -152,10 +152,10 @@ to save the current settings to XML. <long>Allows completely disabling background videos. It is recommended to leave this enabled as Performous will still smoothly fade out the video if your computer is not fast enough.</long> </locale> </entry> - <entry name="graphic/webcam" type="bool" value="true"> + <entry name="graphic/webcam" type="bool" value="false"> <locale name="C"> <short>Webcam background</short> - <long>Performous can try to use webcam as a background video. You can disable it if it annoys you.</long> + <long>Performous can use webcam as a background video. Disable it if Performous crashes while entering a song.</long> </locale> </entry> <entry name="graphic/webcamid" type="int" value="-1"> |
|
From: Tapio V. <aa...@us...> - 2011-02-23 16:35:29
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 23 18:34:30 2011 +0200
Highlight piano keys matching selected notes.
---
editorapp.cc | 35 +++++++++++++++++++++++++++++------
editorapp.hh | 2 +-
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index f513b4e..2254125 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -112,7 +112,7 @@ EditorApp::EditorApp(QWidget *parent)
setupNoteGraph();
updateNoteInfo(NULL);
- piano->updatePixmap(noteGraph->n2px(0) - noteGraph->n2px(1));
+ piano->updatePixmap(noteGraph);
song.reset(new Song);
@@ -291,6 +291,10 @@ void EditorApp::updateNoteInfo(NoteLabel *note)
ui.chkLineBreak->setChecked(note->note().lineBreak);
}
updateMenuStates();
+ // Update piano
+ if (piano && noteGraph) {
+ piano->updatePixmap(noteGraph);
+ }
}
void EditorApp::analyzeProgress(int value, int maximum)
@@ -913,7 +917,7 @@ AboutDialog::AboutDialog(QWidget* parent)
in.setCodec("UTF-8");
txtAuthors->setPlainText(in.readAll());
}
- // Poplate License text
+ // Populate License text
{
QFile f(":/docs/License.txt");
f.open(QIODevice::ReadOnly);
@@ -928,6 +932,16 @@ AboutDialog::AboutDialog(QWidget* parent)
+namespace {
+ bool selectionMatches(int n, NoteGraphWidget *ngw) {
+ if (!ngw) return false;
+ const NoteLabels& nls = ngw->selectedNotes();
+ for (int i = 0; i < nls.size(); ++i)
+ if (nls[i]->note().note == n) return true;
+ return false;
+ }
+}
+
void EditorApp::updatePiano(int y)
{
if (!piano) return;
@@ -936,17 +950,18 @@ void EditorApp::updatePiano(int y)
Piano::Piano(QWidget *parent): QLabel(parent) {}
-void Piano::updatePixmap(int noteHeight)
+void Piano::updatePixmap(NoteGraphWidget *ngw)
{
+ if (!ngw) return;
const int notes = 12 * 4; // Four octaves
+ int noteHeight = ngw->n2px(0) - ngw->n2px(1);
QImage image(50, notes * noteHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
setFixedSize(image.width(), image.height());
{
QPainter painter(&image);
MusicalScale scale;
- QPen pen; pen.setWidth(2); pen.setColor(QColor("#c0c0c0"));
- painter.setPen(pen);
+ QPen pen; pen.setWidth(2);
int y;
int w = image.width();
// Render only the white keys first
@@ -954,10 +969,14 @@ void Piano::updatePixmap(int noteHeight)
if (scale.isSharp(i)) continue;
int y2 = image.height() - i * noteHeight; // Note center y
y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y
+ // Pick border color according to selection status
+ if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
+ else pen.setColor(QColor("#c0c0c0"));
+ painter.setPen(pen);
// Skip the first key because y hasn't been calculated yet
if (i > -1) {
painter.fillRect(0, y2, w, y - y2, QColor("#ffffff"));
- painter.drawRect(0, y2, w, y - y2);
+ painter.drawRect(0, y2 + 2, w-1, y - y2 - 2);
}
y = y2; // The next key bottom y
}
@@ -966,6 +985,10 @@ void Piano::updatePixmap(int noteHeight)
for (int i = 0; i < notes; ++i) {
if (!scale.isSharp(i)) continue;
y = image.height() - i*noteHeight - noteHeight / 2;
+ // Pick border color according to selection status
+ if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
+ else pen.setColor(QColor("#c0c0c0"));
+ painter.setPen(pen);
painter.fillRect(0, y, w, noteHeight, QColor("#000000"));
painter.drawRect(0, y, w, noteHeight);
}
diff --git a/editorapp.hh b/editorapp.hh
index aa01cd9..66e273c 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -33,7 +33,7 @@ class Piano: public QLabel
public:
Piano(QWidget *parent = 0);
public slots:
- void updatePixmap(int noteHeight);
+ void updatePixmap(NoteGraphWidget *ngw);
};
|
|
From: Tapio V. <aa...@us...> - 2011-02-23 16:35:22
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 23 17:51:19 2011 +0200
BusyDialog tweaks.
---
busydialog.hh | 4 ++--
editorapp.cc | 2 +-
notegraphwidget.cc | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/busydialog.hh b/busydialog.hh
index 60ff038..6d2d5c1 100644
--- a/busydialog.hh
+++ b/busydialog.hh
@@ -8,7 +8,7 @@
class BusyDialog: public QDialog {
public:
- BusyDialog(QWidget *parent = NULL, int eventsInterval = 30): QDialog(parent), timer(), interval(eventsInterval), count() {
+ BusyDialog(QWidget *parent = NULL, int eventsInterval = 10): QDialog(parent), timer(), interval(eventsInterval), count() {
QProgressBar *progress = new QProgressBar(this);
progress->setRange(0,0);
setWindowTitle(tr("Working..."));
@@ -18,7 +18,7 @@ public:
timer.start();
}
void operator()() {
- if (count == 0) // Let's not process events all the time
+ if (count == 0 && isVisible()) // Let's not process events all the time
QApplication::processEvents();
count = (count + 1) % interval;
// Only show the dialog after certainamount of time
diff --git a/editorapp.cc b/editorapp.cc
index 3490bcb..f513b4e 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -182,7 +182,7 @@ void EditorApp::statusBarMessage(const QString& message)
void EditorApp::doOpStack()
{
- BusyDialog busy(this);
+ BusyDialog busy(this, 20);
noteGraph->clearNotes();
QString newMusic = "";
// Re-apply all operations in the stack
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 0c8e03d..96f584c 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -58,7 +58,7 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
void NoteGraphWidget::setLyrics(QString lyrics)
{
- BusyDialog busy(this, 5);
+ BusyDialog busy(this, 2);
QTextStream ts(&lyrics, QIODevice::ReadOnly);
doOperation(Operation("CLEAR"));
|
|
From: Tapio V. <aa...@us...> - 2011-02-23 12:17:07
|
Author: Tapio Vierros <tap...@gm...> Date: Wed Feb 23 14:15:39 2011 +0200 Splitter doesn't like the new piano, so fallback to fixed layout for now. --- editor.ui | 853 +++++++++++++++++++++++++++++----------------------------- editorapp.cc | 4 +- 2 files changed, 433 insertions(+), 424 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 11:44:02
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 12:43:49 2011 +0100 Fixes to piano rendering --- editorapp.cc | 11 ++++++----- notes.cc | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/editorapp.cc b/editorapp.cc index a8ce3f8..44196cf 100644 --- a/editorapp.cc +++ b/editorapp.cc @@ -949,20 +949,21 @@ void Piano::updatePixmap(int noteHeight) painter.setPen(pen); int y; int w = image.width(); - for (int i = 0; i < notes; ++i) { + // Render only the white keys first + for (int i = -1; i < notes; ++i) { if (scale.isSharp(i)) continue; int y2 = image.height() - i * noteHeight; // Note center y y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y // Skip the first key because y hasn't been calculated yet - if (i > 0) { - bool sh = false; + if (i > -1) { painter.fillRect(0, y2, w, y - y2, QColor("#ffffff")); painter.drawRect(0, y2, w, y - y2); } y = y2; // The next key bottom y } - w /= 2; // Half length black keys - for (int i = 1; i < notes; ++i) { + // Now render the black keys + w *= 0.6; + for (int i = 0; i < notes; ++i) { if (!scale.isSharp(i)) continue; y = image.height() - i*noteHeight - noteHeight / 2; painter.fillRect(0, y, w, noteHeight, QColor("#000000")); diff --git a/notes.cc b/notes.cc index 94a9ba2..51b5cf6 100644 --- a/notes.cc +++ b/notes.cc @@ -25,9 +25,10 @@ unsigned int MusicalScale::getNoteNum(int id) const { } bool MusicalScale::isSharp(int id) const { - if (id < 0) throw std::logic_error("MusicalScale::isSharp: Invalid note ID"); + id %= 12; + if (id < 0) id += 12; // Fix the modulus of a negative value // C major scale - switch (id % 12) { + switch (id) { case 1: case 3: case 6: case 8: case 10: return true; } return false; |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 11:35:02
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 12:34:32 2011 +0100 Merge branch 'master' of performous.git.sourceforge.net:/gitroot/performous/editor Conflicts: editorapp.cc --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-23 11:34:55
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Wed Feb 23 12:30:50 2011 +0100 Correct piano key rendering. --- editorapp.cc | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/editorapp.cc b/editorapp.cc index 48edf71..56db5cd 100644 --- a/editorapp.cc +++ b/editorapp.cc @@ -946,11 +946,26 @@ void Piano::updatePixmap(int noteHeight) MusicalScale scale; QPen pen; pen.setWidth(2); pen.setColor(QColor("#c0c0c0")); painter.setPen(pen); + int y; + int w = image.width(); for (int i = 0; i < notes; ++i) { - bool sh = scale.isSharp(i); - QColor background(sh ? "#000000" : "#ffffff"); - painter.fillRect(0, image.height() - i*noteHeight - noteHeight/2, image.width() * (sh ? 0.8 : 1.0), noteHeight, background); - painter.drawRect(0, image.height() - i*noteHeight - noteHeight/2, image.width(), noteHeight); + if (scale.isSharp(i)) continue; + int y2 = image.height() - i * noteHeight; // Note center y + y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y + // Skip the first key because y hasn't been calculated yet + if (i > 0) { + bool sh = false; + painter.fillRect(0, y2, w, y - y2, QColor("#ffffff")); + painter.drawRect(0, y2, w, y - y2); + } + y = y2; // The next key bottom y + } + w /= 2; // Half length black keys + for (int i = 1; i < notes; ++i) { + if (!scale.isSharp(i)) continue; + y = image.height() - i*noteHeight - noteHeight / 2; + painter.fillRect(0, y, w, noteHeight, QColor("#000000")); + painter.drawRect(0, y, w, noteHeight); } } setPixmap(QPixmap::fromImage(image)); |