openGL -> 函数‘glCreateShader’的隐式声明

问题描述 投票:0回答:0

我从 gcc 收到错误。错误是:

warning: implicit declaration of function ‘glCreateShader’ [-Wimplicit-function-declaration]
  137 |  unsigned int vertex_shader = glCreateShader(GL_VERTEX_SHADER);

我包括标题如下:

ath.h>
#include <time.h>

#include <GL/freeglut.h>
#include <GL/gl.h>

然后我编译程序如下:

gcc main.c -lglut -lGL -lGLEW -lGLU -lm -o snakeGame

顺便说一句,我正在使用 Linux。我的主要功能代码在这里:

int main(int argc, char **argv){
    srand(time(NULL));

    for (int i=0; i<snake_size; ++i){
        snake[i] = 0;
    }

//glut set
    glutInit(&argc, argv);

    glutInitWindowSize(window_x, window_y);
    glutInitWindowPosition(window_position_x, window_position_y);
    glutInitDisplayMode(display_mode);

    int window = glutCreateWindow("snake game");

    glutDisplayFunc(display_function);
    glutKeyboardFunc(keyboard_function);
    glutIdleFunc(idle_function);

//opengl set

    unsigned int vertex_shader = glCreateShader(GL_VERTEX_SHADER);

    glutMainLoop();

    glutDestroyWindow(window);
    printf("game over\n");

    return 0;
}

很可能标题有问题,但我不知道如何解决。

c gcc opengl freeglut
© www.soinside.com 2019 - 2024. All rights reserved.