NSString not drawing?



我正在尝试绘制一个NSString,但由于某种原因它不会呈现。

- (void)renderScene {
    // Make sure we are renderin to the frame buffer
    [EAGLContext setCurrentContext:context];
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    // Clear the color buffer with the glClearColor which has been set      
    glClear(GL_COLOR_BUFFER_BIT);
    //Render the game Scene 
    if(gameState == 0){
        //MENU
        [menu renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
    } else if(gameState == 1){
        //GAMEPLAY
        [bk renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
        [self drawScore];
        [player draw];
        [squares render];
        [scoreString drawAtPoint: CGPointMake(262, 250) withFont:[UIFont fontWithName:@"TimesNewRoman" size: 1.0f]]; //RIGHT HERE IS THE DRAW STRING
    } else if(gameState ==2){
        //DEATH SCREEN
        [squared renderAtPoint: CGPointMake(0, 0) centerOfImage: NO];
    }

您正在尝试混合使用 Core Graphics 和 OpenGL。解决此问题的一种简单方法是创建一个子窗口(UIView 或 UILabel),然后在子窗口中设置文本字符串。您也可以设置子视图的透明度。

还有其他方法(例如绘制到位图,然后将其用作OpenGL纹理,或使用OpenGL将字体绘制为位图或轮廓),但它们需要更多的工作 - 取决于您的需求。

相关内容

  • 没有找到相关文章

最新更新