繁体   English   中英

OpenGL Shader编译代码在哪里?

[英]Where is OpenGL Shader Compilation code located?

我怀疑我的opengl头文件中可能缺少代码,或者我的编译无法查询和加载与着色器编译有关的代码。 我正在使用简单DirectMedia层,并且可以编写和运行所有OpenGL代码的简短内容-直到接触着色器为止。 我有一个遇到同样问题的朋友。 当我到达着色器时,我得到了很多未声明的语句:

$ 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>

我的makefile看起来像这样:

proceduralTexture: proceduralTexture.o
#   Windows
    gcc -Wall -O3 -o $@ $^ -lopengl32 -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lz

我想念什么?

我想念什么?

在大多数操作系统中,适用于OpenGL的应用程序二进制接口(ABI)仅适用于1.1或1.2版,晚于该版本的版本附带的所有内容都必须在运行时加载。 这称为扩展机制

MacOS X是一个例外,其中可用的OpenGL版本直接由OS版本确定,并且OpenGL框架将已经满足该特定版本的所有需求。

获得现代OpenGL功能的最简单方法是使用扩展程序loader-wrapper。 不幸的是,最受欢迎的(GLEW)仍然不能完全涵盖核心配置文件(您必须启用实验功能)。 但是,要使着色器正常工作就足够了。

因此,我建议转到GLEW主页, 首先阅读所有文档,然后下载GLEW 源代码 (不要担心预构建的二进制库版本),将源代码添加到项目中并以静态版本使用它。 创建OpenGL上下文后,请调用glewInit() ,并将其覆盖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM