Vertice help --


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

//*************************************************************************** // HG-22155-Assignment1.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 "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];


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

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.
	glGenBuffers(2, Buffers);
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[0]);
	glBindAttribLocation(program, 0, "vPosition");
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(0);
	
	//Randomizing vertices coordinates
	for (int i = 0; i < NumVertices; i++)
	{
		float x = (rand() % 200 + 1) / 100.0f - 1;
		float y = (rand() % 200 + 1) / 100.0f - 1;
		vertices[i][0] = x;
		vertices[i][1] = y;

		}


	}


//---------------------------------------------------------------------
//
// display
//

void
display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
	
	//Selecting the buffer
	glBindBuffer(GL_ARRAY_BUFFER, Buffers[0]);
	
	

	//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
	glDrawArrays(GL_LINE_STRIP, 0, NumVertices);
	
	glFlush();
}

void idle()
{
	glutPostRedisplay();
}

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

int
main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA);
	glutInitWindowSize(900, 900);
	glutCreateWindow("Moore Abel 101156682");

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

	init();

	glutDisplayFunc(display);

	glutIdleFunc(idle);

	glutMainLoop();
	
	

}

how do I change rightnow.jpg to look like squaresss.jpg


#2

Sorry, but this is not a “Please do my homework for me”-forum. You could at least have removed the comment section at the start to make it look less like a homework.

Learn how to draw a single line and then start drawing multiple lines. If you encounter a specific problem, than feel free to ask.


#3

[QUOTE=ProgrammerX;1293596]Sorry, but this is not a “Please do my homework for me”-forum. You could at least have removed the comment section at the start to make it look less like a homework.

Learn how to draw a single line and then start drawing multiple lines. If you encounter a specific problem, than feel free to ask.[/QUOTE]

how do I draw a line


#4

https://learnopengl.com/


#5

cant find the one with the line drawing


#6

You’re not supposed to. That site is where you go when you want to learn how to use OpenGL. Once you understand how to use the API, you will have the tools to apply that knowledge to your project and particular needs.