mirror of https://github.com/BOINC/boinc.git
added preliminary windows font support
svn path=/trunk/boinc/; revision=2333
This commit is contained in:
parent
e6a02ad49b
commit
1846da73d4
261
api/gutil.C
261
api/gutil.C
|
@ -104,6 +104,147 @@ void mode_unshaded() {
|
|||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void mode_ortho()
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0,1,0,1);
|
||||
//glScalef(1, -1, 1);
|
||||
//glTranslatef(0, -1, 0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluLookAt(0.0,0.0,1.0, // eye position
|
||||
0,0,0, // where we're looking
|
||||
0.0, 1.0, 0.); // up is in positive Y direction
|
||||
}
|
||||
|
||||
void ortho_done()
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
bool get_matrix(float src[16])
|
||||
{
|
||||
glPushMatrix();
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX,src);
|
||||
glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get_matrix_invert(float src[16])
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX,src);
|
||||
glPopMatrix();
|
||||
|
||||
float tmp[12]; /* temp array for pairs */
|
||||
float dst[16]; /* array of destination matrix */
|
||||
float det; /* determinant */
|
||||
|
||||
int i;
|
||||
|
||||
/* calculate pairs for first 8 elements (cofactors) */
|
||||
tmp[0] = src[10] * src[15];
|
||||
tmp[1] = src[11] * src[14];
|
||||
tmp[2] = src[9] * src[15];
|
||||
tmp[3] = src[11] * src[13];
|
||||
tmp[4] = src[9] * src[14];
|
||||
tmp[5] = src[10] * src[13];
|
||||
tmp[6] = src[8] * src[15];
|
||||
tmp[7] = src[11] * src[12];
|
||||
tmp[8] = src[8] * src[14];
|
||||
tmp[9] = src[10] * src[12];
|
||||
tmp[10] = src[8] * src[13];
|
||||
tmp[11] = src[9] * src[12];
|
||||
|
||||
/* calculate first 8 elements (cofactors) */
|
||||
dst[0] = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7];
|
||||
dst[0] -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7];
|
||||
dst[1] = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7];
|
||||
dst[1] -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7];
|
||||
dst[2] = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7];
|
||||
dst[2] -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7];
|
||||
dst[3] = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6];
|
||||
dst[3] -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6];
|
||||
dst[4] = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3];
|
||||
dst[4] -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3];
|
||||
dst[5] = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3];
|
||||
dst[5] -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3];
|
||||
dst[6] = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3];
|
||||
dst[6] -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3];
|
||||
dst[7] = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2];
|
||||
dst[7] -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2];
|
||||
|
||||
/* calculate pairs for second 8 elements (cofactors) */
|
||||
tmp[0] = src[2]*src[7];
|
||||
tmp[1] = src[3]*src[6];
|
||||
tmp[2] = src[1]*src[7];
|
||||
tmp[3] = src[3]*src[5];
|
||||
tmp[4] = src[1]*src[6];
|
||||
tmp[5] = src[2]*src[5];
|
||||
tmp[6] = src[0]*src[7];
|
||||
tmp[7] = src[3]*src[4];
|
||||
tmp[8] = src[0]*src[6];
|
||||
tmp[9] = src[2]*src[4];
|
||||
tmp[10] = src[0]*src[5];
|
||||
tmp[11] = src[1]*src[4];
|
||||
|
||||
/* calculate second 8 elements (cofactors) */
|
||||
dst[8] = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15];
|
||||
dst[8] -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15];
|
||||
dst[9] = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15];
|
||||
dst[9] -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15];
|
||||
dst[10] = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15];
|
||||
dst[10]-= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15];
|
||||
dst[11] = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14];
|
||||
dst[11]-= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14];
|
||||
dst[12] = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9];
|
||||
dst[12]-= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10];
|
||||
dst[13] = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10];
|
||||
dst[13]-= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8];
|
||||
dst[14] = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8];
|
||||
dst[14]-= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9];
|
||||
dst[15] = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9];
|
||||
dst[15]-= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8];
|
||||
|
||||
/* calculate determinant */
|
||||
det=src[0]*dst[0]+src[1]*dst[1]+src[2]*dst[2]+src[3]*dst[3];
|
||||
|
||||
/* calculate matrix inverse */
|
||||
if(det == 0) return false;
|
||||
det = 1.0f/det;
|
||||
for (i = 0; i < 16; i++) {
|
||||
dst[i] *= det;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
src[i*4] = dst[i*4];
|
||||
src[i*4+1] = dst[i*4+1];
|
||||
src[i*4+2] = dst[i*4+2];
|
||||
src[i*4+3] = dst[i*4+3];
|
||||
}
|
||||
|
||||
/*
|
||||
char buf[512];
|
||||
sprintf(buf,"%f,%f,%f,%f\n%f,%f,%f,%f\n%f,%f,%f,%f\n%f,%f,%f,%f\n",
|
||||
dst[0],dst[1],dst[2],dst[3],
|
||||
dst[4],dst[5],dst[6],dst[7],
|
||||
dst[8],dst[9],dst[10],dst[11],
|
||||
dst[12],dst[13],dst[14],dst[15]);
|
||||
fprintf(stderr, "%s: modelview\n", buf);
|
||||
MessageBox(NULL,buf,"F",0);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
void mode_lines() {
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -204,6 +345,15 @@ static void draw_text_end() {
|
|||
// draw a line of text in the XY plane at the given starting position,
|
||||
// character height, and line width.
|
||||
//
|
||||
|
||||
void draw_text_simple(char* text,float line_width,float char_height)
|
||||
{
|
||||
glLineWidth(line_width);
|
||||
float w = char_height/STROKE_SCALE;
|
||||
glScalef(w, w, w);
|
||||
draw_text_line_aux(text);
|
||||
}
|
||||
|
||||
void draw_text_line(
|
||||
GLfloat* _pos, GLfloat char_height, GLfloat line_width, char *text,
|
||||
int justify
|
||||
|
@ -552,3 +702,114 @@ void draw_texture(float* p, float* size) {
|
|||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
//star drawing functions -<oliver wang>-
|
||||
#define STARFIELD_SIZE 1000
|
||||
#define STAR_SPEED 40.0f
|
||||
#define PI 3.14159265358979323846264
|
||||
|
||||
//pointer to the begining of the list
|
||||
Star* stars = new Star;
|
||||
|
||||
void build_stars()
|
||||
{
|
||||
int i=0;
|
||||
Star* tmpStar = stars;
|
||||
float fov=45.0f;
|
||||
while(i<STARFIELD_SIZE)
|
||||
{
|
||||
float z = (float)(rand()%2000-1000);
|
||||
float alpha = 2.0*PI*(float)((rand()%359)/359.0) ;
|
||||
float beta = asin(z/1000.0f);
|
||||
float x = 1000.0f * cos(beta) * cos(alpha);
|
||||
float y = 1000.0f * cos(beta) * sin(alpha);
|
||||
|
||||
tmpStar->x=x;
|
||||
tmpStar->y=y;
|
||||
tmpStar->z=z;
|
||||
|
||||
float v = (float)((rand()%1000)/1000.0f);
|
||||
tmpStar->v=v;
|
||||
|
||||
tmpStar->next = new Star;
|
||||
tmpStar=tmpStar->next;
|
||||
i++;
|
||||
}
|
||||
tmpStar->next=NULL;
|
||||
tmpStar=NULL;
|
||||
}
|
||||
|
||||
|
||||
void update_stars()
|
||||
{
|
||||
float modelview[16];
|
||||
float dist;
|
||||
float eye[3];
|
||||
float camera[3];
|
||||
Star* tmpStar = stars;
|
||||
|
||||
if(get_matrix_invert(modelview)==false)
|
||||
fprintf(stderr,"ERROR: 0 determinant in modelview matrix");
|
||||
|
||||
eye[0]=modelview[2];
|
||||
eye[1]=modelview[6];
|
||||
eye[2]=modelview[10];
|
||||
|
||||
camera[0]=modelview[2];
|
||||
camera[1]=modelview[6];
|
||||
camera[2]=modelview[10];
|
||||
|
||||
while(tmpStar!=NULL)
|
||||
{
|
||||
dist=sqrt((camera[0]-tmpStar->x)*(camera[0]-tmpStar->x) +
|
||||
(camera[1]-tmpStar->y)*(camera[1]-tmpStar->y) +
|
||||
(camera[2]-tmpStar->z)*(camera[2]-tmpStar->z));
|
||||
|
||||
if(tmpStar->z>0) //replace it if its behind the camera
|
||||
{
|
||||
replaceStar(tmpStar);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmpStar->x+=(eye[0])*tmpStar->v*STAR_SPEED;
|
||||
tmpStar->y+=(eye[1])*tmpStar->v*STAR_SPEED;
|
||||
tmpStar->z+=(eye[2])*tmpStar->v*STAR_SPEED;
|
||||
|
||||
|
||||
//grow objects as the approach you
|
||||
if(dist>900) glPointSize(1.0f);
|
||||
else if(dist>700) glPointSize(2.0f);
|
||||
else if(dist>10) glPointSize(3.0f);
|
||||
|
||||
GLfloat mat_emission[] = {1, 1, 1, 1};
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission );
|
||||
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3f(tmpStar->x,tmpStar->y,tmpStar->z);
|
||||
glEnd();
|
||||
|
||||
GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, no_mat );
|
||||
tmpStar=tmpStar->next;
|
||||
}
|
||||
}
|
||||
|
||||
void replaceStar(Star* star)
|
||||
{
|
||||
float z = (float)(rand()%2000-1000);
|
||||
float alpha = 2.0*PI*(float)((rand()%359)/359.0) ;
|
||||
float beta = asin(z/1000.0f);
|
||||
float x = 1000.0f * cos(beta) * cos(alpha);
|
||||
float y = 1000.0f * cos(beta) * sin(alpha);
|
||||
star->x=x;
|
||||
star->y=y;
|
||||
star->z=z;
|
||||
star->x=x;
|
||||
|
||||
float v = (float)((rand()%1000)/1000.0f);
|
||||
star->v=v;
|
||||
}
|
||||
|
||||
|
||||
|
|
18
api/gutil.h
18
api/gutil.h
|
@ -42,6 +42,9 @@ extern void draw_text_line(
|
|||
GLfloat* pos, GLfloat height, GLfloat width, char *text,
|
||||
int justify=TEXT_LEFT
|
||||
);
|
||||
|
||||
void draw_text_simple(char* text,float line_width,float char_height);
|
||||
|
||||
extern void draw_text(
|
||||
GLfloat* pos, GLfloat height, GLfloat width, GLfloat spacing, char *text
|
||||
);
|
||||
|
@ -58,9 +61,13 @@ extern void draw_text_panel(
|
|||
);
|
||||
|
||||
extern void mode_texture();
|
||||
extern void mode_ortho();
|
||||
extern void mode_shaded(GLfloat*);
|
||||
extern void mode_unshaded();
|
||||
extern void mode_lines();
|
||||
extern void ortho_done();
|
||||
extern bool get_matrix_invert(float[16]);
|
||||
extern bool get_matrix(float[16]);
|
||||
|
||||
// draw a progress bar as an opaque cylinder within a translucent cylinder
|
||||
//
|
||||
|
@ -95,3 +102,14 @@ extern int read_ppm(char* name, int& w, int& h, unsigned char** arrayp);
|
|||
extern int init_texture(char* filename);
|
||||
extern void draw_texture(float* pos, float* size);
|
||||
|
||||
|
||||
//stars
|
||||
struct Star
|
||||
{
|
||||
float x,y,z,v;
|
||||
Star* next;
|
||||
};
|
||||
|
||||
extern void build_stars();
|
||||
extern void update_stars();
|
||||
extern void replaceStar(Star* tmpStar);
|
||||
|
|
49
api/reduce.C
49
api/reduce.C
|
@ -1,6 +1,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -317,7 +318,7 @@ void REDUCED_ARRAY::draw_row_rect_x(int row) {
|
|||
|
||||
mode_unshaded();
|
||||
//draw lines
|
||||
glLineWidth(.8);
|
||||
glLineWidth(.8f);
|
||||
glBegin(GL_LINES);
|
||||
// glEnable(GL_LINE_SMOOTH);
|
||||
glColor4f(0,0,0,1);
|
||||
|
@ -559,7 +560,7 @@ void REDUCED_ARRAY::draw_axes() {
|
|||
glBegin(GL_LINES);
|
||||
glColor4d(1,1,1,1);
|
||||
|
||||
float adj=-.18;
|
||||
float adj=-.18f;
|
||||
glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+adj);
|
||||
glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+adj);
|
||||
|
||||
|
@ -575,11 +576,51 @@ void REDUCED_ARRAY::draw_axes() {
|
|||
glEnd();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glColor4d(1,1,1,.4);
|
||||
glColor4d(1,1,1,.3);
|
||||
|
||||
glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+adj);
|
||||
glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+adj);
|
||||
glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj);
|
||||
glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj);
|
||||
glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj);
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
|
||||
void REDUCED_ARRAY::draw_labels()
|
||||
{
|
||||
float model[16];
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
get_matrix_invert(model);
|
||||
// get_matrix(model);
|
||||
mode_ortho();
|
||||
|
||||
float w = .05f;
|
||||
float pos[3];
|
||||
pos[0]=draw_pos[0]*model[0]+draw_pos[1]*model[4]+draw_pos[2]*model[8];
|
||||
pos[1]=draw_pos[0]*model[1]+draw_pos[1]*model[5]+draw_pos[2]*model[9];
|
||||
pos[2]=draw_pos[0]*model[2]+draw_pos[1]*model[6]+draw_pos[2]*model[10];
|
||||
//convert to 2d space
|
||||
if(pos[2]>0)
|
||||
{
|
||||
pos[0]=pos[0]/pos[2];
|
||||
pos[1]=pos[1]/pos[2];
|
||||
pos[2]=1;
|
||||
}
|
||||
|
||||
//scale to [-1,1]
|
||||
pos[0]=pos[0]/4.0f;
|
||||
pos[1]=pos[1]/4.0f;
|
||||
pos[2]=1;
|
||||
|
||||
char buf[512];
|
||||
sprintf(buf,"%f,%f,%f",pos[0],pos[1],pos[2]);
|
||||
//MessageBox(NULL,buf,"F",0);
|
||||
|
||||
mode_unshaded();
|
||||
glColor3d(1,1,1);
|
||||
glLineWidth(2);
|
||||
draw_text_line(pos, w, 2, "Time");
|
||||
|
||||
ortho_done();
|
||||
}
|
||||
|
|
|
@ -74,4 +74,5 @@ public:
|
|||
void draw_part(double frac);
|
||||
void draw_axes();
|
||||
void draw_axis_labels();
|
||||
void draw_labels();
|
||||
};
|
||||
|
|
|
@ -30,6 +30,12 @@ static UINT m_uEndSSMsg;
|
|||
|
||||
BOOL win_loop_done;
|
||||
|
||||
void SetupPixelFormat(HDC hDC);
|
||||
unsigned int CreateFont(char *fontName, int fontSize);
|
||||
void PrintText(unsigned int base, char *string);
|
||||
void ClearGLFont(unsigned int base);
|
||||
unsigned int listBase;
|
||||
|
||||
extern bool using_opengl;
|
||||
extern bool standalone;
|
||||
extern HANDLE hQuitEvent;
|
||||
|
@ -108,7 +114,13 @@ void SetMode(int mode) {
|
|||
SetForegroundWindow(hWnd);
|
||||
|
||||
GetCursorPos(&mousePos);
|
||||
|
||||
//
|
||||
hDC = GetDC(hWnd);
|
||||
SetupPixelFormat(hDC);
|
||||
ClearGLFont(listBase);
|
||||
listBase = CreateFont("Arial", 24);
|
||||
//
|
||||
/*
|
||||
PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
||||
|
@ -135,6 +147,7 @@ void SetMode(int mode) {
|
|||
int PixelFormat;
|
||||
PixelFormat = ChoosePixelFormat(hDC, &pfd);
|
||||
SetPixelFormat(hDC, PixelFormat, &pfd);
|
||||
*/
|
||||
|
||||
if(!(hRC = wglCreateContext(hDC))) {
|
||||
ReleaseDC(hWnd, hDC);
|
||||
|
@ -319,3 +332,118 @@ BOOL unreg_win_class() {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//my text drawing functions -<oliver wang>-
|
||||
void SetupPixelFormat(HDC hDC)
|
||||
{
|
||||
int nPixelFormat;
|
||||
|
||||
static PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), // size of structure.
|
||||
1, // always 1.
|
||||
PFD_DRAW_TO_WINDOW | // support window
|
||||
PFD_SUPPORT_OPENGL | // support OpenGl
|
||||
PFD_DOUBLEBUFFER, // support double buffering
|
||||
PFD_TYPE_RGBA, // support RGBA
|
||||
32, // 32 bit color mode
|
||||
0, 0, 0, 0, 0, 0, // ignore color bits
|
||||
0, // no alpha buffer
|
||||
0, // ignore shift bit
|
||||
0, // no accumulation buffer
|
||||
0, 0, 0, 0, // ignore accumulation bits.
|
||||
16, // number of depth buffer bits.
|
||||
0, // number of stencil buffer bits.
|
||||
0, // 0 means no auxiliary buffer
|
||||
PFD_MAIN_PLANE, // The main drawing plane
|
||||
0, // this is reserved
|
||||
0, 0, 0 }; // layer masks ignored.
|
||||
|
||||
|
||||
// this chooses the best pixel format and returns index.
|
||||
nPixelFormat = ChoosePixelFormat(hDC, &pfd);
|
||||
// This set pixel format to device context.
|
||||
SetPixelFormat(hDC, nPixelFormat, &pfd);
|
||||
}
|
||||
|
||||
void PrepareWindow()
|
||||
{
|
||||
// Always clear the screen and depth buffer then reset modleview matrix.
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clears the screen.
|
||||
glLoadIdentity(); //Reset modelview matrix for new frame.
|
||||
}
|
||||
|
||||
|
||||
// There is a lot of new code in our render scene function.
|
||||
void RenderScene()
|
||||
{
|
||||
glTranslatef(0.0f, 0.0f, -1.0f);// Move back 1 into the screen.
|
||||
glColor3f(1.0f, 1.0f, 1.0f); // Set the color of the text.
|
||||
|
||||
// This is the X and Y coordinate that the text will be printed at.
|
||||
glRasterPos2f(-0.35f, 0.1f);
|
||||
PrintText(listBase, "www.UltimateGameProgramming.com");// The string to print.
|
||||
|
||||
// Print second line
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
glRasterPos2f(-0.35f, 0.0f);
|
||||
PrintText(listBase, "Created by the Programming Ace!");
|
||||
|
||||
// Print third line.
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glRasterPos2f(-0.35f, -0.1f);
|
||||
PrintText(listBase, "Order the CD for more great tutorials!");
|
||||
}
|
||||
|
||||
unsigned int CreateFont(char *fontName, int Size)
|
||||
{
|
||||
// windows font
|
||||
HFONT hFont;
|
||||
unsigned int base;
|
||||
|
||||
// Create space for 96 characters.
|
||||
base = glGenLists(96);
|
||||
|
||||
if(stricmp(fontName, "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, fontName);
|
||||
}
|
||||
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, fontName);
|
||||
}
|
||||
|
||||
if(!hFont)
|
||||
return 0;
|
||||
|
||||
hDC = GetDC(hWnd);
|
||||
SelectObject(hDC, hFont);
|
||||
wglUseFontBitmaps(hDC, 32, 96, base);
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
|
||||
void PrintText(unsigned int base, char *string)
|
||||
{
|
||||
if((base == 0 || string == NULL))
|
||||
return;
|
||||
|
||||
glPushAttrib(GL_LIST_BIT);
|
||||
glListBase(base - 32);
|
||||
glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
void ClearGLFont(unsigned int base)
|
||||
{
|
||||
if(base != 0)
|
||||
glDeleteLists(base, 96);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue