Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 671859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:25:12+00:00 2026-05-14T00:25:12+00:00

I need to draw a counter onto an OpenGL view. Here is my source

  • 0

I need to draw a counter onto an OpenGL view. Here is my source code for the video frame display.

cgl_ctx = CGLContextObj ( [[self openGLContext]  CGLContextObj]);

glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(1, &_surfaceTexture);
glDisable(GL_TEXTURE_RECTANGLE_ARB);
GLint swapInt = 1;//100;//1;

[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; 
[[self openGLContext] makeCurrentContext];//make the current opengl the priority

glMatrixMode(GL_TEXTURE);

glGenTextures(1, &_surfaceTexture);
glBindTexture(GL_TEXTURE_2D, _surfaceTexture);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);

glTexImage2D(
     GL_TEXTURE_2D,
     0,
     GL_RGBA,
     displayWidth,//960,//1920,
     displayHeight,//540,//1080,
     0,
     GL_BGRA,//GL_YCBCR_422_APPLE,//GL_RGB,//GL_APPLE_ycbcr_422,
     GL_UNSIGNED_BYTE,//GL_BYTE,//GL_UNSIGNED_BYTE,//GL_UNSIGNED_SHORT_8_8_REV_APPLE,
     IOSurfaceGetBaseAddress(videoBuffer->ioSurfaceDataBuffer[bufferCounter].RGBDest ));

glBegin(GL_QUADS);
  glTexCoord2f(0.0, 0.0);
  glVertex3f(-1.0, -1.0, 0.0);
  glTexCoord2f(1.0, 0.0);
  glVertex3f(1.0, -1.0, 0.0);
  glTexCoord2f(1.0, 1.0);
  glVertex3f(1.0, 1.0, 0.0);
  glTexCoord2f(0.0, 1.0);
  glVertex3f(-1.0, 1.0, 0.0);
glEnd();
glFlush();  
threadTracking ("view 11\n");
printf("view 2.2) videoBuffer->ioSurfaceDataBuffer[bufferCounter].played  %d\n",videoBuffer->ioSurfaceDataBuffer[bufferCounter].played);

[[self openGLContext] flushBuffer]; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:25:12+00:00Added an answer on May 14, 2026 at 12:25 am

    I got the source from another video player that displays video information, here is what i added to add text directly the displayed frame with openGL.

    char frameNumberBuffer[256];
    CGColorSpaceRef frameCounterColorSpace;
    CGContextRef frameCounterCglCtx;
    frameCounterColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
    
    frameCounterCglCtx = CGBitmapContextCreate( IOSurfaceGetBaseAddress (videoBuffer->ioSurfaceDataBuffer[bufferCounter].RGBDest),
                                                                  displayWidth, displayHeight, 8, IOSurfaceGetBytesPerRow(videoBuffer->ioSurfaceDataBuffer[bufferCounter].RGBDest),
                                                                  frameCounterColorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
    
    
    CGContextSelectFont(frameCounterCglCtx, "Helvetica", 72.0, kCGEncodingMacRoman);
    snprintf(frameNumberBuffer,256,"Frame Counter:  %d",playCounter);
    
    CGContextSetRGBFillColor(frameCounterCglCtx, 1.0f, 0.0f, 0.0f, 1.0f);
    CGContextShowTextAtPoint(frameCounterCglCtx, 100.0f, 100.0f, frameNumberBuffer, strlen(frameNumberBuffer));         
    
    snprintf(frameNumberBuffer,256,"Buffer Counter:  %d",bufferCounter);
    
    CGContextSetRGBFillColor(frameCounterCglCtx, 0.0f, 0.0f, 1.0f, 1.0f);
    CGContextShowTextAtPoint(frameCounterCglCtx, 100.0f, 200.0f, frameNumberBuffer, strlen(frameNumberBuffer));         
    

    where the IOSurfaceGetBaseAddress (videoBuffer->ioSurfaceDataBuffer[bufferCounter].RGBDest) returns the data pointer to my original frame data which was stored on an IOSurface

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to draw text onto a window HDC along a circular path using
I need to draw a circle onto a bitmap in a specific colour given
I need to draw text in the middle of a view, the text can
I need to draw single character on my view as BIG thin text as
I need to draw text of different sizes. however below code only gives choice
I need to draw a gridded image using opengl. I've read that images created
I need to draw 3d projections and i am using opengl wrapper for JAVA.
I need to draw an image pixel by pixel and display it inside a
I need to draw a pie chart. I found a nice tutorial here http://mac-objective-c.blogspot.com/2009/04/drawing-pie-charts.html
I need to draw over the html page. Page displayed in a Frame element.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.