0
void PatratTexturat(PATRAT patrat, int numar)
        {
            switch(numar)
            {
            case 1:
                if(numar==1)
                    glBindTexture(GL_TEXTURE_2D, id_textura[2]);
                else
                    glBindTexture(GL_TEXTURE_2D,id_textura[3]);
                break;
            case 2:
                if(numar==2)
                    glBindTexture(GL_TEXTURE_2D, id_textura[4]);
                else
                    glBindTexture(GL_TEXTURE_2D, id_textura[5]);
                break;
            case 3:
                if(numar==3)
                    glBindTexture(GL_TEXTURE_2D, id_textura[6]);
                else
                    glBindTexture(GL_TEXTURE_2D, id_textura[7]);
            case 4:
                if(numar==4)
                {
                        glBindTexture(GL_TEXTURE_2D, id_textura[8]);
                }
                else
                {
                glBindTexture(GL_TEXTURE_2D, id_textura[9]);
                }
                break;
            case 5:
                glBindTexture(GL_TEXTURE_2D,id_textura[10]);
                break;
            case 6:
                glBindTexture(GL_TEXTURE_2D,id_textura[11]);
                break;
            case 7:
                glBindTexture(GL_TEXTURE_2D,id_textura[12]);
                break;
            case 8:
                glBindTexture(GL_TEXTURE_2D,id_textura[13]);
                break;
            case 9:
                glBindTexture(GL_TEXTURE_2D,id_textura[14]);
                break;

            default:
                glBindTexture(GL_TEXTURE_2D, NULL);
                break;
            }

            glBegin(GL_QUADS);

            glTexCoord2f(0.0,0.0);
            glVertex2f(patrat.stanga,patrat.jos);

            glTexCoord2f(1.0,0.0);
            glVertex2f(patrat.dreapta,patrat.jos);
            glTexCoord2f(1.0,1.0);
            glVertex2f(patrat.dreapta,patrat.sus);
            glTexCoord2f(0.0,1.0);
            glVertex2f(patrat.stanga,patrat.sus);
            glEnd();
        }

I have the code above and i get the error that case may only be used in a switch statement, and with break the same error. Am i missing some braces?

2
Contributors
4
Replies
16
Views
1 Year
Discussion Span
Last Post by Marius_3
0

Why did you double test for numar over and over like that? (line 6)

Your code is quite the mess. I'd clean it up and try posting again.

0

The code is for a menu. and the menu has more options. If numar==1 then the first option means new game, and the program will show a certain image, thats why i used glBindTexture.

0

Sorry, it's a mess. Let's read just a few lines.

About line 3 you have your switch with numar. Then why are you using an if on line 6? Line 9 never would be executed.

It's a bum code passage. Fix it and post again with the blatent problems cleaned up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.