<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>可可熊的窝 &#187; SDL</title>
	<atom:link href="http://cocobear.info/blog/category/my-programming/sdl/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocobear.info/blog</link>
	<description>K.I.S.S</description>
	<lastBuildDate>Sat, 10 Dec 2011 16:11:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>SDL中使用点阵字库-续</title>
		<link>http://cocobear.info/blog/2007/11/30/sdl%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93-%e7%bb%ad/</link>
		<comments>http://cocobear.info/blog/2007/11/30/sdl%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93-%e7%bb%ad/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 12:46:19 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/11/30/sdl%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93-%e7%bb%ad/</guid>
		<description><![CDATA[前一篇文章提到的是SDL中的英文点阵显示，原理上汉字的显示也是相同的，不过由于汉字较多，有不同的编码方式，因此花了些时间写了GBK和UTF-8两种编码的点阵显示，网上有很多文章介绍SDL中显示GBK编码的汉字，基本上是按搬DOS下汉字显示的方式，我主要说一下Linux的UTF-8编码的汉字显示。 由于点阵字库的排序都是按照区位码的方式在HZK16这样的文件中保存，因此如果需要显示汉字必须先得到汉字的区位码，由于GBK编码的汉字转换区位码比较简单: char *s = &#8220;中&#8221;; 区码：(unsigned char)s[0]－161; 位码：(unsigned char)s[1] &#8211; 161; 你至少得明白GBK编码的汉字是由两个字节组成。但是UTF-8与区位码之间的转换就比较麻烦，我到现在具体的实现还不清楚，大概就是先把UTF-8转换为GBK(使用查表的方式可能比较好)，然后再由GBK转换为区位码。在网上找了好长时间只找到了VB的实现，看不懂就先用了Linux下的ivcon这个库来进行编码转换，这个库应该是一般Linux系统都有的吧，如果没有的话我还得考虑自己实现这个编码转换。 具体的代码我就不贴出来了，因为还不完善，谁有兴趣可以给我发邮件索取。]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/11/30/sdl%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93-%e7%bb%ad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SDL使用点阵字库</title>
		<link>http://cocobear.info/blog/2007/11/27/sdl%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93/</link>
		<comments>http://cocobear.info/blog/2007/11/27/sdl%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 07:39:03 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/11/27/sdl%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93/</guid>
		<description><![CDATA[以前的文章中已经提到SDL是相对比较底层的一个开发库，因此需要自己手动写一些比较常用的功能库，前段时间完成了绘图库，这两天写程序时突然发现我还需要一个显示字符的函数，在SDL邮件列表里问了一下，大家的回答都是使用一个bmp的图像文件，把ASCII码的可见字符存在这幅图片中，然后读取图片中的信息，但这样不能灵活的控制字符的大小、颜色，那应该怎么办呢？点阵字库，就是这个东西，以前做DOS下的游戏时也接触到过比较熟悉，只是在寻找字库时花了好大功夫，最后还是从DOS98系统中找到了asc16这个ASCII的点阵字库文件。这个字库的大小是16&#215;8，还有些点阵字库的生成程序但都需要注册不然只能生成最大16&#215;16的字库，郁闷，有时间我自己研究下这个字库生成，写个Linux下的。 当然SDL还有相应的SDL_ttf可以使用，不过如果你对画面中字体要求不是很高的话没必要使用的。 我简单的说一下ASC16这个字库的使用: unsigned char match[16]; FILE *ASC; unsigned char temp = 0&#215;80; unsigned int addr = 0; /*offset of a character*/ int x1 = x; int y1 = y; if (size == 16) { ; } if ((ASC = fopen(&#8220;ASC16&#8243;,&#8221;rb&#8221;)) == NULL) { fprintf(stderr,&#8221;Open ASC16 error!\n&#8221;); return -1; } addr = c >1;/*右移，比较下一位*/ } [...]]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/11/27/sdl%e4%bd%bf%e7%94%a8%e7%82%b9%e9%98%b5%e5%ad%97%e5%ba%93/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>编译了个Win下的DouSnake</title>
		<link>http://cocobear.info/blog/2007/11/02/%e7%bc%96%e8%af%91%e4%ba%86%e4%b8%aawin%e4%b8%8b%e7%9a%84dousnake/</link>
		<comments>http://cocobear.info/blog/2007/11/02/%e7%bc%96%e8%af%91%e4%ba%86%e4%b8%aawin%e4%b8%8b%e7%9a%84dousnake/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 01:34:17 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/11/02/%e7%bc%96%e8%af%91%e4%ba%86%e4%b8%aawin%e4%b8%8b%e7%9a%84dousnake/</guid>
		<description><![CDATA[SDL是跨平台的开发库，因此移植到WIN下只需要重新编译一次就可以了，源代码我基本没做修改，只是把SDL的包含方式改为了： #include &#60;SDL/SDL.h&#62; 因为我不知道在WIN下如何使用-I/usr/include/SDL 使用的是Dev-C++ 4.9.2.2编译的，还做了个图标，呵呵，练练手，为了SuperMario的WIN版，没办法啊，有人期待WIN的啊！ 源码下载 游戏下载]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/11/02/%e7%bc%96%e8%af%91%e4%ba%86%e4%b8%aawin%e4%b8%8b%e7%9a%84dousnake/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DouSnake1.0正式版</title>
		<link>http://cocobear.info/blog/2007/10/23/dousnake10%e6%ad%a3%e5%bc%8f%e7%89%88/</link>
		<comments>http://cocobear.info/blog/2007/10/23/dousnake10%e6%ad%a3%e5%bc%8f%e7%89%88/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 12:33:49 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/10/23/dousnake10%e6%ad%a3%e5%bc%8f%e7%89%88/</guid>
		<description><![CDATA[较上次更新： 对各模块主要代码加入注释 加入避免食物产生在蛇身上 加入蛇是否碰到自己身体的检查 一些其它优化工作 下载地址： DouSnake1.0 by cocobear]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/10/23/dousnake10%e6%ad%a3%e5%bc%8f%e7%89%88/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>DouSnake with SDL</title>
		<link>http://cocobear.info/blog/2007/10/21/dousnake-with-sdl/</link>
		<comments>http://cocobear.info/blog/2007/10/21/dousnake-with-sdl/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 12:27:05 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/10/21/dousnake-with-sdl/</guid>
		<description><![CDATA[根据小林子同学的建议，写了个加强版的贪吃蛇： 同时有两条蛇存在，分别有不同的方向键操作，两个蛇不可以碰撞，也不可以吃对方的食物。两条蛇的速度会随着它们所吃的食物数量的增加而加快。 调用了上次写的draw.c。 存在的问题： 新生成的食物可能会在蛇的身上 DouSnake下载]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/10/21/dousnake-with-sdl/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SDL绘图库</title>
		<link>http://cocobear.info/blog/2007/10/20/sdl%e7%bb%98%e5%9b%be%e5%ba%93/</link>
		<comments>http://cocobear.info/blog/2007/10/20/sdl%e7%bb%98%e5%9b%be%e5%ba%93/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 15:59:46 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/10/20/sdl%e7%bb%98%e5%9b%be%e5%ba%93/</guid>
		<description><![CDATA[SDL本身并没有提供绘图的函数，不过已经有第三方的实现，比如SDL_draw。我看了它的一些代码，感觉很乱，里面宏的应用应该说是到了“滥用”的地步，（也许作者为了显示自己高超的架御宏的能力吧）。 只好自己去实现这些基本的绘图函数，目前已经可以实现点，线段，矩形，圆，椭圆的函数。这些基本上已经够用了，不过里面有个斜线的实现使用了别人的代码，没看懂他的实现方法，有时间再想想吧。 给个截图： BTW：SDL还是算比较底层的吧，这些很基本的东西也得自己写函数实现:-) 代码可以在这里下载。]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/10/20/sdl%e7%bb%98%e5%9b%be%e5%ba%93/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SDL初窥</title>
		<link>http://cocobear.info/blog/2007/09/04/sdl%e5%88%9d%e7%aa%a5/</link>
		<comments>http://cocobear.info/blog/2007/09/04/sdl%e5%88%9d%e7%aa%a5/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 05:03:57 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/09/04/sdl%e5%88%9d%e7%aa%a5/</guid>
		<description><![CDATA[这几天的时间读了Programming Linux Game这本书，作者是John R. Hall,作为一本入门级的Linux游戏编程读物，这本书讲得确实不错，从游戏分类，游戏的解剖，到Linux下开发工具介绍，开发库的介绍，以及一个完整的游戏开发实例，让读者可以快速的进入Linux游戏开发中去。本书重点介绍了SDL这个跨平台的开发库，而我看这本书也是由于喜欢SDL。不像其它GTK，QT等开发库，SDL给我的感觉入手非常容易，这个感觉也可能是我比较熟悉DOS下的图象处理，而SDL开发方式与DOS下游戏开发方式非常相似，同时SDL给人整体的框架非常清楚，让人很容易理解。 PLG这本书中的例子Penguin Warrior虽然很完整，不过我觉得作者似乎是为了介绍OpenAL,sndfile库而在例子中加入了这些东西，我觉得这个完全可以用SDL的库完成。当然这仅仅是我目前的感觉，我也没有亲自去做过例子，过一段时间我会自己做一个小游戏来测试是否可以只用SDL的库完成PLG书上那个例子。 貌似SDL在X中使用全屏有bug,在我使用的F7中，如果设置了全屏方式，X就会重启。]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/09/04/sdl%e5%88%9d%e7%aa%a5/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linux(F7)下使用SDL开发</title>
		<link>http://cocobear.info/blog/2007/09/01/linuxf7%e4%b8%8b%e4%bd%bf%e7%94%a8sdl%e5%bc%80%e5%8f%91/</link>
		<comments>http://cocobear.info/blog/2007/09/01/linuxf7%e4%b8%8b%e4%bd%bf%e7%94%a8sdl%e5%bc%80%e5%8f%91/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 16:42:46 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[SDL]]></category>
		<category><![CDATA[编程相关]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/2007/09/01/linuxf7%e4%b8%8b%e4%bd%bf%e7%94%a8sdl%e5%bc%80%e5%8f%91/</guid>
		<description><![CDATA[F7的软件包里边有SDL，如果你选择了一些基本的开发包，那么应该包含了SDL，就不需要了再另外安装了。可以使用下面的命令来查看SDL的安装情况： rpm -qa &#124; grep SDL 如果没有找到相应的RPM包，那么可以去这里下载。 SDL只包含了最基本的东西，更多的扩展可以在这里下载.其中常用的有SDL_image,SDL_ttf,SDL_mixer等，安装的时候需要注意带有devel的是开发库，而不带的是运行库，一般两个都需要安装。 安装好SDL以后就可以开始写第一个程序了，需要注意的是编译程序时应该加上SDL的链接，如： gcc -lSDL -o hello hello.c 如果你还使用了其它库，那么也要加上相应库的连接： gcc-lSDL -lSDL_image -o hello hello.c 下面就可以使用运行SDL程序了，在X下面应该不会有什么问题的，不过如果想在终端下运行可能就会出现问题了。一个先决条件是启动Linux时要在grub中加参数vga=0&#215;314（后面这个根据你的需要可以调整）,加这个参数后Linux终端就开始使用FrameBuffer了。 下面是不同分辨率、位数所对应的16进制数： &#124;640&#215;480 800&#215;600 1024&#215;768 1280&#215;1024 &#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 256 &#124; 0&#215;301 0&#215;303 0&#215;305 0&#215;307 32k &#124; 0&#215;310 0&#215;313 0&#215;316 0&#215;319 64k &#124; 0&#215;311 0&#215;314 0&#215;317 0x31A 16M&#124; 0&#215;312 0&#215;315 0&#215;318 0x31B 这样在终端下使用SDL的条件已经具备了，开始运行编译好的SDL程序（你可以在SDL官方网站上下载一些不错的例子），不过你很可能会得到下面的错误信息： Enable to open mouse. [...]]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2007/09/01/linuxf7%e4%b8%8b%e4%bd%bf%e7%94%a8sdl%e5%bc%80%e5%8f%91/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

