[email protected] 5REQ7K1L:~$ cd cppcode/Bouncing Ball Animation master/src/ [email protected]">

当前位置:网站首页>glut库更新旧程序无法完成编译问题描述

glut库更新旧程序无法完成编译问题描述

2022-08-10 15:58:00 zhangrelay

其实就是很多变量名称出现了变动。

手工替换即可。

绿色部分是系统给出的提示。对应错误需要全部都修订。

全部记录如下:

[email protected]:~$ cd cppcode/Bouncing-Ball-Animation-master/src/

[email protected]:~/cppcode/Bouncing-Ball-Animation-master/src$ make

g++ -std=c++11 -g -o a.out main.cpp ball.cpp eventHandling.cpp gui.cpp imageloader.cpp tinyfiledialogs.c -lglui -lglut -lGLU -lGL -lm

main.cpp: In function ‘int main(int, char**)’:

main.cpp:17:5: error: ‘glutInit’ was not declared in this scope

17 | glutInit(&argc, argv); //Initialize GLUT

| ^~~~~~~~

main.cpp:18:25: error: ‘GLUT_DOUBLE’ was not declared in this scope; did you mean ‘GL_DOUBLE’?

18 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

| ^~~~~~~~~~~

| GL_DOUBLE

main.cpp:18:39: error: ‘GLUT_RGBA’ was not declared in this scope; did you mean ‘GL_RGBA’?

18 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

| ^~~~~~~~~

| GL_RGBA

main.cpp:18:51: error: ‘GLUT_DEPTH’ was not declared in this scope; did you mean ‘GL_DEPTH’?

18 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

| ^~~~~~~~~~

| GL_DEPTH

main.cpp:18:5: error: ‘glutInitDisplayMode’ was not declared in this scope

18 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

| ^~~~~~~~~~~~~~~~~~~

main.cpp:19:5: error: ‘glutInitWindowSize’ was not declared in this scope

19 | glutInitWindowSize(winw,winh); //Set the window size

| ^~~~~~~~~~~~~~~~~~

main.cpp:20:37: error: ‘GLUT_SCREEN_WIDTH’ was not declared in this scope

20 | glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-winw)/2,(glutGet(GLUT_SCREEN_HEIGHT)-winh)/2);

| ^~~~~~~~~~~~~~~~~

main.cpp:20:29: error: ‘glutGet’ was not declared in this scope

20 | glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-winw)/2,(glutGet(GLUT_SCREEN_HEIGHT)-winh)/2);

| ^~~~~~~

main.cpp:20:73: error: ‘GLUT_SCREEN_HEIGHT’ was not declared in this scope

20 | glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-winw)/2,(glutGet(GLUT_SCREEN_HEIGHT)-winh)/2);

| ^~~~~~~~~~~~~~~~~~

main.cpp:20:5: error: ‘glutInitWindowPosition’ was not declared in this scope

20 | glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-winw)/2,(glutGet(GLUT_SCREEN_HEIGHT)-winh)/2);

| ^~~~~~~~~~~~~~~~~~~~~~

main.cpp:22:23: error: ‘glutCreateWindow’ was not declared in this scope

22 | main_window = glutCreateWindow("Bouncing Balls Animation"); //Create the window

| ^~~~~~~~~~~~~~~~

main.cpp:27:5: error: ‘glutDisplayFunc’ was not declared in this scope

27 | glutDisplayFunc(drawScene);

| ^~~~~~~~~~~~~~~

main.cpp:28:5: error: ‘glutTimerFunc’ was not declared in this scope

28 | glutTimerFunc(_time, update, 0);

| ^~~~~~~~~~~~~

main.cpp:33:9: error: ‘glutMotionFunc’ was not declared in this scope

33 | glutMotionFunc(MouseMotion);

| ^~~~~~~~~~~~~~

main.cpp:34:9: error: ‘glutPassiveMotionFunc’ was not declared in this scope

34 | glutPassiveMotionFunc(MousePassiveMotion);

| ^~~~~~~~~~~~~~~~~~~~~

main.cpp:145:5: error: ‘glutMainLoop’ was not declared in this scope

145 | glutMainLoop(); //Start the main loop. glutMainLoop doesn't return.

| ^~~~~~~~~~~~

eventHandling.cpp: In function ‘void MouseButton(int, int, int, int)’:

eventHandling.cpp:63:33: error: ‘GLUT_UP’ was not declared in this scope

63 | if (state == GLUT_UP) // Disregard redundant GLUT_UP events

| ^~~~~~~

eventHandling.cpp:67:32: error: ‘GLUT_LEFT_BUTTON’ was not declared in this scope

67 | if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {

| ^~~~~~~~~~~~~~~~

eventHandling.cpp:67:61: error: ‘GLUT_DOWN’ was not declared in this scope

67 | if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {

| ^~~~~~~~~

eventHandling.cpp:75:22: error: ‘GLUT_DOWN’ was not declared in this scope

75 | if (state == GLUT_DOWN) {

| ^~~~~~~~~

eventHandling.cpp:79:30: error: ‘GLUT_LEFT_BUTTON’ was not declared in this scope

79 | case GLUT_LEFT_BUTTON:

| ^~~~~~~~~~~~~~~~

eventHandling.cpp:81:30: error: ‘GLUT_MIDDLE_BUTTON’ was not declared in this scope

81 | case GLUT_MIDDLE_BUTTON:

| ^~~~~~~~~~~~~~~~~~

eventHandling.cpp:84:30: error: ‘GLUT_RIGHT_BUTTON’ was not declared in this scope

84 | case GLUT_RIGHT_BUTTON:

| ^~~~~~~~~~~~~~~~~

eventHandling.cpp:90:30: error: ‘GLUT_LEFT_BUTTON’ was not declared in this scope

90 | case GLUT_LEFT_BUTTON:

| ^~~~~~~~~~~~~~~~

eventHandling.cpp:93:30: error: ‘GLUT_MIDDLE_BUTTON’ was not declared in this scope

93 | case GLUT_MIDDLE_BUTTON:

| ^~~~~~~~~~~~~~~~~~

eventHandling.cpp:96:30: error: ‘GLUT_RIGHT_BUTTON’ was not declared in this scope

96 | case GLUT_RIGHT_BUTTON:

| ^~~~~~~~~~~~~~~~~

eventHandling.cpp:109:9: error: ‘glutPostRedisplay’ was not declared in this scope

109 | glutPostRedisplay();

| ^~~~~~~~~~~~~~~~~

eventHandling.cpp: In function ‘void MouseMotion(int, int)’:

eventHandling.cpp:124:9: error: ‘glutPostRedisplay’ was not declared in this scope

124 | glutPostRedisplay();

| ^~~~~~~~~~~~~~~~~

eventHandling.cpp: In function ‘void handleSpecialKeypress(int, int, int)’:

eventHandling.cpp:150:22: error: ‘GLUT_KEY_UP’ was not declared in this scope

150 | case(GLUT_KEY_UP): //Up Arrow

| ^~~~~~~~~~~

eventHandling.cpp:153:22: error: ‘GLUT_KEY_DOWN’ was not declared in this scope

153 | case(GLUT_KEY_DOWN): // Down Arrow

| ^~~~~~~~~~~~~

eventHandling.cpp:156:22: error: ‘GLUT_KEY_LEFT’ was not declared in this scope

156 | case(GLUT_KEY_LEFT): // Down Arrow

| ^~~~~~~~~~~~~

eventHandling.cpp:159:22: error: ‘GLUT_KEY_RIGHT’ was not declared in this scope

159 | case(GLUT_KEY_RIGHT): // Down Arrow

| ^~~~~~~~~~~~~~

eventHandling.cpp: In function ‘void cbMode(int)’:

eventHandling.cpp:332:9: error: ‘glutPostRedisplay’ was not declared in this scope

332 | glutPostRedisplay();

| ^~~~~~~~~~~~~~~~~

gui.cpp: In function ‘void update(int)’:

gui.cpp:97:9: error: ‘glutPostRedisplay’ was not declared in this scope

97 | glutPostRedisplay(); //Tell GLUT that the scene has changed

| ^~~~~~~~~~~~~~~~~

gui.cpp:98:5: error: ‘glutTimerFunc’ was not declared in this scope

98 | glutTimerFunc(_time, update, 0);

| ^~~~~~~~~~~~~

gui.cpp: In function ‘void drawScene()’:

gui.cpp:213:41: error: ‘glutSolidSphere’ was not declared in this scope

213 | glutSolidSphere(Balls[z].getRadius(),50,50);

| ^~~~~~~~~~~~~~~

gui.cpp:218:17: error: ‘glutSwapBuffers’ was not declared in this scope

218 | glutSwapBuffers(); //Send the 3D scene to the screen

| ^~~~~~~~~~~~~~~

gui.cpp:283:41: error: ‘glutSolidSphere’ was not declared in this scope

283 | glutSolidSphere(Balls[z].getRadius(),50,50);

| ^~~~~~~~~~~~~~~

gui.cpp:286:81: error: ‘glutWireSphere’ was not declared in this scope; did you mean ‘gluSphere’?

286 | if (ball_selected == Balls[z].getId()) glutWireSphere(Balls[z].getRadius()+0.03,20,20);

| ^~~~~~~~~~~~~~

| gluSphere

gui.cpp:292:17: error: ‘glutSwapBuffers’ was not declared in this scope

292 | glutSwapBuffers(); //Send the 3D scene to the screen

| ^~~~~~~~~~~~~~~

gui.cpp: In function ‘void myGlutIdle()’:

gui.cpp:314:8: error: ‘glutGetWindow’ was not declared in this scope

314 | if ( glutGetWindow() != main_window )

| ^~~~~~~~~~~~~

gui.cpp:315:5: error: ‘glutSetWindow’ was not declared in this scope

315 | glutSetWindow(main_window);

| ^~~~~~~~~~~~~

gui.cpp:319:9: error: ‘glutPostRedisplay’ was not declared in this scope

319 | glutPostRedisplay();

| ^~~~~~~~~~~~~~~~~

tinyfiledialogs.c: In function ‘int tkinter2Present()’:

tinyfiledialogs.c:592:48: warning: ‘%s’ directive writing up to 255 bytes into a region of size between 240 and 255 [-Wformat-overflow=]

592 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ^~ ~~~~~~~~~~~~~

tinyfiledialogs.c:592:25: note: ‘sprintf’ output between 2 and 272 bytes into a destination of size 256

592 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tinyfiledialogs.c:609:32: warning: ‘%s’ directive writing up to 255 bytes into a region of size between 240 and 255 [-Wformat-overflow=]

609 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ^~ ~~~~~~~~~~~~~

tinyfiledialogs.c:609:9: note: ‘sprintf’ output between 2 and 272 bytes into a destination of size 256

609 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tinyfiledialogs.c:599:32: warning: ‘%s’ directive writing up to 255 bytes into a region of size between 240 and 255 [-Wformat-overflow=]

599 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ^~ ~~~~~~~~~~~~~

tinyfiledialogs.c:599:9: note: ‘sprintf’ output between 2 and 272 bytes into a destination of size 256

599 | sprintf ( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;

| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

make: *** [makefile:7: all] Error 1

[email protected]:~/cppcode/Bouncing-Ball-Animation-master/src$


编译案例简介:

弹跳球动画

  • 一个模拟 2D 和 3D 球之间碰撞的 c++ 项目。
  • 使用 openGL、glut 和 glui 库构建。
  • Glui 实现了一个非常简单和强大的 GUI,允许用户控制球的不同属性。

特征

  • 用户可以播放/暂停场景,改变球的数量,改变球的颜色,增加/减少球的速度。
  • 用户可以通过单击来选择特定的球,然后更改其相应的属性。
  • 如果没有球被选中,那么所有球的属性都会改变。
  • 支持四种“外观和感觉”选项 - 默认、金属、高对比度、台球/台球
  • 2D 和 3D 模式。

原网站

版权声明
本文为[zhangrelay]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/2069691