[問題] 用c++練習寫OpenGL程式時出錯...
最近在試著學OpenGL,用的是C++。
使用的是Xcode。
加了兩個framework:
OpenGL.framework 和 GLUT.framework
然後參考這個網頁的教學: http://janusbooks.myweb.hinet.net/
寫了以下的程式碼:
#include <iostream>
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
using namespace std;
{有點長就放在最後面...}
--
但是神奇的是build過了,也產生了一個執行擋。
但是在run的時候什麼事都沒發生,而在Debugger Console裡出現了這一個錯誤訊息:
NSSoftLinking - The function 'CGLSetOption' can't be found in
the OpenGL framework.
去查Apple的網頁的時候有看到這麼一個描述:
======================================================
CGLSetOption
Sets the value of a global option.
(Deprecated. Use CGLSetGlobalOption instead.)
CGLError CGLSetOption (
CGLGlobalOption pname,
GLint param
);
========================================================
想問一下有沒有什麼解決方法....
人生的第一個openGL就跌股....Orz...
=============程式碼分隔線,感謝教學頁網==================
#include <iostream>
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
using namespace std;
int WinNumber;
void OnDraw(void){
printf("OnDraw\n");
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 1.0);
glRectf(-25, -25, 25, 25);
glFlush();
}
void OnSize(int w, int h){
printf("OnSize\n");
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-50, 50, -50, 50, -50.0, 50.0);
glMatrixMode(GL_MODELVIEW);
}
void OnKey(unsigned char key, int x, int y){
printf("key = %x x=%d y=%d\n",key,x,y);
switch (key) {
case 27:
glutDestroyWindow(WinNumber);
exit(0);
break;
}
}
void OnMouse(int button, int state, int x, int y){
printf("button = %d, state = %d, (%d, %d)\n",button,state,x,y);
}
int main (int argc, char** argv) {
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(300, 300);
glutInitWindowPosition(50, 50);
WinNumber = glutCreateWindow("Base");
glutReshapeFunc(OnSize );
glutDisplayFunc(OnDraw );
glutKeyboardFunc(OnKey);
glutMouseFunc(OnMouse);
glutMainLoop();
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.125.162
→
11/13 22:30, , 1F
11/13 22:30, 1F
→
11/14 00:37, , 2F
11/14 00:37, 2F
→
11/14 00:37, , 3F
11/14 00:37, 3F
→
11/14 02:00, , 4F
11/14 02:00, 4F
→
11/14 02:01, , 5F
11/14 02:01, 5F
推
11/15 13:45, , 6F
11/15 13:45, 6F
→
11/15 15:47, , 7F
11/15 15:47, 7F
→
11/15 15:47, , 8F
11/15 15:47, 8F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章
52
80