Vertex Buffer Object

Hi
I have written a coding using opengl to draw 5 circle at a distance of 50 km each.

I have implemented this using vertex array , it is working fine
I am trying to do this using vertex buffer object, i have created vbo ,binded it with array vertices but i am not getting proper circle.

I am attaching my code with this if someone knows what mistake i am doing kindly reply.

CODING

/////////////////Declartions///////////////
void createVBO(GLuint* vboId);
GLuint vboId;
float circlevertexarray[5000];

void circledata();
void display();

////////////////////Function to calculate circle vertices///////////////////
void circledata()
{
float v1,v2;
for(int no=1;no<6;no++)
{

                 for(float angle=0;angle&lt;360.0*(3.14/180);angle=angle+0.02)
                     {
                        v1=no*0.42*cos(angle);
                        v2=no*0.42*sin(angle);
                        circlevertexarray[(j*2)+0]=v1;
                        circlevertexarray[(j*2)+1]=v2;
                        j++;
                     }
               }
              indices=j+1;
             printf("%d

",indices);

}

//////////////////////Function to create VBO//////////////////////////////
void createVBO(GLuint* vboId)
{
// create buffer object
glGenBuffers(1,vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
// initialize buffer object
glBufferData(GL_ARRAY_BUFFER,2
indices*sizeof(float),circlevertexarray ,GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if 1
int bufferSize = 0;

glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &bufferSize);

if(indices != bufferSize)
{
   glDeleteBuffersARB(1, vboId);
   vboId = 0;
    printf("datasize mismatch

");
}
else
{
printf("matching
");
}
#endif
}

/////////////////Main///////////////////////////////////
int main(int argc, char** argv)
{
initGL(argc, argv);
circledata();
createVBO(&vboId);

 MulticastInit();
 threadid=pthread_create(&Receivethread,NULL,&sweep,NULL);
 glutDisplayFunc(display);
 glutMainLoop();

}

//////////////////////DISPLAY Function/////////////////
void display()
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
 while(1)
 {
            //usleep(10000);
             glClearColor(0.0,0.0,0.0,1.0);

             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

////////////////////Vertex Buffer Object////////////////////////
#if 1
glColor3f(1.0,1.0,1.0);
glBindBuffer(GL_ARRAY_BUFFER,vboId);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0,0);
glDrawArrays(GL_POINTS,0,indices);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#endif

///////////////////////Vertex array//////////////////////////
#if 0
glColor3f(1.0f,1.0f,1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0,circlevertexarray );
glDrawArrays(GL_POINTS,0,indices);
glDisableClientState(GL_VERTEX_ARRAY);

#endif
}
}

Thank You
 Janani

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.