Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include <SDL/SDL_ttf.h>
- #include <string>
- SDL_Surface* Backbuffer = NULL;
- TTF_Font* Font = NULL;
- int FontSize=48; /////dirty hack lol
- int FS();
- void DrawOutlineText(SDL_Surface* surface, char* string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b);
- void DrawTTFFonts(char * text,int line); //assume everything
- //void DrawTTFFonts(SDL_Surface* surface, char* string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b); //IDK, maybe I can make a better function
- //void DrawOutlineText(SDL_Surface* surface, std::string string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b);
- bool ProgramIsRunning();
- /*
- *
- #include <string>
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg);
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg);
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font, const Uint16 *text, SDL_Color fg);
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, string *text, SDL_Color fg);
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font, string *text, SDL_Color fg);
- extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font, string *text, SDL_Color fg);
- *
- *
- Honestly fixing it is probably a wormhole
- * */
- int FS(){
- return FontSize;
- }
- //void DrawTTFFonts(SDL_Surface* surface, std::string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b);
- void DrawTTFFonts(char * text ,int line){
- //track lines, clear screen if flagged, increment line by fontsize+margin
- //Font size (FS*lines)+margin>=screenHeight clear screen and keep typing
- //add functions for text animation
- printf(" %d\n", line);
- int margin=5;
- int var= (FS()*line)+margin;
- if(line==0){
- DrawOutlineText(Backbuffer, text, 10, 10, Font, 255, 0, 0);
- }
- if(line>=1){
- DrawOutlineText(Backbuffer, text, 10, var, Font, 255, 0, 0);
- }
- }
- void DrawOutlineText(SDL_Surface* surface, char* string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b){
- //void DrawOutlineText(SDL_Surface* surface, std::string string, int x, int y, TTF_Font* font, Uint8 r, Uint8 g, Uint8 b){
- SDL_Surface* renderedText = NULL;
- SDL_Color color;
- color.r = r;
- color.g = g;
- color.b = b;
- renderedText = TTF_RenderText_Solid(font, string, color); //needs to be fixed in sdl lib in /usr/local/include/SDL_ttf.h
- SDL_Rect pos;
- pos.x = x;
- pos.y = y;
- SDL_BlitSurface(renderedText, NULL, surface, &pos);
- SDL_FreeSurface(renderedText);
- }
- bool ProgramIsRunning(){
- SDL_Event event;
- bool running = true;
- while(SDL_PollEvent(&event)){
- if(event.type == SDL_QUIT)
- running = false;
- }
- return running;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement