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

  • Home
  • SEARCH
  • 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 8260721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:09:39+00:00 2026-06-08T03:09:39+00:00

I need to draw a line between two meshes I’ve created. Each mesh is

  • 0

I need to draw a line between two meshes I’ve created. Each mesh is associated with a different model matrix. I’ve been thinking on how to do this and I thought of this:

glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(first_object_model_matrix);
glBegin(GL_LINES);
glVertex3f(0, 0, 0); // object coord
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(first_object_model_matrix);
glVertex3f(0, 0, 0); // ending point of the line
glEnd( );

But the problem is that I can’t call glMatrixMode and glLoadMatrixf between glBegin and glEnd. I’m also using shaders and the programmable pipeline, so the idea of turning back to the fixed pipeline with my scene rendered isn’t exciting.

Can you:

  • Suggest me precisely how to draw a line between two meshes (I have their model matrix) with shaders.

or

  • Suggest me how to write code similar to the one above to draw a line having two meshes model matrices.
  • 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-08T03:09:40+00:00Added an answer on June 8, 2026 at 3:09 am

    Calculate the line’s two points by multiplying each one with one of your model matrices. The following is pseudo-code. Since you’re using Qt, you could use its built-in maths libraries to accomplish this effect.

    vec3 line_point_1 = model_matrix_object1 * vec4(0, 0, 0, 1);
    vec3 line_point_2 = model_matrix_object2 * vec4(0, 0, 0, 1);
    // Draw Lines
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would you draw a line connector between two shapes, such that the line
I need to draw a line between 2 divs. I currently use jQuery. The
I'm trying to draw a line between two (2D) points when the user swipes
I need to draw a line one inch long on any device given a
I need to draw a rectange,circle and line and then animate them(press left ->
How can I find the Angle of a line between two points in actionscript
I would like to draw a straight line between where a user touches the
I need a software to draw vectors (line with an arrow) in 3D. Also
I have two coordinates for which I would like to draw a perpendicular line
I've been busy for a long time finding out how to draw a line

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.