summaryrefslogtreecommitdiff
path: root/library.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-30 21:04:57 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-30 21:04:57 +0100
commit9f84ef2686feab6c82f7f523319fda65ff077962 (patch)
treeb625f31ba5666694caa7ec77c75965c256f4519d /library.cpp
parent6c0a0cc29b00d0a58a3ee55a8a7e4909ebf3454c (diff)
Have draw_text working with SFML
Diffstat (limited to 'library.cpp')
-rw-r--r--library.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/library.cpp b/library.cpp
index cee789e..eda5628 100644
--- a/library.cpp
+++ b/library.cpp
@@ -2,15 +2,30 @@
#include <iostream>
#include <cstdarg>
#include <cassert>
+#include <SFML/Graphics.hpp>
#include "global.h"
#include "library.h"
-#include "main.h"
using namespace std;
+extern sf::RenderWindow window;
+
static void draw_text(int x,int y,const char *s,size_t len){
- fl_draw(s,len,x,y);
+ static sf::Font font;
+ static bool fontLoaded=false;
+ static sf::Text text;
+
+ if(!fontLoaded){
+ font.loadFromFile("/Library/Fonts/Arial.ttf");
+ fontLoaded=true;
+ }
+
+ text.setFont(font);
+ text.setFillColor(sf::Color::Black);
+ text.setString(string(s,len));
+ text.setPosition(x,y);
+ window.draw(text);
}
void draw_text(int x,int y,const char *s){