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 6661939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:14+00:00 2026-05-26T02:20:14+00:00

I have an Nx4 array of vertices that I’d like to plot using glVertexArray

  • 0

I have an Nx4 array of vertices that I’d like to plot using glVertexArray and glDrawArray. as a 2D scatter plot. I currently initialize the array like so:

GLint data[4][MAX_N_POINT];

for (int j=0; j<MAX_N_POINT; j++)
{
    data[j][0] = 200 + rand()%20 - 10; // X Dimension
    data[j][1] = 400 + rand()%20 - 10; // Y Dimension
    data[j][2] = 600 + rand()%20 - 10; // Z Dimension
    data[j][3] = 1; // W Dimension
}

Then I draw the 2d scatter with:

glVertexPointer(4, GL_INT, 0, data);
glDrawArrays(GL_POINTS, 0, nPlot);

Which shows up correctly as this:

enter image description here

note: the colored squares in the background are so I can easily judge if the points are falling in the correct location

However as I’m only want a 2d plot I’d like to skip over the 2 unused dimensions. I tried telling glVertexPointer that my vertices only have 2 points and then setting the stride between vertices as 2 as well but that doesn’t seem to be working as I thought it should.

glVertexPointer(2, GL_INT, 2, data2); 
glDrawArrays(GL_POINTS, 0, nPlot);

However when I plot this I get a very different result with points showing up at XxY, YxZ, ZxW:

enter image description here

Have I misunderstood the proper function of the stride variable? If not how can I properly set the stride so the bottom plot resembles the top plot?

  • 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-05-26T02:20:15+00:00Added an answer on May 26, 2026 at 2:20 am

    The stride is not the “gap” between vectors, the stride is the distance between vector start locations. So in your case your vectors are “sizeof(int)*4” apart, which is the stride distance to use:

    glVertexPointer(2, GL_INT, sizeof(GLint)*4, data2); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
Have some dates in my local Oracle 11g database that are in this format:
have an an array String classname[]={'a','b','c','d'}; ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>( getApplicationContext(), R.layout.spinner_item_class, R.id.spinnerclasstxt,
Have any one tried to activate fancybox thumbnail gallery using a button or an
I have the following computation I'd like to vectorize in matlab. I have a
Have a photography site that I want to prevent image copying from. How can
Have a look on following application http://itunes.apple.com/us/app/fatbooth/id372268904?mt=8 i think they are using the same
Have some validating problems which seem to appear only when using the Auth component.

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.