我遇到了GLUT的問題。我試圖讓我的程序在按下某個按鈕或點擊鼠標按鈕時關閉。這是ESC和右鍵單擊。爲什麼我的GLUT窗口不會關閉?
我不知道爲什麼它不工作,這裏是低於
#include "stdafx.h"
#include <glut.h>
#include <iostream>
void keyboard(unsigned char c, int x, int y);
void mouse (int button, int state, int x, int y);
void render(void);
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100); //Position of the window
glutInitWindowSize(640, 480); //Screen Size
glutCreateWindow("Greeting Card"); //Creates the window and names it
glutDisplayFunc(render);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop(); //Finished, now render
}
void keyboard(unsigned char c, int x, int y) {
if (c == 27) {
exit(0);
}
}
void mouse (int button, int state, int x, int y) {
if (button == GLUT_RIGHT_BUTTON) {
exit(0);
}
下面的代碼是
Error 3 error C3861: 'exit': identifier not found i:\computer graphics\consoleapplication1\consoleapplication1\consoleapplication1.cpp 31 1 ConsoleApplication1
Error 2 error C3861: 'exit': identifier not found i:\computer graphics\consoleapplication1\consoleapplication1\consoleapplication1.cpp 25 1 ConsoleApplication1
Error 1 error C2381: 'exit' : redefinition; __declspec(noreturn) differs c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdlib.h 360 1 ConsoleApplication1
我已經包含的#include並仍然得到同樣的錯誤,這些錯誤:(
我已經試過這一點,我仍然得到錯誤:/ – Siyico
是什麼在你的stdafx.h?另外,對於cstdlib,則必須用'的std ::退出()做'使用命名空間std'或調用exit()' – chbaker0
Stdafx.h中的唯一事情是的#include 「stdafx.h中」 d: – Siyico