how do I fix the undefined part


#1
 ///////////////////////////////////////////////////////////////////////
//
// MA-101156682-triangles.cpp
//
///////////////////////////////////////////////////////////////////////

//*************************************************************************** // HG-22155-Assignment2.cpp by Abel Moore 101156682 (C) 2018 All Rights Reserved. // // Assignment 1 submission. // // Description: this looks cool //   Click run to see the results. // ***************************************************************************** 



using namespace std;

#include "stdlib.h"
#include "time.h"
#include "vgl.h"
#include <iostream>
#include "LoadShaders.h"
#include "glm\glm.hpp"
#include "glm\gtc\matrix_transform.hpp"


enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };

GLuint Buffers[NumBuffers];


#define X_AXIS glm::vec3(1,0,0)
#define Y_AXIS glm::vec3(0,1,0)
#define Z_AXIS glm::vec3(0,0,1)

const GLuint NumVertices = 10;
const GLfloat scale = 0.5f;
GLfloat vertices[NumVertices][2];

glm::mat4 Projection;
GLuint gVAO;
GLuint MatrixID;
glm::mat4 MVP;
glm::mat4 View;
GLuint colours_vbo;

void init(void)
{

	//Specifying the name of vertex and fragment shaders.
	ShaderInfo shaders[] = {
		{ GL_VERTEX_SHADER, "triangles.vert" },
		{ GL_FRAGMENT_SHADER, "triangles.frag" },
		{ GL_NONE, NULL }
	};

	//Loading and compiling shaders
	GLuint program = LoadShaders(shaders);
	glUseProgram(program);	//My Pipeline is set up

	//Generating two buffers, one is used to store the coordinates of the vertices
	//The other one is not used. Just wanted to show that we can allocate as many as buffers, some of which might left unused.
	GLuint cube_IBO; 
	glGenBuffers(1, &cube_IBO); 
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cube_IBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(index_list), index_list , GL_STATIC_DRAW);
	glBindAttribLocation(program, 0, "vPosition");
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(0);
	glEnable(GL_DEPTH_TEST);
	
	Projection = glm::perspective(glm::radians(45.0f), 4.0f / 3.0f, 0.1f, 100.0f);

	float angle = glutGet(GLUT_ELAPSED_TIME) / 1000.0 * 45; // 45° per second 
	transformObject(1.0f, Z_AXIS, angle, glm::vec3(0, 0, 0));
	glDrawArrays(GL_LINE_LOOP, 0, 4);
}

void transformObject(float scale, glm::vec3 rotationAxis, float rotationAngle, glm::vec3 translation) {
	glm::mat4 Model;
	Model = glm::mat4(1.0f);
	Model = glm::translate(Model, translation);
	Model = glm::rotate(Model, glm::radians(rotationAngle), rotationAxis);
	Model = glm::scale(Model, glm::vec3(scale));

	MVP = Projection * View * Model;
	glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
}

void KeyDown(unsigned char key, int x, int y){
switch(key) {
case'w':
// call a function
break;
case's':
// call a function
break;

default:
break;
    }
}

void KeyUp(unsigned char key, int x, int y) {
	switch (key) {
	case'w':
		// call a function
		break;
	case's':
		// call a function
		break;

	default:
		break;
	}
}
//---------------------------------------------------------------------
//
// display
//

void
display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

	//Selecting the buffer
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[0]);
	
	float cube_vertices[] = { -0.45, -0.45,  0.45,   
		0.45, -0.45,  0.45,  };

	GLushort cube_index_array[] = {
		// front
		0, 1, 2,
		2, 3, 0,
		// top
		1, 5, 6,
		6, 2, 1,
		
		
	};

	//Pushing the coordinates of the vertices into the buffer
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	//Ordering the GPU to start the pipeline
	glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);

	
	glutSwapBuffers();

}

void idle()
{
	
}

void Timer(int id) {
	glutPostRedisplay();
	glutTimerFunc(33, Timer, 0);

};

//---------------------------------------------------------------------
//
// main
//

int
main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(600, 600);
	glutCreateWindow("Abel Moore 101156682");
	glutKeyboardFunc(KeyDown);
	glutKeyboardFunc(KeyUp);
	glutTimerFunc(1000.0 / 60.0, Timer, 0);
		
	glutGet(GLUT_ELAPSED_TIME);




	glewInit();	//Initializes the glew and prepares the drawing pipeline.

	init();

	glutDisplayFunc(display);

	glutIdleFunc(idle);

	glutMainLoop();
	
	

}

can anyone help me index_list says its undefined how do I define it


#2

You have it inside your display() method - GLushort cube_index_array[]
You need to pass this as index_list in init function


#3

transformObject: identifier not found line 73

 ///////////////////////////////////////////////////////////////////////
//
// MA-101156682-triangles.cpp
//
///////////////////////////////////////////////////////////////////////

//*************************************************************************** // HG-22155-Assignment2.cpp by Abel Moore 101156682 (C) 2018 All Rights Reserved. // // Assignment 1 submission. // // Description: this looks cool //   Click run to see the results. // ***************************************************************************** 



using namespace std;

#include "stdlib.h"
#include "time.h"
#include "vgl.h"
#include <iostream>
#include "LoadShaders.h"
#include "glm\glm.hpp"
#include "glm\gtc\matrix_transform.hpp"


enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };

GLuint Buffers[NumBuffers];


#define X_AXIS glm::vec3(1,0,0)
#define Y_AXIS glm::vec3(0,1,0)
#define Z_AXIS glm::vec3(0,0,1)

const GLuint NumVertices = 10;
const GLfloat scale = 0.5f;
GLfloat vertices[NumVertices][2];

glm::mat4 Projection;
GLuint gVAO;
GLuint MatrixID;
glm::mat4 MVP;
glm::mat4 View;
GLuint colours_vbo;

void init(void)
{

	//Specifying the name of vertex and fragment shaders.
	ShaderInfo shaders[] = {
		{ GL_VERTEX_SHADER, "triangles.vert" },
		{ GL_FRAGMENT_SHADER, "triangles.frag" },
		{ GL_NONE, NULL }
	};

	//Loading and compiling shaders
	GLuint program = LoadShaders(shaders);
	glUseProgram(program);	//My Pipeline is set up

	//Generating two buffers, one is used to store the coordinates of the vertices
	//The other one is not used. Just wanted to show that we can allocate as many as buffers, some of which might left unused.
	GLuint cube_IBO; 
	glGenBuffers(1, &cube_IBO); 
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cube_IBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
	glBindAttribLocation(program, 0, "vPosition");
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(0);
	glEnable(GL_DEPTH_TEST);
	
	Projection = glm::perspective(glm::radians(45.0f), 4.0f / 3.0f, 0.1f, 100.0f);

	float angle = glutGet(GLUT_ELAPSED_TIME) / 1000.0 * 45; // 45° per second 
	transformObject(1.0f, Z_AXIS, angle, glm::vec3(0, 0, 0));
	glDrawArrays(GL_LINE_LOOP, 0, 4);
}

void transformObject(float scale, glm::vec3 rotationAxis, float rotationAngle, glm::vec3 translation) {
	glm::mat4 Model;
	Model = glm::mat4(1.0f);
	Model = glm::translate(Model, translation);
	Model = glm::rotate(Model, glm::radians(rotationAngle), rotationAxis);
	Model = glm::scale(Model, glm::vec3(scale));

	MVP = Projection * View * Model;
	glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
}

void KeyDown(unsigned char key, int x, int y){
switch(key) {
case'w':
// call a function
break;
case's':
// call a function
break;

default:
break;
    }
}

void KeyUp(unsigned char key, int x, int y) {
	switch (key) {
	case'w':
		// call a function
		break;
	case's':
		// call a function
		break;

	default:
		break;
	}
}
//---------------------------------------------------------------------
//
// display
//

void
display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

	//Selecting the buffer
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[0]);
	
	float cube_vertices[] = { -0.45, -0.45,  0.45,   
		0.45, -0.45,  0.45,  };

	GLushort cube_index_array[] = {
		// front
		0, 1, 2,
		2, 3, 0,
		// top
		1, 5, 6,
		6, 2, 1,
		
		
	};

	//Pushing the coordinates of the vertices into the buffer
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	//Ordering the GPU to start the pipeline
	glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);

	
	glutSwapBuffers();

}

void idle()
{
	
}

void Timer(int id) {
	glutPostRedisplay();
	glutTimerFunc(33, Timer, 0);

};

//---------------------------------------------------------------------
//
// main
//

int
main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(600, 600);
	glutCreateWindow("Abel Moore 101156682");
	glutKeyboardFunc(KeyDown);
	glutKeyboardFunc(KeyUp);
	glutTimerFunc(1000.0 / 60.0, Timer, 0);
		
	glutGet(GLUT_ELAPSED_TIME);




	glewInit();	//Initializes the glew and prepares the drawing pipeline.

	init();

	glutDisplayFunc(display);

	glutIdleFunc(idle);

	glutMainLoop();
	
	

}


#4

You cannot use an identifier before you declare it. With the exception of statements within a class member which refer to other members of that class that have yet to be defined.


#5

i get a lot of warnings how do I fix them

warningsssssssssssssssssssssss

 ///////////////////////////////////////////////////////////////////////
//
// MA-101156682-triangles.cpp
//
///////////////////////////////////////////////////////////////////////

//*************************************************************************** // HG-22155-Assignment2.cpp by Abel Moore 101156682 (C) 2018 All Rights Reserved. // // Assignment 1 submission. // // Description: this looks cool //   Click run to see the results. // ***************************************************************************** 



using namespace std;

#include "stdlib.h"
#include "time.h"
#include "vgl.h"
#include <iostream>
#include "LoadShaders.h"
#include "glm\glm.hpp"
#include "glm\gtc\matrix_transform.hpp"


enum VAO_IDs { Triangles, NumVAOs };
enum Buffer_IDs { ArrayBuffer, NumBuffers };
enum Attrib_IDs { vPosition = 0 };

GLuint Buffers[NumBuffers];


#define X_AXIS glm::vec3(1,0,0)
#define Y_AXIS glm::vec3(0,1,0)
#define Z_AXIS glm::vec3(0,0,1)

const GLuint NumVertices = 10;
const GLfloat scale = 0.5f;
GLfloat vertices[NumVertices][2];

glm::mat4 Projection;
GLuint gVAO;
GLuint MatrixID;
glm::mat4 MVP;
glm::mat4 View;
GLuint colours_vbo;

void transformObject(float scale, glm::vec3 rotationAxis, float rotationAngle, glm::vec3 translation) {
	glm::mat4 Model;
	Model = glm::mat4(1.0f);
	Model = glm::translate(Model, translation);
	Model = glm::rotate(Model, glm::radians(rotationAngle), rotationAxis);
	Model = glm::scale(Model, glm::vec3(scale));

	MVP = Projection * View * Model;
	glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
}

void init(void)
{

	//Specifying the name of vertex and fragment shaders.
	ShaderInfo shaders[] = {
		{ GL_VERTEX_SHADER, "triangles.vert" },
		{ GL_FRAGMENT_SHADER, "triangles.frag" },
		{ GL_NONE, NULL }
	};

	//Loading and compiling shaders
	GLuint program = LoadShaders(shaders);
	glUseProgram(program);	//My Pipeline is set up

	//Generating two buffers, one is used to store the coordinates of the vertices
	//The other one is not used. Just wanted to show that we can allocate as many as buffers, some of which might left unused.
	GLuint cube_IBO; 
	glGenBuffers(1, &cube_IBO); 
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cube_IBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
	glBindAttribLocation(program, 0, "vPosition");
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(0);
	glEnable(GL_DEPTH_TEST);
	
	Projection = glm::perspective(glm::radians(45.0f), 4.0f / 3.0f, 0.1f, 100.0f);

	float angle = glutGet(GLUT_ELAPSED_TIME) / 1000.0 * 45; // 45° per second 
	transformObject(1.0f, Z_AXIS, angle, glm::vec3(0, 0, 0));
	glDrawArrays(GL_LINE_LOOP, 0, 4);
}



void KeyDown(unsigned char key, int x, int y){
switch(key) {
case'w':
// call a function
break;
case's':
// call a function
break;

default:
break;
    }
}

void KeyUp(unsigned char key, int x, int y) {
	switch (key) {
	case'w':
		// call a function
		break;
	case's':
		// call a function
		break;

	default:
		break;
	}
}
//---------------------------------------------------------------------
//
// display
//

void
display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

	//Selecting the buffer
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[0]);
	
	float cube_vertices[] = { -0.45, -0.45,  0.45,   
		0.45, -0.45,  0.45,  };

	GLushort cube_index_array[] = {
		// front
		0, 1, 2,
		2, 3, 0,
		// top
		1, 5, 6,
		6, 2, 1,
		
		
	};

	//Pushing the coordinates of the vertices into the buffer
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

	//Ordering the GPU to start the pipeline
	glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);

	
	glutSwapBuffers();

}

void idle()
{
	
}

void Timer(int id) {
	glutPostRedisplay();
	glutTimerFunc(33, Timer, 0);

};

//---------------------------------------------------------------------
//
// main
//

int
main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
	glutInitWindowSize(600, 600);
	glutCreateWindow("Abel Moore 101156682");
	glutKeyboardFunc(KeyDown);
	glutKeyboardFunc(KeyUp);
	glutTimerFunc(1000.0 / 60.0, Timer, 0);
		
	glutGet(GLUT_ELAPSED_TIME);




	glewInit();	//Initializes the glew and prepares the drawing pipeline.

	init();

	glutDisplayFunc(display);

	glutIdleFunc(idle);

	glutMainLoop();
	
	

}


#6

1: Your list of warnings is illegible.

2: Your list of warnings is an image, rather than text that we can interact with normally (copying and pasting, etc).

3: Your question overall doesn’t seem at present to have anything to do with OpenGL. It seems more like general C++ programming problems in an application that just so happens to use OpenGL.