OSX 1.7 does not draw anything

I’ve used opengl 1.2 for quite many years and want to expand to opengl 3.2+ now. I have a mini mac (osx 1.7.3 Nvidia GeForce 9400) and have looked into several webpages with OpenGL examples. So far I haven’t gotten any one to work. The examples on opengl-tutorial.org don’t compile - respectivly Link.
I have installed GLEW (1.7.0) and GLFW (2.7.2) manualy which compiled with no errors or warnings. Installed with sudo.
Now I have tried to put together a minimalistic programm (from the different example sources). This compiles and links but shows nothing but a black screen. If I set glClearColor it will clear the screen to the set color. But nothing is drawn. Here’s the code:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>

// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <GL/glfw.h>

// Include GLM
//#include <glm/glm.hpp>
//using namespace glm;

int main( void )
// Initialise GLFW
if( !glfwInit() )
fprintf( stderr, "Failed to initialize GLFW
" );
return -1;

glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);

// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
    fprintf( stderr, "Failed to open GLFW window

" );
return -1;

    // Initialize GLEW
    if (glewInit() != GLEW_OK) {
            fprintf(stderr, "Failed to initialize GLEW

return -1;

    glfwSetWindowTitle( "Tutorial 01" );

    // Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );

    // Dark blue background
    glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
    // An array of 3 vectors which represents 3 vertices
    static const GLfloat g_vertex_buffer_data[] = {
       -1.0f, -1.0f, 0.0f,
       1.0f, -1.0f, 0.0f,
       0.0f,  1.0f, 0.0f,

// This will identify our vertex buffer
GLuint vertexbuffer;

// Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);

// The following commands will talk about our ‘vertexbuffer’ buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);

            // Draw nothing, see you in tutorial 2 !

            // 1rst attribute buffer : vertices
            glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
               0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
               3,                  // size
               GL_FLOAT,           // type
               GL_FALSE,           // normalized?
               0,                  // stride
               (void*)0            // array buffer offset

    // Draw the triangle !
    glDrawArrays(GL_TRIANGLES, 0, 3); // Starting from vertex 0; 3 vertices total -&gt; 1 triangle

    // Swap buffers

} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
       glfwGetWindowParam( GLFW_OPENED ) );

// Close OpenGL window and terminate GLFW

return 0;


I also tried one with vertex and fragment shaders with the same result that nothing is drawn. Just a black screen.

Hope any one with more experiance on the subject can give me a hint what the cause of the problem might be.



you will need to use a VertexArrayObject, per default VAO 0 is bound which will lead to an INVALID_OPERATION if you try to draw something.
A vertex and fragment shader is also mandatory.
Note that GLEW will throw an INVALID_ENUM as it tries to get the extension list with a deprecated call, you can ignore the error but you will have to live without any extensions (GLEW still does not play well with core).

@menzel, thanks for your input.

So far the only source of examples I could find that works are these https://github.com/beelsebob/Cocoa-GL-Tutorial. The link came from a thread in the opengl in the Macintosh section. All other examples using glew and glfw had different issues. Either not compilable or do not run as expected. I could compile the previously mentioned opengl-tutorial.org examples my making my own Makefile. But resulting in the same problem that nothing is drawn to the screen. As I’m still new to OGL 3.2+ I can’t say what the cause is and it might just as well be my lack of knowledge.
However the examples from beelzebob are woking fine on osx 10.7.3 with nvidia 9400 chip using OGL 3.2 and glsl 150 core.

Just thought I mention that here in case some other OGL 3.2+ (OSX) newbie has similar issues and is looking for a starting point.

And just to mention it, I also tried compiling the glew / glfw examples on an Ubuntu 10.xx machine which has similar issues as the mac.