OpenGL "expression must have a constant value"

  • Energizer94
    Likes 0

    Problem Description

    Here is my full code :s

     

    #define _USE_MATH_DEFINES

    #include <GL/glew.h>
    #include <GLFW/glfw3.h>
    #include <math.h>

    void drawCircle(GLfloat x, GLfloat y, GLfloat z, GLfloat radius, GLint numberOfSides);

    int main(void)
    {
        GLFWwindow *window;

        if (!glfwInit())
        {
            return -1;
        }

        window = glfwCreateWindow(512, 512, "OpenGL Test", NULL, NULL);

        if (!window)
        {
            glfwTerminate();
            return -1;
        }

        while (!glfwWindowShouldClose(window))
        {
            glClear(GL_COLOR_BUFFER_BIT);

            glfwSwapBuffers(window);

            glfwPollEvents();
        }

        glfwTerminate();
    }

    void drawCircle(GLfloat x, GLfloat y, GLfloat z, GLfloat radius, GLint numberOfSides)
    {
        const GLint numberOfVertices = numberOfSides + 2;

        GLfloat doublePi = 2.0f * M_PI;

        GLfloat circleVerticesX[numberOfVertices];
        GLfloat circleVerticesY[numberOfVertices];
        GLfloat circleVerticesZ[numberOfVertices];
    }

     

    My problem is at

    GLfloat circleVerticesX[numberOfVertices];
    GLfloat circleVerticesY[numberOfVertices];
    GLfloat circleVerticesZ[numberOfVertices];

     

    numberOfVertices gives me the error

     

    Thank you!

Login to reply