Advertisement
Guest User

Functions for print the text

a guest
Aug 17th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. GLvoid GlPrint(const char* fmt, ...){
  2. char text[256];
  3. va_list ap;
  4. if (fmt == NULL) return;
  5. va_start(ap, fmt);
  6. vsprintf_s(text, 256, fmt, ap);
  7. va_end(ap);
  8. glPushAttrib(GL_LIST_BIT);
  9. glListBase(base - 32);
  10. glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
  11. glPopAttrib();
  12. }
  13.  
  14. GLvoid GlText(HDC dc, const char* text, ERGB color, GLint x, GLint y) {
  15. RECT rect;
  16. GetWindowRect(WindowFromDC(dc), &rect);
  17. int width = rect.right - rect.left;
  18. int height = rect.bottom - rect.top;
  19.  
  20. glMatrixMode(GL_PROJECTION);
  21. glLoadIdentity();
  22.  
  23. glOrtho(0, width, height, 0, 0, 1);
  24. glDisable(GL_DEPTH_TEST);
  25. glMatrixMode(GL_MODELVIEW);
  26. glLoadIdentity();
  27. glTranslatef(0, 0, 0);
  28. glColor3f(RGB_TO_FLOAT(color.r, color.g, color.b));
  29. glRasterPos2i(x, y);
  30. GlPrint(text);
  31. glEnable(GL_DEPTH_TEST);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement