I am looking for a very simple OpenGL program that uses cocoa to create the native window rather than glut. That doesn't use xcode, as I need to be able to build the OpenGL inside a larger project using make. I am new to cocoa so have been struggling to create the OpenGL window.I have no problems writing the OpenGL code, but have spent a lot of time unsuccessfully trying to get a simple OpenGL window.
David
The ogl code goes something like this:
David
The ogl code goes something like this:
Code:
void display()
{
glClear (GL_COLOR_BUFFER_BIT);
glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
glBegin(GL_POLYGON);
glVertex3f (0.25f, 0.25f, 0.0f);
glVertex3f (0.75f, 0.25f, 0.0f);
glVertex3f (0.75f, 0.75f, 0.0f);
glVertex3f (0.25f, 0.75f, 0.0f);
glEnd();
glFlush ();
}
void init()
{
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
}
int main(int argc, char** argv)
{
create_window();
init();
display();
swapbuffer();
return 0;
}