示例#1
0
    static bool bSetupPixelFormat(HDC hdc, int buffer) {
      PIXELFORMATDESCRIPTOR pfd;

      // clean out the descriptor
      memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));

      pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
      pfd.nVersion = 1;
      pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
      if (buffer == 2)
        pfd.dwFlags = pfd.dwFlags | PFD_DOUBLEBUFFER;
      pfd.dwLayerMask = PFD_MAIN_PLANE;
      pfd.iPixelType = PFD_TYPE_RGBA;
      pfd.cColorBits = 24;
      pfd.cRedBits = 8;
      pfd.cBlueBits = 8;
      pfd.cGreenBits = 8;
      pfd.cDepthBits = 16;
      pfd.cAccumBits = 0;
      pfd.cStencilBits = 8;

      int pixelformat;
      if ( (pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0 )
        {
            throw(GemException("ChoosePixelFormat failed"));
        }
      if (SetPixelFormat(hdc, pixelformat, &pfd) == FALSE)
        {
            throw(GemException("SetPixelFormat failed"));
          return(false);
        }
      return(true);
    }
示例#2
0
/////////////////////////////////////////////////////////
//
// pix_convolve
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_convolve :: pix_convolve(t_floatarg fRow, t_floatarg fCol) :
  m_imatrix(NULL),
  m_irange(255),
  m_rows(0), m_cols(0),
  m_chroma(0)
{
  int row = static_cast<int>(fRow);
  int col = static_cast<int>(fCol);

  if (!row || !col ) {
    throw(GemException("matrix must have some dimension"));
  }

  if (!(row % 2) || !(col % 2) ) {
    throw(GemException("matrix must have odd dimensions"));
  }

  m_rows = row;
  m_cols = col;
  m_imatrix = new signed short[m_rows * m_cols];

  // zero out the matrix
  int i;
  for (i = 0; i < m_cols * m_rows; i++) {
    m_imatrix[i] = 0;
  }
  // insert a one for the default center value (identity matrix)
  m_imatrix[ ((m_cols / 2 + 1) * m_rows) + (m_rows / 2 + 1) ] = 255;

  inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"),
            gensym("ft1"));
  inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("list"),
            gensym("matrix"));
}
示例#3
0
  FFPlugin(std::string name, const t_canvas*canvas=NULL)
    : m_plugin(NULL)
    , m_instance(NULL)
    , m_rgba(false)
    , m_type(FF_EFFECT)
    , m_majorVersion(0)
    , m_minorVersion(0)
    , m_cancopy(false)
#ifdef DL_OPEN
    , m_dlhandle(NULL)
#endif
#ifdef _WIN32
    , m_w32handle(NULL)
#endif
  {
    if(!open(name, canvas)) {
      throw(GemException(std::string("unable to open '"+name+"'")));
      return;
    }

    if(!init_()) {
      throw(GemException(std::string("unable to initialize '"+name+"'")));
      return;
    }
  }
示例#4
0
  static GemDylibHandle*open(const std::string filename) {
    GemDylibHandle*handle=new GemDylibHandle();

    char buf[MAXPDSTRING];
    if(filename.empty()) {
      throw(GemException(std::string("No DyLib name given!")));
    }

    sys_bashfilename(filename.c_str(), buf);
  
#ifdef DL_OPEN
    handle->dlhandle=dlopen(filename.c_str(), RTLD_NOW);
    if(handle->dlhandle) {
      handle->fullname=filename;
      return handle;
    }
#endif
#ifdef _WIN32
    UINT errorboxflags=SetErrorMode(SEM_FAILCRITICALERRORS);
    handle->w32handle=LoadLibrary(buf);
    errorboxflags=SetErrorMode(errorboxflags);
    if(handle->w32handle) {
      handle->fullname=filename;
      return handle;
    }
#endif

    delete handle;
    handle=NULL;

    std::string errormsg;
#ifdef DL_OPEN
    errormsg=dlerror();
    if(!errormsg.empty()) {
      std::string error="dlerror '";
      error+=errormsg;
      error+="'";
      throw(GemException(error));
    }
#endif
#ifdef _WIN32
    DWORD errorNumber = GetLastError();
    LPVOID lpErrorMessage;
    FormatMessage(
                  FORMAT_MESSAGE_ALLOCATE_BUFFER | 
                  FORMAT_MESSAGE_FROM_SYSTEM,
                  NULL,
                  errorNumber,
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  (LPTSTR) &lpErrorMessage,
                  0, NULL );
    //std::cerr << "GemDylib: "<<errorNumber<<std::endl;
    std::string error = "DLLerror: ";
    error+=(unsigned int)errorNumber;
    throw(GemException(error));
#endif
  
    return NULL;
  }
示例#5
0
文件: gemhead.cpp 项目: megrimm/Gem
/////////////////////////////////////////////////////////
//
// gemhead
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
gemhead :: gemhead(int argc, t_atom*argv) :
  gemreceive(gensym("__gem_render")),
  m_cache(new GemCache(this)), m_renderOn(1)
{
  if(m_fltin) {
    inlet_free(m_fltin);
  }
  m_fltin=NULL;

  m_basename=m_name->s_name;
  float priority=50.;
#if 1
  switch(argc) {
  case 2:
    if(argv[0].a_type == A_FLOAT && argv[1].a_type == A_SYMBOL) {
      priority=atom_getfloat(argv+0);
      m_basename+=atom_getsymbol(argv+1)->s_name;
    } else if(argv[1].a_type == A_FLOAT && argv[0].a_type == A_SYMBOL) {
      priority=atom_getfloat(argv+1);
      m_basename+=atom_getsymbol(argv+0)->s_name;
    } else if(argv[1].a_type == A_FLOAT && argv[0].a_type == A_FLOAT) {
      priority=atom_getfloat(argv+0);
      m_basename+=::float2str(atom_getfloat  (argv+1));
    }
    break;
  case 1:
    if(argv[0].a_type == A_FLOAT) {
      priority=atom_getfloat(argv+0);
    } else if(argv[0].a_type == A_SYMBOL) {
      m_basename+=atom_getsymbol(argv+0)->s_name;
    }
    break;
  case 0:
    priority=50.f;
    break;
  default:
    throw(GemException("invalid arguments: 'gemhead [<priority> [<basereceivename>]]'"));
  }
#else
  if(argc==0) {
    priority=50.;
  } else if(argv[0].a_type == A_FLOAT) {
    priority=atom_getfloat(argv);
  } else {
    throw(GemException("invalid arguments: 'gemhead [<priority>]'"));
  }
#endif
  m_priority=priority+1;
  setMess(priority);
}
示例#6
0
  F0RPlugin(std::string name) :
    m_width(0), m_height(0),
    m_instance(NULL),
    m_name(""), m_author(""),
    m_type(0), m_color(0),
    m_frei0rVersion(0), m_majorVersion(0), m_minorVersion(0),
    m_explanation(""),
    m_dylib(name)
  {
    f0r_init           =reinterpret_cast<t_f0r_init           >(m_dylib.proc("f0r_init"));
    f0r_get_plugin_info=reinterpret_cast<t_f0r_get_plugin_info>(m_dylib.proc("f0r_get_plugin_info"));
    f0r_get_param_info =reinterpret_cast<t_f0r_get_param_info >(m_dylib.proc("f0r_get_param_info"));
    f0r_construct      =reinterpret_cast<t_f0r_construct      >(m_dylib.proc("f0r_construct"));
    f0r_destruct       =reinterpret_cast<t_f0r_destruct       >(m_dylib.proc("f0r_destruct"));
    f0r_set_param_value=reinterpret_cast<t_f0r_set_param_value>(m_dylib.proc("f0r_set_param_value"));
    f0r_get_param_value=reinterpret_cast<t_f0r_get_param_value>(m_dylib.proc("f0r_get_param_value"));
    f0r_update         =reinterpret_cast<t_f0r_update         >(m_dylib.proc("f0r_update"));
    f0r_update2        =reinterpret_cast<t_f0r_update2        >(m_dylib.proc("f0r_update2"));
    f0r_deinit         =reinterpret_cast<t_f0r_deinit         >(m_dylib.proc("f0r_deinit"));

    if(!init()) {
      deinit();
      throw(GemException("couldn't instantiate frei0r plugin"));
    }
  }
示例#7
0
/////////////////////////////////////////////////////////
//
// ambientRGB
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
ambientRGB :: ambientRGB(int argc, t_atom *argv)
{
    if (argc == 4)
    {
        m_vector[0] = atom_getfloat(&argv[0]);
        m_vector[1] = atom_getfloat(&argv[1]);
        m_vector[2] = atom_getfloat(&argv[2]);
        m_vector[3] = atom_getfloat(&argv[3]);
    }
    else if (argc == 3)
    {
        m_vector[0] = atom_getfloat(&argv[0]);
        m_vector[1] = atom_getfloat(&argv[1]);
        m_vector[2] = atom_getfloat(&argv[2]);
        m_vector[3] = 1;
    }
    else if (argc == 0)
    {
        m_vector[0] = 0.2f;
        m_vector[1] = 0.2f;
        m_vector[2] = 0.2f;
        m_vector[3] = 1.f;
    }
    else
    {
      throw(GemException("needs 0, 3 or 4 arguments"));
    }

    // create the new inlets
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("rVal"));
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("gVal"));
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("bVal"));
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("aVal"));
}
示例#8
0
gemw32window::gemw32window(void) :
  m_topmost(false),
  m_win(NULL)
{
  if(!initGemWin())
    throw(GemException("could not initialize window infrastructure"));
}
示例#9
0
文件: torus.cpp 项目: Jackovic/Gem
/////////////////////////////////////////////////////////
//
// torus
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
torus :: torus(int argc, t_atom *argv)
      : GemGluObj(1.f)
{
  float size = 1.f;
  int numSlices = 10;
  m_innerRadius = 0.5f;

  switch(argc){
  case 3:
    size = atom_getfloat(&argv[0]);
    numSlices = atom_getint(&argv[1]);
    m_innerRadius = atom_getfloat(&argv[2]);
    break;
  case 2:
    size = atom_getfloat(&argv[0]);
    numSlices = atom_getint(&argv[1]);
    break;
  case 1:
    size = atom_getfloat(&argv[0]);
  case 0:
    break;
  default:
    throw(GemException("needs 0, 1, 2 or 3 arguments"));
  }

  sizeMess(size);
  numSlicesMess(numSlices);
  inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym("inner"));
}
示例#10
0
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_share_write :: pix_share_write(int argc, t_atom*argv) :
#if USE_SHM
  shm_id(0), shm_addr(NULL),
#endif
  m_size(0),
  m_outlet(0)
{
#if USE_SHM
  memset(&shm_desc, 0, sizeof(shm_desc));
#elif defined _WIN32
#else
  error("Gem has been compiled without shared memory support!")
#endif
  if(argc<1) {
    //~ throw(GemException("no ID given"));
  } else {
    int err  = getShm(argc, argv);

    switch(err) {
    case 0:
      break;
    case 1:
      throw(GemException("no valid size given"));
      break;
    case 2:
      throw(GemException("given size < 0"));
      break;
    case 3:
      throw(GemException("no valid dimensions given"));
      break;
    case 4:
      throw(GemException("<color> must be one of: 4,2,1,RGBA,YUV,Grey"));
      break;
    case 5:
      throw(GemException("arguments: <id> <width> <height> <color>"));
      break;
    case 6:
      throw(GemException("couldn't get shared memory"));
      break;
    case 7:
      throw(GemException("no ID given"));
      break;
    case 8:
      throw(GemException("invalid ID..."));
      break;
    default:
      throw(GemException("unknown error"));
      break;
    }
  }
  m_outlet = outlet_new(this->x_obj,0);
}
示例#11
0
/////////////////////////////////////////////////////////
//
// GEMglViewport
//
/////////////////////////////////////////////////////////
// Constructor
//
GEMglRenderMode :: GEMglRenderMode	(int argc, t_atom*argv) :
  mode(0)
{
  if(1==argc)modeMess(argv[0]); else if(argc) throw(GemException("invalid number of arguments"));

  m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("mode"));
  m_outlet=outlet_new(this->x_obj, 0);
}
示例#12
0
/////////////////////////////////////////////////////////
//
// GEMglViewport
//
/////////////////////////////////////////////////////////
// Constructor
//
GEMglPolygonMode :: GEMglPolygonMode	(int argc, t_atom*argv) :
		face(0), 
		mode(0)
{
  if(2==argc){faceMess(argv[0]); modeMess(argv[1]);} else if (argc) throw(GemException("invalid number of arguments"));

	m_inlet[0] = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("face"));
	m_inlet[1] = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("mode"));
}
示例#13
0
GemDylib::GemDylib(const GemDylib&org) : m_handle(NULL) {
  std::string filename=org.m_handle->fullname;
  m_handle=GemDylibHandle::open(filename);
  if(NULL==m_handle) {
    std::string err="unable to open '";
    err+=filename;
    err+="'";
    throw GemException(err);
  }
}
示例#14
0
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_share_write :: pix_share_write(int argc, t_atom*argv)
#ifdef _WIN32
#else
  : shm_id(0), shm_addr(NULL)
#endif
{
  if(argc<1){
    throw(GemException("no ID given"));
  }
  int err  = getShm(argc, argv);

  switch(err){
  case 0:
    break;
  case 1:
    throw(GemException("no valid size given"));
    break;
  case 2:
    throw(GemException("given size < 0"));
    break;
  case 3:
    throw(GemException("no valid dimensions given"));
    break;
  case 4:
    throw(GemException("<color> must be one of: 4,2,1,RGBA,YUV,Grey"));
    break;
  case 5:
    throw(GemException("arguments: <id> <width> <height> <color>"));
    break;
  case 6:
    throw(GemException("couldn't get shared memory"));
    break;
  case 7:
    throw(GemException("no ID given"));
    break;
  case 8:
    throw(GemException("invalid ID..."));
    break;
   default:
    throw(GemException("unknown error"));
    break;
  }
}
示例#15
0
/////////////////////////////////////////////////////////
//
// gemglfw2window
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
gemglfw2window :: gemglfw2window(void) :
  m_profile_major(0), m_profile_minor(0),
  m_wheelpos(0)
{
  if(s_instances==0) {
    if(!glfwInit()) {
      throw(GemException("could not initialize GLFW infrastructure"));
    }
  }
  s_instances++;
}
示例#16
0
    void create(VideoInfoStruct&vis) {
      if(!m_plugin) {
        throw(GemException("no plugin loaded"));
      }
      FFMixed input;
      input.PointerValue = &vis;
      FFMixed result = m_plugin(FF_INSTANTIATE, input, m_instance);
      if(FF_FAIL==result.UIntValue)
        throw(GemException("couldn't instaniate"));

      m_instance = result.PointerValue;

      if(NULL==m_instance)
        throw(GemException("could not instaniate"));

      m_width =vis.FrameWidth;
      m_height=vis.FrameHeight;
      m_orientation=vis.Orientation;
      m_depth =vis.BitDepth;

    }
示例#17
0
/////////////////////////////////////////////////////////
//
// shininess
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
shininess :: shininess(int argc, t_atom *argv)
{
    if (argc == 1) shininessMess(atom_getfloat(&argv[0]));
    else if (argc == 0)  shininessMess(0.f);
	else
    {
      throw(GemException("needs 0 or 1 arguments"));
    }

    // create the new inlet
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("shininess"));
}
示例#18
0
 FFInstance(FF_Main_FuncPtr plugin, imageStruct&image)
   : m_instance(NULL)
   , m_plugin(plugin)
 {
   VideoInfoStruct vis;
   vis.FrameWidth =image.xsize;
   vis.FrameHeight=image.ysize;
   vis.BitDepth   = csize2depth(image.csize);
   if(0==vis.BitDepth) throw(GemException("unsupported colorspace"));
   vis.Orientation=updown2orientation(image.upsidedown);
   create(vis);
 }
示例#19
0
GemDylib::GemDylib(const std::string filename, const std::string extension) throw (GemException) : m_handle(0) {
  m_handle=GemDylibHandle::open(0,   filename, extension);
  if(NULL==m_handle) {
    std::string err="unable to open '";
    err+=filename;
    if(!extension.empty()) {
      err+=".";
      err+=extension;
    }
    err+="'";
    throw GemException(err);
  }
}
示例#20
0
/////////////////////////////////////////////////////////
//
// gemsdlwindow
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
gemsdlwindow :: gemsdlwindow(void) :
  m_surface(NULL),
  m_videoFlags(0),
  m_bpp(0)
{
  if(!sdl_count) {
    pre_init();
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
      throw(GemException("could not initialize SDL window infrastructure"));
    SDL_EnableUNICODE(1);
  }
  sdl_count++;
}
示例#21
0
文件: diffuse.cpp 项目: Jackovic/Gem
/////////////////////////////////////////////////////////
//
// diffuse
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
diffuse :: diffuse(int argc, t_atom *argv)
{
    if (argc == 4) diffuseMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
    	    	    	     atom_getfloat(&argv[2]), atom_getfloat(&argv[3]));
    else if (argc == 3) diffuseMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
    	    	    	          atom_getfloat(&argv[2]), 1.f);
    else if (argc == 0) diffuseMess(0.8f, 0.8f, 0.8f, 1.f);
    else
    {
      throw(GemException("needs 0, 3, or 4 arguments"));
    }

    // create the new inlet
    inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_list, gensym("diffuse"));
}
示例#22
0
文件: color.cpp 项目: umlaeute/Gem
/////////////////////////////////////////////////////////
//
// color
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
color :: color(int argc, t_atom *argv)
{
  if (argc == 4) colorMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
                             atom_getfloat(&argv[2]), atom_getfloat(&argv[3]));
  else if (argc == 3) colorMess(atom_getfloat(&argv[0]),
                                  atom_getfloat(&argv[1]),
                                  atom_getfloat(&argv[2]), 1.f);
  else if (argc == 0) {
    colorMess(1.f, 1.f, 1.f, 1.f);
  } else {
    throw(GemException("needs 0, 3, or 4 arguments"));
  }

  // create the new inlet
  inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_list, gensym("color"));
}
示例#23
0
/////////////////////////////////////////////////////////
//
// depth
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
depth :: depth(int argc, t_atom*argv)
       : m_state(1)
{ 
  switch(argc) {
  case 0: 
    break;
  case 1:
    if(A_FLOAT==argv->a_type){
      m_state=(atom_getint(argv)>0);
      break;
    }
  default:
    throw(GemException("invalid argument"));
    break;
  }
}
示例#24
0
pix_freeframe :: pix_freeframe(t_symbol*s)
#ifndef DONT_WANT_FREEFRAME
  : m_plugin(NULL)
  , m_canopen(false)
#endif /* DONT_WANT_FREEFRAME */
{
#ifdef DONT_WANT_FREEFRAME
  throw(GemException("Gem has been compiled without FreeFrame-support!"));
#else
  int can_rgba=0;
  if(!s || s==&s_) {
    m_canopen=true;
    return;
  }
  char *pluginname = s->s_name;

  m_plugin = new FFPlugin(pluginname, getCanvas());
  m_image.setCsizeByFormat(m_plugin->GLformat());

  unsigned int numparams = m_plugin->getNumParameters();
  char tempVt[5];

  unsigned int i;
  for(i=1; i<numparams; i++) {
    snprintf(tempVt, 5, "#%d", i);
    tempVt[4]=0;
    unsigned int parmType=0;
    t_symbol*s_inletType;
    parmType=m_plugin->getParameterType(i);
    switch(parmType){
    case FF_TYPE_EVENT:
      s_inletType=&s_bang;
      break;
    case FF_TYPE_TEXT:
      s_inletType=&s_symbol;
      break;
    default:
      s_inletType=&s_float;
    }
    m_inlet.push_back(inlet_new(this->x_obj, &this->x_obj->ob_pd, s_inletType, gensym(tempVt)));
  }
#endif /* DONT_WANT_FREEFRAME */
}
示例#25
0
  static GemDylibHandle*open(const CPPExtern*obj, const std::string filename, const std::string extension) {
    const t_canvas*canvas=(obj)?(canvas=const_cast<CPPExtern*>(obj)->getCanvas()):0;
    const char*ext=extension.c_str();

    std::string fullname=getFullfilename(canvas, filename.c_str(), ext);
    if(fullname.empty()) {
      fullname=getFullfilename(canvas, filename.c_str(), GemDylibHandle::defaultExtension.c_str());
    }

    if(fullname.empty()) {
      std::string error="couldn't find '";
      error+=filename;
      error+="'.'";
      error+=ext;
      error+="'";
      throw(GemException(error));
    }

    return open(fullname);
  }
示例#26
0
文件: pix_roi.cpp 项目: Jackovic/Gem
pix_roi :: pix_roi(int argc, t_atom*argv) :
  m_oldrect(NULL)
{
  if(s_ID<0)
    s_ID=GemState::getKey("pix.roi.rectangle");

  switch(argc) {
  case 0:
    break;
  case 4:
    m_rectangle=gem::Rectangle::createNormalized(
                                                 atom_getfloat(argv+0),
                                                 atom_getfloat(argv+1),
                                                 atom_getfloat(argv+2),
                                                 atom_getfloat(argv+3));
    break;
  default:
    throw(GemException("arguments: [<x1> <y1> <x2> <y2>]"));
    break;
  }
}
示例#27
0
/////////////////////////////////////////////////////////
//
// pix_gain
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_gain :: pix_gain(int argc, t_atom *argv)
  : m_saturate(true)
{
  inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym("ft1"));
  inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("list"), gensym("vec_gain"));
  m_gain[chRed] = m_gain[chGreen] = m_gain[chBlue] = m_gain[chAlpha] = 1.0f;

  switch(argc){
  case 3:
  case 4:
    vecGainMess(argc,argv);
    break;
  case 1:
    floatGainMess(atom_getfloat(argv));
  case 0:
    break;
  default:
    throw(GemException("needs 0, 1, 3, or 4 arguments"));
    break;
  }
}
示例#28
0
/////////////////////////////////////////////////////////
//
// part_targetcolor
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
part_targetcolor :: part_targetcolor(int argc, t_atom *argv)
{
	scaleMess(.05f);

	if (argc == 5) {
		colorMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
              atom_getfloat(&argv[2]), atom_getfloat(&argv[3]));
		scaleMess(atom_getfloat(&argv[4]));
	}
  else if (argc == 4) colorMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
                                atom_getfloat(&argv[2]), atom_getfloat(&argv[3]));
  else if (argc == 3) colorMess(atom_getfloat(&argv[0]), atom_getfloat(&argv[1]),
                                atom_getfloat(&argv[2]), 1.f);
  else if (argc == 0) colorMess(1.f, 1.f, 1.f, 1.f);
  else {
    throw(GemException("needs 0, 3, 4, or 5 arguments"));
  }

  // create the new inlet
  inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_list, gensym("color"));
  inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("ft1"));
}
示例#29
0
/////////////////////////////////////////////////////////
//
// pix_multitexture
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_multitexture :: pix_multitexture(t_floatarg reqTexUnits)
  : m_inlet(NULL),
    m_reqTexUnits((GLint)reqTexUnits), m_max(0), m_textureType(GL_TEXTURE_2D), m_mode(0),
    m_xRatio(1.f), m_yRatio(1.f), upsidedown(false), m_texSizeX(0), m_texSizeY(0),
    m_oldTexCoords(NULL), m_oldNumCoords(0), m_oldTexture(0)
{
  if (m_reqTexUnits<=0) {
    throw (GemException("[pix_multitexture]: Please specify more than 0 texture units"));
  }

#ifdef __APPLE__
  m_mode = 1;  //default to the fastest mode for systems that support it
  m_textureType = GL_TEXTURE_RECTANGLE_EXT;
#endif
  
  m_inlet=new t_inlet*[m_reqTexUnits]; 
  char tempVt[5];
  for(int i=0;i<m_reqTexUnits; i++){
    snprintf(tempVt, 5, "#%d", i);
    tempVt[4]=0;
    m_inlet[i]=inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym(tempVt));
  }
}
示例#30
0
/////////////////////////////////////////////////////////
//
// GEMglViewport
//
/////////////////////////////////////////////////////////
// Constructor
//
GEMglStencilOp :: GEMglStencilOp	(int argc, t_atom*argv) :
		fail(0), 
		zfail(0), 
		zpass(0)
{
  if(3==argc){failMess(argv[0]); zfailMess(argv[1]); zpassMess(argv[2]);}else if(argc) throw(GemException("invalid number of arguments"));

	m_inlet[0] = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("fail"));
	m_inlet[1] = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("zfail"));
	m_inlet[2] = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("zpass"));
}