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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:15:42+00:00 2026-05-25T00:15:42+00:00

In OpenGL (specifically ES 2.0 in this case), what happens if I pass 2

  • 0

In OpenGL (specifically ES 2.0 in this case), what happens if I pass 2 components per vertex, like so:

  glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, sizeof( MyVertexStruct ), pPos );

…but the shader expects three?

It seems to default the third (Z, in this case) component to 0, which is what I want, but I’m hesitant to rely on the behavior. Is this defined somewhere in the OpenGL, ES, or GLSL standards?

(My search-fu is failing me: can’t find anything in the red book, purple book, or in the khronos.org reference pages, but I may have just overlooked it.)

  • 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-25T00:15:42+00:00Added an answer on May 25, 2026 at 12:15 am

    Although I haven’t looked it up in the OpenGL specification, I’m pretty sure it is defined behaviour, that every attribute gets extended to (0,0,0,1) if it has fewer components, as it is also done this way when using the single attribute functions, like glVertexAttrib2f (which is indeed specified by the standard).

    EDIT: I looked it up in the OpenGL ES 2.0 specification and it says:

    When an array element i is transferred to the GL by the DrawArrays or
    DrawElements commands, each generic attribute is expanded to four
    components. If size is one then the x component of the attribute is
    specified by the array; the y, z, and w components are implicitly set
    to zero, zero, and one, respectively. If size is two then the x and y
    components of the attribute are specified by the array; the z, and w
    components are implicitly set to zero, and one, respectively. If size
    is three then x, y, and z are specified, and w is implicitly set to
    one. If size is four then all components are specified.

    So it is indeed like you and I assumed.

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

Sidebar

Related Questions

OpenGL newbie question: if I do something like this: GLfloat vertices[] = { ....
I am making a GUI in OpenGL (more specifically lwjgl). I have tried hard
I'm having a slight problem with my SDL/Opengl code, specifically, when i try to
In OpenGL, is there a way to use framebuffer data as vertex data without
In OpenGL GLSL syntax, is there any difference between the components of a vector?
This isn't exactly specifically a programming question (or is it?) but I was wondering:
In OpenGL I can do this: glOrtho(-10, 10, -10, 10, -1, 1) to establish
I'm trying to get voice over working with an openGL view, specifically from the
part of my makefile looks like this ... ifdef vis flg += -framework GLUT
I'm working on a 3d game using OpenGL and would like to take it

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.