【问题标题】:freetype 2 usage in openglopengl 中的 freetype 2 用法
【发布时间】:2014-01-19 23:39:53
【问题描述】:

我有一个关于在 opengl 中使用 freetype 字体的问题。 我目前正在阅读本教程http://www.freetype.org/freetype2/docs/tutorial/step1.html 并且有代码示例 http://www.freetype.org/freetype2/docs/tutorial/example1.c

在方法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?

【问题讨论】:

    标签: c++ opengl freetype2


    【解决方案1】:

    您可以尝试将image 作为纹理加载,然后在四边形上渲染该纹理。

    这家伙有问题,解决了,应该是你要找的代码:

    Problems copying freetype bitmap to opengl texture

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-21
      • 1970-01-01
      • 2011-08-07
      相关资源
      最近更新 更多