#include "bindable.h"
#include "gl.h"
#include "font.h"
-#include "immediate.h"
-#include "primitivetype.h"
+#include "primitivebuilder.h"
#include "texture2d.h"
using namespace std;
return x;
}
-void Font::draw_string(const string &str, StringCodec::Decoder &dec, const Color &color) const
-{
- BindRestore bind_tex(get_texture());
- Immediate imm((TEXCOORD2, COLOR4_UBYTE, VERTEX2));
- imm.color(color);
- build_string(str, dec, imm);
-}
-
void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveBuilder &bld) const
{
VertexBuilder::PushMatrix push_mtx(bld);
float get_string_width(const std::string &str) const
{ return get_string_width<StringCodec::Utf8>(str); }
- /** Draws a string to the framebuffer with Immediate. It is drawn with size
- 1.0; set up matrices for the desired size before the call. */
- void draw_string(const std::string &, StringCodec::Decoder &, const Color & = Color()) const;
-
- template<class C>
- void draw_string(const std::string &str, const Color &color = Color()) const
- {
- typename C::Decoder dec;
- draw_string(str, dec, color);
- }
-
- void draw_string(const std::string &str, const Color &color = Color()) const
- { draw_string<StringCodec::Utf8>(str, color); }
-
/** Builds the primitives for a string. Two-dimensional vertex and texture
coordinates are generated. Size 1.0 is used for building; set up the
builder's matrix before the call. The texture is not bound, to avoid
+++ /dev/null
-#include "batch.h"
-#include "error.h"
-#include "immediate.h"
-
-namespace Msp {
-namespace GL {
-
-Immediate::Immediate(VertexFormat f):
- PrimitiveBuilder(array),
- array(f)
-{
- array.use_buffer(0);
-}
-
-void Immediate::reset()
-{
- if(in_batch)
- throw invalid_operation("Immediate::reset");
-
- array.clear();
-}
-
-void Immediate::begin_()
-{
- indices.clear();
-}
-
-void Immediate::end_()
-{
- Batch batch(type);
- batch.append(indices);
- array.apply();
- batch.draw();
-}
-
-void Immediate::element_(unsigned i)
-{
- indices.push_back(i);
-}
-
-} // namespace GL
-} // namespace Msp
+++ /dev/null
-#ifndef MSP_GL_IMMEDIATE_H_
-#define MSP_GL_IMMEDIATE_H_
-
-#include "primitivebuilder.h"
-
-namespace Msp {
-namespace GL {
-
-/**
-Draws primitives on the screen. This works similarly to the OpenGL immediate
-mode: call begin() to start a batch of primitives, specify vertices, and call
-end() to terminate the batch. However, unlike OpenGL immediate mode, vertices
-are not drawn as they are specified. Instead, they are accumulated in a
-VertexArray and drawn when end() is called.
-*/
-class Immediate: public PrimitiveBuilder
-{
-private:
- VertexArray array;
- std::vector<unsigned> indices;
-
-public:
- Immediate(VertexFormat);
- void reset();
-private:
- virtual void begin_();
- virtual void end_();
- virtual void element_(unsigned);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif