Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FONT.CPP
Package: openglsystem.rar [view]
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 2k
Category:
OpenCV
Development Platform:
Visual C++
- #define WIN32_MEAN_AND_LEAN
- #define WIN32_EXTRA_LEAN
- #include "font.h"
- #include <windows.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <gl/gl.h>
- CFont::CFont()
- {
- screenX = 0;
- screenY = 0;
- xpos = 0.0;
- ypos = 0.0;
- zpos = 0.0;
- }
- CFont::CFont(char *name, int size)
- {
- screenX = 0;
- screenY = 0;
- xpos = 0.0;
- ypos = 0.0;
- zpos = 0.0;
- Build(name, size);
- }
- CFont::~CFont()
- {
- glDeleteLists(callList, 96);
- }
- void CFont::Build(char *name, int size)
- {
- HFONT hFont; // font ID
- HDC hDC; // device context
- hDC = wglGetCurrentDC();
- callList = glGenLists(96);
- if (stricmp(name, "symbol") == 0)
- {
- hFont = CreateFont(-size, 0,0,0,FW_BOLD, FALSE, FALSE, FALSE, SYMBOL_CHARSET,
- OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
- FF_DONTCARE | DEFAULT_PITCH, name);
- }
- else
- {
- hFont = CreateFont(-size, 0,0,0,FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
- OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
- FF_DONTCARE | DEFAULT_PITCH, name);
- }
- SelectObject(hDC, hFont);
- wglUseFontBitmaps(hDC, 32, 96, callList);
- }
- void CFont::Print(const char *str, ...)
- {
- char text[256];
- va_list args;
- if (str == NULL)
- return;
- va_start(args, str);
- vsprintf(text, str, args);
- va_end(args);
- glPushMatrix();
- glColor4f(r, g, b, a);
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, -1.0f); // translate one unit into the screen
- if (xpos == 0.0 && ypos == 0.0 && zpos == 0.0)
- glRasterPos2i(screenX, screenY);
- else
- glRasterPos3f(xpos, ypos, zpos);
- glPushAttrib(GL_LIST_BIT);
- glListBase(callList - 32);
- glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
- glPopAttrib();
- glPopMatrix();
- }
- void CFont::ClearFont()
- {
- glDeleteLists(callList, 96);
- }