我正在学习OpenGL
并尝试在我的应用程序中创建一个聚光灯。我使用的代码#vertex-shader
如下所示:
#:vertex-shader #{
#version 150 core
in vec3 in_pos;
in vec2 in_tc;
out vec2 tc;
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 20.0f);
GLfloat spot_direction[] = { -1.0, -1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
glEnable(GL_LIGHT0);
void main() {
vec4 pos= vec4(vec3(1.0)*in_pos - vec3(1.0), 1.0);
pos.z=0.0;
gl_Position = pos;
tc = in_tc;
}
}
问题是,每次我尝试运行代码时都会出现一个错误,上面写着:
Type: other, Source: api, ID: 131169, Severity: low
Message: Framebuffer detailed info: The driver allocated storage for renderbuffer 1.
len = 157, written = 0
failed to compile vertex shader of deferred: directional
info log for shader deferred: directional
vertex info log for shader deferred: directional:
ERROR: Unbound variable: when
规格:
Renderer: GeForce GTX 580/PCIe/SSE2
Version: 3.3.0 NVIDIA 319.17
GLSL: 3.30 NVIDIA via Cg compiler
Status: Using GLEW 1.9.0
1024 x 768
OS: Linux debian
我想创建这个聚光灯非常简单,但由于我真的很OpenGL
陌生,直到现在我都不知道如何去做,即使阅读如下来源:
http://www.glprogramming.com/red/chapter05.html#name3
还要在一些亮点可能很难理解的地方阅读,但我现在无法避免这一步,因为我正在按照我的课程安排。有人可以帮助我吗?