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:

    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:

        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

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.

Thanks, that worked! I thought I can use a vertex shader without a fragment shader.

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.

Nice! thanks for pointing this out - that works as well.

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.