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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:22:52+00:00 2026-05-27T07:22:52+00:00

Please help me understand what the following is doing. Specifically, what is variable ‘c’,

  • 0

Please help me understand what the following is doing. Specifically, what is variable ‘c’, and what is the third array dimension for (isn’t an image a 2-dimensional pixel rectangle)?
I’ll post a link to this code if context is needed, but the context in general is mapping this checkerboard pattern to a rotating cube.

GLubyte image[TextureSize][TextureSize][3];
GLubyte image2[TextureSize][TextureSize][3];

// Create a checkerboard pattern
for ( int i = 0; i < 64; i++ ) {
    for ( int j = 0; j < 64; j++ ) {
        GLubyte c = (((i & 0x8) == 0) ^ ((j & 0x8)  == 0)) * 255;
        image[i][j][0]  = c;
        image[i][j][1]  = c;
        image[i][j][2]  = c;
        image2[i][j][0] = c;
        image2[i][j][1] = 0;
        image2[i][j][2] = c;
    }
}
  • 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-27T07:22:53+00:00Added an answer on May 27, 2026 at 7:22 am

    An image is 2 spatial dimensions and color – so 3 dimensions in a way.
    The last [] is the red,green,blue pixel values

    This is just using the ‘c’ array syntax to do the calculations into the memory for you.

    The layout in memory is just
    [row1][col1][red], [row1][col1][green], [row1][col1][blue], [row1][col2][red], [row1][col2][green], [row1][col2][blue] ........

    So if c is either 0 or 255 then

    // sets all red,green,blue to same value = black (c=0) or white (c=255)
    image[i][j][0]  = c;
    image[i][j][1]  = c;
    image[i][j][2]  = c;
    
    // sets red and blue on but green off = purple
    image[i][j][0]  = c;
    image[i][j][1]  = 0;
    image[i][j][2]  = c;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help me understand the following: I create a CharBuffer using CharBuffer.wrapped(new char[12], 2,
Can someone please help me understand the following: In the previous version of NHibernate
Please help me understand the root cause of the following behaviour. In file a.cpp
Please help me to understand why the following code works: <script> var re =
Could someone please help me to understand why the following block of code keeps
Java docs says the following about Set interface, can someone please help me understand
Please help me to understand the following issue. Look at the code example below:
Please help me understand if the following choices I have made are idiomatic/good and
Please help me understand how the process goes. I understand that web browsers contain
I cannot understand how this is possible. Please help!! I have an app with

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.