- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有这个功能,当我按下 a
时,我会在 GL_LINE
和 GL_FILL
之间切换。当我运行程序时,它以 GL_FILL
开头,当我按下 a
时,它切换到 GL_LINE
。但是我希望它在按下 a
时继续在两者之间切换。
谁能告诉我哪里出错了。
void keyPressed (unsigned char key, int x, int y) {
switch (key){
case 'a':
bool f = false;
if(!f){
glPolygonMode(GL_FRONT,GL_LINE);
glPolygonMode(GL_BACK, GL_LINE);
}else{
//bOutline=false;
glPolygonMode(GL_FRONT,GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);
}
f=!f;
break;
}
}
最佳答案
我认为您必须在由 f 处理的 2 个状态之间切换,因此您需要在外部范围内定义 f 或像这样将其定义为静态变量
static bool f = false;
关于c++ - switch 语句 C++ 和 glut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12821341/
我想开始使用OpenGl开发图形程序 为了开始,我正在关注 OpenGL 我遇到过使用 GLUT 和不使用 GLUT 进行编程,但作为 OpenGL 的新手,我更加困惑如何使用它? 最佳答案 GLUT
我的应用程序在使用 wglCreateContext 上下文的 Windows 上仅使用 gl/glu。 该应用程序有自己的 key 管理器,现在我喜欢为输入框和选择列表实现 GUI 框架。 我找到了
我正在用 C++ 进行一些 OpenGL 编程。 这是我的代码的一部分: #include #include #include #include #include Properties.
我正在使用 Win32 API 处理 OpenGL。因此我正在使用 wgl (Wiggle)。一切安好。除非我想使用 FREEGLUT 库中的一些形状。例如,茶壶。我正在查看 freeglut 的源代
我正在尝试在 Haskell 中制作图形,并且一直在使用 Haskell.org 的教程 (http://www.haskell.org/haskellwiki/OpenGLTutorial1)。但是
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求提供代码的问题必须表现出对所解决问题的最低限度的了解。包括尝试的解决方案、为什么它们不起作用以及预期结果
我正在用 C 语言开发一个带有 GLUT 的应用程序。我有一个基本的 GLUT Canvas ,我可以在其中绘制 OpenGL 内容。 当其他 X11 窗口与 GLUT Canvas 重叠然后被删除时
我最近重新设计了我的应用程序,以便在 Idle 函数中完成数据收集。该程序从 argv[1] 读取文件并从该文件中解析出命令。这部分似乎都可以正常工作,并且解析的数据是准确的。 问题出在显示功能上。命
我遇到了一个奇怪的问题,当我以零延迟调用它时,glutTimerFunc 似乎随机停止工作。 这是我的代码: #include #include #include int x = 0; void
我正在处理一项作业,要求我仅使用隐藏线渲染图像。我在网上找到了有关如何删除隐藏线的内容,但我一直未能成功地弄清楚如何反转代码以使其仅绘制隐藏线。 通常,当我访问 Stack Overflow 时,我喜
我想将一个对象(立方体)乘以一定的数字,在本例中假设为 25,我确实有一个立方体的代码,并且它可以工作,但我不知道如何制作更多。我是 GLUT 的新人。 #include #include #in
嘿, 我正在尝试使用 C++ 使用 OpenGL 和 CUDA 创建场景,但是当我尝试传递函数进行初始化时收到错误消息。这是我的标题: class SimpleScene { public:
我有一个我在 6 个多月前编写的程序,它使用了 GLUT 库。 6 个月前我写的时候它运行得非常好。从那以后我就没有使用过它,也没有以任何方式编辑过代码。 该程序有一些立方体以一些随机速度四处漂浮,它
我有一个过剩的问题,我想要一个回调来知道用户何时移动我的应用程序的窗口,但我没有在过剩中发现任何东西。 我的目标是只在 Windows 上制作一个应用程序,是否可以使用 MFC 保留我的过剩代码来做到
我正在尝试在 GLUT c++ 上编写“Classic Snake”,但遇到了一些问题。 例如,当我的蛇向右移动时,我将目的地更改为向上,同时将其更改为向右蛇进入自身内部(我禁止将目的地从右更改为左)
我正在尝试使用以下摄像机代码实现摄像机控制的场景:http://www.swiftless.com/tutorials/opengl/camera2.html 还有书中的风景代码,随机生成地形。通过使
上周,我尝试了几个在阅读 GLUT 教程时发现的示例,一切都运行良好。 现在,当我重试这些相同的示例时,我得到了一个奇怪的行为:我的 GLUT 窗口显示了窗口所在位置的桌面部分(所以如果 GLUT 窗
我正在尝试使用以下方法将纹理渲染到平面: unsigned char image[HEIGHT][WIDTH][3]; ... GLuint textureId; glGenTextures(1, &
我编写了模拟选择排序操作的程序。我添加了函数 myKeyboard 来退出程序,但是由于使用函数 sleep() 来模拟动画,myKeyboard 仅在排序完成后才起作用。有什么方法可以替换函数 sl
当我编译后尝试运行这段代码时,我得到的只是一个没有内容的窗口边框,那么错误在哪里? 注意:我用的是ubuntu和gcc编译 gcc -lglut Simple.c -o Simple The out
我是一名优秀的程序员,十分优秀!