~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to api/txf_util.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "filesys.h"
27
27
#include "boinc_api.h"
28
28
 
29
 
#include "texfont.h"
 
29
//#include "texfont.h"
30
30
#include "txf_util.h"
31
31
 
32
32
#ifndef _MAX_PATH
33
33
#define _MAX_PATH 256
34
34
#endif 
35
35
 
36
 
static TexFont* txf[TXF_NUM_FONT];
 
36
//static TexFont* txf[TXF_NUM_FONT];
 
37
static void* txf[TXF_NUM_FONT];
37
38
 
38
39
// load fonts. call once.
39
40
//
63
64
        float fscale,                 // scale factor
64
65
        GLfloat * col,                // colour 
65
66
        int i,                        // font index see texfont.h 
66
 
        char * s                                          // string ptr
 
67
        char * s,                                         // string ptr
 
68
        float fRotAngle,        // optional rotation angle
 
69
        float fRotX,            // optional rotation vector for X
 
70
        float fRotY,            // optional rotation vector for Y
 
71
        float fRotZ            // optional rotation vector for Z
67
72
){
 
73
    // if requested font isn't available, find first one that is
 
74
    //
 
75
    while((i < TXF_NUM_FONT) && !txf[i]) i++;
 
76
        if((i >= TXF_NUM_FONT) || !txf[i]) {
 
77
        // bad font index
 
78
        return;
 
79
    }
68
80
        glPushMatrix();
69
81
        glEnable(GL_TEXTURE_2D);
70
 
        if((i < TXF_NUM_FONT) && txf[i]) {
71
 
            glBindTexture(GL_TEXTURE_2D, txf[i]->texobj);
72
 
            glTranslated(x, y, z);
73
 
            glScalef(1/fscale, 1/fscale, 1/fscale);
74
 
            glEnable(GL_ALPHA_TEST);
75
 
            // use .1 and .5 for a dark and bright background respectively
76
 
            glAlphaFunc(GL_GEQUAL, alpha_value);
77
 
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
78
 
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
79
 
            glColor4fv(col);
80
 
            txfRenderString(txf[i], s, (int)strlen(s));
81
 
        }
 
82
    glBindTexture(GL_TEXTURE_2D, txf[i]->texobj);
 
83
    glTranslated(x, y, z);
 
84
    glScalef(1/fscale, 1/fscale, 1/fscale);
 
85
    if (fRotAngle != 0.0f) {
 
86
        // we want to rotate around Z y default,
 
87
        // which keeps our text in 2D plane
 
88
       glRotatef(fRotAngle, fRotX, fRotY, fRotZ);
 
89
    }
 
90
    glEnable(GL_ALPHA_TEST);
 
91
    // use .1 and .5 for a dark and bright background respectively
 
92
    glAlphaFunc(GL_GEQUAL, alpha_value);
 
93
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
94
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
95
    glColor4fv(col);
 
96
    txfRenderString(txf[i], s, (int)strlen(s));
82
97
        glDisable(GL_TEXTURE_2D);       
83
98
        glPopMatrix();
84
99
}