gpt4 book ai didi

c++ - GLSL 隔行扫描似乎在 3DTV 上甚至跳过了行

转载 作者:行者123 更新时间:2023-11-28 08:08:19 24 4
gpt4 key购买 nike

<分区>

我正在尝试创建一些交错图像以在 3DTV 上输出。我的方法使用 OpenGL 的模板缓冲区在每个偶数行像素上绘制线条网格。在我的笔记本电脑上,生成的图像看起来 是交错的,但是当我输出到 3DTV(通过 HDMI 电缆)时,看起来好像每偶数行像素上都没有绘制线条。我的笔记本电脑和电视的垂直分辨率是 1080 像素。下面使用的屏幕坐标范围从屏幕左下角的 (-1, -1) 到右上角的 (1, 1)。这是我用来在模板缓冲区上绘制网格的代码。如果有人能为我检查一下,看看我是否做错了根本性的事情,我将不胜感激。如果我的代码没问题,问题可能出在电视调整笔记本电脑输出的大小。

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);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com