我真的很困惑如何gluLookAt
和glOrtho
或gluPersective
一起工作.这是问题所在.
我在-5轴的z轴上绘制了一个2D三角形和一个2D五边形.
//pentagon
glVertex3f(0.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);
glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.5f, -5.0f);
//Triangle
glVertex3f(-0.5f, 0.5f, -5.0f);
glVertex3f(-1.0f, 1.5f, -5.0f);
glVertex3f(-1.5f, 0.5f, -5.0f);
Run Code Online (Sandbox Code Playgroud)
然后我定义我的相机位置(0,0,-10)和透视
//Tell OpenGL how to convert from coordinates to pixel values
glViewport(0, 0, w, h);
gluLookAt(0, 0, -10, 0, 0, -200, 0, 1, 0);
glMatrixMode(GL_PROJECTION); //Switch to setting the camera perspective
//Set the camera …
Run Code Online (Sandbox Code Playgroud) 我试图理解为什么uint64_t
类型无法正常显示pow(2,64)-1
.cplusplus标准是199711L.
我检查了pow()
C++ 98标准下的函数
double pow (double base , double exponent);
float pow (float base , float exponent);
long double pow (long double base, long double exponent);
double pow (double base , int exponent);
long double pow (long double base, int exponent);
Run Code Online (Sandbox Code Playgroud)
所以我写了下面的代码片段
double max1 = (pow(2, 64) - 1);
cout << max1 << endl;
uint64_t max2 = (pow(2, 64) - 1);
cout << max2 << endl;
uint64_t max3 = -1;
cout << max3 << …
Run Code Online (Sandbox Code Playgroud)