Code: Select all
glGenTextures(1,&m_textureName);
glBindTexture(GL_TEXTURE_2D,m_textureName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,data);
glGenerateMipmap(GL_TEXTURE_2D); // Allocate the mipmaps
Code: Select all
void drawSprite(SDL_Surface* _bitmap,SDL_Surface* _screen,int _x, int _y)
{
// Part of the bitmap that we want to draw
static SDL_Rect source;
source.x = 0;
source.y = 0;
source.w = 64;
source.h = 64;
// Part of the screen we want to draw the sprite to
SDL_Rect destination;
destination.x = _x;
destination.y = _y;
destination.w = 64;
destination.h = 64;
SDL_BlitSurface(_bitmap, &source, _screen, &destination);
SDL_Flip(_screen);
}