|
From: Lasse Kärkkäi. <tr...@us...> - 2011-03-12 19:34:16
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Mar 12 20:25:06 2011 +0100
All FixedFunc transform stuff removed (gl2cleanup)
---
game/3dobject.hh | 5 ++---
game/dialog.hh | 8 ++++----
game/glutil.hh | 14 --------------
game/guitargraph.cc | 18 ++++++++++--------
game/instrumentgraph.cc | 3 +--
game/instrumentgraph.hh | 4 ++--
game/notegraph.cc | 5 ++---
game/screen_sing.cc | 4 ++--
8 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/game/3dobject.hh b/game/3dobject.hh
index 1479c3b..5ce33f5 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -33,9 +33,8 @@ class Object3d: boost::noncopyable {
void drawVBO();
/// draws the object
void draw(float x = 0, float y = 0, float z = 0, float s = 1.0) {
- glutil::PushMatrix pm;
- glTranslatef(x, y, z); // Move to position
- if (s != 1.0) glScalef(s,s,s); // Scale if needed
+ using namespace glmath;
+ Transform trans(translate(vec3(x, y, z)) * scale(s)); // Move to position and scale
if (m_texture) {
UseTexture tex(*m_texture);
drawVBO();
diff --git a/game/dialog.hh b/game/dialog.hh
index b3e63a8..b33c1b3 100644
--- a/game/dialog.hh
+++ b/game/dialog.hh
@@ -1,9 +1,9 @@
#pragma once
-#include "opengl_text.hh"
+#include "configuration.hh"
#include "fs.hh"
+#include "opengl_text.hh"
#include "surface.hh"
-#include "configuration.hh"
/// class for printing dialogues
class Dialog {
@@ -18,8 +18,8 @@ class Dialog {
}
/// draws dialogue
void draw() {
- glutil::PushMatrix pm;
- glTranslatef(0.0f, 0.0f, 0.1f); // Raise a bit in 3D
+ using namespace glmath;
+ Transform(translate(vec3(0.0f, 0.0f, 0.1f))); // Raise a bit in 3D
m_dialog.draw();
m_svgText.draw(m_text);
}
diff --git a/game/glutil.hh b/game/glutil.hh
index f36cf91..9b737ff 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -13,20 +13,6 @@ glmath::mat4& getColorMatrix(); ///< A temporary hack for global access to the
namespace glutil {
/// wrapper struct for RAII
- struct PushMatrix {
- PushMatrix() { glPushMatrix(); }
- ~PushMatrix() { glPopMatrix(); }
- };
-
- /// wrapper struct for RAII
- struct PushMatrixMode {
- PushMatrixMode(GLenum mode) { glGetIntegerv(GL_MATRIX_MODE, &m_old); glMatrixMode(mode); glPushMatrix(); }
- ~PushMatrixMode() { glPopMatrix(); glMatrixMode(m_old); }
- private:
- GLint m_old;
- };
-
- /// wrapper struct for RAII
struct UseDepthTest {
/// enable depth test (for 3d objects)
UseDepthTest() {
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 38ada22..62518f4 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -23,7 +23,7 @@ namespace {
const size_t diffsz = sizeof(diffv) / sizeof(*diffv);
const int death_delay = 20; // Delay in notes after which the player is hidden
const float join_delay = 3.0f; // Time after join menu before playing when joining mid-game
- const float g_angle = 80.0f; // How much to rotate the fretboards
+ const float g_angle = 1.4f; // How many radians to rotate the fretboards
const float past = -0.2f; // Relative time from cursor that is considered past (out of screen)
const float future = 1.5f; // Relative time from cursor that is considered future (out of screen)
const float timescale = 25.0f; // Multiplier to get graphics units from time
@@ -794,20 +794,22 @@ void GuitarGraph::draw(double time) {
float ng_r = 0, ng_g = 0, ng_b = 0; // neck glow color components
int ng_ccnt = 0; // neck glow color count
{ // Translate, rotate and scale to place
+ using namespace glmath;
double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
+ /*
glutil::PushMatrixMode pmm(GL_PROJECTION);
glTranslatef(frac * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
- glTranslatef((1.0 - frac) * offsetX, dimensions.y2(), 0.0f);
+ glTranslatef((1.0 - frac) * offsetX, 0.0f, 0.0f);
+ */
+ mat4 m = translate(vec3(0.0f, dimensions.y2(), 0.0f)) * rotate(g_angle, vec3(1.0f, 0.0f, 0.0f)) * scale(dimensions.w() / 5.0f);
// Do some jumping for drums
if (m_drums) {
float jumpanim = m_drumJump.get();
if (jumpanim == 1.0) m_drumJump.setTarget(0.0);
- if (jumpanim > 0) glTranslatef(0.0f, -m_drumJump.get() * 0.01, 0.0f);
+ if (jumpanim > 0) m = translate(vec3(0.0f, -m_drumJump.get() * 0.01, 0.0f)) * m;
}
- glRotatef(g_angle, 1.0f, 0.0f, 0.0f);
- float temp_s = dimensions.w() / 5.0f;
- glScalef(temp_s, temp_s, temp_s);
+ Transform trans(m);
// Draw the neck
{
@@ -1156,8 +1158,8 @@ void GuitarGraph::drawDrumfill(float tBeg, float tEnd) {
void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
// Draw info
if (!menuOpen()) {
- glutil::PushMatrix mat;
- glTranslatef(0.0f, 0.0f, -0.5f);
+ using namespace glmath;
+ Transform trans(translate(vec3(0.0f, 0.0f, -0.5f)));
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)
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index 95de035..5a7aca9 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -75,10 +75,9 @@ void InstrumentGraph::drawMenu() {
// Some helper vars
ThemeInstrumentMenu& th = *m_menuTheme;
MenuOptions::const_iterator cur = static_cast<MenuOptions::const_iterator>(&m_menu.current());
- glutil::PushMatrix pm; // Save scaling state
double w = m_menu.dimensions.w();
const float s = std::min(m_width.get(), 0.5) / w;
- glScalef(s, s, 1.0f);
+ Transform trans(glmath::scale(s)); // Fit better menu on screen
// We need to multiply offset by inverse scale factor to keep it always constant
// All these vars are ultimately affected by the scaling matrix
const double offsetX = 0.5f * (dimensions.x1() + dimensions.x2()) / s;
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index 85d3585..fe6d0d4 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -34,8 +34,8 @@ class Popup {
glutil::Color color(m_color);
m_popupText->render(m_msg);
{
- glutil::PushMatrix mat;
- glTranslatef(0.0f, 0.0f, 0.5f * anim);
+ using namespace glmath;
+ Transform trans(translate(vec3(0.0f, 0.0f, 0.5f * anim)));
m_popupText->dimensions().center(0.1 - 0.03 * anim).middle(offsetX).stretch(0.2f, 0.2f);
m_popupText->draw();
}
diff --git a/game/notegraph.cc b/game/notegraph.cc
index f012ea8..f3c36e1 100644
--- a/game/notegraph.cc
+++ b/game/notegraph.cc
@@ -122,9 +122,8 @@ void NoteGraph::draw(double time, Database const& database, Position position) {
float centerx = x + w - (player_star_offset + 1.2) * hh; // Star is 1.2 units from end
float rot = fmod(time * 360, 360); // They rotate!
float zoom = (std::abs((rot-180) / 360.0f) * 0.8f + 0.6f) * (position == NoteGraph::TOP ? 2.3 : 2.0) * hh;
- glutil::PushMatrix pm;
- glTranslatef(centerx, centery, 0.0f);
- glRotatef(rot, 0.0f, 0.0f, 1.0f);
+ using namespace glmath;
+ Transform trans(translate(vec3(centerx, centery, 0.0f)) * rotate(rot, vec3(0.0f, 0.0f, 1.0f)));
{
glutil::Color c(Color(it_col->r, it_col->g, it_col->b, it_col->a));
m_star_hl.draw(Dimensions().stretch(zoom*1.2, zoom*1.2).center().middle(), TexCoords());
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index f4c0d0a..fb3bc43 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -646,8 +646,8 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database, Dancers&
}
void ScoreWindow::draw() {
- glutil::PushMatrix block;
- glTranslatef(0.0, m_pos.get(), 0.0);
+ using namespace glmath;
+ Transform trans(translate(vec3(0.0, m_pos.get(), 0.0)));
m_bg.draw();
const double spacing = 0.1 + 0.1 / m_database.scores.size();
unsigned i = 0;
|