WhirlyGlobe  1.2
A 3D interactive globe toolkit for iOS
/Users/sjg/iPhone/WhirlyGlobe/WhirlyGlobeSrc/WhirlyGlobeLib/include/RenderCache.h
00001 /*
00002  *  RenderCache.h
00003  *  WhirlyGlobeLib
00004  *
00005  *  Created by Steve Gifford on 9/19/11.
00006  *  Copyright 2011 mousebird consulting
00007  *
00008  *  Licensed under the Apache License, Version 2.0 (the "License");
00009  *  you may not use this file except in compliance with the License.
00010  *  You may obtain a copy of the License at
00011  *  http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  *  Unless required by applicable law or agreed to in writing, software
00014  *  distributed under the License is distributed on an "AS IS" BASIS,
00015  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  *  See the License for the specific language governing permissions and
00017  *  limitations under the License.
00018  *
00019  */
00020 
00021 #import <UIKit/UIKit.h>
00022 #import <map>
00023 #import "Texture.h"
00024 #import "Drawable.h" 
00025 #import "GlobeScene.h"
00026 
00027 namespace WhirlyGlobe 
00028 {
00029     
00031 bool RenderCacheExists(NSString *baseName);
00032     
00037 class RenderCacheWriter
00038 {
00039 public:
00040     RenderCacheWriter(NSString *fileName);
00041     ~RenderCacheWriter();
00042     
00048     std::string addTexture(SimpleIdentity texId,UIImage *);
00049     
00052     bool addDrawable(const Drawable *);
00053     
00056     void setIgnoreTextures();
00057     
00058 protected:
00059     std::string fileBase;
00060     unsigned int numTextures,numDrawables;
00061     TextureIDMap texIDMap;
00062     FILE *fp;
00063     bool ignoreTextures;
00064 };
00065     
00071 class RenderCacheReader
00072 {
00073 public:
00074     RenderCacheReader(NSString *fileName);
00075     ~RenderCacheReader();
00076 
00079     bool getDrawablesAndTextures(std::vector<Texture *> &textures,std::vector<Drawable *> &drawables);
00080 
00085     bool getDrawablesAndTexturesAddToScene(GlobeScene *scene,SimpleIDSet &texIDs,SimpleIDSet &drawIDs,float fade);
00086     
00087 protected:
00088     unsigned int numTextures,numDrawables;
00089     std::string fileBase;
00090     std::string fileDir;
00091     TextureIDMap texIDMap;
00092     FILE *fp;
00093 };
00094 
00095 }