﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-all gone-随笔分类-OpenGL</title><link>http://www.blogjava.net/felicity/category/5832.html</link><description>all gone</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 01:44:47 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 01:44:47 GMT</pubDate><ttl>60</ttl><item><title>Eclipse + CDT + MinGW 下编写OpenGL程序</title><link>http://www.blogjava.net/felicity/archive/2006/06/16/53376.html</link><dc:creator>all gone</dc:creator><author>all gone</author><pubDate>Fri, 16 Jun 2006 11:33:00 GMT</pubDate><guid>http://www.blogjava.net/felicity/archive/2006/06/16/53376.html</guid><wfw:comment>http://www.blogjava.net/felicity/comments/53376.html</wfw:comment><comments>http://www.blogjava.net/felicity/archive/2006/06/16/53376.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/felicity/comments/commentRss/53376.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/felicity/services/trackbacks/53376.html</trackback:ping><description><![CDATA[
		<p>
				<br />Eclipse + CDT + MinGW环境的搭建比较简单，由于机器内存不够大，我在preference里将C＋＋的indexer都置为NO INDEXER。<br />安装MinGW后可以看到，在Include和Lib目录下有了与OpenGL相关的头文件和静态库。为了使用GLUT,我将glut.h放到了相应的<br />GL目录下，看到Lib目录下有libglut.a库文件，我没有将glut。lib放进去（后来发现libglut。a好像在windows不可用）。</p>
		<p>新建一个Standtart Make C++ project,将原来可运行的OpenGL程序复制过来，写好Makefile，结果编译的时候还是出现错误。<br />还好找到了这个非常有用的网页：<a href="http://www.mingw.org/MinGWiki/index.php/Glut">http://www.mingw.org/MinGWiki/index.php/Glut</a><br />按照上面列出的错误，我在每个＃include&lt;GL/glut.h&gt;前都加上#define _STDCALL_SUPPORTED，然后又将glut32。lib、<br />opengl32.lib、glu32.lib都放到当前的工程目录下，用”glut32。lib opengl32.lib glu32.lib“ 代替原来的 ”-lglut -lopengl32 -lglu32",<br />最后终于编译通过。</p>
		<p> </p>
<img src ="http://www.blogjava.net/felicity/aggbug/53376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/felicity/" target="_blank">all gone</a> 2006-06-16 19:33 <a href="http://www.blogjava.net/felicity/archive/2006/06/16/53376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下编写OpenGL程序的一些准备工作</title><link>http://www.blogjava.net/felicity/archive/2005/12/09/23193.html</link><dc:creator>all gone</dc:creator><author>all gone</author><pubDate>Fri, 09 Dec 2005 11:22:00 GMT</pubDate><guid>http://www.blogjava.net/felicity/archive/2005/12/09/23193.html</guid><wfw:comment>http://www.blogjava.net/felicity/comments/23193.html</wfw:comment><comments>http://www.blogjava.net/felicity/archive/2005/12/09/23193.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/felicity/comments/commentRss/23193.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/felicity/services/trackbacks/23193.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1pa32rjBo9-o-oOdxWtryZrg!106><STRONG>linux下编写OpenGL程序的一些准备工作</STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1pa32rjBo9-o-oOdxWtryZrg!106>
<P>需要用到的软件包有两个，glut 和tmake,分别可以从以下两个网址下载：<BR><A href="http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz"><U><FONT color=#0000ff>http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz</FONT></U></A><BR><A href="ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz"><U><FONT color=#0000ff>ftp://ftp.trolltech.com/freebies/tmake/tmake-1.8.tar.gz</FONT></U></A></P>
<P>下载后的文件假设都放在/usr/src中</P>
<P>首先是安装glut库，以下是从<A href="http://www.linux.com/"><U><FONT color=#0000ff>www.linux.com</FONT></U></A>找到的编译glut库的手册。</P>
<P>Install GLUT 3.7 Distribution (optional)</P>
<P>If you installed the MesaDemos/MesaLib package, then you have already installed GLUT 3.7 since it is included with MesaDemos. However, you may be interested in installing the GLUT </P>
<P>manpages and you can skip right to the "Install GLUT manual pages", below ...</P>
<P>Installing GLUT is a bit tricky. I'm not too familiar with imake, the program that it uses to manage the Makefiles, and didn't quite see how to get GLUT to install to where I wanted it (/usr/lib, </P>
<P>but MesaDemos will do this without any trouble though). It can be done manually anyhow:</P>
<P>&nbsp;cd /usr/src<BR>&nbsp;tar -xvzf glut-3.7.tar.gz<BR>&nbsp;cd glut-3.7</P>
<P>&nbsp;Read the file: README.linux<BR>&nbsp;cd linux<BR>&nbsp;READ the file: README<BR>&nbsp;cp Glut.cf ..<BR>&nbsp;cd ..<BR>&nbsp;Edit Glut.cf: remove any Mesa references.<BR>&nbsp;Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.<BR>&nbsp;In particular, replace:<BR>&nbsp;&nbsp;OPENGL = $(TOP)/../lib/libMesaGL.so<BR>&nbsp;&nbsp;GLU = $(TOP)/../lib/libMesaGLU.so<BR>&nbsp;with:<BR>&nbsp;&nbsp;OPENGL = -lGL<BR>&nbsp;&nbsp;GLU = -lGLU</P>
<P>&nbsp;./mkmkfiles.imake<BR>&nbsp;cd lib/glut<BR>&nbsp;cp /usr/src/glut-3.7/linux/Makefile .<BR>&nbsp;Edit the Makefile: remove any Mesa references.<BR>&nbsp;Replace any -lMesaGL -lMesaGLU with -lGL -lGLU if needed.<BR>&nbsp;In particular, replace:<BR>&nbsp;&nbsp;OPENGL = $(TOP)/../lib/libMesaGL.so<BR>&nbsp;&nbsp;GLU = $(TOP)/../lib/libMesaGLU.so<BR>&nbsp;with:<BR>&nbsp;&nbsp;OPENGL = -lGL<BR>&nbsp;&nbsp;GLU = -lGLU</P>
<P>&nbsp;make<BR>&nbsp;ln -s libglut.so.3.7 libglut.so<BR>&nbsp;ln -s libglut.so.3.7 libglut.so.3<BR>&nbsp;cp -d libglut.* /usr/lib<BR>&nbsp;cd ..<BR>&nbsp;cd gle<BR>&nbsp;# make a shared lib for libgle<BR>&nbsp;make<BR>&nbsp;gcc -shared -o libgle.so.3.7 *.o<BR>&nbsp;ln -s libgle.so.3.7 libgle.so<BR>&nbsp;ln -s libgle.so.3.7 libgle.so.3<BR>&nbsp;cp -d libgle.* /usr/lib<BR>&nbsp;cd ..<BR>&nbsp;cd mui<BR>&nbsp;# make a shared lib for libmui<BR>&nbsp;make<BR>&nbsp;gcc -shared -o libmui.so.3.7 *.o<BR>&nbsp;ln -s libmui.so.3.7 libmui.so<BR>&nbsp;ln -s libmui.so.3.7 libmui.so.3<BR>&nbsp;cp -d libmui.* /usr/lib</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Install the GLUT manual pages (not included with MesaDemos)<BR>&nbsp;cd /usr/src/glut-3.7<BR>&nbsp;make SUBDIRS=man Makefile<BR>&nbsp;cd man/glut<BR>&nbsp;make install.man<BR>&nbsp;ldconfig</P>
<P>&nbsp;cd ../../progs/demos/ideas<BR>&nbsp;# edit the Makefile, change OPENGL = -lGL and GLU = -lGLU<BR>&nbsp;make<BR>&nbsp;./ideas<BR>&nbsp;# test compiling some demos<BR>&nbsp;# take a look at which libraries have to be linked (-lX11 ...) in<BR>&nbsp;# the Makefiles.&nbsp; Qt's tmake program available at <A href="http://www.troll.no/"><U><FONT color=#0000ff>www.troll.no</FONT></U></A><BR>&nbsp;# is a quick way to make a Makefile but you have to edit it<BR>&nbsp;# and add the -l needed.<BR>ideas如果运行成功的话，说明glut已经可以用了,这时可以将include/GL下的glut等头文件复制到/usr/include中去。</P>
<P>上面的几步中,下载的glut包放在/usr/src目录下，如果放在其他目录下，将/usr/src改为相应的目录即可。<BR>此外应该注意的是两个Makefile文件的修改<BR>&nbsp;改&nbsp;<BR>·&nbsp;&nbsp;OPENGL = $(TOP)/../lib/libMesaGL.so<BR>&nbsp;&nbsp;GLU = $(TOP)/../lib/libMesaGLU.so<BR>&nbsp;为<BR>&nbsp;&nbsp;OPENGL = -lGL<BR>&nbsp;&nbsp;GLU = -lGLU<BR>因为所指定的目录中没有libMesaGL.so和libMesaGLU.so。</P>
<P>之后是tmake的配置，后面我们可以用它来生成pro工程文件和makefile文件。</P>
<P>先将下载的tmake解压缩，tar&nbsp; -zxvf&nbsp; tmake-1.8.tar.gz<BR>得到tmake-1.8目录,之后设置两个环境变量：PATH和TMAKEPATH<BR>PATH=$PATH:/usr/src/tmake-1.8/bin<BR>export PATH<BR>TMAKEPATH=/usr/src/tmake-1.8/lib/linux-g++<BR>export TMAKEPATH</P>
<P>新建一个测试目录test，将glut-3.7目录下的progs/redbook目录下的hello.c复制到test目录中</P>
<P>之后生成一个pro文件：progen&nbsp; -o hello.pro</P>
<P>然后生成makefile文件：tmake hello.pro -o Makefile</P>
<P>编辑生成的Makefile文件，在加载动态连接库的行里面加入 -lglut -lXi -lXmu</P>
<P>保存，make。</P>
<P>./hello 可以看到运行结果就可以了。</P></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 border=0>
<TBODY></TBODY></TABLE></TD></TR>
<TR>
<TD class=bvh8></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/felicity/aggbug/23193.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/felicity/" target="_blank">all gone</a> 2005-12-09 19:22 <a href="http://www.blogjava.net/felicity/archive/2005/12/09/23193.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FreeBSD下OpenGL程序的问题 </title><link>http://www.blogjava.net/felicity/archive/2005/12/09/23191.html</link><dc:creator>all gone</dc:creator><author>all gone</author><pubDate>Fri, 09 Dec 2005 11:20:00 GMT</pubDate><guid>http://www.blogjava.net/felicity/archive/2005/12/09/23191.html</guid><wfw:comment>http://www.blogjava.net/felicity/comments/23191.html</wfw:comment><comments>http://www.blogjava.net/felicity/archive/2005/12/09/23191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/felicity/comments/commentRss/23191.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/felicity/services/trackbacks/23191.html</trackback:ping><description><![CDATA[五一期间装了个FreeBSD，5.3 release，KDE桌面，感觉还是不错 
<P>
<P>前些天在Redhat Linux弄过OpenGL的开发环境，那时是自己编译的glut库，然后用tmake编写makefile，感觉很方便。</P>
<P>五一期间装了个FreeBSD，5.3 release，KDE桌面，感觉还是不错的，用多了感觉图形界面都快赶上WindowsXP了。</P>
<P>还是入正题吧。我想试试glut，pkg_info|grep glut</P>
<P>发现有个libglut.6...的，是支持OpenGL的，不知道是不是我想要的glut.</P>
<P>查找libglut.so,发现在/usr/X11R6/lib里面了，版本3，对头。</P>
<P>把在linux里用过的tmake，和opengl redbook源码拷了过来，设置好tmake相关的环境变量</P>
<P>当然最重要的是改相应的tmake.conf文件了，将glut相关的库加进去</P>
<P>新建目录test，将hello.c拷进去，</P>
<P>progen -o hello.pro</P>
<P>tmake hello.pro "CONFIG+=opengl" -o Makefile</P>
<P>可以先检查一下生成的Makefile，我没有发现问题</P>
<P>make，成功，生成可执行的hello</P>
<P>./hello出现一新窗口，本来应该高兴的，却有点不对劲，窗口上什么也没话</P>
<P>而且是白色背景，应该是黑色背景然后画一个白色的正方形。</P>
<P>google了好久，终于发现有人跟我遇到过同样的问题</P>
<P>解决的方法很简单 <STRONG>link的时候加上 -pthread选项,</STRONG>我先改了一下生成的Makefile，加上了－pthread</P>
<P>make，也通过了，看来问题有可能解决了</P>
<P>./hello 终于正确的结果出现了</P><img src ="http://www.blogjava.net/felicity/aggbug/23191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/felicity/" target="_blank">all gone</a> 2005-12-09 19:20 <a href="http://www.blogjava.net/felicity/archive/2005/12/09/23191.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>