max_index(0)
{ }
-void Batch::append(uint i)
+Batch &Batch::append(uint i)
{
if(indices.empty())
min_index=max_index=i;
max_index=max(max_index, i);
}
indices.push_back(i);
+
+ return *this;
}
void Batch::append(const vector<uint> &ind)
};
Batch(PrimitiveType t);
- void append(uint);
+ Batch &append(uint);
void append(const std::vector<uint> &);
void draw() const;
private:
Color(float v): r(v), g(v), b(v), a(1) { }
Color(float r_, float g_, float b_): r(r_), g(g_), b(b_), a(1) { }
Color(float r_, float g_, float b_, float a_): r(r_), g(g_), b(b_), a(a_) { }
+ Color operator*(float f) const { return Color(r*f, g*f, b*f, a); }
+ Color operator+(const Color &c) const { return Color(r+c.r, g+c.g, b+c.g, 1-(1-a)*(1-c.a)); }
+ bool operator==(const Color &c) const { return (r==c.r && b==c.b && g==c.g && a==c.a); }
+ bool operator!=(const Color &c) const { return !operator==(c); }
};
} // namespace GL
ExtFunc *get_proc_address(const string &name)
{
#ifndef WIN32
- return glXGetProcAddress(reinterpret_cast<const GLubyte *>(name.c_str()));
+ return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(name.c_str()));
#endif
}
shininess=s;
}
-void Material::apply()
+void Material::apply() const
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
void set_specular(const Color &s);
void set_emission(const Color &e);
void set_shininess(float s);
- void apply();
+ void apply() const;
};
} // namespace GL
vertices.use_vertex_buffer();
}
+Mesh::Mesh(VertexFormat f):
+ vertices(f)
+{
+ vertices.use_vertex_buffer();
+}
+
+void Mesh::add_batch(const Batch &b)
+{
+ batches.push_back(b);
+}
+
void Mesh::draw() const
{
vertices.apply();
};
Mesh();
+ Mesh(VertexFormat f);
+ RefPtr<VertexArrayBuilder> modify_vertices() { return vertices.modify(); }
+ void add_batch(const Batch &b);
void draw() const;
private:
VertexArray vertices;
glUniform4fARB(i, x, y, z, w);
}
+void Program::uniform4(int i, const float *v)
+{
+ glUniform4fvARB(i, 1, v);
+}
+
void Program::uniform_matrix4(int i, const float *v)
{
glUniformMatrix4fvARB(i, 1, false, v);
void uniform(int, float, float);
void uniform(int, float, float, float);
void uniform(int, float, float, float, float);
+ void uniform4(int, const float *);
void uniform_matrix4(int, const float *);
static void unbind();