Ejemplo n.º 1
0
BOOL CVectorCtl::SetBackgroundImage (UINT uBackgroundBitmapID)
{
	if (m_bBackgroundBitmapUsed) {
		ClearBackgroundBitmap ();
		CreateBackground ();
	}
	if (!m_bmpBack.LoadBitmap (uBackgroundBitmapID))
		return FALSE;
	m_bBackgroundBitmapUsed = TRUE;
	CreateBackground ();
	return TRUE;
}
Ejemplo n.º 2
0
void CVectorCtl::SetBackgroundColor (COLORREF clrStart, COLORREF clrEnd)
{
	ClearBackgroundBitmap ();
	m_clrBackgroundStart = clrStart;
	m_clrBackgroundEnd = clrEnd;
	CreateBackground ();
}
Ejemplo n.º 3
0
void CVectorCtl::SetRadius (UINT uRadius)
{
	m_iRadius = uRadius;
	m_iSqrRadius = m_iRadius * m_iRadius;
	CreateBackground ();
	Redraw (TRUE);
}
Ejemplo n.º 4
0
void CVectorCtl::SetCenter (UINT uHorizPos, UINT uVertPos)
{
	m_iXCenter = uHorizPos;
	m_iYCenter = uVertPos;
	CreateBackground ();
	Redraw (TRUE);
}
Ejemplo n.º 5
0
BackgroundDef BackgroundImpl::Layer::CreateRandomBGA( const Song *pSong, const RString &sEffect, deque<BackgroundDef> &RandomBGAnimations, Actor *pParent )
{
	if( g_RandomBackgroundMode == BGMODE_OFF )
		return BackgroundDef();

	// Set to not show any BGChanges, whether scripted or random
	if( GAMESTATE->m_SongOptions.GetCurrent().m_bStaticBackground )
		return BackgroundDef();

	if( RandomBGAnimations.empty() )
		return BackgroundDef();

	/* XXX: every time we fully loop, shuffle, so we don't play the same sequence
	 * over and over; and nudge the shuffle so the next one won't be a repeat */
	BackgroundDef bd = RandomBGAnimations.front();
	RandomBGAnimations.push_back( RandomBGAnimations.front() );
	RandomBGAnimations.pop_front();

	if( !sEffect.empty() )
		bd.m_sEffect = sEffect;

	map<BackgroundDef,Actor*>::const_iterator iter = m_BGAnimations.find( bd );

	// create the background if it's not already created
	if( iter == m_BGAnimations.end() )
	{
		bool bSuccess = CreateBackground( pSong, bd, pParent );
		ASSERT( bSuccess );	// we fed it valid files, so this shouldn't fail
	}
	return bd;
}
Ejemplo n.º 6
0
bool App::initialize()
{
    //initialize SDL video
    if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) != 0)
    {
        fprintf(stderr,"Error building SDL: %s", SDL_GetError());
        return false;
    }
    
    // make sure SDL cleans up before exit
    atexit(SDL_Quit);
    
    // Create main window and renderer.
    window = SDL_CreateWindow("Invaders From Space", 300, 100, 0, 0,
							  SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
							  SDL_WINDOW_BORDERLESS);
    
    SDL_GetWindowSize(window, &SCREEN_RECT.w, &SCREEN_RECT.h);
    //SDL_SetWindowSize(window, SCREEN_RECT.w, SCREEN_RECT.h);
    
    renderer = SDL_CreateRenderer(window, 0, 0);
    
    CreateBackground(renderer);
    
    return true;
}
wxImage *CreateSysBackground(int width, int height, int offset,
                             wxColour colour)
{
   #ifdef USE_AQUA_THEME
   return CreateAquaBackground(width, height, offset);
   #else
   return CreateBackground(width, height, colour);
   #endif
}
Ejemplo n.º 8
0
// Start memory buffer bitmap and measure it
void CVectorCtl::InitBitmap (LPDRAWITEMSTRUCT lpDrawItemStruct, CDC *pDC)
{
	m_iWidth = lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left;
	m_iHeight = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top;
	m_bmpBuffer.CreateCompatibleBitmap (pDC, m_iWidth, m_iHeight);
	m_bBmpCreated = TRUE;
	m_dcMem.CreateCompatibleDC (pDC);
	m_pOldBitmap = m_dcMem.SelectObject (&m_bmpBuffer);
	SetRadius (max (min (m_iWidth, m_iHeight) - 2, 0) / 2);
	SetCenter (m_iWidth / 2, m_iHeight / 2);
	CreateBackground ();
}
Ejemplo n.º 9
0
void CreateMainMenu(struct MainMenu** ppMenu, int nLevelNum, struct Config* pConfig)
{
   *ppMenu = malloc(sizeof(struct MainMenu));
   struct MainMenu* pMenu = (*ppMenu);
   pMenu->m_eChoice = Play;
   pMenu->m_nLevelNum = nLevelNum >= 1 ? nLevelNum : 1;

   pMenu->m_pBackground = NULL;
   CreateBackground(&pMenu->m_pBackground, pConfig);

   pMenu->m_pConfig = pConfig;
}
Ejemplo n.º 10
0
std::unique_ptr<wxImage> CreateSysBackground
#ifdef USE_AQUA_THEME
   (int width, int height, int offset, wxColour colour)
#else
   (int width, int height, int WXUNUSED(offset), wxColour colour)
#endif
{
   #ifdef USE_AQUA_THEME
   return CreateAquaBackground(width, height, offset);
   #else
   return CreateBackground(width, height, colour);
   #endif
}
Ejemplo n.º 11
0
CHUD::CHUD(unsigned long &score, signed char &lives, unsigned int &charges) :
m_score(score),
m_lives(lives),
m_charges(charges),
mp_Background(NULL)
{
	m_Rect.x = 4;
	m_Rect.y = 2;
	m_Rect.w = 80;
	m_Rect.h = 29;

	size_t Episode = g_pBehaviorEngine->getEpisode();

	if( Episode>=1 && Episode<=3 )
		CreateBackground();
}
Ejemplo n.º 12
0
    bool ShiftDetectorRandSpecialTest()
    {
        typedef Simd::ShiftDetector<Simd::Allocator> ShiftDetector;

        ::srand(1);

        Rect region;
        View background(1920, 1080, View::Gray8);
        if (!CreateBackground(background, region))
            return false;

        ShiftDetector shiftDetector;
        double time;

        time = GetTime();
        shiftDetector.InitBuffers(background.Size(), 6, ShiftDetector::TextureGray, ShiftDetector::SquaredDifference);
        TEST_LOG_SS(Info, "InitBuffers : " << (GetTime() - time) * 1000 << " ms ");

        time = GetTime();
        shiftDetector.SetBackground(background);
        TEST_LOG_SS(Info, "SetBackground : " << (GetTime() - time) * 1000 << " ms ");

        int n = 10;
        time = GetTime();
        for (int i = 0; i < n; ++i)
        {
            const int ms = (int)region.Width() / 4;
            Point ss(Random(2*ms) - ms, Random(2*ms) - ms);

            shiftDetector.Estimate(background.Region(region), region.Shifted(ss), ms*2);

            ShiftDetector::FPoint ds = shiftDetector.ProximateShift();

            if (Simd::SquaredDistance(ShiftDetector::FPoint(ss), ds) > 1.0)
            {
                Simd::DrawRectangle(background, region, uint8_t(255));
                Simd::DrawRectangle(background, region.Shifted(ss), uint8_t(0));
                background.Save("background.pgm");
                TEST_LOG_SS(Error, "Detected shift (" << ds.x << ", " << ds.y << ") is not equal to original shift (" << ss.x << ", " << ss.y << ") !");
                return false;
            }
        }
        TEST_LOG_SS(Info, "Estimate : " << (GetTime() - time) * 1000.0 / n << " ms ");

        return true;
    }
void MasterControl::CreateScene()
{
  world_.scene = new Scene(context_);

  //Create octree, use default volume (-1000, -1000, -1000) to (1000,1000,1000)
  {
    world_.scene->CreateComponent<Octree>();
  }
  //Create the physics
  {
    PhysicsWorld * const physicsWorld = world_.scene->CreateComponent<PhysicsWorld>();
    physicsWorld->SetGravity(Vector3::ZERO);
  }

  world_.scene->CreateComponent<DebugRenderer>();

  //Create an invisible plane for mouse raycasting
  world_.voidNode = world_.scene->CreateChild("Void");
  //Location is set in update since the plane moves with the camera.
  world_.voidNode->SetScale(Vector3(1000.0f, 1.0f, 1000.0f));
  StaticModel* planeModel = world_.voidNode->CreateComponent<StaticModel>();
  planeModel->SetModel(cache_->GetResource<Model>("Models/Plane.mdl"));
  planeModel->SetMaterial(cache_->GetResource<Material>("Materials/Terrain.xml"));

  CreateBackground();

  {
    // Create skybox. The Skybox component is used like StaticModel, but it will be always located at the camera, giving the
    // illusion of the box planes being far away. Use just the ordinary Box model and a suitable material, whose shader will
    // generate the necessary 3D texture coordinates for cube mapping
    Node* skyNode = world_.scene->CreateChild("Sky");
    skyNode->SetScale(500.0f); // The scale actually does not matter
    Skybox* skybox = skyNode->CreateComponent<Skybox>();
    skybox->SetModel(cache_->GetResource<Model>("Models/Box.mdl"));
    skybox->SetMaterial(cache_->GetResource<Material>("Materials/Skybox.xml"));
  }

  //Create a directional light to the world. Enable cascaded shadows on it
  {
    Node* lightNode = world_.scene->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.0f, -1.0f, 0.0f));
    Light* light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetBrightness(1.0f);
    light->SetColor(Color(1.0f, 0.8f, 0.7f));
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));

    //Set cascade splits at 10, 50, 200 world unitys, fade shadows at 80% of maximum shadow distance
    light->SetShadowCascade(CascadeParameters(7.0f, 23.0f, 42.0f, 500.0f, 0.8f));
  }

  //Create a second directional light without shadows
  {
    Node * const lightNode = world_.scene->CreateChild("DirectionalLight");
    lightNode->SetDirection(Vector3(0.0, 1.0, 0.0));
    Light * const light = lightNode->CreateComponent<Light>();
    light->SetLightType(LIGHT_DIRECTIONAL);
    light->SetBrightness(0.25);
    light->SetColor(Color(1.0, 1.0, 1.0));
    light->SetCastShadows(true);
    light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
  }

  //Create camera
  world_.camera = new CameraMaster(context_, this);
}