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

  • Home
  • SEARCH
  • 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 7739225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:28:12+00:00 2026-06-01T08:28:12+00:00

I have a function that renders RGB video frames to a window. This works

  • 0

I have a function that renders RGB video frames to a window. This works fine for the captured dimensions (640 x 480) if the window is the same dimensions but when I resize the window the rendering is not correct:

img http://img855.imageshack.us/img855/1694/screenshot20120404at536.png

Edit: The now working function.

static inline void draw_rgb(
     unsigned char * buf, unsigned x, unsigned y, unsigned window_width,
     unsigned window_height, unsigned frame_width, unsigned frame_height
 )
{
    glEnable(GL_TEXTURE_RECTANGLE_EXT);
    glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1);

    glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, window_width * window_height * 2, buf);

    glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, frame_width, frame_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buf);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);

    glViewport(x, y, window_width, window_height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glOrtho((GLfloat)0, (GLfloat)window_width, (GLfloat)0, (GLfloat)window_height, -1.0, 1.0);

    glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1);

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();

    glBegin(GL_QUADS);
    {
        glTexCoord2f(0.0f, 0.0f);
        glVertex2f(0.0f, window_height);
        glTexCoord2f(0.0f, frame_height);
        glVertex2f(0.0f, 0.0f);
        glTexCoord2f(frame_width, frame_height);
        glVertex2f(window_width, 0.0f);
        glTexCoord2f(frame_width, 0.0f);
        glVertex2f(window_width, window_height);
    }
    glEnd();
}
  • 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-06-01T08:28:13+00:00Added an answer on June 1, 2026 at 8:28 am

    Your problem is a combination of two factors.

    First, as datenwolf pointed out, your texture’s width/height is constant. It doesn’t change when the window’s size does. BTW, you shouldn’t be rebuilding the texture every frame unless the texture’s data changes. And even then, you can upload changes with glTexSubImage2D rather than glTexImage. You don’t need to call the glTexParameter stuff either.

    Second, this also means that your texture coordinates don’t change. So you need to change your quad drawing to be this:

    glBegin(GL_QUADS);
    {
        glTexCoord2f(0.0f, 0.0f);
        glVertex2f(0.0f, window_height);
        glTexCoord2f(0.0f, texture_height);
        glVertex2f(0.0f, 0.0f);
        glTexCoord2f(texture_width, texture_height);
        glVertex2f(window_width, 0.0f);
        glTexCoord2f(texture_width, 0.0f);
        glVertex2f(window_width, window_height);
    }
    glEnd();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in a view that renders the xml in the browser,
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have a function that accepts a class (not an instance) and, depending on
I have a function that is being called from different threads in the application.
I have a function that allows users to edit a row in a table
I have a function that is recursively calling itself, and i want to detect
I have a function that pulls rows from a database, the content->id and content->type
I have an ASP.NET application that renders multiple questions with the option to provide

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.