Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Gource to use latest version of Core library.

Vector math now done with GLM ( http://glm.g-truc.net ).

Work in progress implementation of window resize and fullscreen toggle.
  • Loading branch information...
commit e5a8c3209edfea58f21f7293e3a789377f469efc 1 parent f1e6c66
@acaudwell authored
View
7 Makefile.am
@@ -5,11 +5,10 @@ bin_PROGRAMS = gource
gource_SOURCES = \
src/action.cpp src/action.h \
src/apache.cpp src/apache.h \
- src/bloom.cpp src/bloom.h \
- src/bzr.cpp src/bzr.h \
+ src/bloom.cpp src/bloom.h \
+ src/bzr.cpp src/bzr.h \
src/commitlog.cpp src/commitlog.h \
src/core/bounds.h \
- src/core/camera.cpp src/core/camera.h \
src/core/conffile.cpp src/core/conffile.h \
src/core/display.cpp src/core/display.h \
src/core/frustum.cpp src/core/frustum.h \
@@ -34,7 +33,7 @@ gource_SOURCES = \
src/core/utf8/unchecked.h \
src/core/utf8/utf8.h \
src/core/vbo.cpp src/core/vbo.h \
- src/core/vectors.h \
+ src/core/vectors.cpp src/core/vectors.h \
src/custom.cpp src/custom.h \
src/cvs-exp.cpp src/cvs-exp.h \
src/cvs2cl.cpp src/cvs2cl.h \
View
50 src/action.cpp
@@ -42,22 +42,27 @@ void RAction::logic(float dt) {
void RAction::drawToVBO(quadbuf& buffer) const {
if(isFinished()) return;
- vec2f src = source->getPos();
- vec2f dest = target->getAbsolutePos();
+ vec2 src = source->getPos();
+ vec2 dest = target->getAbsolutePos();
- vec2f offset = (dest - src).normal().perpendicular() * target->getSize() * 0.5;
- vec2f offset_src = offset * 0.3f;
+ //TODO: could use glm::perp
+
+ vec2 n = normalize(dest - src);
+ vec2 perp = vec2(-n.y, n.x);
+
+ vec2 offset = perp * target->getSize() * 0.5f;
+ vec2 offset_src = offset * 0.3f;
float alpha = 1.0 - progress;
float alpha2 = alpha * 0.1;
- vec4f col1 = vec4f(colour, alpha);
- vec4f col2 = vec4f(colour, alpha2);
+ vec4 col1 = vec4(colour, alpha);
+ vec4 col2 = vec4(colour, alpha2);
- quadbuf_vertex v1(src - offset_src, col2, vec2f(0.0f, 0.0f));
- quadbuf_vertex v2(src + offset_src, col2, vec2f(0.0f, 1.0f));
- quadbuf_vertex v3(dest + offset, col1, vec2f(1.0f, 1.0f));
- quadbuf_vertex v4(dest - offset, col1, vec2f(1.0f, 0.0f));
+ quadbuf_vertex v1(src - offset_src, col2, vec2(0.0f, 0.0f));
+ quadbuf_vertex v2(src + offset_src, col2, vec2(0.0f, 1.0f));
+ quadbuf_vertex v3(dest + offset, col1, vec2(1.0f, 1.0f));
+ quadbuf_vertex v4(dest - offset, col1, vec2(1.0f, 0.0f));
buffer.add(0, v1, v2, v3, v4);
}
@@ -65,26 +70,29 @@ void RAction::drawToVBO(quadbuf& buffer) const {
void RAction::draw(float dt) {
if(isFinished()) return;
- vec2f src = source->getPos();
- vec2f dest = target->getAbsolutePos();
+ vec2 src = source->getPos();
+ vec2 dest = target->getAbsolutePos();
- vec2f offset = (dest - src).normal().perpendicular() * target->getSize() * 0.5;
- vec2f offset_src = offset * 0.3f;
+ vec2 n = normalize(dest - src);
+ vec2 perp = vec2(-n.y, n.x);
+
+ vec2 offset = perp * target->getSize() * 0.5f;
+ vec2 offset_src = offset * 0.3f;
float alpha = 1.0 - progress;
float alpha2 = alpha * 0.1;
- vec4f col1 = vec4f(colour, alpha);
- vec4f col2 = vec4f(colour, alpha2);
+ vec4 col1 = vec4(colour, alpha);
+ vec4 col2 = vec4(colour, alpha2);
glBegin(GL_QUADS);
- glColor4fv(col2);
+ glColor4fv(glm::value_ptr(col2));
glTexCoord2f(0.0,0.0);
glVertex2f(src.x - offset_src.x, src.y - offset_src.y);
glTexCoord2f(0.0,1.0);
glVertex2f(src.x + offset_src.x, src.y + offset_src.y);
- glColor4fv(col1);
+ glColor4fv(glm::value_ptr(col1));
glTexCoord2f(1.0,1.0);
glVertex2f(dest.x + offset.x, dest.y + offset.y);
glTexCoord2f(1.0,0.0);
@@ -93,11 +101,11 @@ void RAction::draw(float dt) {
}
CreateAction::CreateAction(RUser* source, RFile* target, float addedtime) : RAction(source, target, addedtime) {
- colour = vec3f(0.0, 1.0, 0.0);
+ colour = vec3(0.0, 1.0, 0.0);
}
RemoveAction::RemoveAction(RUser* source, RFile* target, float addedtime): RAction(source, target, addedtime) {
- colour = vec3f(1.0, 0.0, 0.0);
+ colour = vec3(1.0, 0.0, 0.0);
}
void RemoveAction::logic(float dt) {
@@ -111,5 +119,5 @@ void RemoveAction::logic(float dt) {
}
ModifyAction::ModifyAction(RUser* source, RFile* target, float addedtime) : RAction(source, target, addedtime) {
- colour = vec3f(1.0, 0.7, 0.3);
+ colour = vec3(1.0, 0.7, 0.3);
}
View
2  src/action.h
@@ -26,7 +26,7 @@ class RFile;
class RAction {
protected:
- vec3f colour;
+ vec3 colour;
public:
RUser* source;
RFile* target;
View
6 src/bloom.cpp
@@ -61,12 +61,12 @@ size_t bloombuf::capacity() {
return data_size;
}
-void bloombuf::add(GLuint textureid, const vec2f& pos, const vec2f& dims, const vec4f& colour, const vec4f& texcoord) {
+void bloombuf::add(GLuint textureid, const vec2& pos, const vec2& dims, const vec4& colour, const vec4& texcoord) {
bloom_vertex v1(pos, colour, texcoord);
- bloom_vertex v2(pos + vec2f(dims.x, 0.0f), colour, texcoord);
+ bloom_vertex v2(pos + vec2(dims.x, 0.0f), colour, texcoord);
bloom_vertex v3(pos + dims, colour, texcoord);
- bloom_vertex v4(pos + vec2f(0.0f, dims.y), colour, texcoord);
+ bloom_vertex v4(pos + vec2(0.0f, dims.y), colour, texcoord);
int i = vertex_count;
View
10 src/bloom.h
@@ -28,12 +28,12 @@
class bloom_vertex {
public:
bloom_vertex() {};
- bloom_vertex(const vec2f& pos, const vec4f& colour, const vec4f& texcoord) :
+ bloom_vertex(const vec2& pos, const vec4& colour, const vec4& texcoord) :
pos(pos), colour(colour), texcoord(texcoord) {};
- vec2f pos;
- vec4f colour;
- vec4f texcoord;
+ vec2 pos;
+ vec4 colour;
+ vec4 texcoord;
char padding[24];
};
@@ -57,7 +57,7 @@ class bloombuf {
size_t vertices();
size_t capacity();
- void add(GLuint textureid, const vec2f& pos, const vec2f& dims, const vec4f& colour, const vec4f& texcoord);
+ void add(GLuint textureid, const vec2& pos, const vec2& dims, const vec4& colour, const vec4& texcoord);
void update();
void draw();
View
8 src/commitlog.cpp
@@ -242,7 +242,7 @@ void RCommitLog::createTempLog() {
// RCommitFile
-RCommitFile::RCommitFile(const std::string& filename, const std::string& action, vec3f colour) {
+RCommitFile::RCommitFile(const std::string& filename, const std::string& action, vec3 colour) {
this->filename = munge_utf8(filename);
@@ -259,7 +259,7 @@ RCommit::RCommit() {
timestamp = 0;
}
-vec3f RCommit::fileColour(const std::string& filename) {
+vec3 RCommit::fileColour(const std::string& filename) {
size_t slash = filename.rfind('/');
size_t dot = filename.rfind('.');
@@ -269,7 +269,7 @@ vec3f RCommit::fileColour(const std::string& filename) {
return colourHash(file_ext);
} else {
- return vec3f(1.0, 1.0, 1.0);
+ return vec3(1.0, 1.0, 1.0);
}
}
@@ -277,7 +277,7 @@ void RCommit::addFile(const std::string& filename, const std::string& action) {
files.push_back(RCommitFile(filename, action, fileColour(filename)));
}
-void RCommit::addFile(const std::string& filename, const std::string& action, vec3f colour) {
+void RCommit::addFile(const std::string& filename, const std::string& action, vec3 colour) {
files.push_back(RCommitFile(filename, action, colour));
}
View
8 src/commitlog.h
@@ -35,13 +35,13 @@ class RCommitFile {
public:
std::string filename;
std::string action;
- vec3f colour;
+ vec3 colour;
- RCommitFile(const std::string& filename, const std::string& action, vec3f colour);
+ RCommitFile(const std::string& filename, const std::string& action, vec3 colour);
};
class RCommit {
- vec3f fileColour(const std::string& filename);
+ vec3 fileColour(const std::string& filename);
public:
time_t timestamp;
std::string username;
@@ -51,7 +51,7 @@ class RCommit {
bool isValid();
void addFile(const std::string& filename, const std::string& action);
- void addFile(const std::string& filename, const std::string& action, vec3f colour);
+ void addFile(const std::string& filename, const std::string& action, vec3 colour);
RCommit();
void debug();
2  src/core
@@ -1 +1 @@
-Subproject commit 1bde58ca54081ac121ea811e00dfd90125d83dc6
+Subproject commit 51987063256f594554c55ba28aa4f081c9d741b7
View
8 src/custom.cpp
@@ -22,14 +22,14 @@ Regex custom_regex("^([0-9]+)\\|([^|]*)\\|([ADM]?)\\|([^|]+)(?:\\|#?([A-F0-9]{6}
CustomLog::CustomLog(const std::string& logfile) : RCommitLog(logfile) {
}
-vec3f CustomLog::parseColour(const std::string& cstr) {
+vec3 CustomLog::parseColour(const std::string& cstr) {
debugLog("parseColour\n");
- vec3f colour;
+ vec3 colour;
int r,g,b;
if(sscanf(cstr.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
- colour = vec3f( r, g, b );
+ colour = vec3( r, g, b );
colour /= 255.0f;
debugLog("colour %.2f %.2f %.2f\n", colour.x,colour.y,colour.z);
@@ -76,7 +76,7 @@ bool CustomLog::parseCommitEntry(RCommit& commit) {
}
bool has_colour = false;
- vec3f colour;
+ vec3 colour;
if(entries.size()>=5 && entries[4].size()>0) {
has_colour = true;
View
2  src/custom.h
@@ -24,7 +24,7 @@ class CustomLog : public RCommitLog {
protected:
bool parseCommit(RCommit& commit);
bool parseCommitEntry(RCommit& commit);
- vec3f parseColour(const std::string& cstr);
+ vec3 parseColour(const std::string& cstr);
public:
CustomLog(const std::string& logfile);
};
View
130 src/dirnode.cpp
@@ -38,16 +38,20 @@ RDirNode::RDirNode(RDirNode* parent, const std::string & abspath) {
parent = 0;
setParent(parent);
+ accel = spos = prev_accel = vel = vec2(0.0f);
+
+ //NOTE: parent is always being set to 0 so this never gets called ...
+
//figure out starting position
if(parent !=0) {
- vec2f parentPos = parent->getPos();
- vec2f offset;
+ vec2 parentPos = parent->getPos();
+ vec2 offset;
RDirNode* parentP = parent->getParent();
pos = parentPos;
} else {
- pos = vec2f(0.0f, 0.0f);
+ pos = vec2(0.0f, 0.0f);
}
float padded_file_radius = gGourceFileDiameter * 0.5;
@@ -114,8 +118,8 @@ void RDirNode::nodeUpdated(bool userInitiated) {
void RDirNode::rotate(float s, float c) {
if(parent != 0) {
- pos = pos.rotate(s, c);
- spos = spos.rotate(s, c);
+ pos = rotate_vec2(pos, s, c);
+ spos = rotate_vec2(spos, s, c);
}
for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) {
@@ -124,7 +128,7 @@ void RDirNode::rotate(float s, float c) {
}
}
-void RDirNode::setPos(const vec2f & pos) {
+void RDirNode::setPos(const vec2 & pos) {
this->pos = pos;
}
@@ -440,7 +444,7 @@ bool RDirNode::addFile(RFile* f) {
// if so create another node, and move those nodes there
std::string commonpath;
- vec2f commonPos;
+ vec2 commonPos;
for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) {
RDirNode* child = (*it);
@@ -490,9 +494,9 @@ float RDirNode::getRadiusSqrt() const{
return dir_radius_sqrt;
}
-vec3f RDirNode::averageFileColour() const{
+vec3 RDirNode::averageFileColour() const{
- vec3f av;
+ vec3 av;
int count = 0;
for(std::list<RFile*>::const_iterator it = files.begin(); it != files.end(); it++) {
@@ -521,7 +525,7 @@ vec3f RDirNode::averageFileColour() const{
return av;
}
-const vec4f & RDirNode::getColour() const{
+const vec4 & RDirNode::getColour() const{
return col;
}
@@ -530,7 +534,7 @@ void RDirNode::calcColour() {
// make branch brighter if recently accessed
float brightness = std::max(0.6f, 1.0f - std::min(1.0f, since_last_node_change / 3.0f));
- col = vec4f(brightness, brightness, brightness, 1.0);
+ col = vec4(brightness, brightness, brightness, 1.0);
int fcount = 0;
@@ -539,10 +543,10 @@ void RDirNode::calcColour() {
if(file->isHidden()) continue;;
- vec3f filecol = file->getColour() * brightness;
+ vec3 filecol = file->getColour() * brightness;
float a = file->getAlpha();
- col += vec4f(filecol.x, filecol.y, filecol.z, a);
+ col += vec4(filecol.x, filecol.y, filecol.z, a);
fcount++;
}
@@ -578,21 +582,21 @@ void RDirNode::calcRadius() {
float RDirNode::distanceToParent() const{
- float posd = (parent->getPos() - pos).length();
+ float posd = glm::length(parent->getPos() - pos);
float distance = posd - (dir_radius + parent->getParentRadius());
-
+
return distance;
}
void RDirNode::applyForceDir(RDirNode* node) {
if(node == this) return;
- vec2f dir = node->getPos() - pos;
+ vec2 dir = node->getPos() - pos;
- float posd2 = dir.length2();
+ float posd2 = glm::length2(dir);
float myradius = getRadius();
float your_radius = node->getRadius();
-
+
float sumradius = (myradius + your_radius);
float distance2 = posd2 - sumradius*sumradius;
@@ -605,14 +609,14 @@ void RDirNode::applyForceDir(RDirNode* node) {
//resolve overlap
if(posd < 0.00001) {
- accel += vec2f( (rand() % 100) - 50, (rand() % 100) - 50).normal();
+ accel += normalize(vec2( (rand() % 100) - 50, (rand() % 100) - 50));
return;
}
- accel += distance * dir.normal();
+ accel += distance * normalize(dir);
}
-const vec2f & RDirNode::getPos() const{
+const vec2 & RDirNode::getPos() const{
return pos;
}
@@ -651,16 +655,18 @@ void RDirNode::applyForces(QuadTree & quadtree) {
// * dirs should attract to sit on the radius of the parent dir ie:
// should attract to distance_to_parent * normal_to_parent
- accel += gGourceForceGravity * parent_dist * (parent->getPos() - pos).normal();
-
+
+
+ accel += gGourceForceGravity * parent_dist * normalize(parent->getPos() - pos);
+
// * dirs should be pushed along the parent_parent to parent normal by a force smaller than the parent radius force
RDirNode* pparent = parent->getParent();
if(pparent != 0) {
- vec2f parent_edge = (parent->getPos() - pparent->getPos());
- vec2f parent_edge_normal = parent_edge.normal();
+ vec2 parent_edge = (parent->getPos() - pparent->getPos());
+ vec2 parent_edge_normal = normalize(parent_edge);
- vec2f dest = (parent->getPos() + (parent->getRadius() + getRadius()) * parent_edge_normal) - pos;
+ vec2 dest = (parent->getPos() + (parent->getRadius() + getRadius()) * parent_edge_normal) - pos;
accel += dest;
}
@@ -668,7 +674,7 @@ void RDirNode::applyForces(QuadTree & quadtree) {
// * dirs should repulse from other dirs of this parent
const std::list<RDirNode*> & siblings = parent->getChildren();
if(!siblings.empty()) {
- vec2f sib_accel;
+ vec2 sib_accel;
int visible = 1;
@@ -680,7 +686,7 @@ void RDirNode::applyForces(QuadTree & quadtree) {
visible++;
- sib_accel -= (node->getPos() - pos).normal();
+ sib_accel -= normalize(node->getPos() - pos);
}
//parent circumfrence divided by the number of visible child nodes
@@ -744,18 +750,18 @@ void RDirNode::updateSplinePoint(float dt) {
if(parent == 0) return;
//update the spline point
- vec2f td = (parent->getPos() - pos) * 0.5;
+ vec2 td = (parent->getPos() - pos) * 0.5f;
- vec2f mid = pos + td;// - td.perpendicular() * pos.normal();// * 10.0;
+ vec2 mid = pos + td;// - td.perpendicular() * pos.normal();// * 10.0;
- vec2f delta = (mid - spos);
+ vec2 delta = (mid - spos);
//dont let spos get more than half the length of the distance behind
- if(delta.length2() > td.length2()) {
- spos += delta.normal() * (delta.length() - td.length());
+ if(glm::length2(delta) > glm::length2(td)) {
+ spos += normalize(delta) * (glm::length(delta) - glm::length(td));
}
- spos += delta * std::min(1.0, dt * 2.0);
+ spos += delta * std::min(1.0f, dt * 2.0f);
}
void RDirNode::setInitialPosition() {
@@ -765,13 +771,15 @@ void RDirNode::setInitialPosition() {
//offset position by some pseudo-randomness
if(parentP != 0) {
- pos += ((parent->getPos() - parentP->getPos()).normal() * 2.0 + vec2Hash(abspath)).normal();
+ //pos += ((parent->getPos() - parentP->getPos()).normal() * 2.0 + vec2Hash(abspath)).normal();
+ pos += normalize(normalize(parent->getPos() - parentP->getPos()) * 2.0f + vec2Hash(abspath));
+
} else {
pos += vec2Hash(abspath);
}
-
+
//the spline point
- spos = pos - (parent->getPos() - pos) * 0.5;
+ spos = pos - (parent->getPos() - pos) * 0.5f;
position_initialized=true;
}
@@ -779,7 +787,7 @@ void RDirNode::move(float dt) {
//the root node is the centre of the world
if(parent == 0) {
- pos = vec2f(0.0, 0.0);
+ pos = vec2(0.0f);
return;
}
@@ -791,30 +799,30 @@ void RDirNode::move(float dt) {
pos += accel * dt;
if(gGourceSettings.elasticity>0.0) {
- vec2f diff = (accel - prev_accel);
+ vec2 diff = (accel - prev_accel);
float m = dt * gGourceSettings.elasticity;
- vec2f accel3 = prev_accel * (1.0-m) + diff * m;
+ vec2 accel3 = prev_accel * (1.0f-m) + diff * m;
pos += accel3;
prev_accel = accel3;
}
//accel = accel * std::max(0.0f, (1.0f - dt*10.0f));
- accel = vec2f(0.0, 0.0);
+ accel = vec2(0.0, 0.0);
}
-const vec2f & RDirNode::getNodeNormal() const{
+const vec2 & RDirNode::getNodeNormal() const{
return node_normal;
}
-vec2f RDirNode::calcFileDest(int max_files, int file_no) {
+vec2 RDirNode::calcFileDest(int max_files, int file_no) {
float arc = 1.0/(float)max_files;
float frac = arc * 0.5 + arc * file_no;
- vec2f dest = vec2f(sinf(frac*PI*2.0), cosf(frac*PI*2.0));
+ vec2 dest = vec2(sinf(frac*PI*2.0), cosf(frac*PI*2.0));
return dest;
}
@@ -832,12 +840,12 @@ void RDirNode::updateFilePositions() {
RFile* f = *it;
if(f->isHidden()) {
- f->setDest(vec2f(0.0,0.0));
+ f->setDest(vec2(0.0,0.0));
f->setDistance(0.0f);
continue;
}
- vec2f dest = calcFileDest(max_files, file_no);
+ vec2 dest = calcFileDest(max_files, file_no);
f->setDest(dest);
f->setDistance(d);
@@ -880,7 +888,7 @@ void RDirNode::logic(float dt) {
//update node normal
if(parent != 0) {
- node_normal = (pos - parent->getPos()).normal();
+ node_normal = normalize(pos - parent->getPos());
}
//update files
@@ -915,7 +923,7 @@ void RDirNode::drawDirName(FXFont& dirfont) const{
float alpha = gGourceSettings.highlight_dirs ? 1.0 : std::max(0.0f, 5.0f - since_last_node_change) / 5.0f;
- vec2f mid = spline.getMidPoint();
+ vec2 mid = spline.getMidPoint();
dirfont.setAlpha(alpha);
dirfont.draw(mid.x, mid.y, path_token);
@@ -935,8 +943,8 @@ void RDirNode::calcScreenPos(GLint* viewport, GLdouble* modelview, GLdouble* pro
projected_spos.x = screen_x;
projected_spos.y = screen_y;
- static vec2f selected_offset(5.5f, -2.0f);
- static vec2f unselected_offset(5.5f, -1.0f);
+ static vec2 selected_offset(5.5f, -2.0f);
+ static vec2 unselected_offset(5.5f, -1.0f);
if(!gGourceSettings.hide_filenames) {
@@ -1019,10 +1027,10 @@ void RDirNode::updateFilesVBO(quadbuf& buffer, float dt) const{
if(f->isHidden()) continue;
- vec3f col = f->getColour();
+ vec3 col = f->getColour();
float alpha = f->getAlpha();
- buffer.add(f->graphic->textureid, f->getAbsolutePos() - f->dims*0.5f, f->dims, vec4f(col.x, col.y, col.z, alpha));
+ buffer.add(f->graphic->textureid, f->getAbsolutePos() - f->dims*0.5f, f->dims, vec4(col.x, col.y, col.z, alpha));
}
}
@@ -1038,13 +1046,13 @@ void RDirNode::updateBloomVBO(bloombuf& buffer, float dt) {
float bloom_radius = dir_radius * 2.0 * gGourceSettings.bloom_multiplier;
float bloom_diameter = bloom_radius * 2.0;
- vec4f bloom_col = col * gGourceSettings.bloom_intensity;
+ vec4 bloom_col = col * gGourceSettings.bloom_intensity;
- vec4f bloom_texcoords(bloom_radius, pos.x, pos.y, 0.0f);
+ vec4 bloom_texcoords(bloom_radius, pos.x, pos.y, 0.0f);
- vec2f bloom_dims(bloom_diameter, bloom_diameter);
+ vec2 bloom_dims(bloom_diameter, bloom_diameter);
- buffer.add(0, pos - bloom_dims*0.5f,bloom_dims, vec4f(bloom_col.x, bloom_col.y, bloom_col.z, 1.0f), bloom_texcoords);
+ buffer.add(0, pos - bloom_dims*0.5f,bloom_dims, vec4(bloom_col.x, bloom_col.y, bloom_col.z, 1.0f), bloom_texcoords);
}
for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
@@ -1057,7 +1065,7 @@ void RDirNode::drawFiles(float dt) const{
if(in_frustum) {
- vec4f col = getColour();
+ vec4 col = getColour();
glPushMatrix();
glTranslatef(pos.x, pos.y, 0.0);
@@ -1080,11 +1088,11 @@ void RDirNode::drawFiles(float dt) const{
}
}
-const vec2f & RDirNode::getSPos() const{
+const vec2 & RDirNode::getSPos() const{
return projected_spos;
}
-const vec2f & RDirNode::getProjectedPos() const{
+const vec2 & RDirNode::getProjectedPos() const{
return projected_pos;
}
@@ -1135,7 +1143,7 @@ void RDirNode::drawBloom(float dt){
float bloom_radius = dir_radius * 2.0 * gGourceSettings.bloom_multiplier;
- vec4f bloom_col = col * gGourceSettings.bloom_intensity;
+ vec4 bloom_col = col * gGourceSettings.bloom_intensity;
glColor4f(bloom_col.x, bloom_col.y, bloom_col.z, 1.0);
@@ -1164,7 +1172,7 @@ void RDirNode::drawBloom(float dt){
void RDirNode::updateQuadItemBounds() {
float radius = getRadius();
- vec2f radoffset(radius, radius);
+ vec2 radoffset(radius, radius);
//set bounds
quadItemBounds.set(pos - radoffset, pos + radoffset);
View
34 src/dirnode.h
@@ -47,16 +47,16 @@ class RDirNode : public QuadItem {
SplineEdge spline;
- vec4f col;
+ vec4 col;
- vec2f spos;
+ vec2 spos;
- vec2f projected_pos;
- vec2f projected_spos;
+ vec2 projected_pos;
+ vec2 projected_spos;
- vec2f pos;
- vec2f vel;
- vec2f accel, prev_accel;
+ vec2 pos;
+ vec2 vel;
+ vec2 accel, prev_accel;
float dir_area;
@@ -77,8 +77,8 @@ class RDirNode : public QuadItem {
int visible_count;
- vec3f screenpos;
- vec2f node_normal;
+ vec3 screenpos;
+ vec2 node_normal;
void calcRadius();
void calcColour();
@@ -93,7 +93,7 @@ class RDirNode : public QuadItem {
void updateSplinePoint(float dt);
void move(float dt);
- vec2f calcFileDest(int layer_no, int file_no);
+ vec2 calcFileDest(int layer_no, int file_no);
void updateFilePositions();
void adjustPath();
@@ -133,7 +133,7 @@ class RDirNode : public QuadItem {
const std::string & getPath() const;
- const vec2f & getNodeNormal() const;
+ const vec2 & getNodeNormal() const;
bool isParent(RDirNode* node) const;
@@ -153,23 +153,23 @@ class RDirNode : public QuadItem {
const std::list<RFile*>* getFiles() const { return &files; };
void getFilesRecursive(std::list<RFile*>& files) const;
- vec3f averageFileColour() const;
+ vec3 averageFileColour() const;
- const vec4f & getColour() const;
+ const vec4 & getColour() const;
RDirNode* getParent() const;
bool isDir(const std::string& path) const;
void findDirs(const std::string& path, std::list<RDirNode*>& dirs);
- const vec2f & getPos() const;
+ const vec2 & getPos() const;
void calcEdges();
- const vec2f & getProjectedPos() const;
- const vec2f & getSPos() const;
+ const vec2 & getProjectedPos() const;
+ const vec2 & getSPos() const;
- void setPos(const vec2f & pos);
+ void setPos(const vec2 & pos);
void rotate(float s, float c);
View
44 src/file.cpp
@@ -24,7 +24,7 @@ std::vector<RFile*> gGourceRemovedFiles;
FXFont file_selected_font;
FXFont file_font;
-RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos, int tagid) : Pawn(name,pos,tagid) {
+RFile::RFile(const std::string & name, const vec3 & colour, const vec2 & pos, int tagid) : Pawn(name,pos,tagid) {
hidden = true;
size = gGourceFileDiameter * 1.05;
radius = size * 0.5;
@@ -35,7 +35,7 @@ RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos,
nametime = 4.0;
name_interval = nametime;
- namecol = vec3f(1.0, 1.0, 1.0);
+ namecol = vec3(1.0, 1.0, 1.0);
file_colour = colour;
last_action = 0.0;
@@ -52,14 +52,14 @@ RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos,
file_selected_font = fontmanager.grab("FreeSans.ttf", 18);
file_selected_font.dropShadow(true);
file_selected_font.roundCoordinates(false);
- file_selected_font.setColour(vec4f(1.0f, 1.0f, 0.0f, 1.0f));
+ file_selected_font.setColour(vec4(1.0f, 1.0f, 0.0f, 1.0f));
}
if(!file_font.initialized()) {
file_font = fontmanager.grab("FreeSans.ttf", 14);
file_font.dropShadow(true);
file_font.roundCoordinates(false);
- file_font.setColour(vec4f(1.0f, 1.0f, 1.0f, 1.0f));
+ file_font.setColour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
}
//namelist = glGenLists(1);
@@ -86,16 +86,16 @@ RDirNode* RFile::getDir() const{
return dir;
}
-vec2f RFile::getAbsolutePos() const{
+vec2 RFile::getAbsolutePos() const{
return pos + dir->getPos();
}
-bool RFile::overlaps(const vec2f& pos) const {
+bool RFile::overlaps(const vec2& pos) const {
- vec2f abs_pos = getAbsolutePos();
+ vec2 abs_pos = getAbsolutePos();
float halfsize_x = size * 0.5f;
- vec2f halfsize ( halfsize_x, halfsize_x * graphic_ratio );
+ vec2 halfsize ( halfsize_x, halfsize_x * graphic_ratio );
Bounds2D file_bounds(abs_pos - halfsize, abs_pos + halfsize);
@@ -154,24 +154,24 @@ void RFile::updateLabel() {
}
void RFile::colourize() {
- file_colour = ext.size() ? colourHash(ext) : vec3f(1.0f, 1.0f, 1.0f);
+ file_colour = ext.size() ? colourHash(ext) : vec3(1.0f, 1.0f, 1.0f);
}
-const vec3f& RFile::getNameColour() const{
+const vec3& RFile::getNameColour() const{
return selected ? selectedcol : namecol;
}
-const vec3f & RFile::getFileColour() const{
+const vec3 & RFile::getFileColour() const{
return file_colour;
}
-vec3f RFile::getColour() const{
- if(selected) return vec3f(1.0, 1.0, 1.0);
+vec3 RFile::getColour() const{
+ if(selected) return vec3(1.0f);
float lc = elapsed - last_action;
- if(lc<1.0) {
- return touch_colour * (1.0-lc) + file_colour * lc;
+ if(lc<1.0f) {
+ return touch_colour * (1.0f-lc) + file_colour * lc;
}
return file_colour;
@@ -191,10 +191,10 @@ float RFile::getAlpha() const{
void RFile::logic(float dt) {
Pawn::logic(dt);
- vec2f dest_pos = dest;
+ vec2 dest_pos = dest;
/*
if(dir->getParent() != 0 && dir->noDirs()) {
- vec2f dirnorm = dir->getNodeNormal();
+ vec2 dirnorm = dir->getNodeNormal();
dest_pos = dirnorm + dest;
}*/
@@ -205,16 +205,16 @@ void RFile::logic(float dt) {
accel = dest_pos - pos;
// apply accel
- vec2f accel2 = accel * speed * dt;
+ vec2 accel2 = accel * speed * dt;
- if(accel2.length2() > accel.length2()) {
+ if(glm::length2(accel2) > glm::length2(accel)) {
accel2 = accel;
}
pos += accel2;
//files have no momentum
- accel = vec2f(0.0f, 0.0f);
+ accel = vec2(0.0f, 0.0f);
// has completely faded out
if(!expiring && elapsed - last_action >= gGourceSettings.file_idle_time + 1.0) {
@@ -239,7 +239,7 @@ void RFile::logic(float dt) {
if(isHidden() && !removing) elapsed = 0.0;
}
-void RFile::touch(const vec3f & colour) {
+void RFile::touch(const vec3 & colour) {
if(removing) return;
//fprintf(stderr, "touch %s\n", fullpath.c_str());
@@ -276,7 +276,7 @@ void RFile::calcScreenPos(GLint* viewport, GLdouble* modelview, GLdouble* projec
static GLdouble screen_x, screen_y, screen_z;
- vec2f text_pos = getAbsolutePos();
+ vec2 text_pos = getAbsolutePos();
text_pos.x += 5.5f;
if(selected)
View
25 src/file.h
@@ -18,16 +18,15 @@
#ifndef RFILE_H
#define RFILE_H
-#include "core/stringhash.h"
-
#include "pawn.h"
#include "dirnode.h"
+#include "core/stringhash.h"
class RDirNode;
class RFile : public Pawn {
- vec3f file_colour;
- vec3f touch_colour;
+ vec3 file_colour;
+ vec3 touch_colour;
RDirNode* dir;
@@ -38,7 +37,7 @@ class RFile : public Pawn {
float radius;
- vec2f dest;
+ vec2 dest;
float distance;
// FXLabel* label;
@@ -47,28 +46,28 @@ class RFile : public Pawn {
void setFilename(const std::string& abs_file_path);
- const vec3f& getNameColour() const;
+ const vec3& getNameColour() const;
void drawNameText(float alpha);
public:
std::string path;
std::string fullpath;
std::string ext;
- RFile(const std::string & name, const vec3f & colour, const vec2f & pos, int tagid);
+ RFile(const std::string & name, const vec3 & colour, const vec2 & pos, int tagid);
~RFile();
bool isExpiring() const { return expiring; }
bool isRemoving() const { return removing; }
- bool overlaps(const vec2f& pos) const;
+ bool overlaps(const vec2& pos) const;
- const vec3f & getFileColour() const;
- vec3f getColour() const;
+ const vec3 & getFileColour() const;
+ vec3 getColour() const;
void colourize();
float getAlpha() const;
- void touch(const vec3f & colour);
+ void touch(const vec3 & colour);
void setSelected(bool selected);
@@ -76,7 +75,7 @@ class RFile : public Pawn {
void setHidden(bool hidden);
- void setDest(const vec2f & dest){ this->dest = dest; }
+ void setDest(const vec2 & dest){ this->dest = dest; }
void setDistance(float distance){ this->distance = distance; }
void calcScreenPos(GLint* viewport, GLdouble* modelview, GLdouble* projection);
@@ -86,7 +85,7 @@ class RFile : public Pawn {
void remove(bool force=false);
- vec2f getAbsolutePos() const;
+ vec2 getAbsolutePos() const;
RDirNode* getDir() const;
void setDir(RDirNode* dir);
View
75 src/gource.cpp
@@ -24,7 +24,7 @@ int gGourceMaxQuadTreeDepth = 6;
int gGourceUserInnerLoops = 0;
Gource::Gource(FrameExporter* exporter) {
-
+
this->logfile = gGourceSettings.path;
commitlog = 0;
@@ -32,7 +32,7 @@ Gource::Gource(FrameExporter* exporter) {
if(!GLEW_VERSION_2_0) gGourceSettings.ffp = true;
if(!gGourceSettings.file_graphic) {
- gGourceSettings.file_graphic = texturemanager.grab("file.png", true, true, true);
+ gGourceSettings.file_graphic = texturemanager.grab("file.png", true, GL_CLAMP_TO_EDGE);
}
fontlarge = fontmanager.grab("FreeSans.ttf", 42);
@@ -52,7 +52,7 @@ Gource::Gource(FrameExporter* exporter) {
bloomtex = texturemanager.grab(bloom_tga);
beamtex = texturemanager.grab("beam.png");
- usertex = texturemanager.grab("user.png", true, true, true);
+ usertex = texturemanager.grab("user.png", true, GL_CLAMP_TO_EDGE);
shadow_shader = text_shader = bloom_shader = 0;
@@ -121,7 +121,7 @@ Gource::Gource(FrameExporter* exporter) {
file_key = FileKey(1.0f);
- camera = ZoomCamera(vec3f(0,0, -300), vec3f(0.0, 0.0, 0.0), gGourceSettings.camera_zoom_default, gGourceSettings.camera_zoom_max);
+ camera = ZoomCamera(vec3(0,0, -300), vec3(0.0, 0.0, 0.0), gGourceSettings.camera_zoom_default, gGourceSettings.camera_zoom_max);
camera.setPadding(gGourceSettings.padding);
setCameraMode(gGourceSettings.camera_mode);
@@ -370,6 +370,13 @@ Gource::~Gource() {
void Gource::init() {
}
+void Gource::unload() {
+}
+
+void Gource::reload() {
+ slider.resize();
+}
+
void Gource::update(float t, float dt) {
float scaled_dt = std::min(dt, max_tick_rate);
@@ -449,7 +456,7 @@ void Gource::mouseMove(SDL_MouseMotionEvent *e) {
//move camera in direction the user dragged the mouse
if(mousedragged || rightmouse) {
- vec2f mag( e->xrel, e->yrel );
+ vec2 mag( e->xrel, e->yrel );
//if right mouse button is held while dragging, rotate tree instead of
//moving camera
@@ -474,7 +481,7 @@ void Gource::mouseMove(SDL_MouseMotionEvent *e) {
if(grab_mouse) return;
- mousepos = vec2f(e->x, e->y);
+ mousepos = vec2(e->x, e->y);
mousemoved=true;
cursor.updatePos(mousepos);
@@ -561,7 +568,7 @@ void Gource::mouseClick(SDL_MouseButtonEvent *e) {
if(e->button == SDL_BUTTON_LEFT) {
- //mousepos = vec2f(e->x, e->y);
+ //mousepos = vec2(e->x, e->y);
mouseclicked=true;
if(canSeek()) {
@@ -953,7 +960,7 @@ void Gource::reset() {
message_timer = 0.0f;
- cursor_move = vec2f(0.0f, 0.0f);
+ cursor_move = vec2(0.0f, 0.0f);
selectedUser = 0;
hoverUser = 0;
@@ -1041,7 +1048,7 @@ RFile* Gource::addFile(const RCommitFile& cf) {
int tagid = tag_seq++;
- RFile* file = new RFile(cf.filename, cf.colour, vec2f(0.0,0.0), tagid);
+ RFile* file = new RFile(cf.filename, cf.colour, vec2(0.0,0.0), tagid);
files[cf.filename] = file;
tagfilemap[tagid] = file;
@@ -1060,12 +1067,12 @@ RFile* Gource::addFile(const RCommitFile& cf) {
RUser* Gource::addUser(const std::string& username) {
- vec2f pos;
+ vec2 pos;
if(dir_bounds.area() > 0) {
pos = dir_bounds.centre();
} else {
- pos = vec2f(0,0);
+ pos = vec2(0,0);
}
int tagid = tag_seq++;
@@ -1296,8 +1303,8 @@ void Gource::interactUsers() {
// update quad tree
Bounds2D quadtreebounds = user_bounds;
- quadtreebounds.min -= vec2f(1.0f, 1.0f);
- quadtreebounds.max += vec2f(1.0f, 1.0f);
+ quadtreebounds.min -= vec2(1.0f, 1.0f);
+ quadtreebounds.max += vec2(1.0f, 1.0f);
update_user_tree_time = SDL_GetTicks();
@@ -1421,8 +1428,8 @@ void Gource::interactDirs() {
// update quad tree
Bounds2D quadtreebounds = dir_bounds;
- quadtreebounds.min -= vec2f(1.0f, 1.0f);
- quadtreebounds.max += vec2f(1.0f, 1.0f);
+ quadtreebounds.min -= vec2(1.0f, 1.0f);
+ quadtreebounds.max += vec2(1.0f, 1.0f);
update_dir_tree_time = SDL_GetTicks();
@@ -1483,13 +1490,13 @@ void Gource::updateCamera(float dt) {
if(manual_camera) {
- if(cursor_move.length2() > 0.0f) {
+ if(glm::length2(cursor_move) > 0.0f) {
float cam_rate = ( -camera.getPos().z ) / ( 5000.0f );
- vec3f cam_pos = camera.getPos();
+ vec3 cam_pos = camera.getPos();
- vec2f cursor_delta = cursor_move * cam_rate * 400.0f * dt;
+ vec2 cursor_delta = cursor_move * cam_rate * 400.0f * dt;
cam_pos.x += cursor_delta.x;
cam_pos.y += cursor_delta.y;
@@ -1499,7 +1506,7 @@ void Gource::updateCamera(float dt) {
auto_rotate = false;
- cursor_move = vec2f(0.0f, 0.0f);
+ cursor_move = vec2(0.0f, 0.0f);
}
} else {
@@ -1509,7 +1516,7 @@ void Gource::updateCamera(float dt) {
if(track_users && (selectedFile !=0 || selectedUser !=0)) {
Bounds2D focusbounds;
- vec3f camerapos = camera.getPos();
+ vec3 camerapos = camera.getPos();
if(selectedUser !=0) focusbounds.update(selectedUser->getPos());
if(selectedFile !=0) focusbounds.update(selectedFile->getAbsolutePos());
@@ -1642,9 +1649,9 @@ void Gource::logic(float t, float dt) {
for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) {
RUser* user = it->second;
- vec2f userpos = user->getPos();
+ vec2 userpos = user->getPos();
- user->setPos(userpos.rotate(s, c));
+ user->setPos(rotate_vec2(userpos, s, c));
}
rotate_angle = 0.0f;
@@ -1750,9 +1757,9 @@ void Gource::logic(float t, float dt) {
void Gource::mousetrace(float dt) {
- vec3f cam_pos = camera.getPos();
+ vec3 cam_pos = camera.getPos();
- vec2f projected_mouse = vec2f( -(mousepos.x * 2.0f - ((float)display.width)) / ((float)display.height),
+ vec2 projected_mouse = vec2( -(mousepos.x * 2.0f - ((float)display.width)) / ((float)display.height),
(1.0f - (2.0f * mousepos.y) / ((float)display.height)))
* cam_pos.z;
projected_mouse.x += cam_pos.x;
@@ -1878,7 +1885,7 @@ void Gource::loadingScreen() {
void Gource::drawBackground(float dt) {
if(!gGourceDrawBackground) return;
- display.setClearColour(vec4f(gGourceSettings.background_colour, gGourceSettings.transparent ? 0.0f : 1.0f));
+ display.setClearColour(vec4(gGourceSettings.background_colour, gGourceSettings.transparent ? 0.0f : 1.0f));
display.clear();
if(backgroundtex!=0) {
@@ -1998,7 +2005,7 @@ void Gource::updateAndDrawEdges() {
shadow_shader->use();
shadow_shader->setFloat("shadow_strength", 0.5);
- vec2f shadow_offset = vec2f(2.0, 2.0);
+ vec2 shadow_offset = vec2(2.0, 2.0);
glPushMatrix();
glTranslatef(shadow_offset.x, shadow_offset.y, 0.0f);
@@ -2141,9 +2148,9 @@ void Gource::updateVBOs(float dt) {
RUser* user = it->second;
float alpha = user->getAlpha();
- vec3f col = user->getColour();
+ vec3 col = user->getColour();
- user_vbo.add(user->graphic->textureid, user->getPos() - user->dims*0.5f, user->dims, vec4f(col.x, col.y, col.z, alpha));
+ user_vbo.add(user->graphic->textureid, user->getPos() - user->dims*0.5f, user->dims, vec4(col.x, col.y, col.z, alpha));
//draw actions
user->updateActionsVBO(action_vbo);
@@ -2203,7 +2210,7 @@ void Gource::drawUserShadows(float dt) {
shadow_shader->use();
shadow_shader->setFloat("shadow_strength", 0.5);
- vec2f shadow_offset = vec2f(2.0, 2.0) * gGourceSettings.user_scale;
+ vec2 shadow_offset = vec2(2.0, 2.0) * gGourceSettings.user_scale;
glPushMatrix();
glTranslatef(shadow_offset.x, shadow_offset.y, 0.0f);
@@ -2279,7 +2286,7 @@ void Gource::draw(float t, float dt) {
return;
}
- Frustum frustum(camera);
+ Frustum frustum(camera.getPos(), camera.getTarget(), camera.getUp(), camera.getFOV(), camera.getZNear(), camera.getZFar());
trace_time = SDL_GetTicks();
@@ -2446,7 +2453,7 @@ void Gource::draw(float t, float dt) {
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
- vec3f campos = camera.getPos();
+ vec3 campos = camera.getPos();
if(logotex!=0) {
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -2457,7 +2464,7 @@ void Gource::draw(float t, float dt) {
glBindTexture(GL_TEXTURE_2D, logotex->textureid);
- vec2f logopos = vec2f(display.width, display.height) - vec2f(logotex->w, logotex->h) - gGourceSettings.logo_offset;
+ vec2 logopos = vec2(display.width, display.height) - vec2(logotex->w, logotex->h) - gGourceSettings.logo_offset;
glPushMatrix();
@@ -2488,7 +2495,7 @@ void Gource::draw(float t, float dt) {
int cwidth = font.getWidth("Software Version Control Visualization");
int awidth = font.getWidth("(C) 2009 Andrew Caudwell");
- vec2f corner(display.width/2 - logowidth/2 - 30.0f, display.height/2 - 40);
+ vec2 corner(display.width/2 - logowidth/2 - 30.0f, display.height/2 - 40);
glDisable(GL_TEXTURE_2D);
glColor4f(0.0f, 0.5f, 1.0f, splash * 0.015f);
@@ -2509,7 +2516,7 @@ void Gource::draw(float t, float dt) {
// text using the specified font goes here
- fontmedium.setColour(vec4f(gGourceSettings.font_colour, 1.0f));
+ fontmedium.setColour(vec4(gGourceSettings.font_colour, 1.0f));
if(!gGourceSettings.hide_date) {
fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate);
View
10 src/gource.h
@@ -86,18 +86,18 @@ class Gource : public SDLApp {
bool mouseclicked;
bool mousedragged;
- vec2f cursor_move;
+ vec2 cursor_move;
bool recolour;
bool update_file_labels;
-
+
bool use_selection_bounds;
Bounds2D selection_bounds;
float rotate_angle;
- vec2f mousepos;
+ vec2 mousepos;
float last_percent;
@@ -279,6 +279,10 @@ class Gource : public SDLApp {
void draw(float t, float dt);
void init();
+
+ void unload();
+ void reload();
+
void update(float t, float dt);
void keyPress(SDL_KeyboardEvent *e);
void mouseMove(SDL_MouseMotionEvent *e);
View
16 src/gource_settings.cpp
@@ -304,7 +304,7 @@ void GourceSettings::setGourceDefaults() {
loop = false;
logo = "";
- logo_offset = vec2f(20.0f,20.0f);
+ logo_offset = vec2(20.0f,20.0f);
colour_user_images = false;
default_user_image = "";
@@ -324,14 +324,14 @@ void GourceSettings::setGourceDefaults() {
bloom_multiplier = 1.0f;
bloom_intensity = 0.75f;
- background_colour = vec3f(0.1f, 0.1f, 0.1f);
+ background_colour = vec3(0.1f, 0.1f, 0.1f);
background_image = "";
title = "";
font_size = 16;
- font_colour = vec3f(1.0f, 1.0f, 1.0f);
- highlight_colour = vec3f(1.0f, 1.0f, 0.3f);
+ font_colour = vec3(1.0f, 1.0f, 1.0f);
+ highlight_colour = vec3(1.0f, 1.0f, 0.3f);
elasticity = 0.0f;
@@ -722,7 +722,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if(entry->isVec3()) {
font_colour = entry->getVec3();
} else if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
- font_colour = vec3f(r,g,b);
+ font_colour = vec3(r,g,b);
font_colour /= 255.0f;
} else {
conffile.invalidValueException(entry);
@@ -740,7 +740,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if(entry->isVec3()) {
background_colour = entry->getVec3();
} else if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
- background_colour = vec3f(r,g,b);
+ background_colour = vec3(r,g,b);
background_colour /= 255.0f;
} else {
conffile.invalidValueException(entry);
@@ -758,7 +758,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if(entry->isVec3()) {
highlight_colour = entry->getVec3();
} else if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
- highlight_colour = vec3f(r,g,b);
+ highlight_colour = vec3(r,g,b);
highlight_colour /= 255.0f;
} else {
conffile.invalidValueException(entry);
@@ -796,7 +796,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
int posy = 0;
if(parseRectangle(logo_offset_str, &posx, &posy)) {
- logo_offset = vec2f(posx, posy);
+ logo_offset = vec2(posx, posy);
} else {
conffile.invalidValueException(entry);
}
View
8 src/gource_settings.h
@@ -59,7 +59,7 @@ class GourceSettings : public SDLAppSettings {
std::string path;
std::string logo;
- vec2f logo_offset;
+ vec2 logo_offset;
float start_position;
float stop_position;
@@ -95,13 +95,13 @@ class GourceSettings : public SDLAppSettings {
float bloom_multiplier;
float bloom_intensity;
- vec3f background_colour;
+ vec3 background_colour;
std::string background_image;
std::string title;
int font_size;
- vec3f font_colour;
+ vec3 font_colour;
float elasticity;
@@ -121,7 +121,7 @@ class GourceSettings : public SDLAppSettings {
bool highlight_dirs;
bool highlight_all_users;
- vec3f highlight_colour;
+ vec3 highlight_colour;
std::vector<std::string> highlight_users;
std::vector<std::string> follow_users;
View
64 src/gource_shell.cpp
@@ -24,6 +24,8 @@ GourceShell::GourceShell(ConfFile* conf, FrameExporter* exporter) {
this->conf = conf;
this->exporter = exporter;
+ min_delta_msec = 16;
+
next = false;
gource = 0;
@@ -35,15 +37,45 @@ GourceShell::GourceShell(ConfFile* conf, FrameExporter* exporter) {
transition_interval = 0.0f;
if(strstr((const char *)glGetString(GL_EXTENSIONS), "GL_ARB_texture_non_power_of_two" )) {
- transition_texture = display.emptyTexture(display.width, display.height, GL_RGBA);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ transition_texture = texturemanager.create(display.width, display.height, false, GL_CLAMP_TO_EDGE, GL_RGBA);
}
}
GourceShell::~GourceShell() {
if(gource!=0) delete gource;
- if(transition_texture!=0) glDeleteTextures(1, &transition_texture);
+ if(transition_texture!=0) texturemanager.release(transition_texture);
+}
+
+void GourceShell::toggleFullscreen() {
+ // texturemanager.unload();
+ // shadermanager.unload();
+
+ if(gource!=0) gource->unload();
+
+ //recreate gl context
+ display.toggleFullscreen();
+
+ // texturemanager.reload();
+ // shadermanager.reload();
+
+ if(gource!=0) gource->reload();
+}
+
+void GourceShell::resize(SDL_ResizeEvent* e) {
+
+ // texturemanager.unload();
+ // shadermanager.unload();
+
+ if(gource!=0) gource->unload();
+
+ //recreate gl context
+ display.resize(e->w, e->h);
+
+ // texturemanager.reload();
+ // shadermanager.reload();
+
+ if(gource!=0) gource->reload();
}
void GourceShell::keyPress(SDL_KeyboardEvent *e) {
@@ -53,12 +85,18 @@ void GourceShell::keyPress(SDL_KeyboardEvent *e) {
if (e->keysym.unicode == SDLK_ESCAPE) {
appFinished=true;
}
-
- if (e->keysym.unicode == SDLK_RETURN) {
- if(gGourceSettings.repo_count>1)
- next = true;
+
+ if(e->keysym.unicode == SDLK_RETURN) {
+ Uint8* keyState = SDL_GetKeyState(NULL);
+ if(keyState[SDLK_RALT] || keyState[SDLK_LALT]) {
+
+ toggleFullscreen();
+
+ } else {
+ if(gGourceSettings.repo_count>1)
+ next = true;
+ }
}
-
}
if(gource!=0) gource->keyPress(e);
@@ -128,7 +166,7 @@ void GourceShell::blendLastFrame(float dt) {
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, transition_texture);
+ transition_texture->bind();
glColor4f(1.0, 1.0, 1.0, transition_interval);
@@ -163,7 +201,11 @@ void GourceShell::update(float t, float dt) {
//copy last frame
if( (next|| gource->isFinished()) && transition_texture!=0) {
- display.renderToTexture(transition_texture, display.width, display.height, GL_RGBA);
+
+ glEnable(GL_TEXTURE_2D);
+ transition_texture->bind();
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, display.width, display.height, 0);
+
} else {
//blend last frame of previous scene
blendLastFrame(dt);
View
5 src/gource_shell.h
@@ -28,7 +28,7 @@ class GourceShell : public SDLApp {
bool next;
- GLuint transition_texture;
+ TextureResource* transition_texture;
float transition_interval;
FrameExporter* exporter;
@@ -43,6 +43,9 @@ class GourceShell : public SDLApp {
void update(float t, float dt);
+ void resize(SDL_ResizeEvent* e);
+ void toggleFullscreen();
+
void keyPress(SDL_KeyboardEvent *e);
void mouseMove(SDL_MouseMotionEvent *e);
void mouseClick(SDL_MouseButtonEvent *e);
View
12 src/key.cpp
@@ -4,7 +4,7 @@
// File Key Entry
// a string for the file ext and a colour
-FileKeyEntry::FileKeyEntry(const FXFont& font, const std::string& ext, const vec3f& colour) {
+FileKeyEntry::FileKeyEntry(const FXFont& font, const std::string& ext, const vec3& colour) {
this->ext = ext;
this->colour = colour;
this->pos_y = -1.0f;
@@ -12,7 +12,7 @@ FileKeyEntry::FileKeyEntry(const FXFont& font, const std::string& ext, const vec
this->font = font;
this->font.dropShadow(false);
- shadow = vec2f(3.0, 3.0);
+ shadow = vec2(3.0, 3.0);
width = 90.0f;
height = 18.0f;
@@ -41,7 +41,7 @@ FileKeyEntry::FileKeyEntry(const FXFont& font, const std::string& ext, const vec
}
}
-const vec3f& FileKeyEntry::getColour() const {
+const vec3& FileKeyEntry::getColour() const {
return colour;
}
@@ -58,7 +58,7 @@ bool FileKeyEntry::isFinished() const {
}
void FileKeyEntry::colourize() {
- colour = ext.empty() ? vec3f(1.0f, 1.0f, 1.0f) : colourHash(ext);
+ colour = ext.empty() ? vec3(1.0f, 1.0f, 1.0f) : colourHash(ext);
}
void FileKeyEntry::inc() {
@@ -107,7 +107,7 @@ void FileKeyEntry::logic(float dt) {
}
}
- pos = vec2f(alpha * left_margin, pos_y);
+ pos = vec2(alpha * left_margin, pos_y);
}
void FileKeyEntry::draw() {
@@ -142,7 +142,7 @@ void FileKeyEntry::draw() {
glEnable(GL_TEXTURE_2D);
- font.setColour(vec4f(1.0f, 1.0f, 1.0f, alpha));
+ font.setColour(vec4(1.0f, 1.0f, 1.0f, alpha));
font.dropShadow(false);
font.draw((int)pos.x+2, (int)pos.y+3, display_ext.c_str());
View
10 src/key.h
@@ -29,7 +29,7 @@
class FileKeyEntry {
FXFont font;
- vec3f colour;
+ vec3 colour;
std::string ext;
std::string display_ext;
float alpha;
@@ -42,13 +42,13 @@ class FileKeyEntry {
float left_margin;
float width;
float height;
- vec2f pos;
- vec2f shadow;
+ vec2 pos;
+ vec2 shadow;
bool show;
public:
- FileKeyEntry(const FXFont& font, const std::string& ext, const vec3f& colour);
+ FileKeyEntry(const FXFont& font, const std::string& ext, const vec3& colour);
- const vec3f& getColour() const;
+ const vec3& getColour() const;
const std::string& getExt() const;
void setDestY(float dest_y);
View
2  src/main.cpp
@@ -119,6 +119,8 @@ int main(int argc, char *argv[]) {
//enable vsync
display.enableVsync(gGourceSettings.vsync);
+ display.enableResize(true);
+
try {
display.init("Gource", gGourceSettings.display_width, gGourceSettings.display_height, gGourceSettings.fullscreen);
View
24 src/pawn.cpp
@@ -19,7 +19,7 @@
float gGourceShadowStrength = 0.5;
-Pawn::Pawn(const std::string& name, vec2f pos, int tagid) {
+Pawn::Pawn(const std::string& name, vec2 pos, int tagid) {
this->name = name;
this->pos = pos;
this->tagid = tagid;
@@ -33,12 +33,12 @@ Pawn::Pawn(const std::string& name, vec2f pos, int tagid) {
namewidth = 0;
- this->shadowOffset = vec2f(2.0, 2.0);
+ this->shadowOffset = vec2(2.0, 2.0);
this->elapsed = 0.0;
this->fadetime = 1.0;
this->nametime = 5.0;
this->name_interval = 0.0;
- this->namecol = vec3f(1.0, 1.0, 1.0);
+ this->namecol = vec3(1.0, 1.0, 1.0);
this->selectedcol = gGourceSettings.highlight_colour;
@@ -50,7 +50,7 @@ float Pawn::getSize() {
return size;
}
-void Pawn::setPos(vec2f pos) {
+void Pawn::setPos(vec2 pos) {
this->pos = pos;
}
@@ -66,7 +66,7 @@ void Pawn::updateQuadItemBounds() {
float halfsize_x = size * 0.5f;
- vec2f halfsize ( halfsize_x, halfsize_x * graphic_ratio );
+ vec2 halfsize ( halfsize_x, halfsize_x * graphic_ratio );
//set bounds
quadItemBounds.set(pos - halfsize, pos + halfsize);
@@ -89,7 +89,7 @@ void Pawn::setGraphic(TextureResource* graphic) {
}
this->graphic = graphic;
- this->dims = vec2f(size, size*graphic_ratio);
+ this->dims = vec2(size, size*graphic_ratio);
}
@@ -102,12 +102,12 @@ void Pawn::setSelected(bool selected) {
this->selected = selected;
}
-const vec3f& Pawn::getNameColour() const {
+const vec3& Pawn::getNameColour() const {
return namecol;
}
-void Pawn::calcScreenPos(const vec2f& offset) {
- screenpos = display.project(vec3f(pos.x+offset.x, pos.y+offset.y, 0.0f));
+void Pawn::calcScreenPos(const vec2& offset) {
+ screenpos = display.project(vec3(pos.x+offset.x, pos.y+offset.y, 0.0f));
}
bool Pawn::nameVisible() const {
@@ -132,7 +132,7 @@ void Pawn::drawShadow(float dt) {
if(isHidden() || !shadow) return;
float halfsize = size * 0.5f;
- vec2f offsetpos = pos - vec2f(halfsize, halfsize*graphic_ratio) + shadowOffset;
+ vec2 offsetpos = pos - vec2(halfsize, halfsize*graphic_ratio) + shadowOffset;
float alpha = getAlpha();
@@ -163,11 +163,11 @@ void Pawn::draw(float dt) {
if(hidden) return;
float halfsize = size * 0.5f;
- vec2f offsetpos = pos - vec2f(halfsize, halfsize*graphic_ratio);
+ vec2 offsetpos = pos - vec2(halfsize, halfsize*graphic_ratio);
float alpha = getAlpha();
- vec3f col = getColour();
+ vec3 col = getColour();
glBindTexture(GL_TEXTURE_2D, graphic->textureid);
View
26 src/pawn.h
@@ -29,12 +29,12 @@
class Pawn : public QuadItem {
protected:
- vec2f pos;
- vec2f shadowOffset;
+ vec2 pos;
+ vec2 shadowOffset;
std::string name;
float namewidth;
- vec2f accel;
+ vec2 accel;
float speed;
float elapsed;
@@ -42,8 +42,8 @@ class Pawn : public QuadItem {
float nametime;
float name_interval;
- vec3f namecol;
- vec3f selectedcol;
+ vec3 namecol;
+ vec3 selectedcol;
bool shadow;
@@ -58,21 +58,21 @@ class Pawn : public QuadItem {
virtual bool nameVisible() const;
virtual void drawNameText(float alpha) {};
- virtual const vec3f& getNameColour() const;
+ virtual const vec3& getNameColour() const;
protected:
bool selected;
public:
float size;
float graphic_ratio;
TextureResource* graphic;
- vec3f screenpos;
- vec2f dims;
+ vec3 screenpos;
+ vec2 dims;
- Pawn(const std::string& name, vec2f pos, int tagid);
- const vec2f & getPos() const { return pos; }
- void setPos(vec2f pos);
+ Pawn(const std::string& name, vec2 pos, int tagid);
+ const vec2 & getPos() const { return pos; }
+ void setPos(vec2 pos);
- void calcScreenPos(const vec2f& offset);
+ void calcScreenPos(const vec2& offset);
void updateQuadItemBounds();
@@ -92,7 +92,7 @@ class Pawn : public QuadItem {
bool isHidden() const { return hidden; }
virtual float getAlpha() const{ return std::min(elapsed/fadetime, 1.0f); }
- virtual vec3f getColour() const { return vec3f(1.0, 1.0, 1.0); }
+ virtual vec3 getColour() const { return vec3(1.0, 1.0, 1.0); }
void setGraphic(TextureResource* graphic);
View
23 src/slider.cpp
@@ -25,21 +25,26 @@ PositionSlider::PositionSlider(float percent) {
font = fontmanager.grab("FreeSans.ttf", 16);
font.dropShadow(true);
- int gap = display.width / 30;
-
- bounds.update(vec2f(gap, display.height - gap*2));
- bounds.update(vec2f(display.width - gap, display.height - gap));
-
- slidercol = vec3f(1.0, 1.0, 1.0);
+ slidercol = vec3(1.0, 1.0, 1.0);
mouseover = -1.0;
mouseover_elapsed = 1.0;
fade_time = 1.0;
alpha = 0.0;
+
+ resize();
+}
+
+void PositionSlider::resize() {
+ int gap = display.width / 30;
+
+ bounds.reset();
+ bounds.update(vec2(gap, display.height - gap*2));
+ bounds.update(vec2(display.width - gap, display.height - gap));
}
-void PositionSlider::setColour(vec3f col) {
+void PositionSlider::setColour(vec3 col) {
slidercol = col;
}
@@ -47,7 +52,7 @@ void PositionSlider::show() {
mouseover_elapsed = 0.0;
}
-bool PositionSlider::mouseOver(vec2f pos, float* percent_ptr) {
+bool PositionSlider::mouseOver(vec2 pos, float* percent_ptr) {
if(bounds.contains(pos)) {
mouseover_elapsed = 0;
@@ -65,7 +70,7 @@ bool PositionSlider::mouseOver(vec2f pos, float* percent_ptr) {
return false;
}
-bool PositionSlider::click(vec2f pos, float* percent_ptr) {
+bool PositionSlider::click(vec2 pos, float* percent_ptr) {
if(mouseOver(pos, &percent)) {
if(percent_ptr != 0) {
View
10 src/slider.h
@@ -33,23 +33,25 @@ class PositionSlider {
float fade_time;
float alpha;
- vec3f slidercol;
+ vec3 slidercol;
float capwidth;
std::string caption;
public:
PositionSlider(float percent = 0.0f);
- void setColour(vec3f col);
+ void setColour(vec3 col);
void setCaption(const std::string& cap);
void setPercent(float percent);
+ void resize();
+
void show();
- bool mouseOver(vec2f pos, float* percent_ptr);
- bool click(vec2f pos, float* percent_ptr);
+ bool mouseOver(vec2 pos, float* percent_ptr);
+ bool click(vec2 pos, float* percent_ptr);
void logic(float dt);
void draw(float dt);
};
View
55 src/spline.cpp
@@ -20,15 +20,17 @@
SplineEdge::SplineEdge() {
}
-void SplineEdge::update(const vec2f& pos1, const vec4f& col1, const vec2f& pos2, const vec4f& col2, const vec2f& spos) {
+void SplineEdge::update(const vec2& pos1, const vec4& col1, const vec2& pos2, const vec4& col2, const vec2& spos) {
- vec2f pt_last;
- vec4f col_last;
+ vec2 pt_last;
+ vec4 col_last;
- vec2f mid = (pos1 - pos2) * 0.5;
- vec2f to = vec2f(pos1 - spos);
+ vec2 mid = (pos1 - pos2) * 0.5f;
+ vec2 to = vec2(pos1 - spos);
- float dp = std::min(1.0f, to.normal().dot(mid.normal()));
+ //TODO: not sure this makes any sense
+ //float dp = std::min(1.0f, to.normal().dot(mid.normal()));
+ float dp = std::min(1.0f, glm::dot(normalize(to), normalize(mid)) );
float ang = acos(dp) / PI;
@@ -47,21 +49,21 @@ void SplineEdge::update(const vec2f& pos1, const vec4f& col1, const vec2f& pos2,
float t = (float)i/edge_detail;
float tt = 1.0f-t;
- vec2f p0 = pos1 * t + spos * tt;
- vec2f p1 = spos * t + pos2 * tt;
+ vec2 p0 = pos1 * t + spos * tt;
+ vec2 p1 = spos * t + pos2 * tt;
- vec2f pt = p0 * t + p1 * tt;
+ vec2 pt = p0 * t + p1 * tt;
- vec4f coln = col1 * t + col2 * tt;
+ vec4 coln = col1 * t + col2 * tt;
spline_point.push_back(pt);
spline_colour.push_back(coln);
}
- midpoint = pos1 * 0.25 + pos2 * 0.25 + spos * 0.5;
+ midpoint = pos1 * 0.25f + pos2 * 0.25f + spos * 0.5f;
}
-const vec2f& SplineEdge::getMidPoint() const {
+const vec2& SplineEdge::getMidPoint() const {
return midpoint;
}
@@ -71,24 +73,31 @@ void SplineEdge::drawToVBO(quadbuf& buffer) const {
for(int i=0; i < edges_count; i++) {
- vec2f perp = (spline_point[i] - spline_point[i+1]).perpendicular().normal() * 2.5f;
+ //vec2 perp = (spline_point[i] - spline_point[i+1]).perpendicular().normal() * 2.5f;
- quadbuf_vertex v1(spline_point[i] + perp, spline_colour[i], vec2f(1.0f, 0.0f));
- quadbuf_vertex v2(spline_point[i] - perp, spline_colour[i], vec2f(0.0f, 0.0f));
- quadbuf_vertex v3(spline_point[i+1] - perp, spline_colour[i+1], vec2f(0.0f, 0.0f));
- quadbuf_vertex v4(spline_point[i+1] + perp, spline_colour[i+1], vec2f(1.0f, 0.0f));
+ vec2 perp = (spline_point[i] - spline_point[i+1]);
+ perp = normalize(vec2(-perp.y, perp.x)) * 2.5f;
+
+ quadbuf_vertex v1(spline_point[i] + perp, spline_colour[i], vec2(1.0f, 0.0f));
+ quadbuf_vertex v2(spline_point[i] - perp, spline_colour[i], vec2(0.0f, 0.0f));
+ quadbuf_vertex v3(spline_point[i+1] - perp, spline_colour[i+1], vec2(0.0f, 0.0f));
+ quadbuf_vertex v4(spline_point[i+1] + perp, spline_colour[i+1], vec2(1.0f, 0.0f));
buffer.add(0, v1, v2, v3, v4);
}
}
-void SplineEdge::drawBeam(const vec2f & pos1, const vec4f & col1, const vec2f & pos2, const vec4f & col2, float radius, bool first) const{
+void SplineEdge::drawBeam(const vec2 & pos1, const vec4 & col1, const vec2 & pos2, const vec4 & col2, float radius, bool first) const{
- vec2f perp = (pos1 - pos2).perpendicular().normal() * radius;
+ //vec2 perp = (pos1 - pos2).perpendicular().normal() * radius;
+ vec2 perp = (pos1 - pos2);
+ perp = normalize(vec2(-perp.y, perp.x)) * radius;
+
+
// src point
if(first) {
- glColor4fv(col1);
+ glColor4fv(glm::value_ptr(col1));
glTexCoord2f(1.0,0.0);
glVertex2f(pos1.x + perp.x, pos1.y + perp.y);
glTexCoord2f(0.0,0.0);
@@ -96,7 +105,7 @@ void SplineEdge::drawBeam(const vec2f & pos1, const vec4f & col1, const vec2f &
}
// dest point
- glColor4fv(col2);
+ glColor4fv(glm::value_ptr(col2));
glTexCoord2f(1.0,0.0);
glVertex2f(pos2.x + perp.x, pos2.y + perp.y);
glTexCoord2f(0.0,0.0);
@@ -107,12 +116,12 @@ void SplineEdge::drawShadow() const{
int edges_count = spline_point.size() - 1;
- vec2f offset(2.0, 2.0);
+ vec2 offset(2.0, 2.0);
glBegin(GL_QUAD_STRIP);
for(int i=0;i<edges_count;i++) {
- drawBeam(spline_point[i] + offset, vec4f(0.0, 0.0, 0.0, gGourceShadowStrength), spline_point[i+1] + offset, vec4f(0.0, 0.0, 0.0, gGourceShadowStrength), 2.5, i==0);
+ drawBeam(spline_point[i] + offset, vec4(0.0, 0.0, 0.0, gGourceShadowStrength), spline_point[i+1] + offset, vec4(0.0, 0.0, 0.0, gGourceShadowStrength), 2.5, i==0);
}
glEnd();
View
12 src/spline.h
@@ -28,18 +28,18 @@
class SplineEdge {
- std::vector<vec2f> spline_point;
- std::vector<vec4f> spline_colour;
+ std::vector<vec2> spline_point;
+ std::vector<vec4> spline_colour;
- vec2f midpoint;
+ vec2 midpoint;
- void drawBeam(const vec2f & pos1, const vec4f & col1, const vec2f & pos2, const vec4f & col2, float radius, bool first) const;
+ void drawBeam(const vec2 & pos1, const vec4 & col1, const vec2 & pos2, const vec4 & col2, float radius, bool first) const;
public:
SplineEdge();
- const vec2f& getMidPoint() const;
+ const vec2& getMidPoint() const;
- void update(const vec2f& pos1, const vec4f& col1, const vec2f& pos2, const vec4f& col2, const vec2f& spos);
+ void update(const vec2& pos1, const vec4& col1, const vec2& pos2, const vec4& col2, const vec2& spos);
void drawToVBO(quadbuf& buffer) const;
View
10 src/textbox.cpp
@@ -23,10 +23,10 @@ TextBox::TextBox() {
TextBox::TextBox(const FXFont& font) {
this->font = font;
- shadow = vec2f(3.0f, 3.0f);
+ shadow = vec2(3.0f, 3.0f);
- colour = vec3f(0.7f, 0.7f, 0.7f);
- corner = vec2f(0.0f,0.0f);
+ colour = vec3(0.7f, 0.7f, 0.7f);
+ corner = vec2(0.0f,0.0f);
alpha = 1.0f;
brightness = 1.0f;
max_width_chars = 1024;
@@ -47,7 +47,7 @@ void TextBox::setBrightness(float brightness) {
this->brightness = brightness;
}
-void TextBox::setColour(const vec3f& colour) {
+void TextBox::setColour(const vec3& colour) {
this->colour = colour;
}
@@ -92,7 +92,7 @@ void TextBox::setText(const std::vector<std::string>& content) {
}
}
-void TextBox::setPos(const vec2f& pos, bool adjust) {
+void TextBox::setPos(const vec2& pos, bool adjust) {
corner = pos;
View
10 src/textbox.h
@@ -28,11 +28,11 @@ class TextBox {
std::vector<std::string> content;
- vec3f colour;
+ vec3 colour;
float alpha;
float brightness;
- vec2f corner;
- vec2f shadow;
+ vec2 corner;
+ vec2 shadow;
FXFont font;
int max_width_chars;
int rect_width;
@@ -48,8 +48,8 @@ class TextBox {
void clear();
- void setPos(const vec2f& pos, bool adjust = false);
- void setColour(const vec3f& colour);
+ void setPos(const vec2& pos, bool adjust = false);
+ void setColour(const vec3& colour);
void setAlpha(float alpha);
void setBrightness(float brightness);