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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:00:03+00:00 2026-06-06T09:00:03+00:00

I have very simple OpenGL ES example similar to Hehe’s example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As

  • 0

I have very simple OpenGL ES example similar to Hehe’s example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/

As shown above triangle filled with three colors – red, blue, green.
Instead in my app i always get triangle almost completely filled with black color, only small area around top vertex filled with green and small area around right bottom filled with red … and there is no blue at all.

The first question is : why do the colors not interpolate in the middle of my triangle and why does blue color is not visible at all?

Any changes in my colors array affect nothing, e.g. when i try to make triangle white the colors do not change anyway … in the meantime if i change Z coordinate in positions array then i can see the blue color.

The second question is : why any changes in colors do nothing and changes in positions change the color instead?

Seems like somewhere here i made one stupid mistake but i can’t catch it.

This is Vertex / Color arrays :

const float colors[] = { // this does not work, triangle still black-green-red
    1.0, 1.0, 1.0, 1.0,
    1.0, 1.0, 1.0, 1.0,
    1.0, 1.0, 1.0, 1.0
};

const float positions[] = { // if i change 3rd index to 1.0 then i will see blue color
    -0.5, -0.5, 0.0, 1.0,
     0.0,  0.5, 0.0, 1.0,
     0.5, -0.5, 0.0, 1.0
};

This is VBO :

- (BOOL)setupVBO 
{
    BOOL success = YES;

    glGenBuffers(1, &_positionBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, _positionBuffer);
    glBufferData(
        GL_ARRAY_BUFFER, 
        sizeof(positions) * sizeof(float), 
        &positions[0], 
        GL_STATIC_DRAW);

    glGenBuffers(1, &_colorBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, _colorBuffer);
    glBufferData(
        GL_ARRAY_BUFFER, 
        sizeof(colors) * sizeof(float), 
        &colors[0], 
        GL_STATIC_DRAW);

    return success;
}

Render :

- (void)render:(CADisplayLink*)displayLink
{
    glClearColor(0.5, 0.5, 0.5, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);

    glBindBuffer(GL_ARRAY_BUFFER, _positionBuffer);
    glVertexAttribPointer(_positionSlot, 4, GL_FLOAT, GL_FALSE, 0, NULL);

    glBindBuffer(GL_ARRAY_BUFFER, _colorRenderBuffer);
    glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 0, NULL);

    glDrawArrays(GL_TRIANGLES, 0, 3);

    [_glContext presentRenderbuffer:GL_RENDERBUFFER];
}

Thanks for any advice …

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

    Ok, i found where was the issue 🙂

    As far as i am beginner in Open GL i just copypasted the code from example and renamed some variables … and did not catch that i renamed ColorBuffer (VBO color, i.e. actual color data of drawing object) variable to ColorRenderBuffer variable (place in memory where GL processes actual color data)

    Stupid mistake and i hope nobody will do the same 🙂

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

Sidebar

Related Questions

I have a problem with OpenGl ES 2.0. I've designed a very simple framework
I have a very simple fxml file, with a checkbox: ... <AnchorPane id=AnchorPane xmlns:fx=http://javafx.com/fxml
I'm trying to build a very simple OpenGL-app under Ubuntu 10.04 (I have a
I have a simple Android OpenGL-ES app, and as all the models are very
I have a very simple openGL program in C++. I have made a Sphere
I am trying to make a very simple MFC OpenGL tutorial. There is a
I have very simple a ajax enabled asp .net website with masterpage. I have
I have very simple example of an un-ordered list with a black border, and
I have very simple piece of code. The goal is when i input four-digit
I have very simple window where I have 2 buttons - one for cancel,

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.