日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mac OS X Glut build instructions

發布時間:2023/12/13 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mac OS X Glut build instructions 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Mac OS X Glut build instructions(在Mac上用glut庫編寫OpenGL程序)

??????????????????????????????????????? Wentao Sun, Autodesk, Inc.

?


1. Building?GLUT?apps?under?Mac?OS?X

There?are?only?a?few?modifications?you?need?to?make?to?the
??robot.c?sample?to?get?it?compiled?on?your?Mac.??These
??instructions?were?tested?under?OS?X?10.3?(Panther)?with?XCode?1.1.
?
XCode?comes?with?everything?you?need?to?build?GL?apps,?including
??stable?versions?of?OpenGL,?GLUT,?gcc?and?all?the?related?make?tools.
?

XCode?by?default?places?the?include?files?for?GLUT?in?a?different
??location?than?MESA,?so?to?build?robot.c?you?need?to?change?line
??46?from

#include?
<GL/glut.h>
to
#include?
<GLUT/glut.h>

After?making?this?change?you?are?ready?to?build?from?the?command
??line:

gcc?-framework?GLUT?-framework?OpenGL?-framework?Cocoa
??robot.c?-o?robot


Note?the?use?of?the?-framework?option?to?make?use
??of?OS?X's?packaged?libraries.??The?Cocoa?framework?provides?the?OS
??services?required?by?GLUT,?such?as?interfacing?with?the?window
??manager?(Aqua).
I?will?post?a?sample?makefile?here?which?can?be?used?to?compile your?files?under?OS?X?or?Linux?as?necessary?without?modification;?as soon?as?my?Sutherland?account?is?activated.

?

?Source code:

#include?<iostream>
using?namespace?std;
#include?
<math.h>

float?myAngle;
float?myTime;

//codefragmentbegin,headerInclude
#include?<GLUT/glut.h>

//codefragmentend,headerInclude

//codefragmentbegin,app
void?prepareOpenGL()
{
????myAngle?
=?0;
????myTime?
=?0;
}

void?draw()
{
????glClearColor(?
0,?.5,?.8,?1?);
????glClear(?GL_COLOR_BUFFER_BIT?
|?GL_DEPTH_BUFFER_BIT?);

????glMatrixMode(?GL_MODELVIEW?);
????glLoadIdentity();
????glRotatef(?myAngle,?
0,?0,?1?);

????glTranslatef(?
0,?0,?1?);
????glColor3f(?
0,?1,?0?);
????glBegin(?GL_QUADS?);
????
float?ww?=?.9;
????
float?hh?=?.9;
????glTexCoord2f(?
0,?0?);
????glVertex3f(?
-ww,?-hh,?0?);
????glTexCoord2f(?
1,?0?);
????glVertex3f(??ww,?
-hh,?0?);
????glTexCoord2f(?
1,?1?);
????glVertex3f(??ww,??hh,?
0?);
????glTexCoord2f(?
0,?1?);
????glVertex3f(?
-ww,??hh,?0?);
????glEnd();

????glutSwapBuffers();
}

void?angleUpdate(?int?delay?)
{
????
float?twopi?=?2?*?M_PI;
????myTime?
=?(?myTime?>?twopi?)???0?:?myTime?+?.03;
????myAngle?
=?sinf(?twopi?*?myTime?);
????glutTimerFunc(?delay,?angleUpdate,?delay?);
????glutPostRedisplay();
}

int?main(?int?argc,
??????????
char?*?argv[]?)
{
????glutInit(?
&argc,?argv?);

????
//?choose?a?visual?and?create?a?window
????glutInitDisplayString(??"stencil>=2?rgb~8?double?depth>=16?samples"?);
//????glutInitDisplayMode(?GLUT_RGB?|?GLUT_DOUBLE?|?GLUT_DEPTH?);
????glutInitWindowSize(?450,?300?);
????glutCreateWindow(?
"GLUT?Configuration?Example"?);

????
//?initalize?our?opengl?(context?is?now?valid)
????prepareOpenGL();

????
//?register?callback?functions
????int?delay?=?50;
????glutTimerFunc(?delay,?angleUpdate,?delay?);
????glutDisplayFunc(?draw?);
????glutMainLoop();

}

//codefragmentend,app

void?altinit()
{
//codefragmentbegin,stringinit
????glutInitDisplayString(??"stencil>=2?rgb~8?double?depth>=16?samples"?);
//codefragmentend,stringinit
}

?

Build commands:

?

?g++?-framework?GLUT?-framework?OpenGL??main.cpp?-o?test

?

Run:

./test

?

?

?

Notice:

(1) Framework 類型提供的lib和其他.a & .dylib的庫文件不同;

(2) 編譯時使用 -framework GLUT的編譯選項。


?

轉載于:https://www.cnblogs.com/SunWentao/archive/2008/08/18/1270497.html

總結

以上是生活随笔為你收集整理的Mac OS X Glut build instructions的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。