Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Check if a varying variable was defined in vertex file

  1. #1
    Newbie Newbie
    Join Date
    Nov 2018

    Check if a varying variable was defined in vertex file

    I'm editing shaders for a game and i came up with a problem.
    There are two files: x.vertex and x.fragment. I'm creating a varying vec3 POS in the vertex file to pass data to the fragment file. Howerver, sometimes POS doesnt get defined in the vertex file, so my code crashes in the fragment file if i try to use it. Is there a way to determine from .fragment file if the variable was defined in the .vertex file?
    Pseudocode might look like this:

    Code glsl:
    varying vec3 POS = vec3(1.0, 1.0, 1.0);

    Code glsl:
    varying vec3 POS;
    float data;
    if(defined(POS)){//i dont know what to do there...
        data = POS.x;
    data = POS.x;//if i just write this it crashes

    I can add the actual code if needed.
    Last edited by Dark Photon; 11-25-2018 at 02:22 PM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Are you sure that you're checking the link status returned from glLinkProgram?

    Ref: GLSL Full Compile Linking

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts