Prikaz jedne poruke
Stara 9.7.2009, 11:07   #15
boshkodj
Veteran
 
Član od: 4.7.2008.
Lokacija: Somewhere along the line
Poruke: 505
Zahvalnice: 85
Zahvaljeno 34 puta na 29 poruka
Određen forumom Re: Problem, game engine u SDL-u

Ali kada stavim static ispred ove dve funkcije izadje mi greska da je apply_surface deklarisan ali ne i definisan ,evo kako sam uradio:

image.h
Kod:
#ifndef _IMAGE_H
#define _IMAGE_H

#include "SDL.h"
#include "SDL_image.h"

static SDL_Surface *load_image( const char *name );

static void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination , SDL_Rect *clip = NULL  );


#endif
image.cpp
Kod:
#include "Image.h"

SDL_Surface *load_image( const char *name )
{
    
    SDL_Surface* loadedImage = NULL;

    SDL_Surface* optimizedImage = NULL;


    loadedImage = IMG_Load( name );


    if( loadedImage != NULL )
    {

        optimizedImage = SDL_DisplayFormat( loadedImage );

   
        SDL_FreeSurface( loadedImage );

        if( optimizedImage != NULL )
        {
    
            Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF );

           
            SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, colorkey );
        }
    }


    return optimizedImage;
}

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination , SDL_Rect *clip /*= NULL*/  )
{
  
    SDL_Rect offset;

  
    offset.x = x;
    offset.y = y;


    SDL_BlitSurface( source,clip , destination, &offset );
}
A izadje ova greska:
Kod:
.\Sprite.cpp(12) : error C2129: static function 'void apply_surface(int,int,SDL_Surface *,SDL_Surface *,SDL_Rect *)' declared but not defined
        c:\documents and settings\korisnik\my documents\visual studio 2008\projects\sdl - vezbe\sdl - vezbe\Image.h(9) : see declaration of 'apply_surface'
??
boshkodj je offline   Odgovor sa citatom ove poruke