lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Dear Sir,

 

I am trying to bring some interactivity to my c appliaction,

To begin with, I am trying to draw a rectangle which is defined in Gui.c from LUA in my application Application_main.c.

 

Gui.c

 

/*structure actually defined in Gui.h*/

 

typedef struct {

char  R;

char  G;

char  B;

} Gui_color_t;

 

Int Gui_Draw_Rectangle( x,y,Width,Height, (Gui_color_t *)color){

 

******Some code*******

}

 

SCSL_Draw_Rect(lua_State*L)

{

      GUI_Color_t asvDrawColor = {31, 31, 0};

 

      int i,j[4];

      int n = lua_gettop(L);

     

      for (i = 1; i <= n; i++){

        if (!lua_isnumber(L, i)){

           lua_pushstring(L, "incorrect argument");

           lua_error(L);

         }

        j[(i-1)] = lua_tonumber(L, i);

 

        printf("from stack %d\n",j[(i-1)]);

      }

      GUI_DrawRectangle(j[1], j[2], j[3], j[4] &asvDrawColor);

}

 

Application_main.c

 

Int Lua_main( void )

{

            int error;

            lua_State *L = lua_open();   /* opens Lua */

            luaL_Reg Creg;

 

            lua_Integer n;

            luaL_openlibs(L);

 

            printf("luaL_openlibs\n");

            lua_pushcfunction(L, SCSL_Draw_Rect(L));

            printf("lua_pushcfunction\n");

 

/*            n = 0;

            lua_pushinteger(L, n);*/

            n = 100;

            lua_pushinteger(L, n);

            n = 100;

            printf("lua_pushinteger\n");

            lua_pushinteger(L, n);

            n = 300;

            lua_pushinteger(L, n);

            n = 300;

            lua_pushinteger(L, n);

            printf("lua_call\n");

            lua_call( L, 5, 0);

            printf("lua_call\n");

            lua_close(L);

 

            return 0;

}

 

 

Int Application_MainEntry ( )

{

            ********Some code ********

Lua_main();

 

*******Some Code********

}

 

 

I get all the prints in the Lua_main function. I see all the prints on the console but not the rectangle.

 

Can you help me out in this regard.

 

Thanks in advance.

 

Best Regards,

Subhash Patil

 



DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.