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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:00:20+00:00 2026-06-07T09:00:20+00:00

I am developing an OpenGL application for the iPhone. In my vertex shader, I

  • 0

I am developing an OpenGL application for the iPhone. In my vertex shader, I need a way to change the color of a large number of (but not all) of my vertices, at once, so I settled on color indexing. This will allow me to leave the VBO static, and modify a single uniform variable rather than looping through each vertex and modifying color information between each frame.

My plan is to create a uniform with a color array, add an integer containing an index in the attributes. Here is my vertex shader:

uniform mat4 u_mvp_matrix;
uniform vec4 u_color_array[];

attribute vec4 a_position;
attribute int a_colorIndex;

varying lowp vec4 v_color;

void main()
{
    v_color = u_color_array[a_colorIndex];

    gl_Position = u_mvp_matrix * a_position;
}

This raises an error:

int can’t be an in in the vertex shader

I did some research. The iPhone supports OpenGL ES 2.0 at the latest, which means it supports GLSL 1.2 at the latest, and apparently integers are only supported in GLSL 1.3 and later. I tried changing a_colorIndex to a float. I didn’t expect it to work, and it didn’t.

How can I specify a color index for each vertex?

  • 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-07T09:00:21+00:00Added an answer on June 7, 2026 at 9:00 am

    Specify the attribute as a float. You can use floats as indices into arrays.

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

Sidebar

Related Questions

I'm developing an iPhone OpenGL application, and I need to use some textures with
I'm developing an OpenGL application. I need to have a model of planet earth
I'm developing an Android 2.2 application. I use C++ to manage all OpenGL ES
I am developing Paint application using OpenGL-ES for iPhone and i want to implement
I'm currently developing an iOS application (iPad and iPhone) that uses OpenGL ES 1.0
I'm developing an slightly animated application (in c++ with opengl). For that, I need
I'm developing an application which make use of display lists offered by OpenGL. My
I'm currently developing an OpenGL ES game for the iPhone and iPod touch. I
I'm developing a desktop OpenGL application, and I want to make sure it'll be
I'm developing a large scale application for iOS 5 using ARC in xcode. The

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.