看板 GameDesign 關於我們 聯絡資訊
※ 引述《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)