C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/Background.cpp

Go to the documentation of this file.
00001 #include "Background.h"
00002 #include "Screen.h"
00003 #include "glfuncs.h"
00004 #include "Level.h"
00005 
00006 Background::Background(std::string filename, double depth)
00007 :Sprite( filename ),
00008  _depth( depth )
00009 {
00010 }
00011 
00012 Background::Background(std::string filename, int width, int height, double depth)
00013 :Sprite( filename, width, height ),
00014  _depth( depth )
00015 {
00016 }
00017 
00018 void Background::draw()
00019 {
00020         SDL_Rect screen = Screen::instance()->getScreenRect();
00021         int height = Level::instance()->getHeight();
00022         int width = Level::instance()->getWidth();
00023 
00024         GLfloat texcoords[4];
00025 
00026         texcoords[ 0 ] = ((GLfloat)screen.x/width)*_coords[2]*_depth;
00027         texcoords[ 2 ] = texcoords[ 0 ] + ((GLfloat)screen.w/width)*_coords[2];
00028         texcoords[ 1 ] = ((GLfloat)screen.y/height)*_coords[3]*_depth;
00029         texcoords[ 3 ] = texcoords[ 1 ] + ((GLfloat)screen.h/height)*_coords[3];
00030 
00031         glfuncs::instance()->glBindTexture(GL_TEXTURE_2D, _hTexture);
00032         glfuncs::instance()->glBegin(GL_QUADS);
00033         glfuncs::instance()->glTexCoord2f(texcoords[0],texcoords[1]);   glfuncs::instance()->glVertex2f(0,0);
00034         glfuncs::instance()->glTexCoord2f(texcoords[2],texcoords[1]);   glfuncs::instance()->glVertex2f(screen.w,0);
00035         glfuncs::instance()->glTexCoord2f(texcoords[2],texcoords[3]);   glfuncs::instance()->glVertex2f(screen.w,screen.h);
00036         glfuncs::instance()->glTexCoord2f(texcoords[0],texcoords[3]);   glfuncs::instance()->glVertex2f(0,screen.h);
00037         glfuncs::instance()->glEnd();
00038 }

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO