Skip to content

Commit

Permalink
Tweak texture preservation
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtCoDFish committed Apr 21, 2018
1 parent 6f9d9f8 commit 74d3f8b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 58 deletions.
27 changes: 0 additions & 27 deletions include/APG/SXXDL.hpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
/*
* Copyright (c) 2014, 2015 See AUTHORS file.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef INCLUDE_APG_SXXDL_INCLUDE_HPP_
#define INCLUDE_APG_SXXDL_INCLUDE_HPP_

Expand Down
2 changes: 1 addition & 1 deletion include/APG/graphics/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Texture {
* Can be used by derived classes to create a texture without uploading straight away.
*/
explicit Texture();
void loadTexture(SDL_Surface *surface);
void loadTexture(SDL_Surface *surface, bool andPreserve = true);

void setWidth(int width) {
this->width = width;
Expand Down
27 changes: 0 additions & 27 deletions src/SXXDL.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
/*
* Copyright (c) 2014, 2015 See AUTHORS file.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef APG_NO_SDL

#include "APG/SDL.hpp"
Expand Down
5 changes: 4 additions & 1 deletion src/graphics/PackedTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ PackedTexture::PackedTexture(int32_t width, int32_t height) :
}

PackedTexture::~PackedTexture() {
if(packBuffer.size() > 0) {
el::Loggers::getLogger("APG")->warn("Non-empty pack-buffer when destroying PackedTexture");
}
clearPackBuffer();
}

Expand All @@ -89,7 +92,7 @@ void PackedTexture::commitPack() {
SDL_BlitSurface(surface, nullptr, preservedSurface.get(), rect);
}

loadTexture(preservedSurface.get());
loadTexture(preservedSurface.get(), false);
clearPackBuffer();
}

Expand Down
6 changes: 4 additions & 2 deletions src/graphics/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void Texture::generateTextureID() {
glGenTextures(1, &textureID);
}

void Texture::loadTexture(SDL_Surface *surface) {
void Texture::loadTexture(SDL_Surface *surface, bool andPreserve) {
const auto logger = el::Loggers::getLogger("APG");

if (surface == nullptr) {
Expand Down Expand Up @@ -147,7 +147,9 @@ void Texture::loadTexture(SDL_Surface *surface) {

logger->info("Loaded texture \"%v\" at unit GL_TEXTURE%v", fileName, textureUnitInt);

preservedSurface = SXXDL::make_surface_ptr(surface);
if (andPreserve) {
preservedSurface = SXXDL::make_surface_ptr(surface);
}
}

void Texture::tempBind() {
Expand Down

0 comments on commit 74d3f8b

Please sign in to comment.