-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
52 lines (42 loc) · 1.42 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// This file is distributed along with GLFT_Font and is in the public domain.
// Compiled with g++ GLFT_Font.cpp test.cpp -o test -Wall -pedantic
// -lglfw -lGL -pthread -lfreetype `freetype-config --cflags`
//
#include <GL/glfw.h>
#include "GLFT_Font.hpp"
#include <iostream>
int main(int argc, char** argv)
{
if(argc != 2)
{
std::cerr << "Usage: test file. Where file is a valid font\n";
}
else
{
glfwInit();
glfwOpenWindow(800, 600, 8, 8, 8, 8, 0, 0, GLFW_WINDOW);
GLFT_Font f;
f.open(argv[1],24);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
do
{
glClear(GL_COLOR_BUFFER_BIT);
f.drawText(0, 0, "drawText");
f.drawText(f.calcStringWidth("drawText"), f.getHeight(),
"drawText 0x%X", 250);
f.beginDraw(200, 200) << "beginDraw: " << 10 << f.endDraw();
glfwSwapBuffers();
} while(glfwGetWindowParam(GLFW_OPENED) &&
glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS);
glfwCloseWindow();
glfwTerminate();
}
}