# Thread: How to creat an array function?

1. ## How to creat an array function?

Hey guys,

Can someone please tell me how can i creat an array function? I want to draw multiple 3-D triangles in open GL. I've drew one and want drew more than one using arrays. I would apperciate the help. Thanks in advance. Below is the code for reference:

Code:
```int DrawGLScene(GLvoid)	{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	//   Clear Screen And Depth Buffer

glLoadIdentity();  			              // Reset The Current Modelview Matrix

glTranslatef(-1.5f, 0.0f, -6.0f);			// Move Triangle Left 1.5 Units And Into The Screen 6.0
glRotatef(rtri, 0.0f, 1.0f, 0.0f);			// Rotate The Triangle On The Y axis
draw3DTri();                                                           // calling draw3DTri() function which draws 3-D Triangle

int draw3DTri() {

glBegin(GL_TRIANGLES);		// Drawing Using Triangles

// Front side of Triangle
glColor3f(1.0f,0.0f,0.0f);			// Red
glVertex3f( 0.0f, 1.0f, 0.0f);			// Top
glColor3f(0.0f,1.0f,0.0f);			// Green
glVertex3f(-1.0f, -1.0f, 1.0f);			// Left
glColor3f(0.0f,0.0f,1.0f);			// Blue
glVertex3f( 1.0f,-1.0f, 1.0f);			// Right

// Right side of Triangle
glColor3f(1.0f,0.0f,0.0f);			// Red
glVertex3f( 0.0f, 1.0f, 0.0f);			// Top
glColor3f(0.0f,0.0f,1.0f);			// Blue
glVertex3f( 1.0f,-1.0f, 1.0f);			// Left
glColor3f(0.0f,1.0f,0.0f);			// Green
glVertex3f(1.0f, -1.0f, -1.0f);			// Right

// Back side of Triangle
glColor3f(1.0f,0.0f,0.0f);			// Red
glVertex3f( 0.0f, 1.0f, 0.0f);			// Top
glColor3f(0.0f,1.0f,0.0f);			// Green
glVertex3f(1.0f, -1.0f, -1.0f);			// Left
glColor3f(0.0f,0.0f,1.0f);			// Blue
glVertex3f( -1.0f,-1.0f, -1.0f);			// Right

// Left side of Triangle
glColor3f(1.0f,0.0f,0.0f);			// Red
glVertex3f( 0.0f, 1.0f, 0.0f);			// Top
glColor3f(0.0f,0.0f,1.0f);			// Blue
glVertex3f( -1.0f, -1.0f, -1.0f);			// Left
glColor3f(0.0f,1.0f,0.0f);			// Green
glVertex3f(-1.0f, -1.0f, 1.0f);			// Right

glEnd();											// Finished Drawing The Triangle

return 0;
}```

2. You mean an array of functions? I tried it before and my compiler didn't allow it.