OpenGL Vertex Shader

This is a discussion on OpenGL Vertex Shader within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm having trouble binding my handlers to my vertex shader, as well as getting to my fragment shader. Not ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    44

    OpenGL Vertex Shader

    Hello,

    I'm having trouble binding my handlers to my vertex shader, as well as getting to my fragment shader. Not sure if this is the right forum, but I found a lot of OpenGL threads in the search.

    I currently have two handlers that are acting up, the handles to my data structure containing all of my normals, and the one that handles my light.
    Code:
    h_aNormal = safe_glGetAttribLocation(ShadeProg, "aNormal");
    h_aLight = safe_glGetAttribLocation(ShadeProg, "aLight");
    Those are the calls to set it to values in the shader program, and the safe calls are this helper function:
    Code:
    inline GLint safe_glGetAttribLocation(const GLuint program, const char varname[]) {
      GLint r = glGetAttribLocation(program, varname);
      if (r < 0)
        std::cerr << "WARN: "<< varname << " cannot be bound (it either doesn't exist or has been optimized away). safe_glAttrib calls will silently ignore it.\n" << std::endl;
      return r;
    }
    The variables inside my vertex shader are declared outside of main() as
    Code:
    attribute vec3 aLight;
    attribute vec3 aNormal;
    I feel like that's my main issue, but I'm also not sure if my program ever gets to my fragment shader. Even with the binding errors, it renders a picture, but it's always entirely one color, with no shading done at all, though I'm trying to do a full Phong rendering. In my vertex shader I have a
    Code:
    varying vec3 vColor;
    whose value is set to the value of the color inherited by my color handler before I intend to pass it into my fragment shader.

    The reason I think I don't get to my fragment shader is because when I put syntactically incorrect code to intentionally produce error messages, all the errors show up in my vertex shader, but NOT from my fragment shader. How do I know if my fragment shader is ever being run? And yes, I have made sure that the fragment shader is properly installed.

    Any help would be appreciated
    Last edited by synhyborex; 11-04-2012 at 05:51 PM.

  2. #2
    Registered User
    Join Date
    Feb 2011
    Posts
    44
    Nevermind, I realized what the problem was. For some reason my file was saving to an entirely different folder, so now the binding is properly occurring, as well as getting the fragment shader run. Completely amateur mistake.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to change width of a Vertex shader??
    By lukeJ in forum Game Programming
    Replies: 6
    Last Post: 12-04-2010, 10:33 PM
  2. Cel Shader
    By taelmx in forum Game Programming
    Replies: 4
    Last Post: 11-15-2006, 06:36 AM
  3. Shader hell
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 08-18-2006, 09:21 PM
  4. Pixel/Vertex shader framework design
    By VirtualAce in forum Game Programming
    Replies: 1
    Last Post: 07-30-2006, 05:02 AM
  5. tank track vertex shader
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 03-20-2004, 01:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21