2011-04-09 29 views
0

我正在做一個簡單的2D遊戲,使用opengl ortho視圖,三角形作爲精靈。OpenGL矩陣在iPh​​one和模擬器上的工作方式不同嗎?

的問題是,這絕對是一樣的遊戲代碼運行完美我的Mac模擬器,但是當我啓動手機上的東西的遊戲出錯。 當我找到問題時,我發現我不明白。

我已經簡化了代碼,具有不同的行爲的硬證據,並且代碼看起來像:

// Setup projection matrix as identity 
GLfixed projectionMatrix[16]; 
projectionMatrix[0] = 65536;//1.0f; 
projectionMatrix[1] = 0; 
projectionMatrix[2] = 0; 
projectionMatrix[3] = 0; 

projectionMatrix[4] = 0; 
projectionMatrix[5] = 65536;//1.0f; 
projectionMatrix[6] = 0; 
projectionMatrix[7] = 0; 

projectionMatrix[8] = 0; 
projectionMatrix[9] = 0; 
projectionMatrix[10] = 65536;//1.0f; 
projectionMatrix[11] = 0; 

projectionMatrix[12] = 0; 
projectionMatrix[13] = 0; 
projectionMatrix[14] = 0; 
projectionMatrix[15] = 65536;//1.0f; 

glMatrixMode(GL_PROJECTION); 
glLoadIdentity(); 
glLoadMatrixx(projectionMatrix); 


// Setup modelview matrix 
glMatrixMode(GL_MODELVIEW); 
glPushMatrix(); 
glLoadIdentity(); 

// And here I printout the content of the matricies 
GLfixed m[4][4]; 
glGetFixedv(GL_MODELVIEW, &(m[0][0])); 
// … Print matrix 
glGetFixedv(GL_PROJECTION, &(m[0][0])); 
// … Print matrix 

The printed values on my mac using simulator (feels right): 
==== MODEL 
[65536][0][0][0] 
[0][65536][0][0] 
[0][0][65536][0] 
[0][0][0][65536] 
==== PROJECTION 
[65536][0][0][0] 
[0][65536][0][0] 
[0][0][65536][0] 
[0][0][0][65536] 

And printed values on my ipod (wtf?): 
==== MODEL 
[-1490935922][1236752][20995][803202364] 
[1][1032192][1245312][803202404] 
[879947476][3][92][803202728] 
[1][10558464][803202404][808970200] 
==== PROJECTION 
[-1490935922][1236752][20995][803202364] 
[1][1032192][1245312][803202404] 
[879947476][3][92][803202728] 
[1][10558464][803202404][808970200] 

我想也許是水木清華在不同初始化GL?但如何弄清楚什麼? 也許有人有任何線索在哪裏尋找答案? 與固定vs浮動有關嗎?

回答

0

Wooohoo ...我張貼後,我發現自己的答案... 對不起打擾...的原因是關鍵字: GL_MODELVIEW和GL_MODELVIEW_MATRIX 我應該使用: glMatrixMode(GL_MODELVIEW); 和 glGetFixedv(GL_MODELVIEW_MATRIX,&(M [0] [0]));

ØØ(^_^)

相關問題