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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:41:40+00:00 2026-06-14T21:41:40+00:00

Given a vertex shader that looks something like #version 400 compatibility const int max_valence

  • 0

Given a vertex shader that looks something like

#version 400 compatibility

const int max_valence = 6;

in int valence;
in vec3 patch_data[1 + 2 * max_valence];

...

What is the the proper way to map the data to the correct vertex attribs? I’m trying to use a VBO, but I can’t figure out how to pass that large of a value in. glVertexAttribPointer takes at most a vector of size 4. What’s the correct way to get the vertex attributes into the shader?

  • 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-14T21:41:41+00:00Added an answer on June 14, 2026 at 9:41 pm

    Arrays of vertex attributes are legal in OpenGL. However, each member of the array takes up a separate attribute index. They are allocated contiguously, starting from whatever attribute index you give patch_data. Since you’re using GLSL 4.00, you should also be specifying attribute locations explicitly with layout(location = #).

    So if you do this:

    layout(location = 1) in vec3 patch_data[1 + 2 * max_valence];
    

    Then patch_data will cover all attribute indices on the half-open range from 1 to 1 + (1 + 2 * max_valence).

    Each array entry is, from the OpenGL side, a separate attribute. Therefore, you need a separate glVertexAttribPointer call for each separate array index.

    So if your array data in memory looks like an array of 13 vec3’s, tightly packed, then you need to do this:

    for(int attrib = 0; attrib < 1 + (2 * max_valence); ++attrib)
    {
      glVertexAttribPointer(attrib + 1, //Attribute index starts at 1.
        3, //Each attribute is a vec3.
        GL_FLOAT, //Change as appropriate to the data you're passing.
        GL_FALSE, //Change as appropriate to the data you're passing.
        sizeof(float) * 3 * (1 + (2 * max_valence)), //Assuming that these array attributes aren't interleaved with anything else.
        reinterpret_cast<void*>(baseOffset + (attrib * 3 * sizeof(float))) //Where baseOffset is the start of the array data in the buffer object.
      );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the next vertex shader, what is the simplest, most efficient and fastest way
If you have a given vertex how could you determine whether that vertex is
Given that the web application doesn't have su privileges, I'd like to execute a
I am trying to write a gremlin expression that will, for a given vertex,
I have a vertex shader with attributes that may or may not be set
Given a Vertex as: class VertexProps { public: int id; float frame; string name;
I'm making a simple WebGL demo. I have a simple vertex shader that takes
I have Depth first searching algorithm whose pseudo code is given below: DFS(Vertex v)
Given a MySQL table of real estate data, I would like to generate a
Suppose I have a function like this: def getNeighbors(vertex) which returns a list of

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.