手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu下Code::Blocks环境中Allegro5的安装配置

[日期:2012-11-01] 来源:Linux社区  作者:caimiyu [字体:大 中 小]

在code::blocks中

setting->compiler and debugger settings ->linker settings

点击add,选/usr/local/lib下所有的liballegro开头的文件,

setting->compiler and debugger settings ->search directories

点add,选/usr/local/include

确定后在code::blocks中建console项目,添加源代码

  1. #include <stdio.h> 
  2. #include <allegro5/allegro.h> 
  3.  
  4. int main(int argc, char **argv) 
  5. { 
  6.     ALLEGRO_DISPLAY *display = NULL; 
  7.  
  8.    if(!al_init()) { 
  9.       fprintf(stderr, "failed to initialize allegro!\n"); 
  10.       return -1; 
  11.    } 
  12.  
  13.    display = al_create_display(640, 480); 
  14.    if(!display) { 
  15.       fprintf(stderr, "failed to create display!\n"); 
  16.       return -1; 
  17.    } 
  18.  
  19.    al_clear_to_color(al_map_rgb(0,0,0)); 
  20.    al_flip_display(); 
  21.    al_rest(10.0); 
  22.    al_destroy_display(display); 
  23.    return 0; 
  24. } 

编译、运行即可。

游戏编写完成后如果需要隐藏console窗口,按照下面的设置即可。

Hiding the console window with Code::Blocks

When you create a "New Project", Code::Blocks, by default set it as a console project, that means that automatically will link a console to your project. This is very good because the console is great for debbuging, but once you're ready to release your game/application you don't need it anymore, so here are the simple steps to build your software without the console.

alt textTo get this menu, press the "project option" button, then press the "Build targets" tab and inside of the "Selected build target options" make sure that the "Type" option is set to "GUI application" instead of "Console application". As you can see in the "build targets" section there is only the release mode, that's because I never use the debug mode, but you should select to which type of build you want to hide the console.

Normally a debug mode should always have a console, while a release mode shouldn't, but it's not a rule.

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款