Пример #1
0
static int ScriptImage__tostring(lua_State *L) {
    AImage ** self;
    self = checkimage(L, 1);

    lua_pushfstring(L, "Image (%s)", (*self)->name());
    return 1;
}
Пример #2
0
int Lua_Framebuffer_setRenderTarget(lua_State *L)
{
	if(!supported.FBO) return 0;
	if (lua_gettop(L) == 0) 
	{
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
		//~ glDrawBuffer(GL_BACK);
		glViewport( 0, 0, screen->w, screen->h );
		glMatrixMode( GL_PROJECTION );
		glLoadIdentity();
		glOrtho( 0, screen->w, screen->h, 0, -1, 1 );
		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
	}
	else
	{
		Lua_Image *image = checkimage(L);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, image->fbo);
		//~ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
		glViewport( 0, 0, image->w, image->h );
		glMatrixMode( GL_PROJECTION );
		glLoadIdentity();
		glOrtho( 0, image->w, image->h, 0, -1, 1 );
		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
	}
	return 0;
}
Пример #3
0
/**
 * Wrapper for the cc3 library's cc3_frame_diff_scanline function.
 * Just gets the framediff object and the image object passed in from lua,
 * calls the c function and then sticks the integer returned onto the stack.
 */
int framediff_scanline(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);
    cc3_frame_diff_pkt_t *pkt = checkframediff(_l, 2);

    int rv = cc3_frame_diff_scanline(img, pkt);
    lua_pushinteger(_l, rv);
    
    return 1;
}
Пример #4
0
/**
 * Free all memory associated with this image.
 */
int image_dispose(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);

    if (img != NULL && img->pix != NULL) {
        free(img->pix);
        img->pix = NULL;
    }

    return 0;
}
Пример #5
0
static int ScriptImage_Copy(lua_State *L) {
    AImage * bar;
    AImage ** self;

    self = checkimage(L, 1);
    bar = (*self)->copy();
    putimage(L, bar);

    return 1;
}
Пример #6
0
/**
 * Wrapper function for cc3_pixbuf_read_rows.  After double-checking the 
 * lua arguments, just call the function and stick the return value on 
 * the lua stack.
 */
int pixbuf_read_rows(lua_State *_l) {
    int rv;
    cc3_image_t *img = checkimage(_l);
    int num_rows = luaL_checkinteger(_l, 2);

    luaL_argcheck(_l, num_rows > 0 && num_rows <= img->height, 2, "Num Rows cannot be bigger than img:");
    rv = cc3_pixbuf_read_rows(img->pix, num_rows);
    lua_pushinteger(_l, rv);

    return 1;
}
Пример #7
0
static int ScriptImage_Tint(lua_State *L) {
    AImage ** self;

    self = checkimage(L, 1);

    (*self)->tint(
        luaL_checknumber(L, 2) * 255.0,
        luaL_checknumber(L, 3) * 255.0,
        luaL_checknumber(L, 4) * 255.0,
        luaL_checknumber(L, 5) * 255.0
    );

    return 0;
}
Пример #8
0
/**
 * Get the width of the cc3_image_t passed as first param
 */
int image_get_width(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);
    lua_pushinteger(_l, img->width);
    return 1;
}
Пример #9
0
/**
 * Set the channels of the cc3_image_t passed as first param to the value
 * passed in the second parameter.
 */
int image_set_channels(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);
    img->channels = luaL_checknumber(_l, 2);
    return 0;
}
Пример #10
0
/**
 * Get the channels of interest of the cc3_image_t passed as first param.
 */
int image_get_channels(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);
    lua_pushinteger(_l, img->channels);
    return 1;
}
Пример #11
0
/**
 * Get the height of the cc3_image_t passed as first param.
 */
int image_get_height(lua_State *_l) {
    cc3_image_t *img = checkimage(_l);
    lua_pushinteger(_l, img->height);
    return 1;
}
Пример #12
0
/*-----------------------------------------------------------------------------------------*/
static int ScriptImage__gc(lua_State *L) {
    printf("Trashing node %p\n", checkimage(L, 1));
    return 0;
}
Пример #13
0
int main(int argc,char **argv)
{
 int   index ;		/* used in argument processing */
 int   erase = FALSE ;	/* perform erase on FlashEPROM */
 int   verify = FALSE ; /* verify file against FlashEPROM (do not program) */
 char *infile = NULL ;	/* input filename */
 word  filesize ;	/* input file size in bytes */
 char *buffer ;		/* image file buffer */
 FILE *ihand ;		/* input FILE handle */

 /* verify FlashEPROM presence */
 if (!FlashCheck())
  {
   fprintf(stderr,"%s: FlashEPROM not found\n",whoami) ;
   exit(9) ;
  }

 for (index=1; (index < argc); index++)
  {
   if (argv[index][0] == '-')
    {
     switch (argv[index][1])
      {
       case 'h' : /* help */
                  usage() ;

       case 'e' : /* erase */
                  erase = TRUE ;
                  break ;

       case 'v' : /* verify */
	          verify = TRUE ;
                  break ;
      }
    }
   else
    {
     /* default input file */
     if (infile == NULL)
      {
       infile = argv[index] ;
       if (!checkimage(infile,&filesize))
        {
	 fprintf(stderr,"%s: \"%s\" not found\n",whoami,infile) ;
	 exit(2) ;
	}
       if (filesize > flash_size)
        {
	 fprintf(stderr,"%s: specified file bigger than &%08X bytes\n",whoami,flash_size) ;
	 exit(3) ;
	}
      }
     else
      {
       fprintf(stderr,"%s: unrecognised arg \"%s\"\n",whoami,argv[index]) ;
       exit(4) ;
      }
    }
  }

 if (erase && verify)
  {
   fprintf(stderr,"%s: -e and -v are mutually exclusive\n",whoami) ;
   exit(5) ; 
  }

 if ((infile == NULL) && !erase)
  {
   fprintf(stderr,"%s: Image file not specified\n",whoami) ;
   exit(5) ;
  }

 /* Erase the FlashEPROM is the user desires */
 if (erase)
  {
   if ((index = FlashErase()) != -1)
    {
     fprintf(stderr,"%s: FlashEPROM erase failed at index &%08X\n",whoami,index) ;
     exit(10) ;
    }
  }

 if (infile != NULL)
  {
   if ((buffer = (char *)malloc(filesize)) == NULL)
    {
     fprintf(stderr,"%s: unable to allocate image buffer memory\n",whoami) ;
     exit(6) ;
    }

   if ((ihand = fopen(infile,"r")) == NULL)
    {
     fprintf(stderr,"%s: unable to open file \"%s\"\n",whoami,infile) ;
     exit(7) ;
    }

   if (fread(buffer,filesize,1,ihand) != 1)
    {
     fprintf(stderr,"%s: unable to read data from file \"%s\"\n",whoami,infile);
     exit(8) ;
    }
   fclose(ihand) ;

   if (verify)
    {
     if ((index = FlashVerify(buffer,filesize)) != -1)
      {
       fprintf(stderr,"%s: verify failed at index &%08X\n",whoami,index) ;
       exit(10) ;
      }
    }
   else
    {
     if ((index = FlashWrite(buffer,filesize)) != -1)
      {
       fprintf(stderr,"%s: write failed at index &%08X\n",whoami,index) ;
       exit(10) ;
      }
    }
  }
 return(0) ;
}