Ejemplo n.º 1
0
Archivo: media.cpp Proyecto: snorp/moon
void
MediaBase::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType() != Type::MEDIABASE) {
		FrameworkElement::OnPropertyChanged (args, error);
		return;
	}
	
	if (args->GetId () == MediaBase::SourceProperty) {
		const char *uri = args->GetNewValue() ? args->GetNewValue()->AsString () : NULL;
		
		if (IsAttached () && AllowDownloads ()) {
			if (uri && *uri) {
				Downloader *dl;
				if ((dl = GetDeployment ()->CreateDownloader ())) {
					dl->Open ("GET", uri, GetDownloaderPolicy (uri));
					SetSource (dl, "");
					dl->unref ();
				} else {
					// we're shutting down
				}
			} else {
				SetSource (NULL, NULL);
			}
		} else {
			source_changed = true;
		}
		
		InvalidateMeasure ();
	}
	
	NotifyListenersOfPropertyChange (args, error);
}
Ejemplo n.º 2
0
static std::shared_ptr<asd::AnimationClip> CreateAnimation()
{
	auto factory = new asd::AnimationSystem_Imp();

	auto clip = factory->CreateAnimationClip();
	auto source = factory->CreateAnimationSource();
	auto key = factory->CreateKeyframeAnimation();

	asd::FCurveKeyframe k1;
	k1.KeyValue.X = 0.0;
	k1.KeyValue.Y = 20;
	k1.LeftHandle = k1.KeyValue;
	k1.RightHandle = k1.KeyValue;

	asd::FCurveKeyframe k2;
	k2.KeyValue.X = 10.0;
	k2.KeyValue.Y = -20;
	k2.LeftHandle = k2.KeyValue;
	k2.RightHandle = k2.KeyValue;

	key->SetName(asd::ToAString("no2.rot.z").c_str());
	key->AddKeyframe(k1);
	key->AddKeyframe(k2);

	source->AddAnimation(key);
	clip->SetSource(source);
	delete factory;

	return clip;
}
Ejemplo n.º 3
0
// Init():
//  Initializes the instance.  If it is already initialized, this
//   will clear and re-initialize it.  This mainly just initializes
//   scene-specific variables
void FreeKey::Init( const char *_source_name, const char *_output_name ) {
  SetSource( _source_name );
  SetOutput( _output_name );

  display_tree      = false;
  items_processed   = 0;
  lights_processed  = 0;
  bones_processed   = 0;

  item_list.Flush();
  groups.Flush();
  scene.Clear();
  scene.SetSceneName( source_name );

  // Interface-level settings
  zoom              =   1.0;
  name_scroll       =   0;
  time_scroll       =   0.0;
  display_min       =   0.0;
  display_max       =   2.0;
  current_time      =   0.0;
  current_item      =  -1;
  item_top          =   0;
  current_group     =   0;
}
Ejemplo n.º 4
0
bool NzShaderStage::SetSourceFromFile(const NzString& filePath)
{
	#if NAZARA_RENDERER_SAFE
	if (!m_id)
	{
		NazaraError("Shader stage is not initialized");
		return false;
	}
	#endif

	NzFile file(filePath);
	if (!file.Open(NzFile::ReadOnly | NzFile::Text))
	{
		NazaraError("Failed to open \"" + filePath + '"');
		return false;
	}

	unsigned int length = static_cast<unsigned int>(file.GetSize());

	NzString source(length, '\0');

	if (file.Read(&source[0], length) != length)
	{
		NazaraError("Failed to read program file");
		return false;
	}

	file.Close();

	SetSource(source);
	return true;
}
Ejemplo n.º 5
0
void FallingObject::Draw(SDL_Renderer* renderer)
{
	if(SDL_GetTicks() - 1000/60 >= m_currentFrame)
	{
		m_currentSprite++;

		if(!dying)
		{
			if( m_currentSprite == 15)
			{
				m_currentSprite = 5;
			}
		}


		m_currentFrame = SDL_GetTicks();
	}

	SetSource(
		(m_currentSprite % SPRITE_PER_LINE) * CLIP_SIZE,
		(m_currentSprite / SPRITE_PER_LINE ) * CLIP_SIZE,
		CLIP_SIZE,
		CLIP_SIZE
	);

	MovableGameObject::Draw(renderer);
}
Ejemplo n.º 6
0
Archivo: media.cpp Proyecto: snorp/moon
void
MediaBase::SetAllowDownloads (bool allow)
{
	const char *uri;
	Downloader *dl;
	
	if ((allow_downloads && allow) || (!allow_downloads && !allow))
		return;
	
	if (allow && IsAttached () && source_changed) {
		source_changed = false;
		
		if ((uri = GetSource ()) && *uri) {
			if (!(dl = GetDeployment ()->CreateDownloader ())) {
				// we're shutting down
				return;
			}
			
			dl->Open ("GET", uri, GetDownloaderPolicy (uri));
			SetSource (dl, "");
			dl->unref ();
		}
	}
	
	allow_downloads = allow;
}
Ejemplo n.º 7
0
void Character::Draw(SDL_Renderer* renderer)
{
	if(SDL_GetTicks() - 1000/FPS >= currentFrame)
	{
		switch (currentDir) {
			case eLeft:
				m_currentSprite += (m_currentSprite != 0 ? -1 : CHARACTER_ANIMATION - 1);
				break;
			case eRight:
				m_currentSprite += (m_currentSprite != CHARACTER_ANIMATION - 1 ? 1 : -(CHARACTER_ANIMATION-1));
				break;
			default:
				break;
		}

		currentFrame = SDL_GetTicks();

		if(currentDir != eNone && currentDir != eUp)
		{
			SetSource(m_currentSprite * CLIP_WIDTH, currentDir * CLIP_HEIGHT, CLIP_WIDTH, CLIP_HEIGHT);
		}
	}

	ControlableGameObject::Draw(renderer);
}
Ejemplo n.º 8
0
bool BXGeneralMessage::ParseFromActionNode(const TiXmlNode *pActionNode) {
	if (!pActionNode || pActionNode->Type() != TiXmlNode::ELEMENT)
		return false;

	TiXmlElement *pElement = (TiXmlElement *)pActionNode;
	const char *szType = pElement->Attribute("type");
  const char *szReferral = pElement->Attribute("referral");
  const char *szSource = pElement->Attribute("source");

	if (szType)
		SetMessageType(szType);
	
  if (szReferral)
    SetReferral(szReferral);

  if (szSource)
    SetSource(szSource);

	m_objects.clear();

	const TiXmlNode *pNode = NULL;
	for( pNode = pActionNode->FirstChild(); pNode; pNode = pNode->NextSibling() ) {
		if ( pNode->ValueStr() == "object") {
			BXObject aObj;
			if (aObj.FromXML(pNode)) {
				m_objects.push_back(aObj);
			}
		}
 	}

	return BXStringMap::FromXML(pActionNode);
}
Ejemplo n.º 9
0
TBSelectDropdown::TBSelectDropdown()
    : m_value(-1)
{
    SetSource(&m_default_source);
    SetSkinBg(TBIDC("TBSelectDropdown"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    m_arrow.SetSkinBg(TBIDC("TBSelectDropdown.arrow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    GetContentRoot()->AddChild(&m_arrow);
}
Ejemplo n.º 10
0
void WAVEFILE::InitValues()
{
	dwAccess=NULL;
	dwStreamSize=NULL;
	SetSource(NULL);
	bOpen=false;
	dwCurrentPos=0;
}
Ejemplo n.º 11
0
CScrError::CScrError(VALUE v, LPCSTR src, int offset) :
	m_lRefCount(1), m_nLine(0)
{
	CreateErrorBase(v);        
	if (m_nLine > 0)
	{
		SetSource(src);
	}
	m_nLine += offset;
}
Ejemplo n.º 12
0
GLShader::GLShader(ShaderType type, int resourceId)
{
    _name = glCreateShader((GLenum)type);

    HRSRC resource = FindResource(NULL, MAKEINTRESOURCE(resourceId), "Shader");
    HGLOBAL global = LoadResource(NULL, resource);
	DWORD size = SizeofResource(NULL, resource);
    char* sourceCode = (char*) LockResource(global);
    SetSource(sourceCode, size);
}
Ejemplo n.º 13
0
AudioResampler::AudioResampler(AudioReader* source, float frameRate,
		float timeScale)
	: AudioReader(),
	  fSource(NULL),
	  fTimeScale(timeScale),
	  fInOffset(0)
{
	SetSource(source);
	if (fSource)
		fFormat.u.raw_audio.frame_rate = frameRate;
}
Ejemplo n.º 14
0
Archivo: media.cpp Proyecto: snorp/moon
void
Image::SetSourceInternal (Downloader *downloader, char *PartName)
{
	// The default value for SourceProperty is NULL, so we need
	// to create one here if required.
	BitmapImage *source = (BitmapImage *) GetSource ();
	if (!source) {
		source = MoonUnmanagedFactory::CreateBitmapImage ();
		SetSource (source);
	}
	MediaBase::SetSourceInternal (downloader, PartName);

	source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
	source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
	source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);

	source->SetDownloader (downloader, NULL, PartName);
}
Ejemplo n.º 15
0
/**
 *	Output a non-formatted message to the log file
 *	
 *	@param message the message
 *	@param source the source of the message, or NULL to use the previous source
 */
void IDebugLog::Message(const char * message, const char * source)
{
	if(source)
		SetSource(source);

	if(inBlock)
	{
		SeekCursor(RoundToTab((indentLevel * 4) + strlen(headerText)));
	}
	else
	{
		SeekCursor(indentLevel * 4);

		PrintText(headerText);
	}

	PrintText(message);
	NewLine();
}
Ejemplo n.º 16
0
bool Port::RPC( const HTTPRequest &request, const std::string &cat, const std::string &action )
{
  if( action == "set" )
  {
    int port_num;
    std::string name;
    int source_id;

    if( !request.GetParam( "port_num", port_num ))
      return false;
    this->port_num = port_num;

    if( !request.GetParam( "name", name ))
      return false;
    this->name = name;

    if( !request.GetParam( "source_id", source_id ))
      return false;

    if( source && ( source_id == -1 || source_id != source->GetKey( )))
    {
      source->RemovePort( this );
      source = NULL;
    }

    if( source_id != -1 )
    {
      if( !source || ( source && source_id != source->GetKey( )))
      {
        source = TVDaemon::Instance( )->GetSource( source_id );
        source->AddPort( this );
        SetSource( source );
      }
    }

    request.Reply( HTTP_OK );
    return true;
  }

  request.NotFound( "Port::RPC unknown action '%s'", action.c_str( ));
  return false;
}
Ejemplo n.º 17
0
void CLensFlareDescriptor::load(CInifile* pIni, LPCSTR sect)
{
	section		= sect;
	m_Flags.set	(flSource,pIni->r_bool(sect,"source" ));
	if (m_Flags.is(flSource)){
		LPCSTR S= pIni->r_string 	( sect,"source_shader" );
		LPCSTR T= pIni->r_string 	( sect,"source_texture" );
		float r = pIni->r_float		( sect,"source_radius" );
		BOOL i 	= pIni->r_bool		( sect,"source_ignore_color" );
		SetSource(r,i,T,S);
	}
	m_Flags.set	(flFlare,pIni->r_bool ( sect,"flares" ));
	if (m_Flags.is(flFlare)){
	    LPCSTR S= pIni->r_string 	( sect,"flare_shader" );
		LPCSTR T= pIni->r_string 	( sect,"flare_textures" );
		LPCSTR R= pIni->r_string 	( sect,"flare_radius" );
		LPCSTR O= pIni->r_string 	( sect,"flare_opacity");
		LPCSTR P= pIni->r_string 	( sect,"flare_position");
		u32 tcnt= _GetItemCount(T);
        string256 name;
		for (u32 i=0; i<tcnt; i++){
			_GetItem(R,i,name); float r=(float)atof(name);
			_GetItem(O,i,name); float o=(float)atof(name);
			_GetItem(P,i,name); float p=(float)atof(name);
			_GetItem(T,i,name);
			AddFlare(r,o,p,name,S);
		}
	}
	m_Flags.set	(flGradient,CInifile::IsBOOL(pIni->r_string( sect, "gradient")));
	if (m_Flags.is(flGradient)){
		LPCSTR S= pIni->r_string 	( sect,"gradient_shader" );
		LPCSTR T= pIni->r_string	( sect,"gradient_texture" );
		float r	= pIni->r_float		( sect,"gradient_radius"  );
		float o = pIni->r_float		( sect,"gradient_opacity" );
		SetGradient(r,o,T,S);
	}
    m_StateBlendUpSpeed	= 1.f/(_max(pIni->r_float( sect,"blend_rise_time" ),0.f)+EPS_S);
    m_StateBlendDnSpeed	= 1.f/(_max(pIni->r_float( sect,"blend_down_time" ),0.f)+EPS_S);

	OnDeviceCreate();
}
Ejemplo n.º 18
0
	void
CParticleAttachCommand::cmd_Execute (
	unsigned		 flags)
	{
	
	CSourceItems		 sel(dyna_Int(0));
	CLxUser_Item		 source, item;
	CLxUser_ValueReference	 ref;

	if (dyna_Object (1, ref))
		ref.Get (source);

	for (sel.LoopInit (); sel.LoopNext (item);) {
		if (SetSource (item, source)) {
			UpDateUI (item, source);
		} else {
			// if there is no source attached, we try to load from file, thus we init features first.
			// restore settings from file.

			CLxUser_ChannelRead	 chanRead;
			CLxUser_ChannelWrite	 chanWrite, chanWriteEdit;
			std::string		 currentFeature;
			std::string		 filename;

			chanRead.from (item);
			int index = item.ChannelIndex (CN_FILE_NAME);
			chanRead.GetString (item, index, filename);

			OpenVDBItemPreLoader itemPreLoader (filename);
			chanWrite.setupFrom (item);
			chanWrite.Set (item, CN_DATA_FILE_NAME, filename.c_str());
			std::string featureList;
			currentFeature = itemPreLoader.getFeatureNameList (featureList);
			chanWrite.Set (item, FEATURE_NAME_LIST, featureList.c_str());

			chanWriteEdit.from (item);
			chanWriteEdit.Set (item, CURRENT_FEATURE, currentFeature.c_str());
		}
	}
		
}
Ejemplo n.º 19
0
void wx28HtmlParser::SetSourceAndSaveState(const wxString& src)
{
    wx28HtmlParserState *s = new wx28HtmlParserState;

    s->m_curTag = m_CurTag;
    s->m_tags = m_Tags;
    s->m_textPieces = m_TextPieces;
    s->m_curTextPiece = m_CurTextPiece;
    s->m_source = m_Source;

    s->m_nextState = m_SavedStates;
    m_SavedStates = s;

    m_CurTag = NULL;
    m_Tags = NULL;
    m_TextPieces = NULL;
    m_CurTextPiece = 0;
    m_Source = wxEmptyString;

    SetSource(src);
}
Ejemplo n.º 20
0
void DummyAnime::Initialize() {
  SetSource(sync::kMyAnimeList);
  SetId(L"4224", sync::kTaiga);
  SetId(L"4224", sync::kMyAnimeList);
  SetId(L"3532", sync::kHummingbird);
  SetSlug(L"toradora");
  SetTitle(L"Toradora!");
  SetSynonyms(L"Tiger X Dragon");
  SetType(anime::kTv);
  SetEpisodeCount(25);
  SetEpisodeLength(24);
  SetAiringStatus(anime::kFinishedAiring);
  SetDateStart(Date(2008, 10, 01));
  SetDateEnd(Date(2009, 03, 25));
  SetImageUrl(L"http://cdn.myanimelist.net/images/anime/5/22125.jpg");
  AddtoUserList();
  SetMyLastWatchedEpisode(25);
  SetMyScore(10);
  SetMyStatus(anime::kCompleted);
  SetMyTags(L"comedy, romance, drama");
}
Ejemplo n.º 21
0
ProjectilePoints::ProjectilePoints(int xPos, int yPos, int nPoints, int fnt, bool type)
{
	this->nPoints = static_cast<int>(nPoints*modifier);

	S_FLICKER = false;

	/* Set Activate & Delay Timer */
	SetActiveTime(3);
	SetDelayTime(0);

	/* Set Start Position */
	SetPosition(xPos, yPos);
	
	SetVelocityVector(0, -20);

	SetSource(true);
	proj_flags.S_NON_PROJECTILE = true;

	bType = type;

	switch(fnt)
	{
	case 0:
		this->fnt = fnt_yellow;
		break;
	case 1:
		this->fnt = fnt_red;
		break;
	case 2:
		this->fnt = fnt_green;
		break;
	case 3:
		this->fnt = fnt_blue;
		break;
	case 4:
		this->fnt = fnt_blue;
		S_FLICKER = true;
		break;
	}
}
Ejemplo n.º 22
0
int WAVEFILE::Open(STREAM* lpStream,DWORD _dwAccess)
{
	CHUNKHEADER	chhdr;
	DWORD		dwHdrLen;
	if (bOpen) return WAVE_OPEN_ERROR;

	if (_dwAccess != WAVE_OPEN_READ && _dwAccess != WAVE_OPEN_ERROR)
		return WAVE_OPEN_ERROR;

	if (_dwAccess == WAVE_OPEN_READ)
	{
		if (!lpStream) 
			return WAVE_OPEN_ERROR;

		SetSource(lpStream);

		if (CheckRIFF_WAVE() <= WAVE_GENERIC_ERROR) {
			Close();
			return WAVE_OPEN_ERROR;
		}
		if (!(LocateData(MakeFourCC("fmt "),NULL,NULL,&chhdr,1000000,DT_CHUNK))) {
			Close();
			return WAVE_OPEN_ERROR;
		}
		dwHdrLen=max(sizeof(WAVEFORMATEX),chhdr.dwLength);
		lpwfe=(WAVEFORMATEX*)malloc(dwHdrLen);
		ZeroMemory(lpwfe,dwHdrLen);
		GetSource()->Read(lpwfe,chhdr.dwLength);
		if (!LocateData(MakeFourCC("data"),NULL,NULL,&chhdr,1000000,DT_CHUNK)) {
			Close();
			return WAVE_OPEN_ERROR;
		}
		dwStreamSize=chhdr.dwLength;
		dwDataStart=(DWORD)(GetSource()->GetPos());
		//dwAccess=WAVE_OPEN_ERROR;
		dwAccess = _dwAccess;
	}

	return WAVE_GENERIC_OK;
}
Ejemplo n.º 23
0
TBSelectList::TBSelectList()
    : m_value(-1)
    , m_list_is_invalid(false)
    , m_scroll_to_current(false)
    , m_header_lng_string_id(TBIDC("TBList.header"))
{
    SetSource(&m_default_source);
    SetIsFocusable(true);
    SetSkinBg(TBIDC("TBSelectList"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    m_container.SetGravity(WIDGET_GRAVITY_ALL);
    m_container.SetRect(GetPaddingRect());
    AddChild(&m_container);
    m_layout.SetGravity(WIDGET_GRAVITY_ALL);
    m_layout.SetAxis(AXIS_Y);
    m_layout.SetSpacing(0);
    m_layout.SetLayoutPosition(LAYOUT_POSITION_LEFT_TOP);
    m_layout.SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    m_layout.SetLayoutSize(LAYOUT_SIZE_AVAILABLE);
    m_container.GetContentRoot()->AddChild(&m_layout);
    m_container.SetScrollMode(SCROLL_MODE_Y_AUTO);
    m_container.SetAdaptContentSize(true);
}
Ejemplo n.º 24
0
int CKadScript::Setup(const string& Source, bool bAuthenticated)
{
	ASSERT(!Source.empty());

	wstring FileName = ToHex(m_CodeID.GetData(), m_CodeID.GetSize());
	
	map<string, string> HeaderFields = ReadHeader(Source);
	uint32 Version = CKadScript::GetVersion(s2w(HeaderFields["Version"]));
	wstring Name = s2w(HeaderFields["Name"]);
	if(Version == 0 || Name.empty())
		return 0;

	if(bAuthenticated && !IsAuthenticated()) // we always update an unauthenticated script with an authentic one
		LogLine(LOG_DEBUG | LOG_WARNING, L"Installing authenticated script %s v%s over present v%s", FileName.c_str(), GetVersion(Version).c_str(), GetVersion(m_Version).c_str());
	else
	{
		if(Version < m_Version)
		{
			LogLine(LOG_DEBUG | LOG_WARNING, L"Atempted to install an older v%s script %s than present v%s", GetVersion(Version).c_str(), FileName.c_str(), GetVersion(m_Version).c_str());
			return -2; // report presence of newer script as success
		}

		if(Version == m_Version && Source == m_Source) // Note: for debuging we may want to update without version increment
			return -1; // nothing to do
	}

	LogLine(LOG_DEBUG | LOG_SUCCESS, L"Install script %s version v%s: ", FileName.c_str(), GetVersion(Version).c_str());
	SetSource(Source, Name, Version);
	
	wstring ScriptPath = GetParent<CKademlia>()->Cfg()->GetString("ScriptCachePath");
	if(!ScriptPath.empty())
	{
		WriteFile(ScriptPath + L"/" + FileName + L".js", m_Source);
		SaveData(ScriptPath + L"/" + FileName + L".dat");
	}
	return 1;
}
Ejemplo n.º 25
0
int SUBTITLES::Open(CTextFile* source)
{
	DWORD	dwHeader;
	char	cBuffer[2048];
	__int64	qwPos;
	char*	lpcName = NULL;

	if (!source) return false;
	SetSource(source);

	subs=NULL;
	iDisplayOrderCount=0;

	// from AVI
	source->Seek(0);
	source->Read(&dwHeader,4);
	if (dwHeader==MakeFourCC("GAB2"))
	{
		source->Read(cBuffer,3);
		source->Read(&dwHeader,4);

		ZeroMemory(cBuffer,sizeof(cBuffer));
		source->Read(cBuffer,dwHeader);
		if (lpcName) delete lpcName;
		newz(char, 2+dwHeader, lpcName);

		WStr2UTF8(cBuffer,&lpcName);
		SetName(lpcName);

		delete lpcName;

		source->Read(&dwHeader,2);
		source->Read(&dwHeader,4);

		source->SetOffset((int)(source->GetPos()));
		source->ReOpen();
	}
Ejemplo n.º 26
0
void wx28HtmlParser::InitParser(const wxString& source)
{
    SetSource(source);
    m_stopParsing = false;
}
Ejemplo n.º 27
0
static void SetData(ProblemData d, MPI_Comm comm, int npes, int myId,
                    long int *neq, long int *l_neq)
{
  int n[DIM], nd[DIM];
  int dim, size;

  /* Set MPI communicator, id, and total number of processes */

  d->comm = comm;
  d->myId = myId;
  d->npes = npes;

  /* Set domain boundaries */

  d->xmin[0] = XMIN;
  d->xmax[0] = XMAX;
  d->m[0]    = MX;

  d->xmin[1] = YMIN;
  d->xmax[1] = YMAX;
  d->m[1]    = MY;

#ifdef USE3D
  d->xmin[2] = ZMIN;
  d->xmax[2] = ZMAX;
  d->m[2]    = MZ;
#endif

  /* Calculate grid spacing and differential volume */

  d->dOmega = ONE;
  FOR_DIM {
    d->dx[dim] = (d->xmax[dim] - d->xmin[dim]) / d->m[dim];
    d->m[dim] +=1;
    d->dOmega *= d->dx[dim];
  }

  /* Set partitioning */

  d->num_procs[0] = NPX;
  n[0] = NPX; 
  nd[0] = d->m[0] / NPX;

  d->num_procs[1] = NPY;
  n[1] = NPY; 
  nd[1] = d->m[1] / NPY;

#ifdef USE3D
  d->num_procs[2] = NPZ;
  n[2] = NPZ; 
  nd[2] = d->m[2] / NPZ;
#endif
  
  /* Compute the neighbors */

  d->nbr_left[0]  = (myId%n[0]) == 0                ? myId : myId-1;
  d->nbr_right[0] = (myId%n[0]) == n[0]-1           ? myId : myId+1;

  d->nbr_left[1]  = (myId/n[0])%n[1] == 0           ? myId : myId-n[0];
  d->nbr_right[1] = (myId/n[0])%n[1] == n[1]-1      ? myId : myId+n[0];

#ifdef USE3D
  d->nbr_left[2]  = (myId/n[0]/n[1])%n[2] == 0      ? myId : myId-n[0]*n[1];
  d->nbr_right[2] = (myId/n[0]/n[1])%n[2] == n[2]-1 ? myId : myId+n[0]*n[1];
#endif
 
  /* Compute the local subdomains 
     m_start: left border in global index space 
     l_m:     length of the subdomain */
  
  d->m_start[0] = (myId%n[0])*nd[0];
  d->l_m[0]     = d->nbr_right[0] == myId ? d->m[0] - d->m_start[0] : nd[0];

  d->m_start[1] = ((myId/n[0])%n[1])*nd[1];
  d->l_m[1]     = d->nbr_right[1] == myId ? d->m[1] - d->m_start[1] : nd[1];

#ifdef USE3D
  d->m_start[2] = (myId/n[0]/n[1])*nd[2];
  d->l_m[2]     = d->nbr_right[2] == myId ? d->m[2] - d->m_start[2] : nd[2];
#endif

  /* Allocate memory for the y_ext array 
     (local solution + data from neighbors) */

  size = 1;
  FOR_DIM size *= d->l_m[dim]+2;
  d->y_ext = (realtype *) malloc( size*sizeof(realtype));

  /* Initialize Buffer field.
     Size of buffer is checked when needed */

  d->buf_send = NULL;
  d->buf_recv = NULL;
  d->buf_size = 0;   

  /* Allocate space for the source parameters */

  *neq = 1; *l_neq = 1;
  FOR_DIM {*neq *= d->m[dim];  *l_neq *= d->l_m[dim];}
  d->p = N_VNew_Parallel(comm, *l_neq, *neq);

  /* Initialize the parameters for a source with Gaussian profile */

  SetSource(d);

}
Ejemplo n.º 28
0
DlgController::DlgController (HWND hwnd) 
   :_hWnd (hwnd),
	_hInst (reinterpret_cast<HINSTANCE>	(::GetWindowLong (hwnd,	GWL_HINSTANCE))),

	_buttonStart (hwnd, IDC_BUTTON_START),
	_buttonAbout (hwnd, IDC_BUTTON_ABOUT),
	_radio8	(hwnd, IDC_RADIO_8_BITS),
	_radio16 (hwnd,	IDC_RADIO_16_BITS),
	_scroll	(hwnd, IDC_SCROLLBAR),
	_edit (hwnd, IDC_EDIT_FFTS),
	_comboFreq (hwnd, IDC_COMBO_SAMPLING),
	_comboPoints (hwnd,	IDC_COMBO_POINTS),
	_mike (hwnd, IDC_RADIO_MIKE),
	_wave (hwnd, IDC_RADIO_FILE),
	_image (hwnd, IDC_RADIO_IMAGE),
	_buttonFile (hwnd, IDC_BUTTON_FILE),
	_editFile (hwnd, IDC_EDIT_FILE),

	_isStopped (true),
	_bitsPerSample (16),
	_samplesPerSecond (Wave::BASE_SAMPLES_SEC),
	_fftPoints (FFT_POINTS * 4),
	_samplesPerBuf (FFT_POINTS * 4),
	_painter (hwnd)
{
	// Attach icon to main dialog
	HICON hIcon	= ::LoadIcon (_hInst, MAKEINTRESOURCE (ICO_FFT));
	::SendMessage (hwnd, WM_SETICON, WPARAM	(ICON_SMALL), LPARAM (hIcon));

	// Display RS icon over	the	button
	hIcon =	::LoadIcon (_hInst,	MAKEINTRESOURCE	(ICO_RS));
	_buttonAbout.SetIcon (hIcon);

	ListCurrentDir ();

	if (::waveInGetNumDevs () == 0)
		throw Win::Exception ("No sound	card installed!");

	Wave::InCapabilities waveInCaps;
	_mike.Check ();
	_wave.UnCheck ();
	_image.UnCheck ();
	SetSource (SRC_MIKE);

	// Initialize radio	buttons	(bits per sample)
	if (!waveInCaps.Is16BitSampling ())
	{
		_radio16.Disable();
		_bitsPerSample = 8;
	}

	// Initialize scroll bar (fft's	per	second)
	InitScrollPositions	();
	// Initialize the combo	box	with sampling frequencies
	if (waveInCaps.Is11_025kHz	())
		_comboFreq.AddValue	(Wave::BASE_SAMPLES_SEC);		
	if (waveInCaps.Is22_05kHz ())
		_comboFreq.AddValue	(2 * Wave::BASE_SAMPLES_SEC);  
	if (waveInCaps.Is44_1kHz ())
		_comboFreq.AddValue	(4 * Wave::BASE_SAMPLES_SEC); 
	assert (_samplesPerSecond == Wave::BASE_SAMPLES_SEC);
	// Select lowest available sampling	frequency
	_comboFreq.SelectPos (0); 
	_samplesPerSecond =	_comboFreq.GetValue();

	// Initialize combo	with FFT points
	_comboPoints.AddValue (FFT_POINTS);			// 0
	_comboPoints.AddValue (2 * FFT_POINTS);		// 1
	_comboPoints.AddValue (4 * FFT_POINTS);		// 2
	_comboPoints.AddValue (8 * FFT_POINTS);		// 3
	_comboPoints.AddValue (16 * FFT_POINTS);	// 4
	assert (_fftPoints == 4	* FFT_POINTS);
	_comboPoints.SelectPos (2);	 //	4 *	FFT_POINTS

	_painter.SetFormat (_samplesPerBuf,	_samplesPerSecond, _fftPoints, _bitsPerSample);
	_painter.ReInit	();
	// could be	changed	by ReInit ()
	_painter.GetFormat (_samplesPerSecond, _bitsPerSample);
	UpdateControls ();
	::PostMessage (hwnd, WM_COMMAND, IDC_BUTTON_START, 0);
}
Ejemplo n.º 29
0
void CCrossfaderBar::OnSelchangeSourceB() 
{
	SetSource(SRC_B);
	OnPosChange();
}
Ejemplo n.º 30
0
bool OGLIndexedDraw::Init(int windowWidth, int windowHeight)
{
    bool res = gs::Stage::Init(windowWidth, windowHeight);
    
    if (res) {
        res &= InitGUI();
        
		/******************************* Shaders ********************************/
		
        auto vertexShader = std::make_unique<gs::Shader>(GL_VERTEX_SHADER);
        auto fragmentShader = std::make_unique<gs::Shader>(GL_FRAGMENT_SHADER);
        auto program = std::make_shared<gs::Program>();
        
        vertexShader->SetSource("heightmap.vert");
        res &= vertexShader->Compile();
        fragmentShader->SetSource("heightmap.frag");
        res &= fragmentShader->Compile();
        
        program->Attach(vertexShader->get());
        program->Attach(fragmentShader->get());
		res &= program->Link();
        program->Use();
        
        programs.push_back(program);
        
        glm::mat4 MVP = projection * glm::lookAt(glm::vec3(0, 40, -30), glm::vec3(0), glm::vec3(0, 1, 0));
        GLint mvpLocation = glGetUniformLocation(program->get(), "MVP");
		glUniformMatrix4fv(mvpLocation, 1, GL_FALSE, glm::value_ptr(MVP));	

		hDivLocation = glGetUniformLocation(program->get(), "heightDivider");
        
		/******************************* Geometry ********************************/
        auto vao = std::make_unique<gs::VertexArray>();
        vao->BindVAO();
        vaos.push_back(std::move(vao));

		auto vbo = std::make_unique<gs::VertexBuffer>(GL_ARRAY_BUFFER);
		vbo->BindVBO();
		vbos.push_back(std::move(vbo));

		heights = { 4.0f, 2.0f, 3.0f, 1.0f,
					3.0f, 5.0f, 8.0f, 2.0f,
					7.0f, 10.0f, 12.0f, 6.0f,
					4.0f, 6.0f, 8.0f, 3.0f };

		const float halfX = WORLD_SIZE_X * 0.5f;
		const float halfZ = WORLD_SIZE_Z * 0.5f;

		for (size_t i = 0; i < HM_SIZE_Z; i++) {
			for (size_t j = 0; j < HM_SIZE_X; j++)
			{
				short currentLineOffset = (short)j * HM_SIZE_Z;

				float xPos = j / (float)(HM_SIZE_X - 1) * WORLD_SIZE_X - halfX;
				float yPos = heights[i + currentLineOffset];
				float zPos = i / (float)(HM_SIZE_Z - 1) * WORLD_SIZE_Z - halfZ;
				vertices[i + currentLineOffset] = glm::vec3(xPos, yPos, zPos);
			}
		}
		glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * vertices.size(), vertices.data(), GL_STATIC_DRAW);

		/******************************* Indices ********************************/
		auto ibo = std::make_unique<gs::VertexBuffer>(GL_ELEMENT_ARRAY_BUFFER);
		ibo->BindVBO();
		vbos.push_back(std::move(ibo));

		const GLushort restartIndex = HM_SIZE_X * HM_SIZE_Z;
		indices = { 0, 4, 1, 5, 2, 6, 3, 7, restartIndex,
					4, 8, 5, 9, 6, 10, 7, 11, restartIndex,
					8, 12, 9, 13, 10, 14, 11, 15};
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * indices.size(), indices.data(), GL_STATIC_DRAW);

		glEnableVertexAttribArray(0);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);

		glEnable(GL_PRIMITIVE_RESTART);
		glEnable(GL_DEPTH_TEST);
		glPrimitiveRestartIndex(restartIndex);
    }
    return res;
}