Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Output of vertex shader is just empty

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    6

    Question Output of vertex shader is just empty

    Hi all,

    I am a beginner and I started playing with vertex shaders and I do not understand why I get an empty screen. This is my paint function:

    Code :
        glPushMatrix();
        glScalef(1.75, 1.75, 1.0);
     
        glClear(GL_COLOR_BUFFER_BIT);
     
        glBlendFunc(GL_ONE, GL_ONE);
        glEnable(GL_BLEND);
        glCallList(myVectors);
     
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_LINE_SMOOTH);
        glLineWidth(2.0);
        glCallList(myGridOverlay);
     
        glDisable(GL_LINE_SMOOTH);
        glDisable(GL_BLEND);
     
        glPopMatrix();


    This code works fine but as soon as I add a vertex shader the output is empty.
    This is the shader:

    Code :
            void main(void)
            {
                gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        	}

    I thought this should basically "do nothing" and display the vertices "as-is". I am sure I do something fundamentally wrong...
    Any suggestions?

    Markus

  2. #2
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    89
    You do not write any outputs to the fragment shader. Without any color or texture coordinates or any information what so ever the fragment shader can not produce any fragments.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    6
    Thanks, that worked! I thought I can use a vertex shader without a fragment shader.

  4. #4
    Intern Newbie
    Join Date
    Dec 2013
    Posts
    45
    This post in another forum suggests that you need to output certain other variables aside from gl_Position if you want to take control of vertex processing but not fragment processing. Specifically, you'll need to give the fixed function fragment processor some colors to work with; the post shows gl_FrontColor as the variable to output for color.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2013
    Posts
    6
    Nice! thanks for pointing this out - that works as well.

  6. #6
    Intern Newbie
    Join Date
    Dec 2013
    Posts
    45
    No problem. Actually, if you like the level of control that playing with vertex shaders gives you, you may want to go ahead and learn OpenGL 3.3+. It drops all the matrix operations, glBegin/glEnd operations, etc. The "core profile" pretty much gives you a platform to write your vertex and fragment (and geometry and tesselation control/evaluation and compute, if you so desire) shaders and functions to give you an interface to your shaders. It is a little more difficult to get going with at first, since it does make you "reinvent the wheel" in a sense, but it gives you MUCH MUCH more flexibility; you decide how all your data is laid out, you decide how to process all your vertices.

Tags for this Thread

Posting Permissions

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