📄 cloading.h
字号:
///////////////////////////////////////////////////////////////////////////////////////
// The Loading Pics
/////////////////////////////////////////////////////////////////////////////////
class CLoading
{
public:
void Init(HDC hDC); //start
void Draw(int part); //draw 1-x
void RestoreMatrix(); //call this after in the end of use
~CLoading() { glDeleteTextures(5,Logos); };
private:
GLuint Logos[5];
HDC hDC;
}Loading;
/////////////////////////////////////////////////////////////////////////////////////
void CLoading::Init(HDC hDC)
{
this->hDC=hDC;
glClear(GL_COLOR_BUFFER_BIT);
SwapBuffers(this->hDC);
//load the textures
Logos[0]=LoadTexture("Data/Images/Shire.jpg ",CT_FIND,CT_LINEAR);
Logos[1]=LoadTexture("Data/Images/Bilbos.jpg",CT_FIND,CT_LINEAR);
Logos[2]=LoadTexture("Data/Images/Mordor.jpg",CT_FIND,CT_LINEAR);
Logos[3]=LoadTexture("Data/Images/Castle.jpg",CT_FIND,CT_LINEAR);
Logos[4]=LoadTexture("Data/Images/Bezier.jpg",CT_FIND,CT_LINEAR);
//set up an orthogonal projection
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,480,640,0,0,2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
};
///////////////////////////////////////////////////////////
void CLoading::Draw(int part)
{
float alpha=0.0f;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,640,480,0,0,2);
glMatrixMode(GL_MODELVIEW);
while(alpha<=1)
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
if(part>=1)
{
if(part==1)glColor3f(alpha,alpha,alpha);
else glColor3f(1,1,1);
Bind(Logos[0]);
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(80, 200, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 240, 200, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 240, 40, -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(80, 40, -1.0f); // Top Left Of The Texture and Quad
glEnd();
}
glTranslatef(320,0,0);
if(part>=2)
{
if(part==2)glColor3f(alpha,alpha,alpha);
else glColor3f(1,1,1);
Bind(Logos[1]);
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(80, 200, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 240, 200, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 240, 40, -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(80, 40, -1.0f); // Top Left Of The Texture and Quad
glEnd();
}
glTranslatef(0,240,0);
if(part>=4)
{
if(part==4)glColor3f(alpha,alpha,alpha);
else glColor3f(1,1,1);
Bind(Logos[3]);
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(80, 200, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 240, 200, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 240, 40, -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(80, 40, -1.0f); // Top Left Of The Texture and Quad
glEnd();
}
glTranslatef(-320,0,0);
if(part>=3)
{
if(part==3)glColor3f(alpha,alpha,alpha);
else glColor3f(1,1,1);
Bind(Logos[2]);
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(80, 200, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 240, 200, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 240, 40, -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(80, 40, -1.0f); // Top Left Of The Texture and Quad
glEnd();
}
glTranslatef(160,-120,0);
if(part>=5)
{
if(part==5)glColor3f(alpha,alpha,alpha);
else glColor3f(1,1,1);
Bind(Logos[4]);
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(80, 200, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 240, 200, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 240, 40, -1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(80, 40, -1.0f); // Top Left Of The Texture and Quad
glEnd();
}
alpha+=0.01f;
SwapBuffers(this->hDC);
Sleep(10); //wait a little
}
}
/////////////////////////////////////////////////////////////////////////////////////
void CLoading::RestoreMatrix()
{
glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -