Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:56:46+00:00 2026-06-11T03:56:46+00:00

i am trying to draw a line using OpenGL while the both end coordinates

  • 0

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

int  main(int argc, char **argv) 
{
glutInit(&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*)&msg_pkt,sizeof(MSG_PACKET),0);
ofile<<"\nByte sent for start generating "<<byte_sent<<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( &x[p] ,buf , 4); // upto 3
x[p] = x[p]/10.0;

memcpy( &y[p] ,buf+4 , 4); //upto 7
y[p] = y[p]/10.0;

glutPostRedisplay();

  } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:56:48+00:00Added an answer on June 11, 2026 at 3:56 am

    Thanks buddies for your time … actually I forget to define the orthographic projection matrix before calling the glutMainloop …

    gluOrtho2D( -250, 250, -250, 250);
    

    its working now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw a line using the Graphics 2D but then the
I'm trying to draw a line using ctx.lineTo in loop. I have small function
Using core graphics , I am trying to draw a line, in that when
I am trying to draw some basic graphics primitives(line, rectangle etc.) using GDI+ apis
I'am trying to draw a line above mapkit. If I try to set the
I am trying to draw a line using on touch method. I want that
I'm currently trying to draw a quadratic surface with openGL.When using a single window,my
When trying to draw the following quads in OpenGL using a vertex array (instead
I'm trying to draw a line between two cities, on a world map, using
I'm trying to draw a single line using OnMouseMove() event. My Problem is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.