1
我正在寫一個函數來創建一個透視投影矩陣,我得到一些錯誤。你可以幫我嗎? 我已經標有錯誤的線條與 ' - '簡單錯誤:在';'之前預期的初級表達式';'令牌
typedef GLfloat mat4x4[16];
功能:
void perspective(float fovy, float aspect, float near, float far, mat4x4& mat)
{
for(int i=0;i<16;i++)
mat[i]=0;
-float range = tan(degreesToRadians(fovy)/2.0f) * near;
float left = range * aspect;
float right = range * aspect;
float bottom = range;
float top = range;
-mat[0] = (2.0f * near)/(right - left);
-mat[5] = (2.0f * near)/(top - bottom);
--mat[10] = (far + near)/(far - near);
-mat[11] = 1.0f;
-mat[14] = (2.0f * far * near)/(far - near);
}
錯誤:
In function 'void perspective(float, float, float, float, GLfloat (&)[16])':
błąd:expected primary-expression before ';' token
błąd:expected primary-expression before ')' token
błąd:expected primary-expression before ')' token
błąd:expected primary-expression before ')' token
błąd:expected primary-expression before ')' token
błąd:expected primary-expression before ')' token
błąd:expected primary-expression before ')' token
你覺得'-float'是什麼意思?同樣,'-mat [0] = ...'也許有意義,但我懷疑它。 – BoBTFish
在代碼中它不是浮動它只是浮動 –
我剛剛標記了錯誤的行 –