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, .81 );
    glClear( GL_COLOR_BUFFER_BIT 
| GL_DEPTH_BUFFER_BIT );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glRotatef( myAngle, 
001 );

    glTranslatef( 
001 );
    glColor3f( 
010 );
    glBegin( GL_QUADS );
    
float ww = .9;
    
float hh = .9;
    glTexCoord2f( 
00 );
    glVertex3f( 
-ww, -hh, 0 );
    glTexCoord2f( 
10 );
    glVertex3f(  ww, 
-hh, 0 );
    glTexCoord2f( 
11 );
    glVertex3f(  ww,  hh, 
0 );
    glTexCoord2f( 
01 );
    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( 450300 );
    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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/264527.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

李战java_【阿里李战】解剖JavaScript中的 null 和 undefined

在JavaScript开发中&#xff0c;被人问到&#xff1a;null与undefined到底有啥区别&#xff1f;一时间不好回答&#xff0c;特别是undefined&#xff0c;因为这涉及到undefined的实现原理。于是&#xff0c;细想之后&#xff0c;写下本文&#xff0c;请各位大侠拍砖。总所周知&…

Android -- 获取摄像头帧数据解码

由于Android下摄像头预览数据只能 ImageFormat.NV21 格式的&#xff0c;所以解码时要经过一翻周折. Camera mCamera Camera.open();Camera.Parameters p mCamera.getParameters();p.setPreviewFormat(ImageFormat.NV21);/*这是唯一值&#xff0c;也可以不设置。有些同学可能…

跨域方法

1.jsonp,原理利用script的src属性(像img,iframe等有src属性的都支持跨域)引入js文件&#xff0c;并在引入成功后调用回调函数&#xff0c;数据通过参数的形式传过来。 例&#xff1a; 2.window.name 3.document.domain 4.h5的方法&#xff1a;window.postMessage 5.flash 6.COR…

C#发送Email邮件方法总结

通过.Net FrameWork 2.0下提供的“System.Net.Mail”可以轻松的实现&#xff0c;本文列举了3种途径来发送&#xff1a; 1.通过Localhost&#xff1b; 2.通过普通SMTP; 3.通过SSL的SMTP; 下面一个一个来说&#xff1a; 1.通过LocalHost 1public void SendMailLocalhost() 2 ...{…

java多线程之wait_(三)java多线程之wait notify notifyAll

引言今天我打算讲一下Object.wait,Object.notify,Object.notifyAll这三个方法. 首先我们查看一下api看看,官方api对这几个方法的介绍.理论Object.wait(): 导致当前线程一直等待,直到另一外一个线程用同一个对象调用Object.notify或Object.notifyAll方法.换种说法,就是调用Objec…

得不到和已失去

凉凉滑滑&#xff0c;这样的天气&#xff0c;我该喜欢的&#xff0c;就像在酷暑时所盼望的一样。可是又一次在凌晨凉飕飕的空气中醒来时&#xff0c;为什么我却倍感凄凉的蜷成一团怀念盛夏的热烈了呢。更加恶劣的是&#xff0c;为什么在正午炙热的阳光下&#xff0c;我却又在怀…

lightoj 1020 (博弈)

思路&#xff1a;很简单的博弈&#xff0c;找出每个人先拿的必胜态进行状态转移即可。#include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main(){int t, n, CASE(0);char …

2019 GDUT Rating Contest II : A. Taming the Herd

题面&#xff1a; A. Taming the Herd Input file: standard inputOutput file: standard outputTime limit: 1 secondMemory limit: 256 megabytesEarly in the morning, Farmer John woke up to the sound of splintering wood. It was the cows, and they were breaking out…

仅对此用户禁用 java_Spring Security实现禁止用户重复登陆的配置原理

这篇文章主要介绍了Spring Security实现禁止用户重复登陆的配置原理,文中通过示例代码介绍的非常详细&#xff0c;对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下系统使用了Spring Security做权限管理&#xff0c;现在对于系统的用户&#xff0c;需要改动配…

SQL server 系统优化--通过执行计划优化索引(1) (转)

SQL server 系统优化--通过执行计划优化索引&#xff08;1&#xff09; 前几天,远离上海&#xff0c;到了温州&#xff0c;在客户的这边处理系统慢&#xff0c;该系统每天正常down机7次左右&#xff0c;在线人员一多&#xff0c;系统运行缓慢&#xff0c;严重影响业务操作,到了…

Linux运维系统工程师系列---13

定制安装定制安装&#xff0c;也叫源码安装&#xff0c;需要自己编译源代码的安装方式步骤&#xff1a;1、解压源代码包2、配置 configure3、编译 make4、安装 make install接下来开始做实验&#xff0c;希望朋友们自己动手实践&#xff0c;有啥不清楚的可以直接提问我&#xf…

java system.setproperties_在JAVA中 System.getProperty 和 System.setProperty 方法.

今天着手研究TOMCAT源码.在刚開始的时候Startup类中init方法中调用非常多次System.getProperty和System.setProperty的方法.后来经过网上搜索才得知,这是对操作系统变量操作的方法.System还提供一个静态方法 System.getProperties(). 这种方法能够罗列出你系统的所有变量.调用S…

雷林鹏分享:XML 编码

XML 编码 XML 文档可以包含非 ASCII 字符&#xff0c;比如挪威语 &#xff0c;或者法语 。 为了避免错误&#xff0c;需要规定 XML 编码&#xff0c;或者将 XML 文件存为 Unicode。 XML 编码错误 如果您载入一个 XML 文档&#xff0c;您可以得到两个不同的错误&#xff0c;…

C#中理解接口以及接口的作用

在C#的开发中&#xff0c;接口是非常重要也非常好用的。可是很多时候很多人都不是很了解接口的做用&#xff0c;以及该如何使用。下面我们就来理解接口的作用&#xff0c;并看看如何使用吧。假设我们公司有两种程序员&#xff1a;VB程序员&#xff0c;指的是用VB写程序的程序员…

java开发中遇到的问题及解决方法(持续更新)

工作中&#xff0c;以C/C开发为主&#xff0c;难免与其他服务和Web进行交换&#xff0c;Java开发必不可少&#xff0c;又不想动用Eclipse大家伙&#xff0c;只能自己动手编写脚本进行Java代码的编译和运行&#xff0c;期间遇到的一些问题&#xff0c;记录下来供自己和大家参考。…

c语言转化java工具_详解C语言常用的一些转换工具函数

1、字符串转十六进制代码实现&#xff1a;void StrToHex(char *pbDest, char *pbSrc, int nLen){char h1,h2;char s1,s2;int i;for (i0; i{h1 pbSrc[2*i];h2 pbSrc[2*i1];s1 toupper(h1) - 0x30; //toupper 转换为大写字母if (s1 > 9)s1 - 7;s2 toupper(h2) - 0x30;if (…

vue项目使用eslint

转载自 https://www.cnblogs.com/hahazexia/p/6393212.html eslint配置方式有两种&#xff1a; 注释配置&#xff1a;使用js注释来直接嵌入ESLint配置信息到一个文件里配置文件&#xff1a;使用一个js&#xff0c;JSON或者YAML文件来给整个目录和它的子目录指定配置信息。这些配…

提里奥·弗丁(魔兽世界里的NPC)

弗丁的名字大家也许并不熟悉&#xff1b;但白银之手骑士团的大名&#xff0c;恐怕天下无人不识。作为白银之手骑士团创始人光明使者乌瑟尔的亲密友人&#xff0c;当年的弗丁是骑士团中地位最为崇高的圣骑士之一。在第二次战争中身先士卒的表现无愧白银之手的神圣之名。荣归故里…

java http请求插件_java http请求工具整理

处理了http 的get和post的请求&#xff0c;分别支持同步处理&#xff0c;异步处理两种方式下见代码。Slf4jpublic class HttpUtils { /** * 同步请求http请求 不推荐 * * param url * return */ public static byte[] httpGetSync(String url) { HttpGet httpGet new HttpGet(…

mysql存储过程语法及实例

2019独角兽企业重金招聘Python工程师标准>>> 存储过程如同一门程序设计语言&#xff0c;同样包含了数据类型、流程控制、输入和输出和它自己的函数库。 --------------------基本语法-------------------- 一.创建存储过程 create procedure sp_name() begin ......…