/* -*- C++ -*- * Copyright ©2005 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #ifndef OUTPUT_H #define OUTPUT_H #include "magellan/plugin.h" class Output; #include "magellan/plugininfo_output.h" #include "magellan/configlexer.h" #include "magellan/parsertools.h" #include "magellan/values.h" #include "magellan/vectors.h" class Output : public Plugin { public: Output(int x, int y) : xmax(x), ymax(y) { } // Drawing primitives virtual void setpixel(const ivec2& pos, int r, int g, int b) = 0; virtual void setpixel(const ivec2& pos, const ivec3& rgb) { setpixel(pos, int(rgb[0]), int(rgb[1]), int(rgb[2])); } virtual void drawline(const ivec2& from, const ivec2& to, int r, int g, int b); virtual void drawline(const ivec2& from, const ivec2& to, const ivec3& rgb) { drawline(from, to, int(rgb[0]), int(rgb[1]), int(rgb[2])); } enum RenderFlags { TP_HCENTRE = 0x01, TP_HLEFT = 0x02, TP_HRIGHT = 0x03, TP_VCENTRE = 0x10, TP_VTOP = 0x20, TP_VBOTTOM = 0x30, TP_VBASELINE = 0x40, TP_OUTLINE = 0x100 }; virtual void textmetrics(const std::string& text, const std::string& font, ivec2& bl, // Bottom-left bound of the rendered text ivec2& tr, // Top-right bound of the rendered text ivec2& base) = 0; // The "start point" of the text virtual void drawtext(const std::string& text, const std::string& font, enum RenderFlags textpos) = 0; // Actually output the results of drawing virtual void commit() = 0; // Informational methods virtual int width(void) const { return xmax; } virtual int height(void) const { return ymax; } virtual bool repeated(void) const { return false; } virtual int updatetime(void) const { return 0; } protected: virtual ~Output() { } int xmax, ymax; }; #endif