Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <GL/glut.h>
- #include <dagger3d.h>
- int font;
- void keyb()
- {
- if (dWindowKeyPressedOnce(D_KEY_ESCAPE))
- {
- exit(0);
- }
- }
- void display()
- {
- char *msg = NULL, *timeOfDay;
- timeOfDay = dTimeOfDayStr();
- dStringAppend(&msg, "^$Hey, the time is now: %s\n"
- "Also ^0this is a huge ^3paragraph of "
- "text to test ^5the word wrap. ^4We are "
- "also ^0testing ^1different colors.", timeOfDay);
- free(timeOfDay);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- dFontPrint(font, 100.0f, 400.0f, 30, msg);
- free(msg);
- msg = NULL;
- dStringAppend(&msg, "^$^5Here is some more text!\n"
- "And ^0here\t^5 is a tab (ie. 8 spaces).");
- dFontPrint(font, 200.0f, 100.0f, 22, msg);
- free(msg);
- msg = NULL;
- dStringAppend(&msg,
- "^$Color codes\n"
- "^1^^1 ^9red\n"
- "^2^^2 ^9green\n"
- "^3^^3 ^9yellow\n"
- "^4^^4 ^9blue\n"
- "^5^^5 ^9teal\n"
- "^6^^6 ^9magenta\n"
- "^7^^7 ^9black\n"
- "^8^^8 ^9gray\n"
- "^9^^9 ^9white\n"
- "^0^^0 ^9orange\n"
- );
- dFontPrint(font, 500.0f, 200.0f, 22, msg);
- free(msg);
- }
- int main(int argc, char **argv)
- {
- dInit(argc, argv, D_WINDOW);
- dWindowOpen("Font", 640, 480, 60, 0);
- dWindowSetDisplayFunc(display);
- dWindowSetInputFunc(keyb);
- font = dFontLoad("examples/FreeSans.ttf", 12);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement