2011-01-24 86 views
0

我很久以前就有過這個問題,最近我得到了一些線索,但還不是很清楚。在不同的顯示模式下完全不同的渲染結果?

我基本上使用深度測試將紋理渲染到現有的圖形。該功能在nvdia顯卡下工作正常,但不是在英特爾顯卡上(有時畫面不穩定,有時只是垃圾)。

首先,我認爲這可能是卡的問題。最近我發現,如果我在choosepixelformat中更改了顯示模式,它在intel卡上工作得也很好。

我也嘗試了getpixelformat函數選擇的模式,並猜測它可能是由於深度精度問題,我嘗試了一些在opengl FAQ上推薦的技術,但沒有成功。我嘗試了幾種RGBA顯示模式,它們是(僅使用具有雙緩衝器模式和它們2,4,6,9,10,13,14):

 Draw Pixel Color    Depth Stencil Double Stereo Aux  
Index To Type Bits R G B A Bits Bits Buffer Buffer Buffers 
====================================================================== 

2  win rgba 32 8 8 8 8 .  .  yes .  .  
4  win rgba 32 8 8 8 8 16 .  yes .  .  
6  win rgba 32 8 8 8 8 24 8  yes .  .  
9  win rgba 32 8 8 8 . 32 8  yes .  .  
10 win rgba 32 8 8 8 . 16 8  yes .  .  
13 win rgba 32 8 8 8 8 32 8  yes .  .  
14 win rgba 32 8 8 8 8 16 8  yes .  .  

哪個顯示正確的2的模式,9,10,13,14。失敗的人是4,6。窗戶選擇模式4.

任何人都可以給我一些提示?

感謝您的評論,我在這裏添加了壞渲染&在同一臺機器上的好渲染圖片。一種是模式4,一種是模式10:

對不起!系統不允許我在這裏粘貼圖像

粘貼在這裏的壞的只是其中的一個,有些可能會顯示其他奇怪的圖片。

偏碼: OpenGL的初始化

m_pDC = new CClientDC(this); 
//m_pDC = new CPaintDC(this); 
m_hDC=m_pDC->GetSafeHdc(); 

static PIXELFORMATDESCRIPTOR pfd = 
{ 
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 
1, // version number 
PFD_DRAW_TO_WINDOW | // support window 
PFD_SUPPORT_OPENGL | // support OpenGL 
PFD_DOUBLEBUFFER, // double buffered 
PFD_TYPE_RGBA, // RGBA type 
24, // 24-bit color depth 
0, 0, 0, 0, 0, 0, // color bits ignored 
0, // no alpha buffer 
0, // shift bit ignored 
0, // no accumulation buffer 
0, 0, 0, 0, // accum bits ignored 
16, // 16-bit z-buffer 
0, // no stencil buffer 
0, // no auxiliary buffer 
PFD_MAIN_PLANE, // main layer 
0, // reserved 
0, 0, 0 // layer masks ignored 
}; 
int m_PixelFormat; 
//we may need to rewrite this function since it does not need the alpha bits 
m_PixelFormat = ::ChoosePixelFormat(m_hDC, &pfd); 

::SetPixelFormat(m_hDC, m_PixelFormat, &pfd); 
//::SetPixelFormat(m_hDC, 10, &pfd); 
// 
m_hRC = ::wglCreateContext(m_hDC); 
wglMakeCurrent(m_hDC, m_hRC); 

wglMakeCurrent(NULL,NULL); 

return TRUE; 

渲染是在WM_PAINT消息函數: :: glEnable(GL_DEPTH_TEST); :: glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

::glViewport(0, 0, rcClient.Width() , rcClient.Height()); 

    .... 
    draw(...); 

繪製函數將是這樣的:

gluPerspective(90, width/height, 0.001, height/1); 

glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 

gluLookAt(cx,cy,cz,cx,cy,0,0,1,0); 

然後繪製這裏地圖...... glDisable(GL_TEXTURE_2D);

glDisable(GL_DEPTH_TEST); 

然後繪製線條這裏&其他物體...

所有對象都在2D頂點格式,沒有任何3D深度值。

+0

您對問題的描述非常含糊。請在渲染過程中提供一些代碼和確切步驟的描述。截圖也會很好。 – datenwolf 2011-01-25 09:26:55

回答

0

我忘了在這個問題上放棄我的解決方案。事實證明,這是intel卡硬件加速的問題。我試圖通過選擇軟件渲染來關閉硬件加速,問題消失了。

相關問題