Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplay function not working while using OpenGL
    text
    copied!<p>i am trying to draw a line using OpenGL while the both end coordinates of the line are set in the idle function , but it is not getting drawn while I am sending the endpoint coordinates over the network using sockets. below is the snap of the code</p> <pre><code>int main(int argc, char **argv) { glutInit(&amp;argc,argv); glutInitWindowSize( 1024,1024); /* A x A pixel screen window */ glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE); glutCreateWindow("Skeleton Tracker"); /* window title */ glutDisplayFunc(display); /* tell OpenGL main loop what */ glutIdleFunc(idle); //first create the connection then we wil talk about the data transfer... /*****Code for server connection *****/ processRequest(); return 0; } void processrequest() { byte_sent = send(ClientSocket,(char*)&amp;msg_pkt,sizeof(MSG_PACKET),0); ofile&lt;&lt;"\nByte sent for start generating "&lt;&lt;byte_sent&lt;&lt;endl; Sleep(1000); memset(buf,0,sizeof(buf)); glutMainLoop(); } void display(void) { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); /* clear the window */ glColor3f ( 0.0, 1.0 , 0.0); /* draw in light red */ glBegin(GL_LINES); glVertex2f(x[0] , y[0]); glVertex2f(x[1] , y[1]); glEnd(); glEnd(); glFlush(); } void idle(void) { printf("\nIn Idle function\n"); nRetVal = recv(ClientSocket , (char*)mainbuf , 192,0); printf("\nAmount of data received : %d\n" , nRetVal); memcpy(buf , mainbuf , sizeof(buf)); //buf is of 8 bytes to hold 2 floating nos. memcpy( &amp;x[p] ,buf , 4); // upto 3 x[p] = x[p]/10.0; memcpy( &amp;y[p] ,buf+4 , 4); //upto 7 y[p] = y[p]/10.0; glutPostRedisplay(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload