]> git.jsancho.org Git - lugaru.git/commitdiff
Minor SkyBox cleanup
authorAlexander Monakov <amonakov@gmail.com>
Fri, 7 Jan 2011 18:06:29 +0000 (21:06 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Fri, 7 Jan 2011 18:06:29 +0000 (21:06 +0300)
Source/GameTick.cpp
Source/Skybox.cpp
Source/Skybox.h

index 383052eedb45b72dbeb79c6377b10059082dade9..3281f6bf167f6984a920c8769575eb13b32d77c2 100644 (file)
@@ -1332,9 +1332,7 @@ void      Game::Setenvironment(int which)
                        ":Data:Textures:Skybox(snow):Back.jpg",
                        ":Data:Textures:Skybox(snow):Right.jpg",
                        ":Data:Textures:Skybox(snow):Up.jpg",
-                       ":Data:Textures:Skybox(snow):Down.jpg",
-                       ":Data:Textures:Skybox(snow):Cloud.jpg",
-                       ":Data:Textures:Skybox(snow):Reflect.jpg");
+                       ":Data:Textures:Skybox(snow):Down.jpg");
 
 
 
@@ -1373,9 +1371,7 @@ void      Game::Setenvironment(int which)
                        ":Data:Textures:Skybox(sand):Back.jpg",
                        ":Data:Textures:Skybox(sand):Right.jpg",
                        ":Data:Textures:Skybox(sand):Up.jpg",
-                       ":Data:Textures:Skybox(sand):Down.jpg",
-                       ":Data:Textures:Skybox(sand):Cloud.jpg",
-                       ":Data:Textures:Skybox(sand):Reflect.jpg");
+                       ":Data:Textures:Skybox(sand):Down.jpg");
 
 
 
@@ -1413,9 +1409,7 @@ void      Game::Setenvironment(int which)
                        ":Data:Textures:Skybox(grass):Back.jpg",
                        ":Data:Textures:Skybox(grass):Right.jpg",
                        ":Data:Textures:Skybox(grass):Up.jpg",
-                       ":Data:Textures:Skybox(grass):Down.jpg",
-                       ":Data:Textures:Skybox(grass):Cloud.jpg",
-                       ":Data:Textures:Skybox(grass):Reflect.jpg");
+                       ":Data:Textures:Skybox(grass):Down.jpg");
 
 
 
@@ -4149,7 +4143,6 @@ void      Game::Tick()
 
 
                                                dialoguetime+=multiplier;
-                                               skybox.cloudmove+=multiplier;
                                                hawkrotation+=multiplier*25;
                                                realhawkcoords=0;
                                                realhawkcoords.x=25;
index 811029ae92b9757704b579ec04128e0798f637a3..5c4aaab1fb10a8748d2edf769d82cf30560d262f 100644 (file)
@@ -23,234 +23,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Game.h"
 
 extern float viewdistance;
-extern int detail;
-extern bool trilinear;
 extern float blurness;
 extern int environment;
-extern TGAImageRec texture;
 extern bool skyboxtexture;
 extern float skyboxr;
 extern float skyboxg;
 extern float skyboxb;
-extern int tutoriallevel;
 
-bool   SkyBox::load( const char *ffront,const char *fleft,const char *fback,const char *fright,const char *fup,const char *fdown,const char *fcloud,const char *freflect)
+void
+SkyBox::load (const char *ffront, const char *fleft, const char *fback,
+             const char *fright, const char *fup,   const char *fdown)
 {
-/*     static GLuint           type;
-       unsigned char fileNamep[256];
-*/
-       LOGFUNC;
-
-       //front
        Game::LoadTexture(ffront, &front, true, false);
-       //left
-       Game::LoadTexture(fleft, &left, true, false);
-       //back
-       Game::LoadTexture(fback, &back, true, false);
-       //right
+       Game::LoadTexture(fleft,  &left,  true, false);
+       Game::LoadTexture(fback,  &back,  true, false);
        Game::LoadTexture(fright, &right, true, false);
-       //up
-       Game::LoadTexture(fup, &up, true, false);
-       //down
-       Game::LoadTexture(fdown, &down, true, false);
-       //cloud
-       Game::LoadTexture(fcloud, &cloud, true, false);
-       //reflect
-       Game::LoadTexture(freflect, &reflect, true, false);
-/*
-       //front
-       CopyCStringToPascal(ffront,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!front)glGenTextures( 1, &front );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, front);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //left
-       CopyCStringToPascal(fleft,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!left)glGenTextures( 1, &left );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, left);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //back
-       CopyCStringToPascal(fback,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!back)glGenTextures( 1, &back );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, back);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //right
-       CopyCStringToPascal(fright,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!right)glGenTextures( 1, &right );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, right);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //up
-       CopyCStringToPascal(fup,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!up)glGenTextures( 1, &up );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, up);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //down
-       CopyCStringToPascal(fdown,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!down)glGenTextures( 1, &down );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, down);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //cloud
-       CopyCStringToPascal(fcloud,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!cloud)glGenTextures( 1, &cloud );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, cloud);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-
-       //up
-       CopyCStringToPascal(freflect,fileNamep);
-       upload_image( fileNamep ,0); 
-       if(1==1){
-               if ( texture.bpp == 24 )
-                       type = GL_RGB;
-               else
-                       type = GL_RGBA;
-
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               if(!reflect)glGenTextures( 1, &reflect );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-               glBindTexture( GL_TEXTURE_2D, reflect);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-               if(trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
-               if(!trilinear)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-
-               gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-       }
-*/
-       return true;
+       Game::LoadTexture(fup,    &up,    true, false);
+       Game::LoadTexture(fdown,  &down,  true, false);
 }
 
 void   SkyBox::draw()
@@ -263,7 +52,6 @@ void SkyBox::draw()
        M[13]=0;
        M[14]=0;
        glLoadMatrixf(M);
-       //if(environment==2)glTranslatef(0,blurness*viewdistance/1000,0);
        if(environment==2)glScalef(1+blurness/1000,1,1+blurness/1000);
        if(environment!=2)glColor3f(.85*skyboxr,.85*skyboxg,.95*skyboxb);
        else glColor3f(1*skyboxr,.95*skyboxg,.95*skyboxb);
@@ -276,7 +64,6 @@ void SkyBox::draw()
        glDisable(GL_CULL_FACE);
        glEnable(GL_BLEND);
        glDisable(GL_LIGHTING);
-       //              glActiveTextureARB(GL_TEXTURE0_ARB);
        if(skyboxtexture)glEnable(GL_TEXTURE_2D);
        glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glBindTexture(GL_TEXTURE_2D, front); 
@@ -309,7 +96,6 @@ void SkyBox::draw()
        glTexCoord2f(1, 0); glVertex3f( size,  size,  size);
        glTexCoord2f(1, 1); glVertex3f( size,  size, -size);
        glEnd();
-       //if(detail!=0){
        glBindTexture(GL_TEXTURE_2D, down);
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
@@ -321,7 +107,6 @@ void        SkyBox::draw()
        glTexCoord2f(1, 1); glVertex3f( size, -size,  size);
        glTexCoord2f(0, 1); glVertex3f(-size, -size,  size);
        glEnd();
-       //}
        glBindTexture(GL_TEXTURE_2D, right);
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
@@ -342,30 +127,11 @@ void      SkyBox::draw()
        glTexCoord2f(1, 1); glVertex3f(-size,  size,  size);
        glTexCoord2f(0, 1); glVertex3f(-size,  size, -size);
        glEnd();
-       /*
-       glEnable(GL_BLEND);
-       glColor4f(1,1,1,1);
-       glBindTexture(GL_TEXTURE_2D, cloud);
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
-       glBegin(GL_QUADS);
-       glNormal3f( 0.0f, -1.0f, 0);
-       glTexCoord2f(0,                                 (1+cloudmove)*30);      glVertex3f(-size,       size/200, -size);
-       glTexCoord2f(0,                                 0);                             glVertex3f(-size,       size/200,  size);
-       glTexCoord2f((1+cloudmove)*30,  0);                             glVertex3f( size,       size/200,  size);
-       glTexCoord2f((1+cloudmove)*30,  (1+cloudmove)*30);      glVertex3f( size,       size/200, -size);
-       glEnd();
-       glDisable(GL_BLEND);*/
        glEnable(GL_CULL_FACE);
        glDepthMask(1);
        glPopMatrix();
 }
 
-SkyBox::SkyBox()
-{
-       front = 0,left = 0,back = 0,right = 0,up = 0,down = 0,cloud = 0,reflect = 0;
-       cloudmove = 0;
-}
 SkyBox::~SkyBox()
 {
        if (front) glDeleteTextures( 1, &front );
@@ -374,7 +140,5 @@ SkyBox::~SkyBox()
        if (right) glDeleteTextures( 1, &right );
        if (up) glDeleteTextures( 1, &up );
        if (down) glDeleteTextures( 1, &down );
-       if (cloud) glDeleteTextures( 1, &cloud );
-       if (reflect) glDeleteTextures( 1, &reflect );
 };
 
index aa9e1f7e76fa35f63bb56dd0b0aab8301451849e..dc602ce216c78d92e7a54daa4a62c37e93575e8b 100644 (file)
@@ -29,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 class SkyBox{
 public:
-       GLuint                          front,left,back,right,up,down,cloud,reflect;
-       float cloudmove;
+       GLuint front, left, back, right, up, down;
 
-       bool load(const char *ffront,const char *fleft,const char *fback,const char *fright,const char *fup,const char *fdown,const char *fcloud,const char *freflect);
+       void load(const char *ffront, const char *fleft, const char *fback,
+                 const char *fright, const char *fup,   const char *fdown);
        void draw();
 
-       SkyBox();
+       SkyBox(): front(0), left(0), back(0), right(0), up(0), down(0) {}
        ~SkyBox();
 };