我懷疑我可能在我的opengl頭文件中缺少代碼,或者我的編譯無法查詢和加載與着色器編譯相關的代碼。我使用Simple DirectMedia Layer,我可以編寫和運行OpenGL代碼的所有短片 - 直到我着色。我有一個朋友有同樣的問題。當我得到着色器時,我得到了很多未聲明的語句:OpenGL Shader編譯代碼位於何處?
$ make
cc -c -o proceduralTexture.o proceduralTexture.c
proceduralTexture.c: In function 'PrintShaderLog':
proceduralTexture.c:60:22: error: 'GL_INFO_LOG_LENGTH' undeclared (first use in
this function)
glGetShaderiv(obj,GL_INFO_LOG_LENGTH,&len);
^
proceduralTexture.c:60:22: note: each undeclared identifier is reported only onc
e for each function it appears in
proceduralTexture.c:70:22: error: 'GL_COMPILE_STATUS' undeclared (first use in t
his function)
glGetShaderiv(obj,GL_COMPILE_STATUS,&len);
^
proceduralTexture.c: In function 'PrintProgramLog':
proceduralTexture.c:76:23: error: 'GL_INFO_LOG_LENGTH' undeclared (first use in
this function)
glGetProgramiv(obj,GL_INFO_LOG_LENGTH,&len);
^
proceduralTexture.c:85:23: error: 'GL_LINK_STATUS' undeclared (first use in this
function)
glGetProgramiv(obj,GL_LINK_STATUS,&len);
^
proceduralTexture.c: In function 'SDL_main':
proceduralTexture.c:430:34: error: 'GL_FRAGMENT_SHADER' undeclared (first use in
this function)
_procShader = glCreateShader(GL_FRAGMENT_SHADER);
^
proceduralTexture.c:438:34: error: 'GL_VERTEX_SHADER' undeclared (first use in t
his function)
_vertShader = glCreateShader(GL_VERTEX_SHADER);
^
make: *** [proceduralTexture.o] Error 1
我有OpenGL版本4.2。我包括proceduralTexture.c的文件有:
#include <stdio.h>
#include <math.h>
#include "SDL/SDL.h"
#include <GL/gl.h>
#include <GL/glu.h>
而且我生成文件看起來像這樣:
proceduralTexture: proceduralTexture.o
# Windows
gcc -Wall -O3 -o [email protected] $^ -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lz
我缺少什麼?
如果你#include'它工作嗎? OpenGL規範指出:「'和''的組合總是爲最新OpenGL版本的所有配置文件以及註冊表中定義的所有擴展定義所有API。」如果你使用核心配置文件,那麼規範說你可以使用'#include '。 –
bames53
我累了'#包括'沒有運氣(沒有變化)。我似乎沒有glcorearb頭文件。 –
danglingPointer