OpenGL:如何剪辑2D区域以避免文本与GlutBitmap打印出这个区域?

时间:2015-09-30 20:21:13

标签: c++ c opengl

如何在我的应用中定义一些可以打印文本的区域,而不会溢出它们?

int printText(char *myChar, int color, double x, double y, double z)
{
    call_color(color);
    int end_of_char=strlen(myChar);
    glRasterPos3d(x,y,-1);
    for(int i=0;i<end_of_char;i++)
    {
        glutBitmapCharacter(GLUT_BITMAP_8_BY_13,myChar[i]);
    }
    return(0);
}

样品:

void window_function()
{
    // printing things before on all screen
    // define clipping aera
    char tem[64];
    sprintf(tem,"mouse x: %.4f mouse y: %.4f",mouse_ox,mouse_oy);
    printText(tem,COL_LIGHT_GREY,x+0.005,y-0.085,1.0);
    //re opening the clipping aera to the complete screen
    //printing other stuff    
}

1 个答案:

答案 0 :(得分:1)

glScissor() + glEnable(GL_SCISSOR_TEST)