⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lua_gui.c

📁 lua脚本语言调用allegro游戏程序库的接口-跨平台
💻 C
字号:
/****************************************************************************
**                                                                         **
**                  LuAllegro library - Lua port of Allegro                **
**                       Copyright (C) 2005 Peter Jamroz                   **
**                 e-mail: peterjam at poczta dot onet dot pl              **
**                                                                         **
**        Permission to use, copy, modify, publish this software           **
**    is hereby granted to any person obtaining a copy of this software,   **
**                              FREE OF CHARGE,                            **
**                     under the following conditions:                     **
**                                                                         **
** 1:  The above copyright notice and this permission notice shall be      **
**     included in all copies or substantial portions of the Software.     **
**                                                                         **
** 2:  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,     **
**   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    **
**   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.**
**   IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE LIABLE FOR ANY    **
**   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  **
**   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     **
**   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                **
**                                                                         **
****************************************************************************/
#include <allegro.h>

#include "lua_aleg.h"
#include "lua_gui.h"



//------------------------------------------------------------------------------------------
//----- Allegro chapter "GUI Routines"  ----------------------------------------------------
//------------------------------------------------------------------------------------------




//------------------------------------------------------------------------------------------
//card,w,h = gfx_mode_select(nil);
static int l_gfx_mode_select(lua_State* L)
{
int card,w,h;
if (gfx_mode_select(&card,&w,&h))
   {
   lua_pushnumber (L, card);
   lua_pushnumber (L, w);
   lua_pushnumber (L, h);
   return 3;
   }
else
   return 0;
}

//------------------------------------------------------------------------------------------
//card,w,h,color_depth = gfx_mode_select_ex(card,w,h,color_depth);
static int l_gfx_mode_select_ex(lua_State* L)
{
int card         = lua_tonumber(L,1);
int w            = lua_tonumber(L,2);
int h            = lua_tonumber(L,3);
int color_depth  = lua_tonumber(L,4);

if (!card) 
   card=GFX_SAFE;

if (!(w) || !(h))
  { w = 320; h=200; }

if (!color_depth)
   color_depth=8;

if (gfx_mode_select_ex(&card,&w,&h,&color_depth))
   {
   lua_pushnumber (L, card);
   lua_pushnumber (L, w);
   lua_pushnumber (L, h);
   lua_pushnumber (L, color_depth);
   return 4;
   }
else
   return 0;
}




//---------------------------------------------------------------------------------------------
static const struct luaL_reg allegro_gui_lib [] = {
      {"gfx_mode_select",     l_gfx_mode_select},
      {"gfx_mode_select_ex",  l_gfx_mode_select_ex},
      {NULL,                  NULL}  /* sentinel */
    };


//-----------------------------------------------------------------------------------------------
int luaopen_allegro_gui(lua_State *L) 
{
int i=0;

   luaL_openlib(L, "allegro",   allegro_gui_lib,   0);
 
   return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -