blob: 94e1e2da79e5f173817372c93adf5b8f16271803 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#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);
unsigned int format;
if(image->format->BytesPerPixel == 4) {
format = image->format->Bshift ? GL_RGBA : GL_BGRA;
} else {
format = image->format->Bshift ? GL_RGB : GL_BGR;
}
build(image->pixels, format, image->w, image->h);
SDL_FreeSurface(image);
}
|