Bug in code.

Hi,
I am trying to learn OpenGL from "OpenGL SuperBible Sixth Edition". I was able to compile sb6source and example from book. But I get a bug. If I try to run program sometimes it draw point and sometimes do not draw. Point are drawn about once in 10 tries. And I can't figure out why it happens. Can someone find a bug or explain why it happens? Here are example source.

You are drawing one primitive, but without any buffer attached, any without any data.
Cause the vertex shader will transform all the input into gl_position 0, 0, 0, 1 sometime you are lucky and you get some byte of memory that is valid.

I think the program really wants to just draw a point at the origin of clip space and since the vertex shader consumes no inputs it should also not read random memory. Hard to say for me what goes wrong. Perhaps the application requests a depth buffer, but it is never cleared and the single point sometimes fails the depth test? Might also be a driver bug, given that rendering without any vertex attributes is perhaps not a 'traditional' use case...

I guess shader compiler seen my shader as one long line until ";" "#version 430 core void main(void) { gl_Position = vec4(0.0, 0.0, 0.0, 1.0);" And could not compile. But I do not understand why sometimes a point appeared running program. And point color was black, but fs shader color is not black.

Unfortunately #version (and other preprocessor directives) are terminated by line endings, so you need to include it for those lines. Most (or all?) other statements are okay to include on the same line because they are terminated by semi-colons/keywords.