作者Achillean (山猪元年革命志士)
看板GameDesign
标题Re: [请益] Opengl对全画面作stipple处理的函式
时间Fri Aug 20 13:58:15 2010
※ 引述《Achillean (山猪元年革命志士)》之铭言:
: 问题:
: why不是从左下-1.-1贴齐?
: 结果:
: http://tinyurl.com/3yowgm4
: 程式:
: void display(void) //绘图 - new
: {
: //Left Eye---------------------------------------
: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
: glMatrixMode(GL_MODELVIEW);
: glLoadIdentity();
: gluLookAt( -fEye_D/2,fEye_Y,fEye_Z,
: fFocus_X, fFocus_Y, fFocus_Z,
: 0,1,0);
: //Draw Object
: drawObjects();
: glFlush();
: glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
: glReadPixels( 0,0,nWinWidth,nWinHeight, GL_RGB,GL_UNSIGNED_BYTE,pRGB_L);
: //Right Eye---------------------------------------
: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
: glMatrixMode(GL_MODELVIEW);
: glLoadIdentity();
: gluLookAt( fEye_D/2,fEye_Y,fEye_Z,
: fFocus_X, fFocus_Y, fFocus_Z,
: 0,1,0);
: //Draw Object
: drawObjects();
: glFlush();
: glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
: glReadPixels( 0,0,nWinWidth,nWinHeight, GL_RGB,GL_UNSIGNED_BYTE,pRGB_R);
: //3D Imagbe---------------------------------------
: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
: LR2Interval();
: glMatrixMode(GL_MODELVIEW);
: glLoadIdentity();
: gluLookAt( 0,fEye_Y,fEye_Z,
: fFocus_X, fFocus_Y, fFocus_Z,
: 0,1,0);
: glRasterPos2f(-1.0,-1.0);
: glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
: glDrawPixels(nWinWidth,nWinHeight, GL_RGB, GL_UNSIGNED_BYTE, pRGB_3D);
: glutSwapBuffers();
: }
成品:
http://tinyurl.com/2vn2w84
问题:
Q1: 请问glFinish()是这样用来同步的吗?
Q2: 不知道是否是绘图速度的问题,当无视差时候
应该left,right影像相同,但是物件边缘还是有些许鬼影
已经修改过
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
解决Window Size Width不为四时候的错位图
叙述:
经改良後的片段程式码如下
//3D Imagbe---------------------------------------
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
LR2Interval();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( 0,0,1,
fFocus_X, fFocus_Y, fFocus_Z,
0,1,0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
{
glLoadIdentity();
if(nWinWidth < nWinHeight)
{
glOrtho( -1,1,
-nWinHeight*1.0/nWinWidth,
nWinHeight*1.0/nWinWidth,
0.01,100);
glRasterPos2f( -1,-nWinHeight*1.0/nWinWidth);
}
else
{
glOrtho( -nWinWidth*1.0/nWinHeight,
nWinWidth*1.0/nWinHeight,
-1,1,0.01,100);
glRasterPos2f( -nWinWidth*1.0/nWinHeight,-1);
}
glDrawPixels( nWidth,nHeight, GL_RGB, GL_UNSIGNED_BYTE, pRGB_3D );
glFinish();
glutSwapBuffers();
}
glPopMatrix();
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.32.40.135
※ 编辑: Achillean 来自: 114.32.40.135 (08/20 17:38)