c - glutBitmapCharacter() doesn't display anything? -




i trying make simple text output opengl, freeglut using glutbitmapcharacter(). problem is, not text shown. triangle works fine. guess problem not displaytext() function maybe call @ wrong place or redraw/clear text? compile 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);     (int = 0; < 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; } 

glrasterpos2f() takes current matrix stack account, either switch glwindowpos() (which works directly in window coordinates, bypassing matrix stacks , viewport transform) or change modelview/projection matrices make transform (200, 200) isn't off-screen.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -