title: Simple Modern OpenGL Hello World
body: <p>I want to make a simple modern OpenGL hello world Program. I already have some experience with modern OpenGL. I once even compiled my own shaders and all that. Now i want to use some more modern functions like glVertexAttribPointer. The Code Compiles but all i get is a black screen. No triangle is showing up. Is it some problem with my graphics card or am i doing something wrong?</p>
  
  <p>I was following this tutorial: <a href="https://www.youtube.com/watch?v=Dyue3MzJDss&amp;index=5&amp;list=PLRwVmtr-pp06qT6ckboaOhnm9FxmzHpbY" rel="nofollow noreferrer">https://www.youtube.com/watch?v=Dyue3MzJDss&amp;index=5&amp;list=PLRwVmtr-pp06qT6ckboaOhnm9FxmzHpbY</a></p>
  
  <p>When i look in the comments many people say that all they get is a black screen.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #define GL3_PROTOTYPES 1
  #include &lt;GL/glew.h&gt;
  #include &lt;SDL/SDL.h&gt;
  #include &lt;GL/gl.h&gt;
  #include &lt;GL/glu.h&gt;
  #include &lt;vector&gt;
  #define BUFFER_OFFSET(i) ((char *)NULL + (i))
  
  GLuint vbo;
  GLuint w=0;
  float f[]={0.0, 1.0, -1.0, -1.0, 1.0, -1.0};    //vertex array
  
  void init()
  {
    glClearColor(0,0,0,1);
    glEnable(GL_DEPTH_TEST);
    glGenBuffers(1,&amp;vbo); //generate an index for the vertexbuffer
    glBindBuffer(GL_ARRAY_BUFFER,vbo);    //use vbo as ARRAY_BUFFER
    glBufferData(GL_ARRAY_BUFFER,sizeof(f),f,GL_STATIC_DRAW);//fill up the array with vertex and color-data
    glEnableVertexAttribArray(w);
    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
  }
  
  
  void display()
  {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glDrawArrays(GL_TRIANGLES,0,3);       //draw it
  }
  
  int main()
  {
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_SetVideoMode(640,480,32,SDL_OPENGL);
    glewInit();
    Uint32 start;
    SDL_Event event;
    bool running=true;
    init(); 
    bool b=false;
    while(running)
    {
      start=SDL_GetTicks();
      while(SDL_PollEvent(&amp;event))
      {
          switch(event.type)
          {
              case SDL_QUIT:
                  running=false;
                  break;
              case SDL_KEYDOWN:
                  switch(event.key.keysym.sym)
                  {
                      case SDLK_ESCAPE:
                          running=false;
                          break;
                  }
                  break;
  
          }
      }
      display();
      SDL_GL_SwapBuffers();
      if(1000.0/30&gt;SDL_GetTicks()-start)
          SDL_Delay(1000.0/30-(SDL_GetTicks()-start));
    }
    glDeleteBuffers(1,&amp;vbo);
    SDL_Quit();
  }
  </code></pre>