-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sfml library support (todo: add shader support)
- Loading branch information
Showing
18 changed files
with
712 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// Created by cpasjuste on 01/12/16. | ||
// | ||
|
||
#include "sfml_font.h" | ||
|
||
SFMLFont::SFMLFont(const char *path, int size) : Font(path, size) { | ||
this->size = size; | ||
|
||
if (!font.loadFromFile(path)) { | ||
printf("SFMLFont: load font error\n"); | ||
} | ||
} | ||
|
||
SFMLFont::~SFMLFont() { | ||
} | ||
|
||
int SFMLFont::GetWidth(const char *fmt, ...) { | ||
|
||
char msg[MAX_PATH]; | ||
memset(msg, 0, MAX_PATH); | ||
va_list args; | ||
va_start(args, fmt); | ||
vsnprintf(msg, MAX_PATH, fmt, args); | ||
va_end(args); | ||
|
||
sf::Text t; | ||
t.setFont(font); | ||
t.setString(msg); | ||
t.setCharacterSize(size); | ||
|
||
return (int)t.getLocalBounds().width; | ||
} | ||
|
||
int SFMLFont::GetHeight(const char *fmt, ...) { | ||
|
||
char msg[MAX_PATH]; | ||
memset(msg, 0, MAX_PATH); | ||
va_list args; | ||
va_start(args, fmt); | ||
vsnprintf(msg, MAX_PATH, fmt, args); | ||
va_end(args); | ||
|
||
sf::Text t; | ||
t.setFont(font); | ||
t.setString(msg); | ||
t.setCharacterSize(size); | ||
|
||
return (int)t.getLocalBounds().height; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Created by cpasjuste on 01/12/16. | ||
// | ||
|
||
#ifndef SFML_FONT_H_ | ||
#define SFML_FONT_H_ | ||
|
||
#include <skeleton/renderer.h> | ||
#include <skeleton/font.h> | ||
#include <SFML/Graphics/Font.hpp> | ||
#include <SFML/Graphics/Text.hpp> | ||
|
||
class SFMLFont : Font { | ||
|
||
public: | ||
SFMLFont(const char *path, int size); | ||
|
||
~SFMLFont(); | ||
|
||
virtual int GetWidth(const char *fmt, ...); | ||
virtual int GetHeight(const char *fmt, ...); | ||
|
||
sf::Font font; | ||
}; | ||
|
||
#endif //_SDL2_FONT_H_ |
Oops, something went wrong.