Пример #1
0
bool TFour::loadMedia(){
    bool success = true;

    gKeyPressSurfaces[DEFAULT] = loadSurface("images/T4/default.bmp");
    if(gKeyPressSurfaces[DEFAULT] == NULL){
        std::cout<<"Error: "<<SDL_GetError()<<std::endl;
        success = false;
    }

    gKeyPressSurfaces[UP] = loadSurface("images/T4/up.bmp");
    if(gKeyPressSurfaces[UP] == NULL){
        std::cout<<"Error: "<<SDL_GetError()<<std::endl;
        success = false;
    }

    gKeyPressSurfaces[DOWN] = loadSurface("images/T4/down.bmp");
    if(gKeyPressSurfaces[DOWN] == NULL){
        std::cout<<"Error: "<<SDL_GetError()<<std::endl;
        success = false;
    }

    gKeyPressSurfaces[LEFT] = loadSurface("images/T4/left.bmp");
    if(gKeyPressSurfaces[LEFT] == NULL){
        std::cout<<"Error: "<<SDL_GetError()<<std::endl;
        success = false;
    }

    gKeyPressSurfaces[RIGHT] = loadSurface("images/T4/right.bmp");
    if(gKeyPressSurfaces[RIGHT] == NULL){
        std::cout<<"Error: "<<SDL_GetError()<<std::endl;
        success = false;
    }

    return success;
}
Пример #2
0
bool loadMedia() {
  bool success = true;
  gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] = loadSurface("04_key_presses/press.bmp");
  if (gKeyPressSurfaces == NULL) {
    std::cout << "Bitmap could not be loaded! SDL_Error: " << SDL_GetError() << "\n";
    success = false;
  }
  gKeyPressSurfaces[KEY_PRESS_SURFACE_UP] = loadSurface("04_key_presses/up.bmp");
  if (gKeyPressSurfaces == NULL) {
    std::cout << "Bitmap could not be loaded! SDL_Error: " << SDL_GetError() << "\n";
    success = false;
  }
  gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN] = loadSurface("04_key_presses/down.bmp");
  if (gKeyPressSurfaces == NULL) {
    std::cout << "Bitmap could not be loaded! SDL_Error: " << SDL_GetError() << "\n";
    success = false;
  }
  gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT] = loadSurface("04_key_presses/left.bmp");
  if (gKeyPressSurfaces == NULL) {
    std::cout << "Bitmap could not be loaded! SDL_Error: " << SDL_GetError() << "\n";
    success = false;
  }
  gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] = loadSurface("04_key_presses/right.bmp");
  if (gKeyPressSurfaces == NULL) {
    std::cout << "Bitmap could not be loaded! SDL_Error: " << SDL_GetError() << "\n";
    success = false;
  }
  return success;
}
Пример #3
0
bool loadMedia()
{
	bool success = true;
	keyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] = loadSurface("press.bmp");
	if (keyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] == NULL) {
		printf("Failed to load default image. \n");
		success = false;
	}
	keyPressSurfaces[KEY_PRESS_SURFACE_UP] = loadSurface("up.bmp");
	if (keyPressSurfaces[KEY_PRESS_SURFACE_UP] == NULL) {
		printf("Failed to load up image. \n");
		success = false;
	}
	keyPressSurfaces[KEY_PRESS_SURFACE_DOWN] = loadSurface("down.bmp");
	if (keyPressSurfaces[KEY_PRESS_SURFACE_DOWN] == NULL) {
		printf("Failed to load down image. \n");
		success = false;
	}
	keyPressSurfaces[KEY_PRESS_SURFACE_LEFT] = loadSurface("left.bmp");
	if (keyPressSurfaces[KEY_PRESS_SURFACE_LEFT] == NULL) {
		printf("Failed to load left image. \n");
		success = false;
	}
	keyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] = loadSurface("right.bmp");
	if (keyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] == NULL) {
		printf("Failed to load right image. \n");
		success = false;
	}
	return success;
}
Пример #4
0
 Surface* loadRgbaSurface(const char* filename) override {
   int old_color_conv = _color_conv;
   set_color_conversion(COLORCONV_NONE);
   Surface* sur = loadSurface(filename);
   set_color_conversion(old_color_conv);
   return sur;
 }
Пример #5
0
bool CCage::PreEnterViewMsg(CPreEnterViewMsg *msg) {
	loadSurface();
	_open = CParrot::_v4 != 0;
	loadFrame(_open ? 8 : 0);

	return true;
}
Пример #6
0
// loads media
bool ExtLoadApp::loadMedia()
{
	bool success = true;
	
	// try changing this to vector later
	// gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] = loadSurface("minecraft24.bmp");
	gKeyPressSurfaces.push_back(loadSurface("minecraft24.png"));	
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] == nullptr)
	{
		std::cout << "Failed to load image: " << "minecraft24" << std::endl;
		success = false;
	}
	
	// gKeyPressSurfaces[KEY_PRESS_SURFACE_UP] = loadSurface("minecraft24_UP.bmp"));
	gKeyPressSurfaces.push_back(loadSurface("minecraft24_UP.png"));	
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_UP] == nullptr)
	{
		std::cout << "Failed to load image: " << "mincraft24_UP.bmp" << std::endl;
		success = false;
	}
	
	// gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN] = loadSurface("minecraft24_DOWN.bmp");
	gKeyPressSurfaces.push_back(loadSurface("minecraft24_DOWN.png"));
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN] == nullptr)
	{
		std::cout << "Failed to load image: " << "minecraft24_DOWN.bmp" << std::endl;
		success = false;
	}

	// gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT] = loadSurface("minecraft24_LEFT.bmp");
	gKeyPressSurfaces.push_back(loadSurface("minecraft24_LEFT.png"));
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT] == nullptr)
	{
		std::cout << "Failed to load image: " << "minecraft24_LEFT.bmp" << std::endl;
		success = false;
	}

	// gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] = loadSurface("minecraft24_RIGHT.bmp");
	gKeyPressSurfaces.push_back(loadSurface("minecraft24_RIGHT.png"));
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] == nullptr)
	{
		std::cout << "Failed to load image: " << "minecraft24_RIGHT.bmp" << std::endl;
		success = false;
	}
	
	return success;
}
Пример #7
0
bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) {
	loadSurface();
	CCarryParrot *parrot = dynamic_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot"));
	if (parrot)
		parrot->_fieldE0 = 0;

	return true;
}
Пример #8
0
//loads media
bool loadMedia()
{
    bool success = true;

    //load default surface
    key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_DEFAULT] = loadSurface("../data/press.bmp");
    if(key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_DEFAULT] == nullptr)
    {
        std::cout << "Failed to load default image!" << std::endl;
        success = false;
    }

    //load up surface
    key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_UP] = loadSurface("../data/up.bmp");
    if(key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_UP] == nullptr)
    {
        std::cout << "Failed to load default image!" << std::endl;
        success = false;
    }

    //load down surface
    key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_DOWN] = loadSurface("../data/down.bmp");
    if(key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_DEFAULT] == nullptr)
    {
        std::cout << "Failed to load default image!" << std::endl;
        success = false;
    }

    //load left surface
    key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_LEFT] = loadSurface("../data/left.bmp");
    if(key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_LEFT] == nullptr)
    {
        std::cout << "Failed to load default image!" << std::endl;
        success = false;
    }

    //load right surface
    key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_RIGHT] = loadSurface("../data/right.bmp");
    if(key_press_surfaces[KeyPressSurfaces::KEY_PRESS_SURFACE_RIGHT] == nullptr)
    {
        std::cout << "Failed to load default image!" << std::endl;
        success = false;
    }

    return success;
}
Пример #9
0
void COpenGL::updateScreen()
{
	glEnable(GL_TEXTURE_2D);
	// Set up an array of values to use as the sprite vertices.
	GLfloat vertices[] =
	{
		0, 0,
		1, 0,
		1, 1,
		0, 1,
	};

	// Set up an array of values for the texture coordinates.
	GLfloat texcoords[] =
	{
		0, 0,
		1, 0,
		1, 1,
		0, 1,
	};

	//Render the vertices by pointing to the arrays.
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glVertexPointer(2, GL_FLOAT, 0, vertices);
	glTexCoordPointer(2, GL_FLOAT, 0, texcoords);

	glEnable(GL_BLEND);

	if(m_VidConfig.m_ScaleXFilter > 1)
	{
		if(getPerSurfaceAlpha(FXSurface))
			SDL_BlitSurface(FXSurface, NULL, BlitSurface, NULL);
	}

	loadSurface(m_texture, BlitSurface);
	renderTexture(m_texture);


	if(m_VidConfig.m_ScaleXFilter == 1)
	{
		if(FXSurface && getPerSurfaceAlpha(FXSurface))
		{
			reloadFX(FXSurface);
			renderTexture(m_texFX, true);
		}
	}

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);

	g_pInput->renderOverlay();

	SDL_GL_SwapBuffers();
}
Пример #10
0
bool loadMedia() {
  bool success = true;
  stretchedSurface = loadSurface("loaded.png");
  if (stretchedSurface == NULL) {
    printf("There was an error while trying to load the stretched image.\nSDL Error: %s\n", SDL_GetError());
    success = false;
  }
  return success;
}
Пример #11
0
void Board::loadBackground()
{
	HelloWorld = loadSurface("assets/Board.png");
	
	if( HelloWorld == NULL )
		printf( "Unable to load image %s! SDL Error: %s\n", "assets/Board.png", SDL_GetError() );
	
	SDL_BlitSurface( HelloWorld, NULL, screenSurface, NULL );
}
surfDepValues *determineSurfaceDepthsBasin(globalBasinData *basinData ,gridStruct *location, char *fileName, int basinNum, int surfNum)
/*
 Purpose:   obtain the depths for all lat lon points within the  for a given surface file
 
 Input variables:
 location  - structure containing lat lon grid
 fileName  - filename of the surface file for reading
 
 Output variables:
 surfDep   - (malloc'd) pointer to structure containing surface depths for all lat lon points
 */
{
    // read in the filename
    surfRead *currentSurface;
    currentSurface = loadSurface(fileName);
    
    surfDepValues *surfDep;
    surfDep = malloc(sizeof(surfDepValues));
    adjacentPointsStruct *points;
    
    // loop over values and find the depth of the surface at all points (2D interpolation)
    for(int i = 0; i < location->nX; i++)
    {
        for(int j = 0; j < location->nY; j++)
        {
            if(basinData->inBasinLatLon[basinNum][basinData->boundaryType[basinNum][surfNum]][i][j] == 1)
            {
                // find adjacent points
                points = findAdjacentPoints(currentSurface, location->Lat[i][j], location->Lon[i][j]);
                //                printf("%lf %lf\n",location->Lat[i][j], location->Lon[i][j]);
                //                printf("%i\n",basinData->inBasinLatLon[basinNum][basinData->boundaryType[basinNum][surfNum]][i][j]);
                
                if (points->inSurfaceBounds == 1)
                {
                    // interpolate
                    surfDep->dep[i][j] = biLinearInterpolation( currentSurface->loni[points->lonInd[0]], currentSurface->loni[points->lonInd[1]], currentSurface->lati[points->latInd[0]], currentSurface->lati[points->latInd[1]], currentSurface->raster[points->lonInd[0]][points->latInd[0]], currentSurface->raster[points->lonInd[0]][points->latInd[1]], currentSurface->raster[points->lonInd[1]][points->latInd[0]], currentSurface->raster[points->lonInd[1]][points->latInd[1]], location->Lon[i][j], location->Lat[i][j]);
                    free(points);
                }
                else
                {
                    printf("%lf %lf\n",location->Lat[i][j], location->Lon[i][j]);

                    printf("Error, point lies outside basin surface domain.\n");
                }
            }
            else
            {
                surfDep->dep[i][j] = NAN; // define as NAN if surface is outside of the boundary
            }
        }
    }
    free(currentSurface);
    
    return surfDep;
}
Пример #13
0
void Game::helpThirdScreen() {
	SDL_Surface* helpThird = NULL;
	helpThird = loadSurface("resources//images//help//helpThird.png");
	SDL_BlitSurface(helpThird,NULL,getSurface(),NULL);
	menuButtons[7].draw();
	menuButtons[9].draw();
	mouseCursor();
	SDL_UpdateWindowSurface(window);
	SDL_FreeSurface(helpThird);
	helpThird = NULL;
}
Пример #14
0
bool loadMedia() {
  bool l_success =  true;

  //Load stretching surface
  g_pngSurface = loadSurface("image.png");
  if(g_pngSurface == NULL) {
    printf("Failed to load image.png! \n");
    l_success = false;
  }
  return l_success;
}
Пример #15
0
//for textures
SDL_Texture* Renderer::loadTexture(char* File) {
	SDL_Surface* newSurface = loadSurface(File);
	if (newSurface != NULL) {
		SDL_Texture* newTexture = SDL_CreateTextureFromSurface(Renderer::g_renderer, newSurface);
		SDL_FreeSurface(newSurface);
		return newTexture;
	}
	else {
		return NULL;
	}
}
Пример #16
0
void Game::helpWindowScreen()
{
	SDL_Surface* helpImage = NULL;
	helpImage = loadSurface("resources//images//help//helpFirst.png");
	SDL_BlitSurface(helpImage,NULL,getSurface(),NULL);
	menuButtons[7].draw();
	menuButtons[8].draw();
	mouseCursor();
	SDL_UpdateWindowSurface(window);
	SDL_FreeSurface(helpImage);
	helpImage = NULL;
}
Пример #17
0
Drawable::Drawable(SDL_Surface* screen, std::string imageloc) :
  m_screen(screen),
  m_center(0, 0)
{

  loadSurface(imageloc);
  m_drawablezoomsurf = rotozoomSurface(m_drawablesurf, 0.0, 1, 1);
  m_pos.w = m_drawablezoomsurf->w;
  m_pos.h = m_drawablezoomsurf->h;

  setTopLeftPos();
}
Пример #18
0
void Game::statsWindowScreen()
{
	SDL_Surface* statsScreen = NULL;
	statsScreen = loadSurface("resources//images//background//background2.png");
	SDL_BlitSurface(statsScreen,NULL,getSurface(),NULL);
	printStatisticData();
	menuButtons[7].draw();
	mouseCursor();
	SDL_UpdateWindowSurface(window);
	SDL_FreeSurface(statsScreen);
	statsScreen = NULL;
}
Пример #19
0
bool loadMedia()
{
//Loading success flag
	bool success = true;
//Load default surface
	gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] = loadSurface("press.bmp");
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT] == NULL)
	{
		printf("Failed to load default image!\n");
		success = false;
	}
//Load up surface
	gKeyPressSurfaces[KEY_PRESS_SURFACE_UP] = loadSurface("up.bmp");
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_UP] == NULL)
	{
		printf("Failed to load up image!\n");
		success = false;
	}
//Load down surface
	gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN] = loadSurface("down.bmp");
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN] == NULL)
	{
		printf("Failed to load down image!\n");
		success = false;
	}
//Load left surface
	gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT] = loadSurface("left.bmp");
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT] == NULL)
	{
		printf("Failed to load left image!\n");
		success = false;
	}
//Load right surface
	gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] = loadSurface("right.bmp");
	if (gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT] == NULL)
	{
		printf("Failed to load right image!\n");
		success = false;
	}
//Load stretching surface
	gStretchedSurface = loadSurface("stretch.bmp");
	if (gStretchedSurface == NULL)
	{
		printf("Failed to load stretching image!\n");
		success = false;
	}
//Load PNG surface
	gPNGSurface = loadSurface("loaded.png");
	if (gPNGSurface == NULL)
	{
		printf("Failed to load PNG image!\n");
		success = false;
	}
	return success;
}
Пример #20
0
static bool loadMediaLocal() {
    //Loading success flag
    bool success = true;

    //Load PNG surface
    gPNGSurface = loadSurface(resources_path("images/lesson06/loaded.png"));
    if (gPNGSurface == NULL) {
        printf("Failed to load PNG image!\n");
        success = false;
    }

    return success;
}
Пример #21
0
//for textures with color key
SDL_Texture* Renderer::loadTexture(char* File, Uint32 key) {
	SDL_Surface* newSurface = loadSurface(File);
	if (newSurface != NULL) {
		SDL_SetColorKey(newSurface, SDL_TRUE, key);
		SDL_Texture* newTexture = SDL_CreateTextureFromSurface(Renderer::g_renderer, newSurface);
		SDL_FreeSurface(newSurface);
		return newTexture;
	}
	else {
		return NULL;
	}

}
Пример #22
0
void Texture::loadImage(const std::string& path)
{
	assert(m_renderer);
	//SDL_Rect rect = {0, 0, 0, 0};
	//m_rect = rect;

	SDL_Surface* surface = loadSurface(path);
	m_texture = SDL_CreateTextureFromSurface(m_renderer, surface);

	SDL_FreeSurface(surface);

	SDL_QueryTexture(m_texture, NULL, NULL, &m_rect.w, &m_rect.h);
}
Пример #23
0
//loads media
bool loadMedia()
{
    bool success = true;

    //load splash image
    hello_world = loadSurface("../data/loaded.png");
    if(hello_world == nullptr)
    {
        std::cout << "Unable to load image! SDL_Error: " << SDL_GetError() << std::endl;
        success = false;
    }
    return success;
}
Пример #24
0
bool RenderManagerGP2X::setBackground(const std::string& filename)
{
	try
	{
		SDL_Surface *tempBackground = loadSurface(filename);
		mBackground = SDL_DisplayFormat(tempBackground);
		SDL_FreeSurface(tempBackground);
	}
	catch (FileLoadException)
	{
		return false;
	}
	return true;
}
Пример #25
0
Image *ImageHelper::load(SDL_RWops *const rw)
{
    SDL_Surface *const tmpImage = loadPng(rw);
    if (!tmpImage)
    {
        logger->log("Error, image load failed: %s", IMG_GetError());
        return nullptr;
    }

    Image *const image = loadSurface(tmpImage);

    MSDL_FreeSurface(tmpImage);
    return image;
}
Пример #26
0
void loadAllKeySurfaces()
{
    //Load default surface
    gKeyPressSurfaces[ KEY_PRESS_SURFACE_DEFAULT ] = loadSurface( "resources/press.bmp" );
    if( gKeyPressSurfaces[ KEY_PRESS_SURFACE_DEFAULT ] == NULL )
    {
        printf( "Failed to load default image!\n" );
    }

    //Load up surface
    gKeyPressSurfaces[ KEY_PRESS_SURFACE_UP ] = loadSurface( "resources/up.bmp" );
    if( gKeyPressSurfaces[ KEY_PRESS_SURFACE_UP ] == NULL )
    {
        printf( "Failed to load up image!\n" );
    }

    //Load down surface
    gKeyPressSurfaces[ KEY_PRESS_SURFACE_DOWN ] = loadSurface( "resources/down.bmp" );
    if( gKeyPressSurfaces[ KEY_PRESS_SURFACE_DOWN ] == NULL )
    {
        printf( "Failed to load down image!\n" );
    }

    //Load left surface
    gKeyPressSurfaces[ KEY_PRESS_SURFACE_LEFT ] = loadSurface( "resources/left.bmp" );
    if( gKeyPressSurfaces[ KEY_PRESS_SURFACE_LEFT ] == NULL )
    {
        printf( "Failed to load left image!\n" );
    }

    //Load right surface
    gKeyPressSurfaces[ KEY_PRESS_SURFACE_RIGHT ] = loadSurface( "resources/right.bmp" );
    if( gKeyPressSurfaces[ KEY_PRESS_SURFACE_RIGHT ] == NULL )
    {
        printf( "Failed to load right image!\n" );
    }
}
Пример #27
0
LTexture::LTexture(SDL_Renderer *ren, std::string path) : mRen(ren), mTexture(nullptr),
	w(0), h(0) {
	SDL_Surface	*tmp = loadSurface(path);
	if (!tmp)
		throw;
	SDL_SetColorKey(tmp, true, SDL_MapRGB(tmp->format, 0xFF, 0, 0xFF));
	mTexture = SDL_CreateTextureFromSurface(ren, tmp);
	w = tmp->w;
	h = tmp->h;
	SDL_FreeSurface(tmp);
	if (!mTexture) {
		Log("Unable to create texture from surface : %s\n", path.c_str());
		throw;
	}
}
bool loadMedia()
{
    //Loading success flag
    bool success = true;

    //Load PNG surface
    gPNGSurface = loadSurface("loaded.png");
    if (gPNGSurface == NULL)
    {
        printf("Failed to load PNG image!\n");
        success = false;
    }

    return success;
}
Пример #29
0
SDL_Texture* SDL::loadTexture( string filename )
{
	map<string,SDL_Texture*>::iterator iter = texes.find( filename );
	if( iter != texes.end() )
	{
		warning( "%s already loaded", filename.c_str() );
		return iter->second;
	}
	
	SDL_Texture* tex = SDL_CreateTextureFromSurface( renderer, loadSurface(filename) );
	if( !tex ) error( "loadTexture: SDL_CreateTextureFromSurface failed %s %s", filename.c_str(), SDL_GetError() );
	SDL_SetTextureBlendMode( tex, SDL_BLENDMODE_BLEND );
	texes[ filename ] = tex;
	return tex;
}
bool loadMedia()
{
    //Loading success flag
    bool success = true;

    //Load stretching surface
    gStretchedSurface = loadSurface("stretch.bmp");
    if (gStretchedSurface == NULL)
    {
        printf("Failed to load stretching image!\n");
        success = false;
    }

    return success;
}