Hi
I have a header file like that. I’m willing to create a grid. By using OpenGl and C++. The problem is in there cpp file. I can’t excatly draw. Hope you can help it.In the for loop i don’t know how to fill inside the vertex blocks
#ifndef Grid_h
#define Grid_h
#include "Shape.h"
class Grid :: public Shape
{
public:
Grid();
Grid(int numberOfLines,int distanceBetweenLines);
void Draw();
int distanceBetweenLines;
int numberOfLines;
};
#endif
#include "Grid.h"
#include <GL/freeglut.h>
Grid :: Grid()
{
numberOfLines = 0.0f;
distanceBetweenLines = 0.0f;
}
Grid:: Grid(int numberOfLines , int distanceBetweenLines )
{
cizimSekli = GL_LINES; //drawing way
numberOfLines= 50; //number of Lines
renk = Renk(0.0f, 1.0f, 0.0f); //Colour
distanceBetweenLines = 20;
for(int x = 0; x < numberOfLines; x++){
glBegin(GL_LINES);
glVertex2f(x,0);
glVertex2f(0,x);
glEnd();
};
for(int y = 0; y < numberOfLines; y++){
glBegin(GL_LINES);
glVertex2f(y,0);
glVertex2f(0,y);
glEnd();
};
}
I’m trying to do the above using vbo. What’s the recommended way of doing it? Been trying to do it via glDrawArrays(GL_LINE_LOOP, …) to no success. Is the only way is to call multiple glDrawArrays or is there a workaround? What if the grid is to be drawn using glElementArras()? Should it be called multiple times too?