blob: bab760b383c7bc321248199aabe00168a82e2af4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <stdexcept>
#include <SDL/SDL_image.h>
#include <SDL/SDL_opengl.h>
#include "texturesdl.h"
TextureSDL::TextureSDL(const char* filename) {
SDL_Surface* image = IMG_Load(filename);
width = image->w;
height = image->h;
if(image->format->BytesPerPixel == 4) {
format = image->format->Bshift ? GL_RGBA : GL_BGRA;
} else {
format = image->format->Bshift ? GL_RGB : GL_BGR;
}
data = (unsigned char*)image->pixels;
build();
SDL_FreeSurface(image);
}
|