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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:20:21+00:00 2026-05-23T16:20:21+00:00

I have problems understanding how to use one buffer with 3 different data in

  • 0

I have problems understanding how to use one buffer with 3 different data in it, I have the following structure for my vert,text,color data:

struct xyzf {
    float x, y, z;
};
struct xyf {
    float x, y;
};

struct vertype {
    xyzf points[4];
};
struct textype {
    xyf points[4];
};
struct coltype {
    GLuint points[4];
};

struct buftype {
    vertype vertex;
    textype texcoord;
    coltype color;
};

Then I (try to) use it in the following way (which makes most sense to me):

glBindBufferARB(GL_ARRAY_BUFFER, mybufid);
glVertexPointer(3, GL_FLOAT, sizeof(buftype), 0);
glTexCoordPointer(2, GL_FLOAT, sizeof(buftype), (GLvoid *)sizeof(vertype));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(buftype), (GLvoid *)(sizeof(vertype)+sizeof(textype)));

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

glDrawArrays(GL_QUADS, 0, indices);

glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);

glBindBufferARB(GL_ARRAY_BUFFER, 0); // unbind

But it fails, and its rendering something else than what I got with setting stride and pointers to zero all. When I do that, I get my vertex data correctly rendered, but text/color still incorrect.

I can’t use &data[0].vertex for the last param in glVertexPointer() etc. because I don’t have the data anymore since I am using a VBO, that method works only with vertex arrays.

Also I’m not sure how the count value for glDrawArrays() works, I read docs which say it is the indices, so a quad would have 4, right? But when I multiply the count of quads by 4, it only renders HALF of my vertices, whats going on there? (it will render them all if I multiply by 8…)

  • 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-23T16:20:22+00:00Added an answer on May 23, 2026 at 4:20 pm

    It seems you are interleaving your data per quad, but you should rather interleave it per vertex (at least that’s what usually done).

    Your code should be right if you change the vertex layout to this:

    xyz
    uv
    rgba
    xyz
    uv
    rgba
    xyz
    uv
    rgba
    xyz
    uv
    rgba
    

    Rather than

    xyzxyzxyzxyz
    uvuvuvuv
    rgbargbargbargba
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to C++ and am having problems understanding struct. I have
I have an understanding problem of how the following code works: XMLInputFactory xif =
I have problems with how I should structure my product listing pages, products pages,
We are having a few problems understanding how best to use NHibernate. We typically
I use a structure of function pointers to implement an interface for different backends.
I have problems with understanding the --blocking-io option in rsync. Here's the descripton from
I seem to have a problem understanding how to conditionally test a boolean value
I think I have a problem in understanding the proper way of using MVC.
There are many skills a programmer could have (understanding the problem, asking good questions,
I have problems with bringing a windows mobile 6 form to the front. I

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.