2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
// KRTextureManager.h
|
2012-03-15 20:09:01 +00:00
|
|
|
// KREngine
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
2012-03-15 20:09:01 +00:00
|
|
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
2011-10-25 06:16:47 +00:00
|
|
|
//
|
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
|
//
|
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
|
//
|
|
|
|
|
// 2. 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.
|
|
|
|
|
//
|
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''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 KEARWOOD GILBERT OR
|
|
|
|
|
// CONTRIBUTORS 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.
|
|
|
|
|
//
|
|
|
|
|
// The views and conclusions contained in the software and documentation are those of the
|
|
|
|
|
// authors and should not be interpreted as representing official policies, either expressed
|
|
|
|
|
// or implied, of Kearwood Gilbert.
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef KRTEXTUREMANAGER_H
|
|
|
|
|
#define KRTEXTUREMANAGER_H
|
|
|
|
|
|
|
|
|
|
#include "KRTexture.h"
|
2012-08-17 01:04:49 +00:00
|
|
|
#include "KRContextObject.h"
|
2012-10-05 21:22:47 +00:00
|
|
|
#include "KREngine-common.h"
|
|
|
|
|
#include "KRDataBlock.h"
|
2012-10-19 23:17:43 +00:00
|
|
|
#include "KRContext.h"
|
2011-10-25 05:03:10 +00:00
|
|
|
|
|
|
|
|
#include <map>
|
2012-10-05 21:22:47 +00:00
|
|
|
#include <set>
|
2011-10-25 05:03:10 +00:00
|
|
|
#import <string>
|
|
|
|
|
|
|
|
|
|
using std::map;
|
|
|
|
|
|
2012-08-17 01:04:49 +00:00
|
|
|
class KRTextureManager : public KRContextObject {
|
2011-10-25 05:03:10 +00:00
|
|
|
public:
|
2012-08-17 01:04:49 +00:00
|
|
|
KRTextureManager(KRContext &context);
|
|
|
|
|
virtual ~KRTextureManager();
|
2011-10-25 05:03:10 +00:00
|
|
|
|
2012-11-17 00:15:52 +00:00
|
|
|
void selectTexture(int iTextureUnit, KRTexture *pTexture);
|
2012-09-11 03:06:35 +00:00
|
|
|
|
2012-10-25 03:15:28 +00:00
|
|
|
KRTexture *loadTexture(const char *szName, const char *szExtension, KRDataBlock *data);
|
2012-10-06 01:43:11 +00:00
|
|
|
KRTexture *getTextureCube(const char *szName);
|
2011-10-25 05:03:10 +00:00
|
|
|
KRTexture *getTexture(const char *szFile);
|
|
|
|
|
|
2012-11-17 00:15:52 +00:00
|
|
|
long getMemUsed();
|
|
|
|
|
|
|
|
|
|
long getMemoryTransferedThisFrame();
|
|
|
|
|
void addMemoryTransferredThisFrame(long memoryTransferred);
|
2012-09-26 20:07:48 +00:00
|
|
|
|
2012-11-17 00:15:52 +00:00
|
|
|
void memoryChanged(long memoryDelta);
|
|
|
|
|
|
2012-12-07 01:49:17 +00:00
|
|
|
void startFrame(float deltaTime);
|
|
|
|
|
void endFrame(float deltaTime);
|
2012-09-11 04:32:04 +00:00
|
|
|
|
2012-12-20 01:23:57 +00:00
|
|
|
std::map<std::string, KRTexture *> &getTextures();
|
|
|
|
|
|
|
|
|
|
void compress();
|
|
|
|
|
|
2011-10-25 05:03:10 +00:00
|
|
|
private:
|
2012-11-17 00:15:52 +00:00
|
|
|
long m_memoryTransferredThisFrame;
|
2012-09-26 20:07:48 +00:00
|
|
|
|
2011-10-25 05:03:10 +00:00
|
|
|
std::map<std::string, KRTexture *> m_textures;
|
2012-09-11 03:06:35 +00:00
|
|
|
|
2012-09-13 20:09:19 +00:00
|
|
|
KRTexture *m_boundTextures[KRENGINE_MAX_TEXTURE_UNITS];
|
|
|
|
|
std::set<KRTexture *> m_activeTextures;
|
|
|
|
|
std::set<KRTexture *> m_poolTextures;
|
2012-09-11 04:32:04 +00:00
|
|
|
|
2012-11-17 00:15:52 +00:00
|
|
|
long m_textureMemUsed;
|
|
|
|
|
|
2012-09-26 20:07:48 +00:00
|
|
|
|
2012-11-17 00:15:52 +00:00
|
|
|
void rotateBuffers();
|
|
|
|
|
void balanceTextureMemory();
|
2011-10-25 05:03:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|