2014-01-19 30 views
1

我有一個關於在opengl中使用freetype字體的問題。 我目前閱讀本教程http://www.freetype.org/freetype2/docs/tutorial/step1.html 和有代碼示例 http://www.freetype.org/freetype2/docs/tutorial/example1.cfreetype 2在opengl中的用法

在方法draw_bitmap

FT_Int i, j, p, q; 
FT_Int x_max = x + bitmap->width; 
FT_Int y_max = y + bitmap->rows; 


for (i = x, p = 0; i < x_max; i++, p++) 
{ 
    for (j = y, q = 0; j < y_max; j++, q++) 
    { 
    if (i < 0  || j < 0  || 
     i >= WIDTH || j >= HEIGHT) 
     continue; 

    image[j][i] |= bitmap->buffer[q * bitmap->width + p]; 
    } 
} 

他們填寫陣列unsigned char image[HEIGHT][WIDTH];與數據 ,然後使用putchar在控制檯顯示圖像。

int i, j; 


for (i = 0; i < HEIGHT; i++) 
{ 
    for (j = 0; j < WIDTH; j++) 
    putchar(image[i][j] == 0 ? ' ' 
           : image[i][j] < 128 ? '+' 
                : '*'); 
    putchar('\n'); 
} 

所以,問題是 - 這個數組image是矩陣,其中包含屏幕上的像素的座標?而爲了繪製像素,我需要使用glRasterPos2i?

回答