}
static void toggleFullscreen(){
- SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
- //~ SDL_Surface* screen=SDL_GetVideoSurface();
- //~ Uint32 flags=screen->flags;
- //~ screen=SDL_SetVideoMode(0,0,0,flags^SDL_FULLSCREEN);
- //~ if(!screen)
- //~ screen=SDL_SetVideoMode(0,0,0,flags);
- //~ if(!screen)
- //~ exit(1);
- //~ //reload opengl state
- //~ initGL();
- //~ for(std::vector<TextureInfo>::iterator it=Game::textures.begin(); it!=Game::textures.end(); it++) {
- //~ it->load();
- //~ }
- //~ pgame->text.BuildFont();
- //~ pgame->LoadScreenTexture();
+ if(!SDL_WM_ToggleFullScreen(SDL_GetVideoSurface())){
+ SDL_Surface* screen=SDL_GetVideoSurface();
+ Uint32 flags=screen->flags;
+ screen=SDL_SetVideoMode(0,0,0,flags^SDL_FULLSCREEN);
+ if(!screen)
+ screen=SDL_SetVideoMode(0,0,0,flags);
+ if(!screen)
+ exit(1);
+ //reload opengl state
+ initGL();
+ Texture::reloadAll();
+ if(text)
+ text->BuildFont();
+ if(firstload){
+ screentexture=0;
+ LoadScreenTexture();
+ }
+ screentexture2=0;
+ }
}
static void sdlEventProc(const SDL_Event &e)
int skinsize;
GLubyte* data;
int datalen;
+ GLubyte* skindata;
void load();
void TextureRes::load(){
//load image into 'texture' global var
- unsigned char filenamep[256];
- CopyCStringToPascal(ConvertFileName(filename.c_str()),filenamep);
- upload_image(filenamep,hasAlpha);
+ if(!skindata){
+ unsigned char filenamep[256];
+ CopyCStringToPascal(ConvertFileName(filename.c_str()),filenamep);
+ upload_image(filenamep,hasAlpha);
+ }
skinsize=texture.sizeX;
GLuint type=GL_RGBA;
}
if(isSkin){
- free(data);
- const int nb=texture.sizeY*texture.sizeX*(texture.bpp/8);
- data=(GLubyte*)malloc(nb*sizeof(GLubyte));
- datalen=0;
- for(int i=0;i<nb;i++)
- if((i+1)%4||type==GL_RGB)
- data[datalen++]=texture.data[i];
- glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
+ if(skindata){
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skinsize, skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, skindata);
+ }else{
+ free(data);
+ const int nb=texture.sizeY*texture.sizeX*(texture.bpp/8);
+ data=(GLubyte*)malloc(nb*sizeof(GLubyte));
+ datalen=0;
+ for(int i=0;i<nb;i++)
+ if((i+1)%4||type==GL_RGB)
+ data[datalen++]=texture.data[i];
+ glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
+ }
}else{
glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, type, GL_UNSIGNED_BYTE, texture.data);
}
TextureRes::TextureRes(const string& _filename, bool _hasMipmap, bool _hasAlpha):
id(0),filename(_filename),hasMipmap(_hasMipmap),hasAlpha(_hasAlpha),isSkin(false),
- skinsize(0),data(NULL),datalen(0) {
+ skinsize(0),data(NULL),datalen(0),skindata(NULL) {
load();
list.push_back(this);
}
TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
id(0),filename(_filename),hasMipmap(_hasMipmap),hasAlpha(false),isSkin(true),
- skinsize(0),data(NULL),datalen(0) {
+ skinsize(0),data(NULL),datalen(0),skindata(NULL) {
load();
*skinsizep=skinsize;
for(int i=0;i<datalen;i++)
array[i]=data[i];
+ skindata=array;
list.push_back(this);
}
}
void TextureRes::reloadAll(){
- for(vector<TextureRes*>::iterator it=list.begin();it!=list.end();it++)
+ for(vector<TextureRes*>::iterator it=list.begin();it!=list.end();it++){
+ (*it)->id=0;
(*it)->load();
+ }
}