菜单显示不正确?(Opengl,C ++)

时间:2013-04-11 16:41:12

标签: c++ opengl graphics

使用:

OpenGL,C ++,Microsoft Visual C ++ 2010 Express。

当游戏开始时,屏幕上没有任何内容。我可以按'd'进入游戏,游戏中的一切都很好,我按“逃跑”,屏幕变黑,但没有显示图像。

这里有应该显示菜单的代码。

void drawMenus(double a[2], double b[2], double c[2], double d[2]){

glBindTexture(GL_TEXTURE_2D, texture[1]);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);

glBegin(GL_QUADS);
    glTexCoord2d(0.0,0.0);
    glVertex2dv(a);
    glTexCoord2d(-1.0,0.0);
    glVertex2dv(d);
    glTexCoord2d(-1.0,-1.0);
    glVertex2dv(c);
    glTexCoord2d(0.0,-1.0);
    glVertex2dv(b);
glEnd();

}

void menuControler(){

      double a[2] = {0,0};
      double b[2] = {0,MAPHEIGHT};
      double c[2] = {MAPDEPTH,MAPHEIGHT};
      double d[2] = {MAPDEPTH,0};
      drawMenus(a,b,c,d);

}

void createMainMenu(){
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glMatrixMode(GL_PROJECTION);
//glEnable(GL_DEPTH_TEST);
//glFlush();
//glMatrixMode(GL_MODELVIEW);

menuControler();
glLoadIdentity();
//glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
//glutPostRedisplay();

}

void toMainMenu(){
gameState = 0;

}

void checkState(){
switch(gameState){
    case 0:
        createMainMenu();
        break;
    default:
        break;
}

}

有什么建议吗?

0 个答案:

没有答案