I am trying to draw this pattern in OpenGL :
To get this, I created the pattern like :
vector< vector<DataPoint> > datas;
float Intensitytemp=0;
float xPos=0, yPos=0, angleInRadians=0;
for (float theta = 0.0f; theta < 4096; theta += 1.f)
{
vector<DataPoint> temp;
angleInRadians = 2 * M_PI*theta / 4096;
for (float r = 0; r < 4096; r += 1.f)
{
xPos = cos(angleInRadians)*r / 4096;
yPos = sin(angleInRadians)*r / 4096;
Intensitytemp = ((float)((int)r % 256)) / 255;
DataPoint dt;
dt.x = xPos;
dt.y = yPos;
dt.Int = Intensitytemp;
temp.push_back(dt);
}
datas.push_back(temp);
}
and I am drawing the pattern as :
glBegin(GL_POINTS);
for (int x = 0; x < 4096; x++)
for (int y = 0; y < 4096; y++)
{
xPos = datas[x][y].x;
yPos = datas[x][y].y;
Intensitytemp = datas[x][y].Int;
glColor4f(0.0f, Intensitytemp, 0.0f, 1.0f);
glVertex3f(xPos, yPos, 0.0f);
}
glEnd();
If I create the data in glBegin()-glEnd()
block,it is working faster. But in both cases,I believe that a better way is doing all in GLSL.I didn't understand the logic behind the modern OpenGL well.
I tried to create vertex buffer array and color arrays but could not get it work. The problem was not about transferring the arrays to graphics card.I am getting stackoverflows in arrays. This is question of another topic but here what I wonder is it possible to do this task in completely GLSL code ( those in .vert file ) without transferring these huge array to graphics card.