gpt4 book ai didi

c++ - 如何使用 glut openGL 绘制一个 4 尖星

转载 作者:行者123 更新时间:2023-12-03 07:00:38 26 4
gpt4 key购买 nike

我想在 C++ 中使用 GLUT 和 openGL 绘制一个四角星。这是我的代码

glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.0f,6.0f,0.0f);
glVertex3f(1.0f,4.0f,0.0f);
glVertex3f(3.0f,3.0f,0.0f);
glVertex3f(1.0f,2.0f,0.0f);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(-1.0f,2.0f,0.0f);
glVertex3f(-3.0f,3.0f,0.0f);
glVertex3f(-1.0f,4.0f,0.0f);

glEnd();
问题是形状从 0,6 直接变为 3,3
谁能帮我解决这个问题,
screenshot
我想要这样的东西
desired output

最佳答案

GL_TRIANGLE_FAN的第1点primitiv 始终保持固定(参见 Triangle primitives)。刚开始GL_TRIANGLE_FAN primitiv 在“内部”点之一:

glBegin(GL_TRIANGLE_FAN);

glVertex3f(1.0f,4.0f,0.0f);
glVertex3f(3.0f,3.0f,0.0f);
glVertex3f(1.0f,2.0f,0.0f);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(-1.0f,2.0f,0.0f);
glVertex3f(-3.0f,3.0f,0.0f);
glVertex3f(-1.0f,4.0f,0.0f);

glVertex3f(0.0f,6.0f,0.0f);

glEnd();

关于c++ - 如何使用 glut openGL 绘制一个 4 尖星,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64139873/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com