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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:52:48+00:00 2026-06-05T11:52:48+00:00

I’m trying to port a simple OpenGL ES 2.0 renderer I made for iOS

  • 0

I’m trying to port a simple OpenGL ES 2.0 renderer I made for iOS to OS X desktop and I’m running into into a ‘nothing rendering’ problem, and I don’t get any errors reported so I’m at a loss what to do. So far I’ve narrowed the problem down to a call I make to glVertexAttrib4f, which is only working in OS X. Can anyone take a look at the following code and see why the call to glVertexAttrib4f doesn’t work on desktop?:

void Renderer::drawTest()
{
    gl::clear( mBackgroundColor );

    static Vec2f vertices[3] = { Vec2f( 0, 0 ), Vec2f( 0.5, 1 ), Vec2f( 1, 0 ) };
    static int indices[3] = { 0, 1, 2 };

    mShader.bind();

    glEnableVertexAttribArray( mAttributes.position );
    glVertexAttribPointer( mAttributes.position, 2, GL_FLOAT, GL_FALSE, 0, &vertices[0] );

#ifdef USING_GENERIC_ARRAY_POINTER
    // works in iOS /w ES2 and OSX:
    static Color colors[3] = { Color( 0, 0, 1 ), Color( 0, 0, 1 ), Color( 0, 0, 1 ) };
    glEnableVertexAttribArray( mAttributes.color );
    glVertexAttribPointer( mAttributes.color, 3, GL_FLOAT, GL_FALSE, 0, &colors[0] );
#else // using generic attribute
    // works in iOS, but doesn't work in OSX ?:
    glVertexAttrib4f( mAttributes.color, 0, 1, 1, 1 );
#endif

    glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, &indices[0] );

    errorCheck(); // calls glGetError, which always returns GL_NO_ERROR
}

note: this is example code that I stripped out of something much more complex, please forgive me for not making it more complete.

versions:
desktop OS X is 2.1 ATI-7.18.18
iPhone simulator is OpenGL ES 2.0 APPLE

  • 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-05T11:52:50+00:00Added an answer on June 5, 2026 at 11:52 am

    The reason why drawing wasn’t happening while calling glVertexAttrib4f was that mAttributes.color was automatically bound to location 0; I did not call glBindAttribLocation, but instead relied on the originally bounded values during linking. Apparently in GL compatibility context (2.1 in OS X), glDrawElements may not draw anything if whatever attribute is bounds at location 0 is not ‘enabled’, i.e. you call glEnableVertexAttribArray on it.

    So, when I explicitly bind position to 0 and color to 1, I can call glVertexAttrib*() on the color attribute and it will draw just fine in both OS X (legacy) and ES 2.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

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.