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 7648125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:38:09+00:00 2026-05-31T10:38:09+00:00

I’m trying to create some interlaced images to output on a 3DTV. My method

  • 0

I’m trying to create some interlaced images to output on a 3DTV. My method uses OpenGL’s stencil buffer to draw a grid of lines on each even row of pixels. On my laptop, the resulting image looks interlaced, but when I output to the 3DTV (via HDMI cable), it looks as though the lines are not drawn on each even row of pixels. The vertical resolution of my laptop and the TV is 1080 pixels. The screen coordinates used below range from (-1, -1) for bottom left of the screen to (1, 1) for top right. Here is the code I am using to draw the grid on the stencil buffer. I’d be grateful if someone could sanity check it for me, to see if I’m doing something fundamentally wrong. If my code is fine, the problem might be the TV resizing the output from the laptop.

glEnable(GL_STENCIL_TEST);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); 
glDisable(GL_DEPTH_TEST);
glStencilFunc(GL_ALWAYS,1,1); 
const int stencilsize = 2500;
// hardcoding 2500, not the greatest solution in the world i know...
GLfloat stencilVertices[stencilsize] = {0.0};
//if we know the window height, we can draw a line in the stencil buffer on even row of pixels in the window
currheight = 1080; 
GLint i = 0;
GLfloat ht = -1;
/*start ht @ -1, increase by 4/currheight each time, until 1 is reached*/
while ((ht < 1) && (i < stencilsize-4)) 
{
    stencilVertices[i] = -1;    //left edge of screen
    i++;
    stencilVertices[i] = ht;    //current line's y coord
    i++;
    stencilVertices[i] = 1;     //right edge of screen
    i++;
    stencilVertices[i] = ht;    //current line's y coord
    i++;
    ht += 4.0/currheight;   //increase ht by (4/(height of window)) each time to mark even rows only (until ht == 1)
}
glGenBuffers(1, &m_ui32Stencilpattern); 
glBindBuffer(GL_ARRAY_BUFFER, m_ui32Stencilpattern);
glBufferData(GL_ARRAY_BUFFER, (stencilsize * sizeof(GLfloat)), stencilVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(VERTEX_ARRAY);
glVertexAttribPointer(VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_LINES, 0, stencilsize);
  • 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-31T10:38:11+00:00Added an answer on May 31, 2026 at 10:38 am

    I think the stencil buffer is not quite the right tool for this. Line interlacing is more easily done using a fragment shader these days. And in the days before OpenGL-3 I’d do this using a polygon stipple (like I did in my interlaced 3D TV patch I got included into mplayer). This saves you the struggle with getting your geometry at the right position.

    In the shader you can select between the two source images on a per pixel basis, using the gl_FragCoord viewport pixel coordinate as conditional. Or you draw two passes and discard fragments of either line/column.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.