Results 1 to 6 of 6

Thread: vertice help

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2019
    Posts
    5

    vertice help

    Code :
     ///////////////////////////////////////////////////////////////////////
    //
    // 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
    Attached Images Attached Images

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2014
    Posts
    110
    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. #3
    Junior Member Newbie
    Join Date
    Jan 2019
    Posts
    5
    Quote Originally Posted by ProgrammerX View Post
    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.
    how do I draw a line

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2014
    Posts
    110
    Quote Originally Posted by sonicflare9 View Post
    how do I draw a line
    https://learnopengl.com/

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2019
    Posts
    5
    Quote Originally Posted by ProgrammerX View Post
    cant find the one with the line drawing

  6. #6
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    Quote Originally Posted by sonicflare9 View Post
    cant find the one with the line drawing
    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.

Similar Threads

  1. Merging vertices into one vertice in OpenGL
    By khofez in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-01-2016, 01:39 PM
  2. Vertice Order matters for Skybox?
    By ParagonArcade in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-13-2014, 09:13 PM
  3. Vertice Normal
    By HaHa in forum OpenGL: General
    Replies: 5
    Last Post: 05-07-2004, 10:27 AM
  4. OT: Vertice magnitude
    By Bode in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-29-2002, 01:51 AM
  5. getting vertice values after transformtions
    By eckiller in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 05-02-2000, 04:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean