Beispiel #1
0
Window::Window(EventManager& events, int w, int h, const char* title) throw(InitialisationError) {
    if(!glfwInit()) {
        throw InitialisationError("Error initialising GLFW");
    }

    glfwSetErrorCallback(internal::error_callback);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, gl::TRUE_);

    this->window = glfwCreateWindow(w, h, title, nullptr, nullptr);
    if(!this->window) {
        throw InitialisationError("Error creating window: " + internal::error_string);
    }

    glfwMakeContextCurrent(this->window);
    glfwSetWindowUserPointer(this->window, &events);
    glfwSetWindowCloseCallback(this->window, callbacks::close_callback);
    glfwSetKeyCallback(this->window, callbacks::key_callback);
    glfwSetFramebufferSizeCallback(this->window, callbacks::resize_callback);

    if(!gl::sys::LoadFunctions()) {
        throw InitialisationError("Error loading OpenGL functions");
    }
}
Beispiel #2
0
SoftFox::SoftFox()
{
	if (SDL_Init(SDL_INIT_VIDEO) < 0) //Initialise the video to allow for display on the window
	{
		throw InitialisationError("SDL_Init failed"); //If a -1 is called then the video couldn't be found such as no video card
	}

	level = new Level(level_name); //gets level from txt doc

	tileSize = WINDOW_HEIGHT / level->getHeight(); //getting tile height txt doc

	SDL_Window* window = SDL_CreateWindow("Return Home by SoftFox", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); //Create the window of the program with (title, x, y, width, height, flag)

	if (window == nullptr) //If the window returns a null
	{
		throw InitialisationError("SDL_CreateWindow failed"); //Get error message if the window isn't created
	}

	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); //Create a pointer to a renderer that renders in the window, in any position for the flag of syncing the frame rate of the computer for 60fps

	if (renderer == nullptr)
	{
		throw InitialisationError("SDL_CreateRenderer failed");
	}

	///Load sprites locations in
	platformSprite = IMG_LoadTexture(renderer, "..\\Sprites\\platform_sprite.png");
	platformSprite_Dirt = IMG_LoadTexture(renderer, "..\\Sprites\\platform_sprite_dirt.png");
	backgroundImage = IMG_LoadTexture(renderer, "..\\Sprites\\background_art.png");
	mushroomSprite = new Texture("..\\Sprites\\mushroom.png");
	winScreen = new Texture("..\\Sprites\\winscreen.png");
	playerSpriteRight = new Texture("..\\Sprites\\foxRight.png");
	playerSpriteLeft = new Texture("..\\Sprites\\foxLeft.png");
	playerSprite = playerSpriteRight; //Sets default sprite direction
	controls = new Texture("..\\Sprites\\controls.png");

	//Thomas Easterbrook Coding Task two start
	hunterSpriteRight = new Texture("..\\Sprites\\hunterRight.png");
	hunterSpriteLeft = new Texture("..\\Sprites\\hunterLeft.png");
	hunterSprite = hunterSpriteLeft; //Sets default sprite direction
	//Thomas Easterbrook Coding Task two end

}
Beispiel #3
0
void Convolution::Construct(){
    if (!fPdf || !fHasAxes)
        throw InitialisationError("Tried to construct convolution without axes and pdf!");
    
    if(!fCachedCompatibleBins)
        CacheCompatibleBins();

    Reset();
    size_t nBins = fPdfMapping.GetNBins();
    size_t nDims = fPdfMapping.GetAxes().GetNDimensions();
    const AxisCollection& axes = fPdfMapping.GetAxes();
    std::vector<size_t> relativeIndicies = fDataRep.GetRelativeIndicies(fPdfDataRep);

    std::vector<double> binCentre(relativeIndicies.size());
    std::vector<double> lowEdges(relativeIndicies.size());
    std::vector<double> highEdges(relativeIndicies.size());

    for(size_t i = 0; i < nBins; i++){
        for(size_t k = 0; k < relativeIndicies.size(); k++)
            binCentre[k] = axes.GetBinCentre(i, relativeIndicies.at(k));

        // Loop over compatible bins and integrate over bin j to work out the response from i -> j
        // others are zero from reset
        for(size_t j = 0; j < fCompatibleBins.at(i).size(); j++){
            size_t mappedBin = fCompatibleBins.at(i).at(j);
            
            for(size_t k = 0; k < relativeIndicies.size(); k++){
                lowEdges[k]  = axes.GetBinLowEdge(mappedBin, relativeIndicies.at(k));
                highEdges[k] = axes.GetBinHighEdge(mappedBin, relativeIndicies.at(k));
                
            }

            // Move the pdf origin to the centre of bin i
            for(size_t k = 0; k < lowEdges.size(); k++){
                lowEdges[k]  -=  binCentre[k];
                highEdges[k] -=  binCentre[k];
            }

            double Rij = fPdf -> Integral(lowEdges, highEdges);
            fPdfMapping.SetComponent(mappedBin, i, Rij);
        }
    }        
}
Beispiel #4
0
void Convolution::SetPdf(IntegrablePdf* pdf_){
    fPdf = dynamic_cast<IntegrablePdf*>(pdf_->Clone());
    fParameterCount = fPdf->GetParameters().size();
    if(!fPdf)
        throw InitialisationError("Non-Integrable pdf used for convolution!");
}