Comment out some debug; change FPS calc; misc changes

This commit is contained in:
2015-03-08 13:55:46 +01:00
parent bdc2ef58f4
commit 31e3a307b5
5 changed files with 47 additions and 46 deletions

View File

@@ -102,10 +102,10 @@ void TextureCubeMap::bind() const
}
Texture2D::Texture2D(unsigned width, unsigned height)
: texID_(0), width_(width), height_(height), alpha_(false)
Texture2D::Texture2D(unsigned width, unsigned height, bool alpha)
: texID_(0), width_(width), height_(height), alpha_(alpha)
{
_glCreate(width, height);
_glCreate(width, height, alpha);
}
Texture2D::Texture2D(std::string const& file)
@@ -115,23 +115,20 @@ Texture2D::Texture2D(std::string const& file)
if (!surf)
throw SDLException();
try {
if(surf->format->Amask == 0)
_glCreate(surf->w, surf->h);
try {
assert(surf->format->format == SDL_PIXELFORMAT_RGB24); // TODO: Proper support of many formats
if (SDL_MUSTLOCK(surf))
SDL_LockSurface(surf);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, surf->w, surf->h, GL_RGB, GL_UNSIGNED_BYTE, surf->pixels);
glGenerateMipmap(GL_TEXTURE_2D);
} catch(...) {
glDeleteTextures(1, &texID_);
throw;
}
else {
_glCreate(surf->w, surf->h, true);
}
catch(...) {
try {
copyFromSurface(surf);
} catch (...) {
glDeleteTextures(1, &texID_);
SDL_FreeSurface(surf);
throw;
}
SDL_FreeSurface(surf);
}