+#include <msp/gl/immediate.h>
#include "graphic.h"
#include "resources.h"
using namespace std;
-#include <iostream>
-
namespace Msp {
namespace GLtk {
-Graphic::Graphic(const Resources &r, const string &n):
- res(r),
- name(n),
+Graphic::Graphic():
texture(0)
{ }
unsigned ymin=border.bottom ? 0 : 1;
unsigned ymax=border.top ? 3 : 2;
+ GL::Immediate imm((GL::TEXCOORD2,GL::VERTEX2));
for(unsigned i=ymin; i<ymax; ++i)
{
- glBegin(GL_QUAD_STRIP);
+ imm.begin(GL::QUAD_STRIP);
for(unsigned j=xmin; j<=xmax; ++j)
{
- glTexCoord2f(u[j], v[i]);
- glVertex2f(x[j], y[i]);
- glTexCoord2f(u[j], v[i+1]);
- glVertex2f(x[j], y[i+1]);
+ imm.texcoord(u[j], v[i]);
+ imm.vertex(x[j], y[i]);
+ imm.texcoord(u[j], v[i+1]);
+ imm.vertex(x[j], y[i+1]);
}
- glEnd();
+ imm.end();
}
}
-Graphic::Sides::Sides():
- top(0),
- right(0),
- bottom(0),
- left(0)
-{ }
-
-
-Graphic::Loader::Loader(Graphic &g):
- graph(g)
+Graphic::Loader::Loader(Graphic &g, Resources &r):
+ graph(g),
+ res(r)
{
add("texture", &Loader::texture);
add("slice", &Loader::slice);
void Graphic::Loader::texture(const string &n)
{
- graph.texture=&graph.res.get_texture(n);
+ graph.texture=&res.get<GL::Texture2D>(n);
graph.slice=Geometry(0, 0, graph.texture->get_width(), graph.texture->get_height());
}
load_sub(graph.shadow);
}
-
-Graphic::Sides::Loader::Loader(Sides &s):
- sides(s)
-{
- add("top", &Sides::top);
- add("right", &Sides::right);
- add("bottom", &Sides::bottom);
- add("left", &Sides::left);
-}
-
} // namespace GLtk
} // namespace Msp