I'm looking at the apple documentation for drawing OpenGL content to the screen, on their 'drawing to a window or view page' (linked below) they show that you can draw by placing data within the drawRect method within the openGL
class. I understand that, but what if you have a customClass
which produces some vertex data you would like to draw. How is that drawn to the screen?
// within the opengl class
-(void) drawRect: (NSRect) bounds
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.85f, 0.35f);
glBegin(GL_TRIANGLES);
{
glVertex3f( 0.0, 0.6, 0.0);
glVertex3f( -0.2, -0.3, 0.0);
glVertex3f( 0.2, -0.3 ,0.0);
}
glEnd();
glFlush();
}
Ideally I would be able to do this within a draw method within my customClass, like...
// within my custom class (ideally)
-(void) draw
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.85f, 0.35f);
glBegin(GL_TRIANGLES);
{
for(int i=0; i<[customClassVertices count]; i++)
glVertex3f(vertices[i].x, vertices[i].y,vertices[i].z);
}
glEnd();
glFlush();
}