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: Tapio V. <aa...@us...> - 2011-01-27 08:22:20
|
Module: editor
Branch: master
Commit: 6d69ae02a2d7213aad1e70e8fdb23f6ad18e74aa
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 27 09:54:58 2011 +0200
Fix del-function.
---
notegraphwidget.cc | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 0e9d3d3..21942d9 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -374,6 +374,9 @@ void NoteGraphWidget::split(NoteLabel *note)
{
if (!note) return;
+ if (m_selectedNote == note)
+ m_selectedNote = NULL;
+
// Cut the text in half
float relRatio = 0.5; //float(hotSpot.x()) / note->width();
int cutpos = int(std::ceil(note->lyric().length() * relRatio));
@@ -389,18 +392,18 @@ void NoteGraphWidget::split(NoteLabel *note)
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);
-
- m_selectedNote = NULL;
}
void NoteGraphWidget::del(NoteLabel *note)
{
if (!note) return;
+ if (m_selectedNote == note)
+ m_selectedNote = NULL;
+
Operation op("DEL");
- op << getNoteLabelId(m_selectedNote);
+ op << getNoteLabelId(note);
doOperation(op);
- m_selectedNote = NULL;
}
void NoteGraphWidget::editLyric(NoteLabel *note) {
|
|
From: Tapio V. <aa...@us...> - 2011-01-27 08:22:20
|
Module: editor
Branch: master
Commit: 4f2f6dfbdd509958b16348cc44ce3f2d962b9074
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 27 09:39:52 2011 +0200
Added dummy NoteLabel context menu.
---
notegraphwidget.cc | 4 ++--
notelabel.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
notelabel.hh | 8 ++++++--
3 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 3d6b9ca..0f981fe 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -321,7 +321,7 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
child->createPixmap(child->size());
// Right Click
- } else if (event->button() == Qt::RightButton) {
+/* } else if (event->button() == Qt::RightButton) {
// Cut the text in a position proportional to the click point
float relRatio = float(hotSpot.x()) / child->width();
@@ -339,7 +339,7 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
Operation combiner("COMBINER"); combiner << 3; // This will combine the previous ones to one undo action
doOperation(new1); doOperation(new2); doOperation(del); doOperation(combiner);
- m_selectedNote = NULL;
+ m_selectedNote = NULL;*/
}
}
diff --git a/notelabel.cc b/notelabel.cc
index f2ada34..ea0627e 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -2,6 +2,7 @@
#include <QResizeEvent>
#include <QToolTip>
#include <QPainter>
+#include <QMenu>
#include <iostream>
#include "notelabel.hh"
#include "notegraphwidget.hh"
@@ -23,6 +24,9 @@ NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, const QPoint &position,
setMouseTracking(true);
setMinimumSize(min_width, 10);
setAttribute(Qt::WA_DeleteOnClose);
+ // Context menu
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
show();
}
@@ -161,3 +165,46 @@ void NoteLabel::updateNote()
.arg(QString::number(m_note.end))
);
}
+
+
+void NoteLabel::showContextMenu(const QPoint &pos)
+{
+ QAction *actionSplit = new QAction(this);
+ QAction *actionFloating = new QAction(this);
+ actionFloating->setCheckable(true);
+ QAction *actionLineBreak = new QAction(this);
+ actionLineBreak->setCheckable(this);
+ QAction *actionNormal = new QAction(this);
+ QAction *actionGolden = new QAction(this);
+ QAction *actionFreestyle = new QAction(this);
+ QAction *actionDelete = new QAction(this);
+
+ QMenu *menuContext = new QMenu(this);
+ QMenu *menuType = new QMenu(menuContext);
+
+ menuContext->addAction(actionSplit);
+ menuContext->addSeparator();
+ menuContext->addAction(actionFloating);
+ menuContext->addAction(actionLineBreak);
+ menuContext->addAction(menuType->menuAction());
+ menuContext->addSeparator();
+ menuContext->addAction(actionDelete);
+ menuType->addAction(actionNormal);
+ menuType->addAction(actionGolden);
+ menuType->addAction(actionFreestyle);
+
+ actionSplit->setText(tr("Split"));
+ actionFloating->setText(tr("Floating"));
+ actionLineBreak->setText(tr("Line break"));
+ actionNormal->setText(tr("Normal"));
+ actionGolden->setText(tr("Golden"));
+ actionFreestyle->setText(tr("Freestyle"));
+ actionDelete->setText(tr("Delete"));
+ menuType->setTitle(tr("Type"));
+
+ QPoint globalPos = mapToGlobal(pos);
+ QAction *selectedItem = menuContext->exec(globalPos);
+ if (selectedItem) {
+ std::cout<< selectedItem->text().toStdString();
+ }
+}
diff --git a/notelabel.hh b/notelabel.hh
index 44c290c..62aed85 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -37,11 +37,15 @@ public:
void startResizing(int dir);
void startDragging(const QPoint& point);
+ bool operator<(const NoteLabel &rhs) const { return x() < rhs.x(); }
+
+public slots:
+ void showContextMenu(const QPoint &pos);
+
+protected:
void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event);
- bool operator<(const NoteLabel &rhs) const { return x() < rhs.x(); }
-
private:
Note m_note;
bool m_selected;
|
|
From: Tapio V. <aa...@us...> - 2011-01-27 08:22:20
|
Module: editor
Branch: master
Commit: 160971a7b58bc860d04b95e78147b8d106bb7ff2
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 27 09:51:40 2011 +0200
Note split and delete now in own functions.
---
notegraphwidget.cc | 61 ++++++++++++++++++++++++++++++---------------------
notegraphwidget.hh | 4 ++-
2 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 0f981fe..0e9d3d3 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -321,25 +321,8 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
child->createPixmap(child->size());
// Right Click
-/* } else if (event->button() == Qt::RightButton) {
-
- // Cut the text in a position proportional to the click point
- float relRatio = float(hotSpot.x()) / child->width();
- int cutpos = int(std::ceil(child->lyric().length() * relRatio));
- QString firstst = child->lyric().left(cutpos);
- QString secondst = child->lyric().right(child->lyric().length() - cutpos);
- int w1 = relRatio * child->width();
-
- // Create operations for adding the new labels and deleting the old one
- int id = getNoteLabelId(child);
- Operation new1("NEW"), new2("NEW");
- new1 << id << firstst << child->pos().x() << child->pos().y() << w1 << 0 << child->isFloating();
- new2 << id+1 << secondst << child->pos().x() + w1 << child->pos().y() << child->width() - w1 << 0 << child->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);
-
- m_selectedNote = NULL;*/
+ } else if (event->button() == Qt::RightButton) {
+ event->ignore();
}
}
@@ -387,6 +370,39 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
editLyric(child);
}
+void NoteGraphWidget::split(NoteLabel *note)
+{
+ if (!note) return;
+
+ // Cut the text in half
+ float relRatio = 0.5; //float(hotSpot.x()) / note->width();
+ int cutpos = int(std::ceil(note->lyric().length() * relRatio));
+ QString firstst = note->lyric().left(cutpos);
+ QString secondst = note->lyric().right(note->lyric().length() - cutpos);
+ int w1 = relRatio * note->width();
+
+ // Create operations for adding the new labels and deleting the old one
+ int id = getNoteLabelId(note);
+ Operation new1("NEW"), new2("NEW");
+ new1 << id << firstst << note->pos().x() << note->pos().y() << w1 << 0 << note->isFloating();
+ new2 << id+1 << secondst << note->pos().x() + w1 << note->pos().y() << note->width() - w1 << 0 << 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);
+
+ m_selectedNote = NULL;
+}
+
+void NoteGraphWidget::del(NoteLabel *note)
+{
+ if (!note) return;
+
+ Operation op("DEL");
+ op << getNoteLabelId(m_selectedNote);
+ doOperation(op);
+ m_selectedNote = NULL;
+}
+
void NoteGraphWidget::editLyric(NoteLabel *note) {
if (!note) return;
@@ -476,12 +492,7 @@ void NoteGraphWidget::keyPressEvent(QKeyEvent *event)
}
break;
case Qt::Key_Delete: // Delete selected note
- if (m_selectedNote) {
- Operation op("DEL");
- op << getNoteLabelId(m_selectedNote);
- doOperation(op);
- m_selectedNote = NULL;
- }
+ del(m_selectedNote);
break;
default:
QWidget::keyPressEvent(event);
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 86f5488..1ff7b7e 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -44,11 +44,13 @@ public:
void selectNote(NoteLabel *note);
NoteLabel* selectedNote() const { return m_selectedNote; }
+ void split(NoteLabel *note);
+ void del(NoteLabel *note);
+ void editLyric(NoteLabel *note);
int getNoteLabelId(NoteLabel* note) const;
NoteLabels& noteLabels() { return m_notes; }
void doOperation(const Operation& op, Operation::OperationFlags flags = Operation::NORMAL);
- void editLyric(NoteLabel *note);
int s2px(double sec) const;
double px2s(int px) const;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:42:12
|
Module: performous
Branch: opengl2
Commit: 29518a18b84b24de4d2d0606db42fa4f8e07f472
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Jan 27 01:39:42 2011 +0100
Added Window::view() for setting up different views (e.g. stereoscopic). Made stereo3d configurable and made it adapt to window size instead of hardcoded FullHD.
---
data/schema.xml | 21 ++++++++++++++++
game/screenmanager.cc | 21 +---------------
game/video_driver.cc | 62 ++++++++++++++++++++++++++++++++++++------------
game/video_driver.hh | 4 +++
4 files changed, 73 insertions(+), 35 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index 3f05b12..ab20020 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -125,6 +125,27 @@ to save the current settings to XML.
<long>Enable fullscreen mode on startup.</long>
</locale>
</entry>
+ <entry name="graphic/stereo3d" type="bool" value="false">
+ <locale name="C">
+ <short>Stereoscopic 3D</short>
+ <long>Enable 3D rendering of Performous.</long>
+ </locale>
+ </entry>
+ <entry name="graphic/stereo3dtype" type="int" value="0">
+ <limits min="0" max="1" 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>
+ </locale>
+ </entry>
+ <entry name="graphic/stereo3dseparation" type="float" value="50">
+ <ui unit=" %" />
+ <limits min="0" max="100" step="1" />
+ <locale name="C">
+ <short>Stereo3D separation</short>
+ <long>The strenght of the effect. Experiment with different settings for best results.</long>
+ </locale>
+ </entry>
<entry name="graphic/video" type="bool" value="true">
<locale name="C">
<short>Video playback</short>
diff --git a/game/screenmanager.cc b/game/screenmanager.cc
index e28dc19..7b3e057 100644
--- a/game/screenmanager.cc
+++ b/game/screenmanager.cc
@@ -42,28 +42,11 @@ Screen* ScreenManager::getScreen(std::string const& name) {
}
void ScreenManager::drawScreen() {
- // FIXME: Rendering using FBO doesn't work
- {
- glViewport(0, 0, 1920, 540);
- glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(0.02f, 0.0f, 0.0f);
- glutil::PushMatrixMode pmv(GL_MODELVIEW);
- glTranslatef(-0.02f, 0.0f, 0.0f);
- //UseFBO fbo(m_fbo);
+ // Draw current frame for all the views
+ for (unsigned i = 0; window().view(i); ++i) {
getCurrentScreen()->draw();
drawNotifications();
}
- {
- glViewport(0, 540, 1920, 540);
- glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(-0.02f, 0.0f, 0.0f);
- glutil::PushMatrixMode pmv(GL_MODELVIEW);
- glTranslatef(0.02f, 0.0f, 0.0f);
- //UseFBO fbo(m_fbo);
- getCurrentScreen()->draw();
- drawNotifications();
- }
- //m_fbo.getTexture().draw(Dimensions().fixedWidth(1.0));
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 54f677b..ecd05d4 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -75,6 +75,52 @@ void Window::blank() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
+bool Window::view(unsigned num) {
+ // Setup the projection matrix for 2D translates
+ using namespace glmath;
+ glMatrixMode(GL_PROJECTION);
+ float h = virtH();
+ // OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
+ upload(scale(Vec3(2.0f, 2.0f / h, 1.0f)));
+ // Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
+ // glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
+ glMatrixMode(GL_MODELVIEW);
+ const float f = near_ / z0;
+ upload(
+ scale(Vec3(0.5, 0.5 * h, 1.0))
+ * frustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_)
+ * translate(Vec3(0.0, 0.0, -z0))
+ );
+ // Setup views
+ 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
+ // 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;
+ if (stereo) {
+ if (num > 1) return false;
+ double separation = 0.0004f * (num ? -1 : 1) * config["graphic/stereo3dseparation"].f();
+ glMatrixMode(GL_PROJECTION);
+ glTranslatef(separation, 0.0f, 0.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(-separation, 0.0f, 0.0f);
+ if (type == 0) {
+ // TODO: implement color shaders for red/cyan
+ }
+ if (type == 1) {
+ double margin = screen->h - s_height;
+ vy = 0.25 * margin + (num ? 0.5 * screen->h : 0.0);
+ vh *= 0.5;
+ }
+ } else {
+ if (num != 0) return false;
+ }
+ glViewport(vx, vy, vw, vh);
+ return true;
+}
+
void Window::swap() {
SDL_GL_SwapBuffers();
}
@@ -133,7 +179,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);
- glViewport(0.5f * (screen->w - s_width), 0.5f * (screen->h - s_height), s_width, s_height);
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
@@ -142,21 +187,6 @@ void Window::resize() {
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);
- float h = virtH();
- // OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
- upload(scale(Vec3(2.0f, 2.0f / h, 1.0f)));
- // Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
- // glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
- glMatrixMode(GL_MODELVIEW);
- const float f = near_ / z0;
- upload(
- scale(Vec3(0.5, 0.5 * h, 1.0))
- * frustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_)
- * translate(Vec3(0.0, 0.0, -z0))
- );
// Check for OpenGL errors
glutil::GLErrorChecker glerror("Window::resize");
}
diff --git a/game/video_driver.hh b/game/video_driver.hh
index 131c3ef..37f9f38 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -25,6 +25,10 @@ public:
Window(unsigned int windowW, unsigned int windowH, bool fullscreen);
/// destructor
~Window();
+ /// 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
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:42:07
|
Module: performous Branch: opengl2 Commit: c9be4b9dca74f2b1fffa6968ac49bdabd7c38e4d Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jan 27 00:07:18 2011 +0100 Merge branch 'opengl2' into stereo3d --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:42:05
|
Module: performous
Branch: opengl2
Commit: 8bf1a0e1b3494f789cbf03669c838bdabedd7d85
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Jan 26 23:41:45 2011 +0100
A lousy attempt to make guitar score calculator 3d and better positioned.
---
game/guitargraph.cc | 26 ++++++++++++--------------
game/guitargraph.hh | 2 +-
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 55ba0f7..986293b 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -799,6 +799,7 @@ void GuitarGraph::draw(double time) {
glTranslatef(frac * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
glTranslatef((1.0 - frac) * offsetX, dimensions.y2(), 0.0f);
+ drawInfo(time); // Go draw some texts and other interface stuff
// Do some jumping for drums
if (m_drums) {
float jumpanim = m_drumJump.get();
@@ -1028,7 +1029,6 @@ void GuitarGraph::draw(double time) {
m_neckglow.draw();
}
- drawInfo(time, offsetX, dimensions); // Go draw some texts and other interface stuff
}
/// Draws a single note
@@ -1159,21 +1159,19 @@ void GuitarGraph::drawDrumfill(float tBeg, float tEnd) {
}
/// Draw popups and other info texts
-void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
+void GuitarGraph::drawInfo(double time) {
// Draw info
if (!menuOpen()) {
- float xcor = 0.35 * dimensions.w();
- float h = 0.075 * 2.0 * dimensions.w();
- // Hack to show the scores better when there is more space (1 instrument)
- if (m_width.get() > 0.99) {
- xcor += 0.15;
- h *= 1.2;
- }
+ float ycor = -0.05;
+ float xcor = 0.50;
+ float h = 0.075 * 2.0;
+ glutil::PushMatrix pm;
+ glTranslatef(0.0f, 0.0f, -2.5f);
// Draw scores
{
glutil::Color c(Color(0.1f, 0.3f, 1.0f, 0.90f));
m_scoreText->render((boost::format("%04d") % getScore()).str());
- m_scoreText->dimensions().middle(-xcor + offsetX).fixedHeight(h).screenBottom(-0.24);
+ m_scoreText->dimensions().middle(-xcor).fixedHeight(h).bottom(ycor);
m_scoreText->draw();
}
// Draw streak counter
@@ -1181,24 +1179,24 @@ void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
glutil::Color c(Color(0.6f, 0.6f, 0.7f, 0.95f));
m_streakText->render(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
- m_streakText->dimensions().middle(-xcor + offsetX).fixedHeight(h*0.75).screenBottom(-0.20);
+ m_streakText->dimensions().middle(-xcor).fixedHeight(h*0.75).bottom(ycor);
m_streakText->draw();
}
}
// Is Starpower ready?
if (canActivateStarpower()) {
float a = std::abs(std::fmod(time, 1.0) - 0.5f) * 2.0f;
- m_text.dimensions.screenBottom(-0.02).middle(-0.12 + offsetX);
+ m_text.dimensions.screenBottom(-0.02).middle(-0.12);
if (m_drums && m_dfIt != m_drumfills.end() && time >= m_dfIt->begin && time <= m_dfIt->end)
m_text.draw(_("Drum Fill!"), a);
else m_text.draw(_("God Mode Ready!"), a);
} else if (m_solo) {
// Solo
float a = std::abs(std::fmod(time, 1.0) - 0.5f) * 2.0f;
- m_text.dimensions.screenBottom(-0.02).middle(-0.03 + offsetX);
+ m_text.dimensions.screenBottom(-0.02).middle(-0.03);
m_text.draw(_("Solo!"), a);
}
- drawPopups(offsetX);
+ drawPopups(0.0f);
}
/// Draw a bar for drum bass pedal/note
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index a1ab5cf..cd561ee 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -119,7 +119,7 @@ class GuitarGraph: public InstrumentGraph {
void drawBar(double time, float h);
void drawNote(int fret, Color, float tBeg, float tEnd, float whammy = 0, bool tappable = false, bool hit = false, double hitAnim = 0.0, double releaseTime = 0.0);
void drawDrumfill(float tBeg, float tEnd);
- void drawInfo(double time, double offsetX, Dimensions dimensions);
+ void drawInfo(double time);
float getFretX(int fret) { return (-2.0f + fret- (m_drums ? 0.5 : 0)) * (m_leftymode.b() ? -1 : 1); }
// Chords & notes
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:42:02
|
Module: performous
Branch: opengl2
Commit: 770202d07ee2252d0399f341bcf8dac28840fb2b
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Jan 26 02:55:26 2011 +0100
Implement OpenGL matrix/transformation operations in C++ & use them in video_driver.
---
game/glmath.hh | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++
game/glutil.hh | 11 ++--
game/video_driver.cc | 14 +++--
3 files changed, 156 insertions(+), 12 deletions(-)
diff --git a/game/glmath.hh b/game/glmath.hh
new file mode 100644
index 0000000..675a3cf
--- /dev/null
+++ b/game/glmath.hh
@@ -0,0 +1,143 @@
+#pragma once
+
+#include <GL/glew.h>
+#include <cmath>
+#include <iomanip>
+#include <iostream>
+#include <stdexcept>
+#include <sstream>
+
+namespace glmath {
+
+ struct Vec3 {
+ GLdouble x, y, z;
+ explicit Vec3(double x = 0.0, double y = 0.0, double z = 0.0): x(x), y(y), z(z) {}
+ };
+
+ struct Vec4 {
+ GLdouble x, y, z, w;
+ explicit Vec4(double x = 0.0, double y = 0.0, double z = 0.0, double w = 0.0): x(x), y(y), z(z), w(w) {}
+ explicit Vec4(Vec3 const& v, double w = 1.0): x(v.x), y(v.y), z(v.z), w(w) {}
+ GLdouble& operator[](unsigned j) { return (&x)[j]; }
+ GLdouble const& operator[](unsigned j) const { return (&x)[j]; }
+ };
+
+ static inline Vec3 operator*(double k, Vec3 const& v) { return Vec3(k * v.x, k * v.y, k * v.z); }
+
+ static inline double dot(Vec3 const& a, Vec3 const& b) {
+ return a.x * b.x + a.y * b.y + a.z * b.z;
+ }
+
+ static inline double len(Vec3 const& v) { return std::sqrt(dot(v, v)); }
+ static inline Vec3 normalize(Vec3 const& v) { return (1 / len(v)) * v; }
+
+ struct Matrix {
+ Vec4 cols[4];
+ /// Identity matrix
+ Matrix() { for (unsigned k = 0; k < 4; ++k) cols[k][k] = 1.0; }
+ operator GLdouble*() { return &cols[0][0]; }
+ operator GLdouble const*() const { return &cols[0][0]; }
+ GLdouble& operator()(unsigned i, unsigned j) { return cols[j][i]; }
+ GLdouble const& operator()(unsigned i, unsigned j) const { return cols[j][i]; }
+ };
+
+ static inline std::ostream& operator<<(std::ostream& os, Matrix const& m) {
+ std::ostringstream oss;
+ oss << std::setprecision(3) << std::fixed;
+ for (int i = 0; i < 4; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ oss.width(7);
+ oss << m(i,j);
+ }
+ oss << '\n';
+ }
+ return os << oss.str() << std::endl;
+ }
+
+ static inline Matrix get(GLenum mode_matrix) {
+ Matrix ret;
+ glGetDoublev(mode_matrix, ret);
+ return ret;
+ }
+
+ static inline Matrix getMatrix() {
+ GLint mode;
+ glGetIntegerv(GL_MATRIX_MODE, &mode);
+ if (mode == GL_MODELVIEW) return get(GL_MODELVIEW_MATRIX);
+ if (mode == GL_PROJECTION) return get(GL_PROJECTION_MATRIX);
+ if (mode == GL_TEXTURE) return get(GL_TEXTURE_MATRIX);
+ throw std::logic_error("Unknown current matrix mode in glmath::get()");
+ }
+ static inline void upload(Matrix const& m) { glLoadMatrixd(m); }
+
+ static inline Matrix operator*(Matrix const& a, Matrix const& b) {
+ Matrix ret;
+ for (unsigned i = 0; i < 4; ++i) {
+ for (unsigned j = 0; j < 4; ++j) {
+ GLfloat sum = 0.0;
+ for (unsigned k = 0; k < 4; ++k) {
+ sum += a(i, k) * b(k, j);
+ }
+ ret(i, j) = sum;
+ }
+ }
+ return ret;
+ }
+
+ static inline Matrix translate(Vec3 const& v) {
+ Matrix ret;
+ ret(0,3) = v.x;
+ ret(1,3) = v.y;
+ ret(2,3) = v.z;
+ return ret;
+ }
+
+ static inline Matrix scale(Vec3 const& v) {
+ Matrix ret;
+ ret(0,0) = v.x;
+ ret(1,1) = v.y;
+ ret(2,2) = v.z;
+ return ret;
+ }
+
+ static inline Matrix scale(double k) { return scale(Vec3(k, k, k)); }
+
+ static inline Matrix rotate(double rad, Vec3 axis) {
+ Matrix ret;
+ Vec3 u = normalize(axis);
+ // Based on http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
+ double s = std::sin(rad);
+ double c = std::cos(rad);
+ double nc = 1 - c;
+ // Column 0
+ ret(0,0) = c + u.x * u.x * nc;
+ ret(1,0) = u.y * u.x * nc + u.z * s;
+ ret(2,0) = u.z * u.x * nc - u.y * s;
+ // Column 1
+ ret(0,1) = u.x * u.y * nc - u.z * s;
+ ret(1,1) = c + u.y * u.y * nc;
+ ret(2,1) = u.z * u.y * nc + u.x * s;
+ // Column 2
+ ret(0,2) = u.x * u.z * nc + u.y * s;
+ ret(1,2) = u.y * u.z * nc - u.x * s;
+ ret(2,2) = c + u.z * u.z * nc;
+ return ret;
+ }
+
+ static inline Matrix frustum(double l, double r, double b, double t, double n, double f) {
+ double w = r - l;
+ double h = t - b;
+ double d = n - f;
+ Matrix ret;
+ ret(0,0) = 2 * n / w;
+ ret(1,1) = 2 * n / h;
+ ret(0,2) = (r + l) / w;
+ ret(1,2) = (t + b) / h;
+ ret(2,2) = (f + n) / d;
+ ret(3,2) = -1.0;
+ ret(2,3) = 2 * f * n / d;
+ ret(3,3) = 0.0;
+ return ret;
+ }
+}
+
diff --git a/game/glutil.hh b/game/glutil.hh
index f25abe1..781b757 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -1,13 +1,12 @@
#pragma once
-#include <string>
-#include <iostream>
-#include <vector>
-
-#include <GL/glew.h>
#include "color.hh"
#include "glshader.hh"
+#include <GL/glew.h>
+#include <string>
+#include <iostream>
+#include <vector>
namespace glutil {
@@ -206,6 +205,6 @@ namespace glutil {
}
static void reset() { glGetError(); }
};
-
}
+
diff --git a/game/video_driver.cc b/game/video_driver.cc
index eb505f1..54f677b 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -2,6 +2,7 @@
#include "config.hh"
#include "fs.hh"
+#include "glmath.hh"
#include "image.hh"
#include "util.hh"
#include "joystick.hh"
@@ -142,19 +143,20 @@ void Window::resize() {
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
// Setup the projection matrix for 2D translates
+ using namespace glmath;
glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
float h = virtH();
// OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
- glScalef(2.0f, 2.0f / h, 1.0f);
+ upload(scale(Vec3(2.0f, 2.0f / h, 1.0f)));
// Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
// glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glScalef(0.5f, 0.5f * h, 1.0f); // Invert the scaling done on projection matrix
const float f = near_ / z0;
- glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_);
- glTranslatef(0.0f, 0.0f, -z0); // Move back the world so that z = 0.0f is the monitor surface
+ upload(
+ scale(Vec3(0.5, 0.5 * h, 1.0))
+ * frustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_)
+ * translate(Vec3(0.0, 0.0, -z0))
+ );
// Check for OpenGL errors
glutil::GLErrorChecker glerror("Window::resize");
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:59
|
Module: performous
Branch: opengl2
Commit: 9a4c21b9c1b635ab4baa2e9090a2aa7c1c725450
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jan 24 03:04:02 2011 +0100
Added depth to song browser plus minor related tweaks.
---
game/screen_songs.cc | 21 ++++++++++++++-------
themes/default/songs_bg.svg | 9 +++++----
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 52af8ff..be904f4 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -142,10 +142,13 @@ void ScreenSongs::drawJukebox() {
}
void ScreenSongs::drawMultimedia() {
- double length = m_audio.getLength();
- double time = clamp(m_audio.getPosition() - config["audio/video_delay"].f(), 0.0, length);
- if (m_songbg.get()) m_songbg->draw(); else m_songbg_default->draw();
- if (m_video.get()) m_video->render(time);
+ {
+ FarTransform ft; // 3D effect
+ double length = m_audio.getLength();
+ double time = clamp(m_audio.getPosition() - config["audio/video_delay"].f(), 0.0, length);
+ if (m_songbg.get()) m_songbg->draw(); else m_songbg_default->draw();
+ if (m_video.get()) m_video->render(time);
+ }
if (!m_jukebox) theme->bg.draw();
}
@@ -248,9 +251,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 ? (0.5 - fabs(shift)) * 0.07 : 0.0);
- double y = 0.27 + 0.5 * diff;
- s.dimensions.middle(-0.2 + 0.17 * (i - shift)).bottom(y - 0.2 * diff).fitInside(0.14 + diff, 0.14 + diff);
+ double diff = (i == 0 ? 2.0 * (0.5 - fabs(shift)) : 0.0); // 0..1 for current cover hilight level
+ double y = 0.26;
+ 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);
// Draw the cover normally
s.draw();
// Draw the reflection
diff --git a/themes/default/songs_bg.svg b/themes/default/songs_bg.svg
index 1c201c7..9f9c8ce 100644
--- a/themes/default/songs_bg.svg
+++ b/themes/default/songs_bg.svg
@@ -17,7 +17,7 @@
height="800"
id="svg559"
sodipodi:version="0.32"
- inkscape:version="0.47 r22583"
+ inkscape:version="0.48.0 r9654"
sodipodi:docname="songs_bg.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<metadata
@@ -44,7 +44,7 @@
pagecolor="#ffffff"
id="base"
inkscape:zoom="0.61522534"
- inkscape:cx="445.08607"
+ inkscape:cx="448.33691"
inkscape:cy="383.70921"
inkscape:window-x="0"
inkscape:window-y="29"
@@ -117,9 +117,10 @@
</defs>
<path
style="fill:#ffffff;fill-opacity:0.2739131"
- d="M 49.884998,210 950.115,210 C 966.67129,210 980,223.3225 980,239.87109 l 0,230.25782 C 980,486.6775 966.67129,500 950.115,500 l -533.01146,0 c 0,0 -119.40515,68.26767 -119.40515,68.26767 0,0 -101.15081,-68.26767 -101.15081,-68.26767 0,0 -146.662582,0 -146.662582,0 C 33.328709,500 20,486.6775 20,470.12891 L 20,239.87109 C 20,223.3225 33.328709,210 49.884998,210 z"
+ d="M 49.884998,210 950.115,210 C 966.67129,210 980,223.3225 980,239.87109 l 0,230.25782 C 980,486.6775 966.67129,500 950.115,500 610.93509,500.50433 352.98475,500 49.884998,500 33.328709,500 20,486.6775 20,470.12891 L 20,239.87109 C 20,223.3225 33.328709,210 49.884998,210 z"
id="rect3394"
- sodipodi:nodetypes="cccccccccccc" />
+ sodipodi:nodetypes="ccccccccc"
+ inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:24.89476013px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:56
|
Module: performous
Branch: opengl2
Commit: a86ba551c0518d31e4cb6c3d2720da53222bab1a
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jan 24 03:03:06 2011 +0100
Use FarTransform
---
game/screen_sing.cc | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 0f8e7b2..d12b5e6 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -424,10 +424,7 @@ void ScreenSing::draw() {
// Rendering starts
{
- glutil::PushMatrix pm;
- float s = 70.0f;
- glTranslatef(0.0f, 0.0f, -90.0f);
- glScalef(s, s, s);
+ FarTransform ft;
double ar = arMax;
// Background image
if (m_background) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:54
|
Module: performous
Branch: opengl2
Commit: 477655db8f247c402e0967327f3c5504fbdcfeb0
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jan 24 03:02:38 2011 +0100
Add scaling to projection matrix so that 2d translations are easier, changed all 2d translations accordingly; added FarTransform which is a RAII object for drawing backgrounds on the far plane but in fullscreen size.
---
game/dancegraph.cc | 2 +-
game/guitargraph.cc | 2 +-
game/screenmanager.cc | 4 ++--
game/video_driver.cc | 28 ++++++++++++++++++++--------
game/video_driver.hh | 13 +++++++++++--
5 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index f37ed39..eabd84c 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -416,7 +416,7 @@ void DanceGraph::draw(double time) {
double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
// Some matrix magic to get the viewport right
glutil::PushMatrixMode pmm(GL_PROJECTION);
- glTranslatef((2.0 * frac) * offsetX, 0.0f, 0.0f);
+ glTranslatef(frac * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
glTranslatef((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
float temp_s = dimensions.w() / 8.0f; // Allow for 8 pads to fit on a track
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 4a6f9c5..55ba0f7 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -796,7 +796,7 @@ void GuitarGraph::draw(double time) {
{ // Translate, rotate and scale to place
double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
glutil::PushMatrixMode pmm(GL_PROJECTION);
- glTranslatef(frac * 2.0 * offsetX, 0.0f, 0.0f);
+ glTranslatef(frac * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
glTranslatef((1.0 - frac) * offsetX, dimensions.y2(), 0.0f);
// Do some jumping for drums
diff --git a/game/screenmanager.cc b/game/screenmanager.cc
index c702966..e28dc19 100644
--- a/game/screenmanager.cc
+++ b/game/screenmanager.cc
@@ -46,7 +46,7 @@ void ScreenManager::drawScreen() {
{
glViewport(0, 0, 1920, 540);
glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(0.04f, 0.0f, 0.0f);
+ glTranslatef(0.02f, 0.0f, 0.0f);
glutil::PushMatrixMode pmv(GL_MODELVIEW);
glTranslatef(-0.02f, 0.0f, 0.0f);
//UseFBO fbo(m_fbo);
@@ -56,7 +56,7 @@ void ScreenManager::drawScreen() {
{
glViewport(0, 540, 1920, 540);
glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(-0.04f, 0.0f, 0.0f);
+ glTranslatef(-0.02f, 0.0f, 0.0f);
glutil::PushMatrixMode pmv(GL_MODELVIEW);
glTranslatef(0.02f, 0.0f, 0.0f);
//UseFBO fbo(m_fbo);
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 97da558..eb505f1 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -1,7 +1,6 @@
#include "video_driver.hh"
#include "config.hh"
-#include "glutil.hh"
#include "fs.hh"
#include "image.hh"
#include "util.hh"
@@ -31,6 +30,11 @@ namespace {
int m_value;
};
+ // stump: under MSVC, near and far are #defined to nothing for compatibility with ancient code, hence the underscores.
+ const float near_ = 0.1f; // This determines the near clipping distance (must be > 0)
+ const float far_ = 110.0f; // How far away can things be seen
+ const float z0 = 1.5f; // This determines FOV: the value is your distance from the monitor (the unit being the width of the Performous window)
+
}
unsigned int screenW() { return s_width; }
@@ -67,7 +71,7 @@ Window::Window(unsigned int width, unsigned int height, bool fs): m_windowW(widt
Window::~Window() { }
void Window::blank() {
- glClear(GL_COLOR_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void Window::swap() {
@@ -137,17 +141,17 @@ void Window::resize() {
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
- // Set projection
+ // Setup the projection matrix for 2D translates
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float h = virtH();
- // stump: under MSVC, near and far are #defined to nothing for compatibility with ancient code, hence the underscores.
- const float near_ = 0.5f; // This determines the near clipping distance (must be > 0)
- const float far_ = 100.0f; // How far away can things be seen
- const float z0 = 1.5f; // This determines FOV: the value is your distance from the monitor (the unit being the width of the Performous window)
- // Set model-view matrix
+ // OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
+ glScalef(2.0f, 2.0f / h, 1.0f);
+ // Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
+ // glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
+ glScalef(0.5f, 0.5f * h, 1.0f); // Invert the scaling done on projection matrix
const float f = near_ / z0;
glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_);
glTranslatef(0.0f, 0.0f, -z0); // Move back the world so that z = 0.0f is the monitor surface
@@ -155,3 +159,11 @@ void Window::resize() {
glutil::GLErrorChecker glerror("Window::resize");
}
+FarTransform::FarTransform() {
+ float z = far_ - 0.1f; // Very near the far plane but just a bit closer to avoid accidental clipping
+ float s = z / z0; // Scale the image so that it looks the same size
+ s *= 1.04; // A bit more for stereo3d (avoid black borders)
+ glTranslatef(0.0f, 0.0f, -z + z0); // Very near the farplane
+ glScalef(s, s, s);
+}
+
diff --git a/game/video_driver.hh b/game/video_driver.hh
index 79c24c9..131c3ef 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -1,6 +1,7 @@
#pragma once
#include "glshader.hh"
+#include "glutil.hh"
#include <boost/scoped_ptr.hpp>
unsigned int screenW();
@@ -9,9 +10,17 @@ static inline float virtH() { return float(screenH()) / screenW(); }
struct SDL_Surface;
+/// Performs a GL transform for displaying background image at far distance
+class FarTransform {
+public:
+ FarTransform();
+private:
+ glutil::PushMatrix pm;
+};
+
/// handles the window
class Window {
- public:
+public:
/// constructor
Window(unsigned int windowW, unsigned int windowH, bool fullscreen);
/// destructor
@@ -39,7 +48,7 @@ class Window {
/// take a screenshot
void screenshot();
- private:
+private:
SDL_Surface* screen;
unsigned int m_windowW, m_windowH;
unsigned int m_fsW, m_fsH;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:51
|
Module: performous
Branch: opengl2
Commit: 9f0e26b2fc83582cbe20e039cafcf849c15a3ee5
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jan 24 00:46:05 2011 +0100
Add 3D to message dialogs
---
game/dialog.hh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/game/dialog.hh b/game/dialog.hh
index 65b7d8e..b3e63a8 100644
--- a/game/dialog.hh
+++ b/game/dialog.hh
@@ -18,6 +18,8 @@ class Dialog {
}
/// draws dialogue
void draw() {
+ glutil::PushMatrix pm;
+ glTranslatef(0.0f, 0.0f, 0.1f); // Raise a bit in 3D
m_dialog.draw();
m_svgText.draw(m_text);
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:48
|
Module: performous
Branch: opengl2
Commit: 7f57f0db64a7cfe6040a5a5d31c64026ca122150
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jan 24 00:45:07 2011 +0100
Proper calculation of frustum instead of arbitrary multiplier
---
game/video_driver.cc | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/game/video_driver.cc b/game/video_driver.cc
index c501639..97da558 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -142,14 +142,15 @@ void Window::resize() {
glLoadIdentity();
float h = virtH();
// stump: under MSVC, near and far are #defined to nothing for compatibility with ancient code, hence the underscores.
- const float near_ = 1.5f; // This determines FOV: the value is your distance from the monitor (the unit being the width of the Performous window)
+ const float near_ = 0.5f; // This determines the near clipping distance (must be > 0)
const float far_ = 100.0f; // How far away can things be seen
+ const float z0 = 1.5f; // This determines FOV: the value is your distance from the monitor (the unit being the width of the Performous window)
// Set model-view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- const float f = 0.9f; // Avoid texture surface being exactly at the near plane (MacOSX fix)
- glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, f * near_, far_);
- glTranslatef(0.0f, 0.0f, -near_); // So that z = 0.0f is still on monitor surface
+ const float f = near_ / z0;
+ glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_);
+ glTranslatef(0.0f, 0.0f, -z0); // Move back the world so that z = 0.0f is the monitor surface
// Check for OpenGL errors
glutil::GLErrorChecker glerror("Window::resize");
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:46
|
Module: performous
Branch: opengl2
Commit: c18e8012f5c2f51334e1f7c99bbc1138ccc3743c
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jan 21 23:55:57 2011 +0100
Revert "Lyric text rendering in 3D instead of zoom (BUGGY HACK)"
This reverts commit 733eb048a4cd472d2d60a687c0f4bcf2b7893773.
---
game/opengl_text.cc | 7 +------
game/video_driver.cc | 2 +-
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/game/opengl_text.cc b/game/opengl_text.cc
index f2c95d0..098f022 100644
--- a/game/opengl_text.cc
+++ b/game/opengl_text.cc
@@ -244,17 +244,12 @@ void SvgTxtTheme::draw(std::vector<TZoomText> const& _text, float alpha) {
TexCoords tex;
double factor = _text[i].factor;
Color color;
- glutil::PushMatrix pm;
if (factor == 1.0) color = Color(1.0f, 1.0f, 1.0f, alpha);
else {
color = Color(m_text_highlight.fill_col.r, m_text_highlight.fill_col.g, m_text_highlight.fill_col.b, alpha);
- glTranslatef(0.0f, 0.0f, factor - 1.0f);
+ dim.fixedWidth(dim.w() * factor);
}
{
- glutil::PushMatrixMode ppm(GL_PROJECTION);
- glTranslatef(2.0f * dim.xc(), -4.0f * dim.yc(), 0.0f);
- dim.middle(0.0f).center(0.0f);
- glutil::PushMatrixMode(GL_MODELVIEW);
glutil::Color c(color);
m_opengl_text[i].draw(dim, tex);
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 187e405..c501639 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -147,7 +147,7 @@ void Window::resize() {
// Set model-view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- const float f = 0.8f; // Add some margin in front of nearplane (needed for 3D effects and OSX to avoid clipping)
+ const float f = 0.9f; // Avoid texture surface being exactly at the near plane (MacOSX fix)
glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, f * near_, far_);
glTranslatef(0.0f, 0.0f, -near_); // So that z = 0.0f is still on monitor surface
// Check for OpenGL errors
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:43
|
Module: performous
Branch: opengl2
Commit: 733eb048a4cd472d2d60a687c0f4bcf2b7893773
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jan 2 03:15:12 2011 +0100
Lyric text rendering in 3D instead of zoom (BUGGY HACK)
---
game/opengl_text.cc | 7 ++++++-
game/video_driver.cc | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/game/opengl_text.cc b/game/opengl_text.cc
index 098f022..f2c95d0 100644
--- a/game/opengl_text.cc
+++ b/game/opengl_text.cc
@@ -244,12 +244,17 @@ void SvgTxtTheme::draw(std::vector<TZoomText> const& _text, float alpha) {
TexCoords tex;
double factor = _text[i].factor;
Color color;
+ glutil::PushMatrix pm;
if (factor == 1.0) color = Color(1.0f, 1.0f, 1.0f, alpha);
else {
color = Color(m_text_highlight.fill_col.r, m_text_highlight.fill_col.g, m_text_highlight.fill_col.b, alpha);
- dim.fixedWidth(dim.w() * factor);
+ glTranslatef(0.0f, 0.0f, factor - 1.0f);
}
{
+ glutil::PushMatrixMode ppm(GL_PROJECTION);
+ glTranslatef(2.0f * dim.xc(), -4.0f * dim.yc(), 0.0f);
+ dim.middle(0.0f).center(0.0f);
+ glutil::PushMatrixMode(GL_MODELVIEW);
glutil::Color c(color);
m_opengl_text[i].draw(dim, tex);
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index c501639..187e405 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -147,7 +147,7 @@ void Window::resize() {
// Set model-view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- const float f = 0.9f; // Avoid texture surface being exactly at the near plane (MacOSX fix)
+ const float f = 0.8f; // Add some margin in front of nearplane (needed for 3D effects and OSX to avoid clipping)
glFrustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, f * near_, far_);
glTranslatef(0.0f, 0.0f, -near_); // So that z = 0.0f is still on monitor surface
// Check for OpenGL errors
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:40
|
Module: performous
Branch: opengl2
Commit: e822d70d0aa87449f34856ded5ed127e4a1e3137
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jan 2 03:14:24 2011 +0100
Render background img/video/blinds far away rather than at zero-plane (HACK)
---
game/screen_sing.cc | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 0e70d46..0f8e7b2 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -424,6 +424,10 @@ void ScreenSing::draw() {
// Rendering starts
{
+ glutil::PushMatrix pm;
+ float s = 70.0f;
+ glTranslatef(0.0f, 0.0f, -90.0f);
+ glScalef(s, s, s);
double ar = arMax;
// Background image
if (m_background) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:41:37
|
Module: performous
Branch: opengl2
Commit: 70a2a045e05fc71c2a05af79be1c023fb7c6716e
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Jan 2 03:13:09 2011 +0100
A hardcoded top-bottom stereoscopic rendering mode for 1920x1080 (HACK)
---
game/screenmanager.cc | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/game/screenmanager.cc b/game/screenmanager.cc
index f0c721c..c702966 100644
--- a/game/screenmanager.cc
+++ b/game/screenmanager.cc
@@ -44,6 +44,21 @@ Screen* ScreenManager::getScreen(std::string const& name) {
void ScreenManager::drawScreen() {
// FIXME: Rendering using FBO doesn't work
{
+ glViewport(0, 0, 1920, 540);
+ glutil::PushMatrixMode pp(GL_PROJECTION);
+ glTranslatef(0.04f, 0.0f, 0.0f);
+ glutil::PushMatrixMode pmv(GL_MODELVIEW);
+ glTranslatef(-0.02f, 0.0f, 0.0f);
+ //UseFBO fbo(m_fbo);
+ getCurrentScreen()->draw();
+ drawNotifications();
+ }
+ {
+ glViewport(0, 540, 1920, 540);
+ glutil::PushMatrixMode pp(GL_PROJECTION);
+ glTranslatef(-0.04f, 0.0f, 0.0f);
+ glutil::PushMatrixMode pmv(GL_MODELVIEW);
+ glTranslatef(0.02f, 0.0f, 0.0f);
//UseFBO fbo(m_fbo);
getCurrentScreen()->draw();
drawNotifications();
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-27 00:39:56
|
Module: performous
Branch: stereo3d
Commit: 29518a18b84b24de4d2d0606db42fa4f8e07f472
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Jan 27 01:39:42 2011 +0100
Added Window::view() for setting up different views (e.g. stereoscopic). Made stereo3d configurable and made it adapt to window size instead of hardcoded FullHD.
---
data/schema.xml | 21 ++++++++++++++++
game/screenmanager.cc | 21 +---------------
game/video_driver.cc | 62 ++++++++++++++++++++++++++++++++++++------------
game/video_driver.hh | 4 +++
4 files changed, 73 insertions(+), 35 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index 3f05b12..ab20020 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -125,6 +125,27 @@ to save the current settings to XML.
<long>Enable fullscreen mode on startup.</long>
</locale>
</entry>
+ <entry name="graphic/stereo3d" type="bool" value="false">
+ <locale name="C">
+ <short>Stereoscopic 3D</short>
+ <long>Enable 3D rendering of Performous.</long>
+ </locale>
+ </entry>
+ <entry name="graphic/stereo3dtype" type="int" value="0">
+ <limits min="0" max="1" 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>
+ </locale>
+ </entry>
+ <entry name="graphic/stereo3dseparation" type="float" value="50">
+ <ui unit=" %" />
+ <limits min="0" max="100" step="1" />
+ <locale name="C">
+ <short>Stereo3D separation</short>
+ <long>The strenght of the effect. Experiment with different settings for best results.</long>
+ </locale>
+ </entry>
<entry name="graphic/video" type="bool" value="true">
<locale name="C">
<short>Video playback</short>
diff --git a/game/screenmanager.cc b/game/screenmanager.cc
index e28dc19..7b3e057 100644
--- a/game/screenmanager.cc
+++ b/game/screenmanager.cc
@@ -42,28 +42,11 @@ Screen* ScreenManager::getScreen(std::string const& name) {
}
void ScreenManager::drawScreen() {
- // FIXME: Rendering using FBO doesn't work
- {
- glViewport(0, 0, 1920, 540);
- glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(0.02f, 0.0f, 0.0f);
- glutil::PushMatrixMode pmv(GL_MODELVIEW);
- glTranslatef(-0.02f, 0.0f, 0.0f);
- //UseFBO fbo(m_fbo);
+ // Draw current frame for all the views
+ for (unsigned i = 0; window().view(i); ++i) {
getCurrentScreen()->draw();
drawNotifications();
}
- {
- glViewport(0, 540, 1920, 540);
- glutil::PushMatrixMode pp(GL_PROJECTION);
- glTranslatef(-0.02f, 0.0f, 0.0f);
- glutil::PushMatrixMode pmv(GL_MODELVIEW);
- glTranslatef(0.02f, 0.0f, 0.0f);
- //UseFBO fbo(m_fbo);
- getCurrentScreen()->draw();
- drawNotifications();
- }
- //m_fbo.getTexture().draw(Dimensions().fixedWidth(1.0));
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 54f677b..ecd05d4 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -75,6 +75,52 @@ void Window::blank() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
+bool Window::view(unsigned num) {
+ // Setup the projection matrix for 2D translates
+ using namespace glmath;
+ glMatrixMode(GL_PROJECTION);
+ float h = virtH();
+ // OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
+ upload(scale(Vec3(2.0f, 2.0f / h, 1.0f)));
+ // Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
+ // glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
+ glMatrixMode(GL_MODELVIEW);
+ const float f = near_ / z0;
+ upload(
+ scale(Vec3(0.5, 0.5 * h, 1.0))
+ * frustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_)
+ * translate(Vec3(0.0, 0.0, -z0))
+ );
+ // Setup views
+ 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
+ // 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;
+ if (stereo) {
+ if (num > 1) return false;
+ double separation = 0.0004f * (num ? -1 : 1) * config["graphic/stereo3dseparation"].f();
+ glMatrixMode(GL_PROJECTION);
+ glTranslatef(separation, 0.0f, 0.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(-separation, 0.0f, 0.0f);
+ if (type == 0) {
+ // TODO: implement color shaders for red/cyan
+ }
+ if (type == 1) {
+ double margin = screen->h - s_height;
+ vy = 0.25 * margin + (num ? 0.5 * screen->h : 0.0);
+ vh *= 0.5;
+ }
+ } else {
+ if (num != 0) return false;
+ }
+ glViewport(vx, vy, vw, vh);
+ return true;
+}
+
void Window::swap() {
SDL_GL_SwapBuffers();
}
@@ -133,7 +179,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);
- glViewport(0.5f * (screen->w - s_width), 0.5f * (screen->h - s_height), s_width, s_height);
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
@@ -142,21 +187,6 @@ void Window::resize() {
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);
- float h = virtH();
- // OpenGL normalized coordinates go from -1 to 1, change scale so that our 2D translates can use the Performous normalized coordinates instead
- upload(scale(Vec3(2.0f, 2.0f / h, 1.0f)));
- // Note: we do the frustum on MODELVIEW so that 2D positioning can be done via projection matrix.
- // glTranslatef on that will move the image, not the camera (i.e. far-away and nearby objects move the same amount)
- glMatrixMode(GL_MODELVIEW);
- const float f = near_ / z0;
- upload(
- scale(Vec3(0.5, 0.5 * h, 1.0))
- * frustum(-0.5f * f, 0.5f * f, 0.5f * h * f, -0.5f * h * f, near_, far_)
- * translate(Vec3(0.0, 0.0, -z0))
- );
// Check for OpenGL errors
glutil::GLErrorChecker glerror("Window::resize");
}
diff --git a/game/video_driver.hh b/game/video_driver.hh
index 131c3ef..37f9f38 100644
--- a/game/video_driver.hh
+++ b/game/video_driver.hh
@@ -25,6 +25,10 @@ public:
Window(unsigned int windowW, unsigned int windowH, bool fullscreen);
/// destructor
~Window();
+ /// 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
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:15
|
Module: performous Branch: stereo3d Commit: c9be4b9dca74f2b1fffa6968ac49bdabd7c38e4d Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jan 27 00:07:18 2011 +0100 Merge branch 'opengl2' into stereo3d --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:13
|
Module: performous Branch: stereo3d Commit: 40bea45633758c4a9b526fd629e6c15c985fda21 Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jan 27 00:02:14 2011 +0100 Merge branch 'master' into opengl2 Conflicts: game/guitargraph.cc game/screen_songs.cc --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:10
|
Module: performous
Branch: stereo3d
Commit: 87b23cdd5bca9ee2fd9feca033f35f28b1a9ecdf
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Jan 26 23:43:52 2011 +0100
Do not parse forced instruments with regex
---
game/joystick.cc | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index af75206..663c12c 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -334,32 +334,25 @@ void input::SDL::init() {
readControllers(g_instruments, getConfigDir() / "controllers.xml");
std::map<unsigned int, input::Instrument> forced_type;
- std::string regexp_match_force("^([0-9]+):(\\(");
- for(input::Instruments::iterator it = g_instruments.begin() ; it != g_instruments.end() ; ++it) {
- if(it == g_instruments.begin())
- regexp_match_force += it->first;
- else
- regexp_match_force += "|" + it->first;
- }
- regexp_match_force += "\\))$";
- boost::regex match_force(regexp_match_force);
- boost::match_results<const char*> what;
-
ConfigItem::StringList const& instruments = config["game/instruments"].sl();
for (ConfigItem::StringList::const_iterator it = instruments.begin(); it != instruments.end(); ++it) {
- if (!regex_search(it->c_str(), what, match_force)) {
- std::clog << "controllers/error: " << *it << "\" is not a valid instrument forced value" << std::endl;
+ std::istringstream iss(*it);
+ unsigned sdl_id;
+ char ch;
+ std::string type;
+ if (!(iss >> sdl_id >> ch >> type) || ch != ':') {
+ std::clog << "controllers/error: \"" << *it << "\" invalid syntax, should be SDL_ID:CONTROLLER_TYPE" << std::endl;
continue;
} else {
- unsigned int sdl_id = boost::lexical_cast<unsigned int>(what[1]);
- std::string instrument_type(what[2]);
-
- for(input::Instruments::const_iterator it2 = g_instruments.begin() ; it2 != g_instruments.end() ; ++it2) {
- if(instrument_type == it2->first) {
+ bool found = false;
+ for (input::Instruments::const_iterator it2 = g_instruments.begin(); it2 != g_instruments.end(); ++it2) {
+ if (type == it2->first) {
forced_type.insert(std::pair<unsigned int,input::Instrument>(sdl_id, input::Instrument(it2->second)));
+ found = true;
break;
}
}
+ if (!found) std::clog << "controllers/error: Controller type \"" << type << "\" unknown" << std::endl;
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:07
|
Module: performous
Branch: stereo3d
Commit: f340c6f12b095347966dc535a612f8cbfba4f1d7
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Jan 23 14:37:59 2011 +0100
Reverted manually bf2c4bdf (practice drum mode not used at all) to simplify guitargraph
---
game/guitargraph.cc | 42 +++++-------------------------------------
game/guitargraph.hh | 4 +---
game/screen_sing.cc | 12 +++---------
game/screen_sing.hh | 4 +---
4 files changed, 10 insertions(+), 52 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 61cb1b0..51cd3d2 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -93,7 +93,7 @@ void GuitarGraph::initDrums() {
//m_samples.push_back("drum tom2");
}
-GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number, bool practmode):
+GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number):
InstrumentGraph(audio, song, drums ? input::DRUMS : input::GUITAR),
m_tail(getThemePath("tail.svg")),
m_tail_glow(getThemePath("tail_glow.svg")),
@@ -105,7 +105,6 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number,
m_neckglowColor(),
m_drums(drums),
m_use3d(config["graphic/3d_notes"].b()),
- m_practmode(practmode),
m_level(),
m_track_index(m_instrumentTracks.end()),
m_dfIt(m_drumfills.end()),
@@ -120,7 +119,6 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number,
m_soloTotal(),
m_soloScore(),
m_solo(),
- m_practHold(false),
m_hasTomTrack(false),
m_whammy(0)
{
@@ -413,31 +411,14 @@ void GuitarGraph::engine() {
// Countdown to start
handleCountdown(time, time < getNotesBeginTime() ? getNotesBeginTime() : m_jointime+1);
- // FIXME: this is a band aid to release m_practHold
- // this may happen in conjunction with the regular pause feature
- if (m_practHold && !m_audio.isPaused()) m_practHold = false;
-
// Skip missed notes
// we hold the note a litle bit *before* they go out of the tolerance window
// this is important in order for the hit-detection to still accept the notes
// FIXME: need to confirm that this timing is reliable,
// if a note gets marked as 'past' completing the chord does not re-start the song
- double past = time - maxTolerance + (m_practmode ? 0.05 : 0.0);
- while (!m_practHold && m_chordIt != m_chords.end() && m_chordIt->begin < past) {
+ while (m_chordIt != m_chords.end() && m_chordIt->begin + maxTolerance < time) {
if ( (m_drums && m_chordIt->status != m_chordIt->polyphony)
- || (!m_drums && m_chordIt->status == 0) ) {
- endStreak();
- if (m_practmode && !dead()) {
- // in practice mode hold the chord here
- // m_chordIt must not change until finishing the chord
- m_audio.seekPos(m_chordIt->begin);
- m_audio.pause(true);
- m_practHold = true;
- endStreak();
- std::cout << "practice: hold chord at " << m_chordIt->begin << ", status = "<< m_chordIt->status << std::endl;
- break;
- }
- }
+ || (!m_drums && m_chordIt->status == 0) ) endStreak();
// Calculate solo total score
if (m_solo) { m_soloScore += m_chordIt->score; m_soloTotal += m_chordIt->polyphony * points(0);
// Solo just ended?
@@ -451,17 +432,6 @@ void GuitarGraph::engine() {
++m_chordIt;
}
- // just finished a chord in practice mode
- if (m_practHold &&
- ( (m_drums && m_chordIt->status == m_chordIt->polyphony)
- || (!m_drums && m_chordIt->status != 0) ) ) {
- // now we have completed the chord
- // m_chordIt must not change from holding the chord until we get here
- if (m_audio.isPaused()) m_audio.togglePause();
- m_practHold = false;
- std::cout << "practice: finish chord at " << m_chordIt->begin << std::endl;
- }
-
if (difficulty_changed) m_dead = 0; // if difficulty is changed, m_dead would get incorrect
// Adjust the correctness value
if (!m_events.empty() && m_events.back().type == 0) m_correctness.setTarget(0.0, true);
@@ -649,18 +619,16 @@ void GuitarGraph::drumHit(double time, int fret) {
// in kiddy mode we don't care about the correct pad
// all that matters is that there is still a missing note in that chord
if (m_chordIt->status == m_chordIt->polyphony) continue;
- } else if ((!it->dur[fret]) || (m_notes[it->dur[fret]])) continue; // invalid fret/hit or already played
+ } else if (m_notes[it->dur[fret]]) continue; // invalid fret/hit or already played
double error = std::abs(it->begin - time);
if (error < tolerance) {
best = it;
tolerance = error;
signed_error = it->begin - time;
- if (m_practHold) break; // during practice hold the chord will always be m_chordIt
}
}
- if ((best == m_chords.end())
- || (m_practHold && best != m_chordIt)) fail(time, fret); // None found
+ if (best == m_chords.end()) fail(time, fret); // None found
else {
// Skip all chords earlier than the best fit chord
for (; best != m_chordIt; ++m_chordIt) {
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index f0dc946..313b744 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -46,7 +46,7 @@ static inline bool operator==(Chord const& a, Chord const& b) {
class GuitarGraph: public InstrumentGraph {
public:
/// constructor
- GuitarGraph(Audio& audio, Song const& song, bool drums, int number, bool practmode=false);
+ GuitarGraph(Audio& audio, Song const& song, bool drums, int number);
/** draws GuitarGraph
* @param time at which time to draw
*/
@@ -99,7 +99,6 @@ class GuitarGraph: public InstrumentGraph {
// Flags
bool m_drums; /// are we using drums?
bool m_use3d; /// are we using 3d?
- bool m_practmode; /// switch to enable practice mode
// Track stuff
enum Difficulty {
@@ -154,7 +153,6 @@ class GuitarGraph: public InstrumentGraph {
double m_soloTotal; /// maximum solo score
double m_soloScore; /// score during solo
bool m_solo; /// are we currently playing a solo
- bool m_practHold; /// true if holding a chord during practice
bool m_hasTomTrack; /// true if the track has at least one tom track
double m_whammy; /// whammy value for pitch shift
};
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 525f035..8febec1 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -30,7 +30,6 @@ namespace {
}
void ScreenSing::enter() {
- //m_practmode = true; // un-comment this line to play with practice mode. temporary, of course!
ScreenManager* sm = ScreenManager::getSingletonPtr();
sm->loading(_("Loading theme..."), 0.0);
theme.reset(new ThemeSing());
@@ -104,7 +103,7 @@ void ScreenSing::enter() {
if (type == 3) break;
}
if (type == 0) m_dancers.push_back(new DanceGraph(m_audio, *m_song));
- else m_instruments.push_back(new GuitarGraph(m_audio, *m_song, type == 2, idx, m_practmode));
+ else m_instruments.push_back(new GuitarGraph(m_audio, *m_song, type == 2, idx));
++idx;
} catch (input::NoDevError&) {
++type;
@@ -508,13 +507,8 @@ void ScreenSing::draw() {
}
if (m_audio.isPaused()) {
- if (!m_practmode) {
- //m_pause_icon->dimensions.middle().center().fixedWidth(.32);
- //m_pause_icon->draw();
- } else {
- // we get here when the song is on hold during practice
- // TODO: display some (small) info screen here
- }
+ //m_pause_icon->dimensions.middle().center().fixedWidth(.32);
+ //m_pause_icon->draw();
}
// Menus on top of everything
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 5df5af6..0b63066 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -49,8 +49,7 @@ class ScreenSing: public Screen {
public:
/// constructor
ScreenSing(std::string const& name, Audio& audio, Database& database, Backgrounds& bgs):
- Screen(name), m_audio(audio), m_database(database), m_backgrounds(bgs), m_latencyAV(), m_only_singers_alive(true), m_practmode(false),
- m_selectedTrack(TrackName::LEAD_VOCAL)
+ Screen(name), m_audio(audio), m_database(database), m_backgrounds(bgs), m_latencyAV(), m_only_singers_alive(true), m_selectedTrack(TrackName::LEAD_VOCAL)
{}
void enter();
void exit();
@@ -94,7 +93,6 @@ class ScreenSing: public Screen {
boost::shared_ptr<ThemeSing> theme;
AnimValue m_quitTimer;
bool m_only_singers_alive;
- bool m_practmode;
std::string m_selectedTrack;
std::string m_selectedTrackLocalized;
ConfigItem m_vocalTrackOpts;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:05
|
Module: performous
Branch: stereo3d
Commit: a8c99571148d20f31272095a4fbea7d01b271bf0
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Jan 23 13:25:28 2011 +0100
Started some simple guitargraph regactoring
---
game/guitargraph.cc | 133 +++++++++++++++++++++++++++++++-------------------
game/guitargraph.hh | 8 +++-
2 files changed, 89 insertions(+), 52 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index d3422d7..61cb1b0 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -59,6 +59,40 @@ namespace {
inline float blend(float a, float b, float f) { return a*f + b*(1.0f-f); }
}
+void GuitarGraph::initGuitar() {
+ // Copy all tracks of guitar types (not DRUMS and not KEYBOARD) to m_instrumentTracks
+ for (InstrumentTracks::const_iterator it = m_song.instrumentTracks.begin(); it != m_song.instrumentTracks.end(); ++it) {
+ std::string index = it->first;
+ if (index != TrackName::DRUMS && index != TrackName::KEYBOARD) m_instrumentTracks[index] = &it->second;
+ }
+ if (m_instrumentTracks.empty()) throw std::logic_error("No guitar tracks found");
+
+ // Adding fail samples
+ m_samples.push_back("guitar fail1");
+ m_samples.push_back("guitar fail2");
+ m_samples.push_back("guitar fail3");
+ m_samples.push_back("guitar fail4");
+ m_samples.push_back("guitar fail5");
+ m_samples.push_back("guitar fail6");
+}
+
+void GuitarGraph::initDrums() {
+ // Copy all tracks of drum type to m_instrumentTracks
+ for (InstrumentTracks::const_iterator it = m_song.instrumentTracks.begin(); it != m_song.instrumentTracks.end(); ++it) {
+ std::string index = it->first;
+ if (index == TrackName::DRUMS) m_instrumentTracks[index] = &it->second;
+ }
+ if (m_instrumentTracks.empty()) throw std::logic_error("No drum tracks found");
+
+ // Adding fail samples
+ m_samples.push_back("drum bass");
+ m_samples.push_back("drum snare");
+ m_samples.push_back("drum hi-hat");
+ m_samples.push_back("drum tom1");
+ m_samples.push_back("drum cymbal");
+ //m_samples.push_back("drum tom2");
+}
+
GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number, bool practmode):
InstrumentGraph(audio, song, drums ? input::DRUMS : input::GUITAR),
m_tail(getThemePath("tail.svg")),
@@ -90,33 +124,17 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number,
m_hasTomTrack(false),
m_whammy(0)
{
- // Copy all tracks of supported types (either drums or non-drums) to m_instrumentTracks
- for (InstrumentTracks::const_iterator it = m_song.instrumentTracks.begin(); it != m_song.instrumentTracks.end(); ++it) {
- std::string index = it->first;
- if (m_drums == (index == TrackName::DRUMS)) m_instrumentTracks[index] = &it->second;
+ if(m_drums) {
+ initDrums();
+ } else {
+ initGuitar();
}
- if (m_instrumentTracks.empty()) throw std::logic_error(m_drums ? "No drum tracks found" : "No guitar tracks found");
// Load 3D fret objects
m_fretObj.load(getThemePath("fret.obj"));
m_tappableObj.load(getThemePath("fret_tap.obj"));
// Score calculator (TODO a better one)
m_scoreText.reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
m_streakText.reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
- if (m_drums) {
- m_samples.push_back("drum bass");
- m_samples.push_back("drum snare");
- m_samples.push_back("drum hi-hat");
- m_samples.push_back("drum tom1");
- m_samples.push_back("drum cymbal");
- //m_samples.push_back("drum tom2");
- } else {
- m_samples.push_back("guitar fail1");
- m_samples.push_back("guitar fail2");
- m_samples.push_back("guitar fail3");
- m_samples.push_back("guitar fail4");
- m_samples.push_back("guitar fail5");
- m_samples.push_back("guitar fail6");
- }
for (size_t i = 0; i < max_panels; ++i) {
m_pressed_anim[i].setRate(5.0);
m_holds[i] = 0;
@@ -135,43 +153,55 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number,
setupJoinMenu();
}
+void GuitarGraph::setupJoinMenuDifficulty() {
+ ConfigItem::OptionList ol;
+ int cur = 0;
+ // Add difficulties to the option list
+ for (int level = 0; level < DIFFICULTYCOUNT; ++level) {
+ if (difficulty(Difficulty(level), true)) {
+ ol.push_back(boost::lexical_cast<std::string>(level));
+ if (Difficulty(level) == m_level) cur = ol.size()-1;
+ }
+ }
+ m_selectedDifficulty = ConfigItem(ol); // Create a ConfigItem from the option list
+ m_selectedDifficulty.select(cur); // Set the selection to current level
+ m_menu.add(MenuOption("", _("Select difficulty"), &m_selectedDifficulty)); // MenuOption that cycles the options
+ m_menu.back().setDynamicName(m_difficultyOpt); // Set the title to be dynamic
+}
+
+void GuitarGraph::setupJoinMenuDrums() {
+ setupJoinMenuDifficulty();
+ m_menu.add(MenuOption(_("Lefty-mode"), "", &m_leftymode));
+ m_menu.back().setDynamicComment(m_leftyOpt);
+}
+
+void GuitarGraph::setupJoinMenuGuitar() {
+ ConfigItem::OptionList ol;
+ int cur = 0;
+ // Add tracks to option list
+ for (InstrumentTracksConstPtr::const_iterator it = m_instrumentTracks.begin(); it != m_instrumentTracks.end(); ++it) {
+ ol.push_back(it->first);
+ if (m_track_index->first == it->first) cur = ol.size()-1; // Find the index of current track
+ }
+ m_selectedTrack = ConfigItem(ol); // Create a ConfigItem from the option list
+ m_selectedTrack.select(cur); // Set the selection to current track
+ m_menu.add(MenuOption("", _("Select track"), &m_selectedTrack)); // MenuOption that cycles the options
+ m_menu.back().setDynamicName(m_trackOpt); // Set the title to be dynamic
+ setupJoinMenuDifficulty();
+ m_menu.add(MenuOption(_("Lefty-mode"), "", &m_leftymode));
+ m_menu.back().setDynamicComment(m_leftyOpt);
+}
void GuitarGraph::setupJoinMenu() {
m_menu.clear();
updateJoinMenu();
// Populate root menu
m_menu.add(MenuOption(_("Ready!"), _("Start performing!")));
- // Create track option only for guitars
- if (!m_drums) {
- ConfigItem::OptionList ol;
- int cur = 0;
- // Add tracks to option list
- for (InstrumentTracksConstPtr::const_iterator it = m_instrumentTracks.begin(); it != m_instrumentTracks.end(); ++it) {
- ol.push_back(it->first);
- if (m_track_index->first == it->first) cur = ol.size()-1; // Find the index of current track
- }
- m_selectedTrack = ConfigItem(ol); // Create a ConfigItem from the option list
- m_selectedTrack.select(cur); // Set the selection to current track
- m_menu.add(MenuOption("", _("Select track"), &m_selectedTrack)); // MenuOption that cycles the options
- m_menu.back().setDynamicName(m_trackOpt); // Set the title to be dynamic
- }
- { // Create difficulty opt
- ConfigItem::OptionList ol;
- int cur = 0;
- // Add difficulties to the option list
- for (int level = 0; level < DIFFICULTYCOUNT; ++level) {
- if (difficulty(Difficulty(level), true)) {
- ol.push_back(boost::lexical_cast<std::string>(level));
- if (Difficulty(level) == m_level) cur = ol.size()-1;
- }
- }
- m_selectedDifficulty = ConfigItem(ol); // Create a ConfigItem from the option list
- m_selectedDifficulty.select(cur); // Set the selection to current level
- m_menu.add(MenuOption("", _("Select difficulty"), &m_selectedDifficulty)); // MenuOption that cycles the options
- m_menu.back().setDynamicName(m_difficultyOpt); // Set the title to be dynamic
+ if(m_drums) {
+ setupJoinMenuDrums();
+ } else {
+ setupJoinMenuGuitar();
}
- m_menu.add(MenuOption(_("Lefty-mode"), "", &m_leftymode));
- m_menu.back().setDynamicComment(m_leftyOpt);
m_menu.add(MenuOption(_("Quit"), _("Exit to song browser"), "Songs"));
}
@@ -188,6 +218,7 @@ void GuitarGraph::updateNeck() {
// TODO: Optimize with texture cache
std::string index = m_track_index->first;
if (index == TrackName::DRUMS) m_neck.reset(new Texture(getThemePath("drumneck.svg")));
+ else if (index == TrackName::KEYBOARD) m_neck.reset(new Texture(getThemePath("guitarneck.svg")));
else if (index == TrackName::BASS) m_neck.reset(new Texture(getThemePath("bassneck.svg")));
else m_neck.reset(new Texture(getThemePath("guitarneck.svg")));
}
@@ -226,7 +257,7 @@ std::string GuitarGraph::getDifficultyString() const {
/// Get a string id for track and difficulty
std::string GuitarGraph::getModeId() const {
return m_track_index->first + " - " + diffv[m_level].name
- + (m_drums && m_input.isKeyboard() ? " (kbd)" : "");
+ + (m_input.isKeyboard() ? " (kbd)" : "");
}
/// Cycle through difficulties
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index a1ab5cf..f0dc946 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -50,7 +50,6 @@ class GuitarGraph: public InstrumentGraph {
/** draws GuitarGraph
* @param time at which time to draw
*/
- void updateNeck();
void draw(double time);
void engine();
bool dead() const;
@@ -62,7 +61,14 @@ class GuitarGraph: public InstrumentGraph {
double getWhammy() const { return m_whammy; }
private:
+ // refactoring methods
+ void initDrums();
+ void initGuitar();
+ void setupJoinMenuDifficulty();
+ void setupJoinMenuDrums();
+ void setupJoinMenuGuitar();
// Engine / scoring utils
+ void updateNeck();
bool canActivateStarpower() { return (m_starmeter > 6000); }
void activateStarpower();
void errorMeter(float error);
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:08:02
|
Module: performous Branch: stereo3d Commit: 53a912fa44275ffdd9c9b6bb1eb57458a0be85d8 Author: Vincent Le Ligeour <yo...@us...> Date: Sat Jan 22 16:52:29 2011 +0100 Made mididrums mapping configurable Conflicts: game/main.cc --- data/CMakeLists.txt | 2 + data/mididrums.xml | 75 +++++++++++++++++++++++++++ game/joystick.cc | 139 +++++++++++++++++++-------------------------------- game/joystick.hh | 3 +- game/main.cc | 4 +- 5 files changed, 134 insertions(+), 89 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:07:59
|
Module: performous Branch: stereo3d Commit: dcdb3a646267e66aa51dc9c86e6d2b7a418ba25d Author: Vincent Le Ligeour <yo...@us...> Date: Sat Jan 22 16:48:06 2011 +0100 Added some more keyboard management --- data/controllers.xml | 12 +++++++ data/schema.xml | 6 ++++ game/joystick.cc | 66 +++++++++++++++++++++++++++++++++++++-- game/joystick.hh | 16 ++++++++-- game/screen_songs.cc | 24 ++++++++++++-- game/song.hh | 3 +- game/songs.cc | 1 + themes/default/instruments.svg | 30 +++++++++++++++--- 8 files changed, 141 insertions(+), 17 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-26 23:07:56
|
Module: performous
Branch: stereo3d
Commit: 2d8629551ef3548ef0cb35d0ff47aa6762c1fac9
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Jan 22 15:41:09 2011 +0100
Added keyboard track name
---
game/song.hh | 1 +
game/songparser-ini.cc | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/game/song.hh b/game/song.hh
index 3250442..87b3d76 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -26,6 +26,7 @@ namespace TrackName {
const std::string GUITAR_COOP = "Coop guitar";
const std::string GUITAR_RHYTHM = "Rhythm guitar";
const std::string BASS = "Bass";
+ const std::string KEYBOARD = "Keyboard";
const std::string DRUMS = "Drums";
const std::string LEAD_VOCAL = "Vocals";
const std::string HARMONIC_1 = "Harmonic 1";
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index c46f476..8548f15 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -96,6 +96,7 @@ void SongParser::iniParseHeader() {
boost::regex audiofile_guitar("(guitar\\.ogg)$", boost::regex_constants::icase);
boost::regex audiofile_drums("(drums\\.ogg)$", boost::regex_constants::icase);
boost::regex audiofile_bass("(rhythm\\.ogg)$", boost::regex_constants::icase);
+ boost::regex audiofile_keyboard("(keyboard\\.ogg)$", boost::regex_constants::icase);
boost::regex audiofile_vocals("(vocals\\.ogg)$", boost::regex_constants::icase);
boost::regex audiofile_other("(.*\\.ogg)$", boost::regex_constants::icase);
boost::cmatch match;
@@ -112,6 +113,8 @@ void SongParser::iniParseHeader() {
testAndAdd(s, TrackName::GUITAR, name);
} else if (regex_match(name.c_str(), match, audiofile_bass)) {
testAndAdd(s, TrackName::BASS, name);
+ } else if (regex_match(name.c_str(), match, audiofile_keyboard)) {
+ testAndAdd(s, TrackName::KEYBOARD, name);
} else if (regex_match(name.c_str(), match, audiofile_drums)) {
testAndAdd(s, TrackName::DRUMS, name);
} else if (regex_match(name.c_str(), match, audiofile_vocals)) {
|