我正在尝试使用glutBitmapCharacter()
使用OpenGL,FreeGlut进行简单的文本输出。我的问题是,我没有显示任何文字。三角形工作正常。我想问题不是displayText()
函数本身,但我可能在错误的地方调用它或重绘/清除文本?我用gcc main.c -lGL -lglut -o filename
#include <stdio.h>
#include <string.h>
#include <GL/freeglut.h>
int WindowHeight = 500;
int WindowWidth = 500;
void displayText(float x, float y, int r, int g, int b, const char *string) {
int j = strlen(string);
glColor3f(r, g, b);
glRasterPos2f(x, y);
for (int i = 0; i < j; i++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, string[i]);
}
printf("Lange: %i - Raster: %f %f", j, x, y);
}
void keyboard(unsigned char key, int x, int y) {
if (key == 27)
exit(0);
else
printf("Sie haben %c gedruckt.\n", key);
}
void display(void) {
glClearColor(1.0, 1.0, 1.0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_LINE_LOOP);
glVertex3f(-0.3, -0.3, 0);
glVertex3f(0, 0.3, 0);
glVertex3f(0.3, -0.3, 0);
glEnd();
displayText(200, 200, 0, 0, 255, "test");
glFlush();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitWindowSize(WindowWidth, WindowHeight);
glutInitWindowPosition(0, 0);
glutCreateWindow("Test");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
答案 0 :(得分:1)
glWindowPos()
考虑当前的矩阵堆栈,切换到(200, 200)
(直接在窗口坐标中工作,绕过矩阵堆栈和视口变换)或更改模型视图/投影矩阵以生成转换Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="tomcat.keystore" keystorePass="secret"
clientAuth="false" ciphers="TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA"
sslProtocol="TLSv1.2"
不在屏幕外的地方。