免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1324 | 回复: 0
打印 上一主题 下一主题

有人用SDL写过程序吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-19 13:14 |只看该作者 |倒序浏览
一个个简单SDL程序,运行的时候出现错误:
"Fatal signal: Segmentation Fault (SDL Parachute Deployed)"
我用的是SDL-devel-1.2.8-1
运行别的Linux游戏一点问题都没有
就是我自己写的这个不行
谁能帮忙看看
谢谢了

  1. #include "../my.h"
  2. #include <SDL/SDL.h>;

  3. void print_Color(SDL_Color *c)
  4. {
  5.         printf("--SDL_Color--\n");
  6.         printf("SDL_Color->;r:%d\n", c->;r);
  7.         printf("SDL_Color->;g:%d\n", c->;g);
  8.         printf("SDL_Color->;b:%d\n", c->;b);
  9.         printf("SDL_Color->;unused:%d\n", c->;unused);
  10.         printf("--end SDL_Color--\n");
  11. }
  12. void print_Palette(SDL_Palette *p)
  13. {
  14.         printf("--SDL_Palette--\n");
  15.         printf("SDL_Palette->;ncolors:%d\n", (*p).ncolors); // can not use, I don't know why
  16.         printf("SDL_Palette->;colors->;:\n");
  17.         print_Color(p->;colors);
  18.         printf("--end SDL_Palette--\n");
  19. }
  20. void print_PixelFormat(SDL_PixelFormat *pf)
  21. {
  22.         printf("--SDL_PixelFormat--\n");
  23.         printf("SDL_PixelFormat->;palette->;:\n");
  24.         print_Palette(pf->;palette);
  25.         printf("SDL_PixelFormat->;BitsPerPixel:%d\n",pf->;BitsPerPixel);
  26.         printf("SDL_PixelFormat->;BytesPerPixel:%d\n",pf->;BytesPerPixel);
  27.         printf("SDL_PixelFormat->;Rmask:%d, Gmask:%d, Bmask:%d, Amask:%d\n",pf->;Rmask, pf->;Gmask, pf->;Bmask, pf->;Amask);
  28.         printf("SDL_PixelFormat->;Rshift:%d, Gshift:%d, Bshift:%d, Ashift:%d\n",pf->;Rshift, pf->;Gshift, pf->;Bshift, pf->;Ashift);
  29.         printf("SDL_PixelFormat->;Rloss:%d, Gloss:%d, Bloss:%d, Aloss:%d\n",pf->;Rloss, pf->;Gloss, pf->;Bloss, pf->;Aloss);
  30.         printf("SDL_PixelFormat->;colorkey:%d\n",pf->;colorkey);
  31.         printf("SDL_PixelFormat->;alpha:%d\n",pf->;alpha);
  32.         printf("--end SDL_PixelFormat--\n");
  33. }
  34. void print_VideoInfo(SDL_VideoInfo *vi)
  35. {
  36.         printf("--SDL_VideoInfo--\n");
  37.         printf("SDL_VideoInfo->;wm_available:%d\n",vi->;wm_available);
  38.         printf("SDL_VideoInfo->;blit_hw:%d\n",vi->;blit_hw);
  39.         printf("SDL_VideoInfo->;blit_hw_CC:%d\n",vi->;blit_hw_CC);
  40.         printf("SDL_VideoInfo->;blit_hw_A:%d\n",vi->;blit_hw_A);
  41.         printf("SDL_VideoInfo->;blit_sw:%d\n",vi->;blit_sw);
  42.         printf("SDL_VideoInfo->;blit_sw_CC:%d\n",vi->;blit_sw_CC);
  43.         printf("SDL_VideoInfo->;blit_sw_A:%d\n",vi->;blit_sw_A);
  44.         printf("SDL_VideoInfo->;blit_fill:%d\n",vi->;blit_fill);
  45.         printf("SDL_VideoInfo->;video_mem:%d\n",vi->;video_mem);
  46.         printf("SDL_VideoInfo->;vfmt->;:\n");
  47.         print_PixelFormat(vi->;vfmt);
  48.         printf("--end SDL_VideoInfo--\n");
  49. }

  50. int main(int argc, char* argv[])
  51. {
  52.         SDL_VideoInfo *vi;
  53.         SDL_Surface *screen;
  54.         int init_t =  SDL_INIT_VIDEO | SDL_INIT_CDROM | SDL_INIT_TIMER | SDL_INIT_EVENTTHREAD;

  55.         atexit(SDL_Quit);
  56.         printf("Game Start...\n");
  57.         if (SDL_Init(init_t) < 0) {
  58.                 fprintf(stderr, "SDL_init error\n");
  59.                 return 1;
  60.         }
  61.         if ((vi = (SDL_VideoInfo *)SDL_GetVideoInfo()) == NULL) {
  62.                 printf("SDL_GetVideoInfo() error\n");
  63.                 return 1;
  64.         }
  65.         print_VideoInfo(vi);

  66.         printf("Exit.\n", argv[0]);
  67.         return 0;
  68. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP