gpt4 book ai didi

c++ - opengl中的freetype 2用法

转载 作者:太空宇宙 更新时间:2023-11-04 11:41:27 26 4
gpt4 key购买 nike

我有一个关于在 opengl 中使用自由字体的问题。我目前正在阅读本教程 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 吗?

最佳答案

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

这个人有问题,并解决了他们,应该是你要找的代码:

Problems copying freetype bitmap to opengl texture

关于c++ - opengl中的freetype 2用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21224144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com