11 cout<<
"background \""<<
mName<<
"\" created"<<endl;
21 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
26 glTranslated(movePos.
x, movePos.
y, 0);
27 glRotatef(
mAngle,0.0f,0.0f,1.0f);
33 glVertex3d( 0, 0, 0 );
37 glVertex3d(
width, 0, 0 );
45 glVertex3d( 0,
height, 0 );
49 glBindTexture(GL_TEXTURE_2D, 0);
60 SDL_Surface *temp=NULL;
61 if((temp =
LoadImage(
"Backgrounds/"+filename)) == NULL)
return -1;
62 cout<<
"Loaded file"<<endl;
68 SDL_Surface* surface = SDL_DisplayFormatAlpha(temp);
69 SDL_FreeSurface(temp);
74 if ( (surface->w & (surface->w - 1)) != 0 ) {
75 cout<<
"warning: "<<filename<<
"'s width is not a power of 2"<<endl;
79 if ( (surface->h & (surface->h - 1)) != 0 ) {
80 cout<<
"warning: "<<filename<<
"'s height is not a power of 2"<<endl;
84 GLint nofcolors=surface->format->BytesPerPixel;
86 GLenum texture_format=0;
89 if(surface->format->Rmask==0x000000ff)
90 texture_format=GL_RGBA;
92 texture_format=GL_BGRA;
93 if(!(nofcolors==4 || nofcolors==3))
95 cout<<
"warning: the image is not truecolor...this will break "<<endl;
105 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
108 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
110 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
113 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
114 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
116 glTexImage2D( GL_TEXTURE_2D, 0, nofcolors, surface->w, surface->h, 0,
117 texture_format, GL_UNSIGNED_BYTE, surface->pixels );
119 SDL_FreeSurface(surface);