// ---------------------------------------------------------------------------
// CFepUiLayoutRootCtrl::UpdateValidRegion
// Update control's valid region after one control Hiden or shown.
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//       
void CFepUiLayoutRootCtrl::UpdateValidRegion(CFepUiBaseCtrl* aCtrl,
                                                             TBool aRemoveFlag)
    {
    //CControlGroup::UpdateValidRegion(aCtrl,aRemoveFlag);
    //if(!aCtrl)
    if(Ready())
        {
        //ask all region aware control to update the region
        for(TInt i =0; i < iCtrlRegionAwareList.Count(); i++)
            {
            //re-calculate the valid region
            iCtrlRegionAwareList[i]->UpdateValidRegion(NULL,EFalse);
            }            
        }
        
     //only check shadow rect when aCtrl is not NULL
    if(aCtrl)
        {
        for(TInt i = 0; i < iCtrlOverlappingAwareList.Count(); ++i)
            {            
            iCtrlOverlappingAwareList[i]->UpdateValidRegion(aCtrl,aRemoveFlag);
            }
        //pop up window will be handled dynamically
        if(!aCtrl->IsKindOfControl(ECtrlPopupWindow) && 
                                        !aCtrl->ShadowRect().IsEmpty())
            {
            TSize s(iShadowRect.Size());
            if(aCtrl->ShadowRect().Width() > s.iWidth)
                s.iWidth = aCtrl->ShadowRect().Width();
            
            if(aCtrl->ShadowRect().Height() > s.iHeight)
                s.iHeight = aCtrl->ShadowRect().Height();
            
            if(s != iShadowRect.Size())
                {
                UiLayout()->LayoutOwner()->LayoutSizeChanged(s);
                }                    
            }
            
        //update iNonHwrStartPtRegion for full screen hwr  
        if(!aCtrl->IsKindOfControl(ECtrlTransparentHwrWnd))
            {            
            CalculateNonHwrStartPtArea();  
            }
        } 
    else
        {
        CalculateNonHwrStartPtArea();        
        }
    CalculateClipRegion();
    }
Example #2
0
// This will ONLY Get Calle
void C_TimerHook::Draw(SCREEN *,UI95_RECT *cliprect)
{
	if(!Ready() || (GetFlags() & C_BIT_INVISIBLE))
		return;

	if(GetFlags() & C_BIT_TIMER)
		SetReady(0);

	if(DrawCallback_)
	{
		if(!(cliprect->left > (GetX()+GetW()) || cliprect->top > (GetY()+GetH()) || cliprect->right < GetX() || cliprect->bottom < GetY()))
			(*DrawCallback_)(GetID(),C_TYPE_TIMER,this);
	}
}
Example #3
0
bool FH2LocalClient::Prepare4BattleOnly(void)
{
    // get color
    if(! GetPlayersInfo()) return false;

    if(2 > players.size())
    {
	GetLoadMaps(true, false);

	LocalEvent & le = LocalEvent::Get();
	Cursor & cursor = Cursor::Get();
	Display & display = Display::Get();

	cursor.Hide();
	TextBox textbox("wait other player", Font::BIG, BOXAREA_WIDTH);
	Dialog::Box box(10 + textbox.h(), Dialog::CANCEL);
	const Rect & pos = box.GetArea();                                                                                          
	textbox.Blit(pos.x, pos.y + 20);

	ButtonGroups btnGroups(box.GetArea(), Dialog::CANCEL);
	btnGroups.Draw();

	cursor.Show();
	display.Flip();

	QueueMessage packet;

	DEBUG(DBG_NETWORK, DBG_INFO, "wait: " << Network::GetMsgString(MSG_UPDATE_PLAYERS));

	while(le.HandleEvents())
	{
	    if(Dialog::ZERO != btnGroups.QueueEventProcessing())
		return false;

	    if(Ready())
    	    {
        	if(!Network::RecvMessage(*this, packet))
            	    return false;

        	if(MSG_UPDATE_PLAYERS == packet.GetID())
		    break;
    	    }
    	    DELAY(10);
	}

	MsgUpdatePlayers(packet);
    }

    return true;
}
Example #4
0
  GeoVector 
  GetVector(fixed time) const
  {
    assert(Ready());

    if (!positive(p[2].t-p[1].t)) {
      return GeoVector(fixed_zero, Angle::zero());
    }

    const Record r0 = Interpolate(time - fixed(0.05));
    const Record r1 = Interpolate(time + fixed(0.05));
    return GeoVector(p[1].loc.distance(p[2].loc)/
                     (p[2].t-p[1].t), r0.loc.bearing(r1.loc));
  }
Example #5
0
int AllegroApp::Init() {
	if(!al_init()) {
		fprintf(stderr, "failed to initialize allegro!\n");
		return -1;
	}

	if(!al_install_keyboard()) {
		fprintf(stderr, "failed to initialize the keyboard!\n");
		return -1;
	}

	timer = al_create_timer(1.0 / FPS);
	if(!timer) {
		fprintf(stderr, "failed to create timer!\n");
		return -1;
	}

	display = al_create_display(screenWidth, screenHeight);
	if(!display) {
		fprintf(stderr, "failed to create display!\n");
		al_destroy_timer(timer);
		return -1;
	}

	al_clear_to_color(al_map_rgb(255, 0, 255));
	al_set_target_bitmap(al_get_backbuffer(display));

	event_queue = al_create_event_queue();
	if(!event_queue) {
		fprintf(stderr, "failed to create event_queue!\n");
		al_destroy_display(display);
		al_destroy_timer(timer);
		return -1;
	}

	al_register_event_source(event_queue, al_get_display_event_source(display));
	al_register_event_source(event_queue, al_get_timer_event_source(timer));
	al_register_event_source(event_queue, al_get_keyboard_event_source());

	al_clear_to_color(al_map_rgb(0,0,0));
	al_start_timer(timer);

	al_set_target_bitmap(al_get_backbuffer(display));
	red_color = al_map_rgb(184, 22, 22);
	grey_color = al_map_rgb(184, 184, 184);
	yellow_color = al_map_rgb(255, 255, 0);
	Ready();

	return 0;
}
Example #6
0
// ***** class: URLLoader *****
void URLLoader::operator()()
{
    wxURL url(fileName);
    url.SetProxy(ConfigManager::GetProxy());

    if (url.GetError() != wxURL_NOERR)
    {
        Ready();
        return;
    }

    std::auto_ptr<wxInputStream> stream(url.GetInputStream());

    if (stream.get() == nullptr || stream->IsOk() == false)
    {
        Ready();
        return;
    }

    char   tmp[8192] = {};
    size_t chunk     = 0;

    while ((chunk = stream->Read(tmp, sizeof(tmp)).LastRead()))
    {
        mBuffer.insert(mBuffer.end(), tmp, tmp + chunk);
    }

#ifdef __APPLE__
    data = &mBuffer[0];
#else
    data = mBuffer.data();
#endif
    len  = mBuffer.size();
    const char Zeros4[] = "\0\0\0\0";
    mBuffer.insert(mBuffer.end(), Zeros4, Zeros4 + 4);
    Ready();
}
Example #7
0
CPlayerMySelf::CPlayerMySelf(const std::string& PlayerName,Ogre::SceneManager* sceneMgr,const std::string& name,const std::string& meshName):CPlayer(
	sceneMgr,name,meshName)
{
	mInitSightNodePos=Ogre::Vector3(0,100,50);
	mInitCameraNodePos=Ogre::Vector3(0,100,500);
	mBodyNode->scale(Ogre::Vector3(0.5,0.5,0.5));
	mSightNode=mBodyNode->createChildSceneNode(mBodyNode->getName()+"_sight",mInitSightNodePos);
	mCameraNode=mBodyNode->createChildSceneNode(mBodyNode->getName()+"_camera",mInitCameraNodePos);
	mPlayerName=PlayerName;
	mTimer=0;
	mLifeBar=new CLifeBar();
	mBlender=new AnimationBlender(mBodyEntity);
	Ready();
	mBlender->init(mPlayerAction[READY]->getAnimationName(READY),true);
}
Example #8
0
static void
clevel (unsigned char *message, int size)
{
  int             nos;
  GETCHAR (message, lastlevel);
  GETCHAR (message + 1, nos);
  GETCHAR (message + 2, gameplan);
  gamemode = GAME;
#ifdef SOUND
  sound = ssound;
#endif
  gameplan_init ();
  effect (nos);
  nodisplayco = 10;
  Ready ();
}
  GeoVector 
  GetVector(fixed time) const
  {
    if (!Ready())
      return fixed_zero;

    if (!positive(p[2].t-p[1].t)) {
      return GeoVector(fixed_zero, Angle::native(fixed_zero));
    }
    fixed alt, palt;
    GeoPoint p0, p1;
    Interpolate(time-fixed(0.05), p0, alt, palt);
    Interpolate(time+fixed(0.05), p1, alt, palt);
    return GeoVector(p[1].loc.distance(p[2].loc)/
                     (p[2].t-p[1].t), p0.bearing(p1));
  }
Example #10
0
int packagesPage::initPackageLists()
{
	setStatus(tr("Generating packages info"), BUSY);
    if (!initPackages())
	{
		setStatus(tr("Generating packages lists"), BUSY);
		initPackagesLists();
		setStatus(tr("Generating packages preview"), BUSY);
		initListViews();
		init = true;
		emit Ready();
		setDone(true);
		return 0;
	}
	return 1;
}
  GeoVector 
  GetVector(fixed _time) const
  {
    assert(Ready());

    if (!positive(p[2].time-p[1].time))
      return GeoVector(fixed(0), Angle::Zero());

    const Record r0 = Interpolate(_time - fixed(0.05));
    const Record r1 = Interpolate(_time + fixed(0.05));

    fixed speed = p[1].location.Distance(p[2].location) / (p[2].time - p[1].time);
    Angle bearing = r0.location.Bearing(r1.location);

    return GeoVector(speed, bearing);
  }
Example #12
0
int
camino_ns_main(int argc, char **argv)
{
	bool cursor;
	unsigned c;

	ncars = 0;
	pass_max = argc > 1 ? atoi(argv[1]): PASS_MAX;

	mt_cons_clear();
	cursor = mt_cons_cursor(false);

	init_road();

	Ready(ctl = CreateTask(control, 0, NULL, "control", DEFAULT_PRIO));

	mprint(OFFSET, MSGLINE,		"I: auto hacia la izquierda");
	mprint(OFFSET, MSGLINE+1,	"D: auto hacia la derecha");
	mprint(OFFSET, MSGLINE+2,	"S: salir");

	do
		switch ( c = mgetch() )
		{
			case 'I':
			case 'i':
				send_car(LEFTBOUND);
				break;
			case 'D':
			case 'd':
				send_car(RIGHTBOUND);
				break;
			default:
				break;
		}
	while ( c != 's' && c != 'S' ); 

	mprint(OFFSET, MSGLINE + 3, "Esperando que terminen los autos...");
	while ( ncars )
		Yield();

	DeleteTask(ctl);

	mt_cons_clear();
	mt_cons_cursor(cursor);

	return 0;
}
Example #13
0
  gcc_pure
  Record
  Interpolate(fixed time) const
  {
    assert(Ready());

    const fixed u = time_fraction(time, false);

    if (!positive(u))
      return p[1];

    if (u > fixed_one)
      return p[2];

    /*
      ps = ( c0   c1    c2  c3)
           [  0    1     0   0] 1
           [ -t    0     t   0] u
           [ 2t  t-3  3-2t  -t] u^2
           [ -t  2-t   t-2   t] u^3
    */

    const fixed u2 = u * u;
    const fixed u3 = u2 * u;
    const fixed c[4]= {-t * u3 + 2 * t * u2 - t * u,
                       (fixed_two - t) * u3 + (t - fixed(3)) * u2 + fixed_one,
                       (t - fixed_two) * u3 + (fixed(3) - 2 * t) * u2 + t * u,
                        t * u3 - t * u2};

    Record r;
    r.loc.Latitude = p[0].loc.Latitude * c[0] + p[1].loc.Latitude * c[1]
      + p[2].loc.Latitude * c[2] + p[3].loc.Latitude * c[3];

    r.loc.Longitude = p[0].loc.Longitude * c[0] + p[1].loc.Longitude * c[1]
      + p[2].loc.Longitude * c[2] + p[3].loc.Longitude * c[3];

    r.alt = p[0].alt * c[0] + p[1].alt * c[1] +
      p[2].alt * c[2] + p[3].alt * c[3];
    r.palt = p[0].palt * c[0] + p[1].palt * c[1] +
      p[2].palt * c[2] + p[3].palt * c[3];

    r.t = time;

    return r;
  }
Example #14
0
/*---------------------------------------------------------------------------
   This function will update either the video texture, or depth texture, or
   both (if applicable). It may also recofigure the filter if the selected
   input has a different resolution. Returns true if either of the textures
   were updated.
  ---------------------------------------------------------------------------*/
bool Filter::Update(Buffers &Buffer)
   {
   if (!Ready()) {return false;}

   //Test for resolution change, if applicable
   Change(Buffer);
   
   bool Updated = false;

   if (Buffer.VideoUpdated(VideoUpdateID) && EnableVideo)
      {
      Texture &VideoFront = Buffer.GetVideo();
      MutexControl Mutex(VideoFront.GetMutexHandle());
      if (Mutex.LockRequest())
         {
         Video.Bind(0);
         Video.Update(VideoFront);
         Video.Unbind(0);
         Mutex.Unlock();
         Updated |= true;
         }
      }

   if (Buffer.DepthUpdated(DepthUpdateID) && EnableDepth)
      {
      Texture &DepthFront = Buffer.GetDepth();
      MutexControl Mutex(DepthFront.GetMutexHandle());
      if (Mutex.LockRequest())
         {
         Depth.Bind(0);
         Depth.Update(DepthFront);
         Depth.Unbind(0);
         Mutex.Unlock();
         Updated |= true;
         }
      }

   #if defined (DEBUG)
      GLenum Error = glGetError();
      if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));}
   #endif

   return Updated;
   }
  gcc_pure
  Record
  Interpolate(fixed _time) const
  {
    assert(Ready());

    const fixed u = GetTimeFraction(_time, false);

    /*
      ps = ( c0   c1    c2  c3)
           [  0    1     0   0] 1
           [ -t    0     t   0] u
           [ 2t  t-3  3-2t  -t] u^2
           [ -t  2-t   t-2   t] u^3
    */

    const fixed u2 = u * u;
    const fixed u3 = u2 * u;
    const fixed c[4]= {-time * u3 + 2 * time * u2 - time * u,
                       (fixed(2) - time) * u3 + (time - fixed(3)) * u2 + fixed(1),
                       (time - fixed(2)) * u3 + (fixed(3) - 2 * time) * u2 + time * u,
                        time * u3 - time * u2};

    Record r;
    r.location.latitude =
        p[0].location.latitude * c[0] + p[1].location.latitude * c[1] +
        p[2].location.latitude * c[2] + p[3].location.latitude * c[3];

    r.location.longitude =
        p[0].location.longitude * c[0] + p[1].location.longitude * c[1] +
        p[2].location.longitude * c[2] + p[3].location.longitude * c[3];

    r.gps_altitude =
        p[0].gps_altitude * c[0] + p[1].gps_altitude * c[1] +
        p[2].gps_altitude * c[2] + p[3].gps_altitude * c[3];

    r.baro_altitude =
        p[0].baro_altitude * c[0] + p[1].baro_altitude * c[1] +
        p[2].baro_altitude * c[2] + p[3].baro_altitude * c[3];

    r.time = _time;

    return r;
  }
Example #16
0
  void Interpolate(double time, double *lon, double *lat, double *alt) {
    if (!Ready()) {
      *lon = p[num].lon;
      *lat = p[num].lat;
      *alt = p[num].alt;
      return;
    }
    double t=0.98;
    LKASSERT( p[2].t != p[1].t );
    double u= (time-p[1].t)/(p[2].t-p[1].t);

    if (u<0.0) {
      *lat = p[1].lat;
      *lon = p[1].lon;
      *alt = p[1].alt;
      return;
    }
    if (u>1.0) {
      *lat = p[2].lat;
      *lon = p[2].lon;
      *alt = p[2].alt;
      return;
    }

    double u2 = u*u;
    double u3 = u2*u;
    double c[4]= {-t*u3+2*t*u2-t*u,
                  (2-t)*u3+(t-3)*u2+1,
                  (t-2)*u3+(3-2*t)*u2+t*u,
                  t*u3-t*u2};
    /*
      double c[4] = {-t*u+2*t*u2-t*u3,
      1+(t-3)*u2+(2-t)*u3,
      t*u+(3-2*t)*u2+(t-2)*u3,
      -t*u2+t*u3};
    */

    *lat = (p[0].lat*c[0] + p[1].lat*c[1] + p[2].lat*c[2] + p[3].lat*c[3]);
    *lon = (p[0].lon*c[0] + p[1].lon*c[1] + p[2].lon*c[2] + p[3].lon*c[3]);
    *alt = (p[0].alt*c[0] + p[1].alt*c[1] + p[2].alt*c[2] + p[3].alt*c[3]);

  }
Example #17
0
BOOL C_Anim::TimerUpdate()
{
	if(!(GetFlags() & C_BIT_ENABLED))
		return(FALSE);
	if(!Ready()) return(FALSE);

	switch(GetType())
	{
		case C_TYPE_LOOP:
			Anim_->SetFrame(Anim_->GetFrame()+Anim_->GetDirection());
			if(Anim_->GetFrame() < 0)
				Anim_->SetFrame(Anim_->GetAnim()->Anim->Frames - 1);
			if(Anim_->GetFrame() >= Anim_->GetAnim()->Anim->Frames)
				Anim_->SetFrame(0);
			return(TRUE);
			break;
		case C_TYPE_STOPATEND:
			Anim_->SetFrame(Anim_->GetFrame()+Anim_->GetDirection());
			if(Anim_->GetFrame() < 0)
			{
				Anim_->SetFrame(0);
				return(FALSE);
			}
			if(Anim_->GetFrame() >= Anim_->GetAnim()->Anim->Frames)
			{
				Anim_->SetFrame(Anim_->GetAnim()->Anim->Frames - 1);
				return(FALSE);
			}
			return(TRUE);
			break;
		case C_TYPE_PINGPONG:
			Anim_->SetFrame(Anim_->GetFrame()+Anim_->GetDirection());
			if((Anim_->GetFrame() < 0) || (Anim_->GetFrame() >= Anim_->GetAnim()->Anim->Frames))
			{
				Anim_->SetFrame(Anim_->GetFrame()-Anim_->GetDirection());
				Anim_->SetDirection(-Anim_->GetDirection());
			}
			return(TRUE);
			break;
	}
	return(FALSE);
}
bool CStartPosSelecter::MousePress(int x, int y, int button)
{
	const float mx = MouseX(x);
	const float my = MouseY(y);

	if ((showReadyBox && InBox(mx, my, readyBox)) || gs->frameNum > 0)
		return (!Ready(false));

	const float dist = CGround::LineGroundCol(camera->GetPos(), camera->GetPos() + mouse->dir * globalRendering->viewRange * 1.4f, false);

	if (dist < 0.0f)
		return true;

	inMapDrawer->SendErase(setStartPos);
	startPosSet = true;
	setStartPos = camera->GetPos() + mouse->dir * dist;
	clientNet->Send(CBaseNetProtocol::Get().SendStartPos(gu->myPlayerNum, gu->myTeam, CPlayer::PLAYER_RDYSTATE_UPDATED, setStartPos.x, setStartPos.y, setStartPos.z));

	return true;
}
Example #19
0
  double GetSpeed(double time) {
    if (p[1].t == p[0].t ) return 0.0;
    if (p[2].t == p[1].t ) return 0.0;
    if (Ready()) {
      double u= (time-p[1].t)/(p[2].t-p[1].t);
      double s0;
      DistanceBearing(p[0].lat, p[0].lon,
                      p[1].lat, p[1].lon, &s0, NULL);

      s0/= (p[1].t-p[0].t);
      double s1;
      DistanceBearing(p[1].lat, p[1].lon,
                      p[2].lat, p[2].lon, &s1, NULL);
      s1/= (p[2].t-p[1].t);
      u = max(0.0,min(1.0,u));
      return s1*u+s0*(1.0-u);
    } else {
      return 0.0;
    }
  }
Example #20
0
int 
main(void)
{
	mon = CreateMonitor("dos");
	cond = CreateCondition("key", mon);

	Ready(CreateTask(consumer, 2000, "consumer", "consumer", DEFAULT_PRIO));

	while ( true )
	{
		EnterMonitor(mon);
		while ( key )
			WaitCondition(cond);
		key = getch();
		if ( key == 'S' || key == 's' )
			return 0;
		SignalCondition(cond);
		LeaveMonitor(mon);
	}
}
Example #21
0
bool InfCh::DataRec(Client * cl, Keys * k)
{
	std::ofstream fout;
	fout.open(path, std::ios_base::out | std::ios_base::ate | std::ios_base::binary);
	union
	{
		char tC[2];
		unsigned short tUS;
	} tmpUnion;
	while(1)
	{
		b_recv = recv(cl->GetSCL(), buf, MAX_DATA, 0);
		if( (b_recv == 0) || (b_recv == USHRT_MAX) ) //connection canceled
		{
			fout.close();
			std::cout << "Connection canceled." << std::endl;
			while( !DeleteFile(path) )
			{
				/*NULL*/
			}
			return false;
		}
		US i;
		for(i = 0; (i < b_recv) && (i < fsu.dfs); i += 2)
		{
			memcpy(tmpUnion.tC, buf + i, 2);
			fout << Decrypt( tmpUnion.tUS , k->GetD(), k->GetN() ); 
		}
		if(i >= fsu.dfs)
		{
			fout.close();
			std::cout << "end of file" << std::endl;
			return true;
		}
		else
		{
			Ready(cl);
		}
		fsu.dfs -= b_recv;
	}
}
Example #22
0
void TApp::OnKeyDown(wxKeyEvent& event)
{
    // Determine if the event originates from a dialog box.
    bool dialog = false;
    if (event.GetEventObject()->IsKindOf(CLASSINFO(wxWindow))) {
        wxWindow* window = (wxWindow*) event.GetEventObject();
        while (window->GetParent() && !window->IsKindOf(CLASSINFO(wxDialog)))
            window = window->GetParent();
        dialog = window->IsKindOf(CLASSINFO(wxDialog));
    }

    if (!dialog) {
        frame->canvas->trackball.OnKeyDown(event);
        switch (event.GetKeyCode()) {
            case WXK_DOWN: frame->programs.OnDown(); break;
            case WXK_UP: frame->programs.OnUp(); break;
        }
    }

    switch (event.GetKeyCode()) {
        case WXK_ESCAPE:
            frame->log.Close();
            frame->adjuster.Close();
            if (frame->IsChecked(Id::ViewFullscreen)) {
                frame->Uncheck(Id::ViewFullscreen);
                frame->ShowFullScreen(false);
            }
            break;

        // Preempt some keystrokes without calling Skip() to prevent them from being processed by controls.
        case WXK_HOME:
            Ready();
            frame->canvas->Reset();

        case WXK_END:
            return;
    }
    frame->canvas->Update();
    event.Skip();
}
Example #23
0
/*---------------------------------------------------------------------------
   Restores the matrix stack, updates the colour buffer texture and then
   unbinds the frame buffer object. The function leaves with matrix mode in 
   projection state.
  ---------------------------------------------------------------------------*/
void Filter::Unbind(void)
   {
   if (!Ready()) {return;}

   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   glMatrixMode(GL_TEXTURE);
   glActiveTexture(GL_TEXTURE0);
   glPopMatrix();

   glMatrixMode(GL_PROJECTION);
   glPopMatrix();

   glPopAttrib();
   
   //Update texture mipmaps post rendering
   glBindTexture(GL_TEXTURE_2D, CBOID);
   glGenerateMipmap(GL_TEXTURE_2D);

   glBindFramebuffer(GL_FRAMEBUFFER, 0);
   }
void C_ServerItem::Draw(SCREEN *surface,UI95_RECT *cliprect)
{
	if(GetFlags() & C_BIT_INVISIBLE || Parent_ == NULL || !Ready())
		return;

	short x=GetState();

	for(int i=0;i<5;i++)
	{
		if(m_arrOutput[i])
		{
			if(m_arrOutput[i])
			{
				m_arrOutput[i]->SetFgColor(Color_[x]);
				m_arrOutput[i]->Draw(surface,cliprect);
			}
		}
	}

	if(MouseOver_ || (GetFlags() & C_BIT_FORCEMOUSEOVER))
		HighLite(surface,cliprect);
}
Example #25
0
/*---------------------------------------------------------------------------
   Class specific setup function for the effects assets.
  ---------------------------------------------------------------------------*/
void Filter::Assets(Buffers &Buffer)
   {
   if (!Ready()) {return;}

   Video.Create(Buffer.GetVideoResolution(), Buffer.GetVideoDataType());
   Video.ClearData();
   Video.Buffer(false);

   Model.Plane(1, Mesh::ModeSolid);
   Model.Buffer(false);

   File::Text Text;
   std::string CodeVert, CodeFrag;
   Text.Load(CodeVert, File::Path::Shader(File::FilterVert));
   Text.Load(CodeFrag, File::Path::Shader(File::FilterFrag));
   Program.Attach(CodeVert, Shader::ShaderVert);
   Program.Attach(CodeFrag, Shader::ShaderFrag);
   Program.Buffer(false);

   GLenum Error = glGetError();
   if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));}
   }
Example #26
0
/*---------------------------------------------------------------------------
   Binds the frame buffer object and intialises the matrix stack. The 
   function leaves with matrix mode in model view state.
  ---------------------------------------------------------------------------*/
void Filter::Bind(void)
   {
   if (!Ready()) {return;}

   glBindFramebuffer(GL_FRAMEBUFFER, FBOID);

   glPushAttrib(GL_ALL_ATTRIB_BITS);
   glViewport(ViewPort.C0, ViewPort.C1, ViewPort.C2, ViewPort.C3);

   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadMatrixf(MP.C);

   glMatrixMode(GL_TEXTURE);
   glActiveTexture(GL_TEXTURE0);
   glPushMatrix();
   glLoadMatrixf(MT.C);

   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadMatrixf(MV.C);
   }
Example #27
0
void C_Tile::Draw(SCREEN *surface,UI95_RECT *cliprect)
{
	UI95_RECT clip;
	long x,y;

	if(GetFlags() & C_BIT_INVISIBLE || !Ready() || !Parent_)
		return;

	clip=*cliprect;
	if(GetFlags() & C_BIT_ABSOLUTE)
	{
		if(clip.left < GetX()) clip.left=GetX();
		if(clip.top < GetY()) clip.top=GetY();
		if(clip.right > (GetX()+GetW())) clip.right=GetX()+GetW();
		if(clip.bottom > (GetY()+GetH())) clip.bottom=GetY()+GetH();
	}

	y=0;
	while(y < GetH())
	{
		x=0;

		while(x < GetW())
		{
			Image_->SetXY(x,y);
			Image_->SetInfo();
			Image_->Draw(surface,&clip);

			if(GetFlags() & C_BIT_HORIZONTAL)
				x+=Image_->GetW();
			else
				x=GetW();
		}
		if(GetFlags() & C_BIT_VERTICAL)
			y+=Image_->GetH();
		else
			y=GetH();
	}
}
Example #28
0
/*---------------------------------------------------------------------------
   Class specific setup function for the effects assets.
  ---------------------------------------------------------------------------*/
void FilterPalette::Assets(Buffers &Buffer)
   {
   if (!Ready()) {return;}

   Depth.Create(Buffer.GetDepthResolution(), Buffer.GetDepthDataType());
   Depth.ClearData();
   Depth.Buffer(false);

   Model.Plane(1, Mesh::ModeSolid);
   Model.Buffer(false);

   File::PNG PNG;
   PNG.Load(Palette, File::Path::Shader(File::TexturePalette));
   Palette.SetMinFilter(Texture::MinNearest); //Disable filtering for palette texture in order to prevent bleeding into adjacent tables
   Palette.SetMagFilter(Texture::MagNearest);
   Palette.Buffer(false);

   File::Text Text;
   std::string CodeVert, CodeFrag;
   Text.Load(CodeVert, File::Path::Shader(File::FilterPaletteVert));
   Text.Load(CodeFrag, File::Path::Shader(File::FilterPaletteFrag));
   Program.Attach(CodeVert, Shader::ShaderVert);
   Program.Attach(CodeFrag, Shader::ShaderFrag);
   Program.Buffer(false);

   //Convert table selector to normalised texture coordinates
   float Select = (float)(Palette.Resolution().V - 1);
   if (Select > Math::feps) {Select = (float)Type / Select;}

   Program.Bind();
   glUniform1f(glGetUniformLocation(Program.ID(), "Select"), Select); 
   glUniform1i(glGetUniformLocation(Program.ID(), "Texture"), 0);   //Texture unit 0
   glUniform1i(glGetUniformLocation(Program.ID(), "Palette"), 1);   //Texture unit 1
   Program.Unbind();

   GLenum Error = glGetError();
   if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));}
   }
Example #29
0
/*---------------------------------------------------------------------------
   Class specific setup function for the effects assets.
  ---------------------------------------------------------------------------*/
void FilterLines::Assets(Buffers &Buffer)
   {
   if (!Ready()) {return;}

   GLint Count = 0;
   glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &Count);
   if (Count < 1) {throw dexception("Current OpenGL context does not support vertex texture image units.");}

   vector2u Res = Buffer.GetDepthResolution();
   Depth.Create(Res, Buffer.GetDepthDataType());
   Depth.ClearData();
   Depth.Buffer(false);

   Model.Plane(1, Mesh::ModeSolid);
   Model.Buffer(false);

   File::PNG PNG;
   PNG.Load(Lines, File::Path::Texture(File::TextureLines));
   Lines.SetWrap(true);
   Lines.Buffer(false);

   File::Text Text;
   std::string CodeVert, CodeFrag;
   Text.Load(CodeVert, File::Path::Shader(File::FilterLinesVert));
   Text.Load(CodeFrag, File::Path::Shader(File::FilterLinesFrag));
   Program.Attach(CodeVert, Shader::ShaderVert);
   Program.Attach(CodeFrag, Shader::ShaderFrag);
   Program.Buffer(false);

   Program.Bind();
   glUniform1i(glGetUniformLocation(Program.ID(), "Texture"), 0);   //Texture unit 0
   glUniform1i(glGetUniformLocation(Program.ID(), "Lines"), 1);   //Texture unit 1
   glUniform1f(glGetUniformLocation(Program.ID(), "Scale"), (float)Res.V / 12.0f); //Scale factor for the line texture sampler
   Program.Unbind();

   GLenum Error = glGetError();
   if (Error != GL_NO_ERROR) {throw dexception("OpenGL generated an error: %s", Debug::ErrorGL(Error));}
   }
Example #30
0
int ExternIO::Read(QByteArray & buffer, int maxlen, int timeout)
{
    if (Error())
    {
        LOG(VB_RECORD, LOG_ERR,
            QString("ExternIO::Read: already in error state: '%1'")
            .arg(m_error));
        return 0;
    }

    if (!Ready(m_appout, timeout))
        return 0;
    if (m_bufsize < maxlen)
    {
        m_bufsize = maxlen;
        delete m_buffer;
        m_buffer = new char[m_bufsize];
    }

    int len = read(m_appout, m_buffer, maxlen);

    if (len < 0)
    {
        m_error = "Failed to read from Extern Recorder: " + ENO;
        LOG(VB_RECORD, LOG_ERR, m_error);
        return 0;
    }
    if (len == 0)
        return 0;

    buffer.append(m_buffer, len);

    LOG(VB_RECORD, LOG_DEBUG,
        QString("ExternIO::Read '%1' bytes, buffer size %2")
        .arg(len).arg(buffer.size()));

    return len;
}