Creating spotlight in OpenGL scene

Posted by Victor Oliveira on Stack Overflow See other posts from Stack Overflow or by Victor Oliveira
Published on 2013-10-31T15:47:16Z Indexed on 2013/10/31 15:53 UTC
Read the original article Hit count: 310

Filed under:
|
|
|

Im studying OpenGL and trying to create a spot light at my application. The code that Im using for my #vertex-shader is below:

    #: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;
            }
}

The thing is, everytime Im trying to run the code an Error that says:

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

Specifications:

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

I guess to create this spotlight is pretty much simple, but since Im really new to OpenGL I dont have a clue how to do it until now, even reading sources like:

http://www.glprogramming.com/red/chapter05.html#name3

Read also in some place that light spots can get really hard to understand, but I cant avoid this step right now since Im following my lecture schedule. Could anybody help me?

© Stack Overflow or respective owner

Related posts about c++

Related posts about opengl