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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:59:52+00:00 2026-05-29T22:59:52+00:00

I have to use glDrawPixels to implement a raster algorithm. Right now I’m only

  • 0

I have to use glDrawPixels to implement a raster algorithm.

Right now I’m only trying to get a simple example of glDrawPixels working but having an issue.

GLint height, width, size = 0;
GLbyte *image = NULL;
int i,j=0;

width = 512;
height = 512;
size = width*height;
image = (GLbyte*)malloc(sizeof(GLbyte)*size*3);

for(i = 0; i < size*3; i=i+width*3){
    for(j = i; j < width*3; j=j+3){
        image[j] = 0xFF;
        image[j+1] = 0x00;
        image[j+2] = 0x00;
    }
}

glDrawPixels(width, height, GL_RGB, GL_BYTE, image);

free(image);
gluSwapBuffers();

Above is the code that I’m trying to get to work, from my understanding it should simply draw a 512×512 red square.

However what I get is one red row at the bottom and everything else is grey.

  • 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-29T22:59:55+00:00Added an answer on May 29, 2026 at 10:59 pm

    Your second for() loop is broken — you’re starting at i, but only going up to width * 3, so it doesn’t run at all when i > 0.

    Here’s a simpler approach:

    GLbyte *p = image;
    for (i = 0; i < height; i++) {
        for (j = 0; j < width; j++) {
            *p++ = 0xFF;
            *p++ = 0x00;
            *p++ = 0x00;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have use include ('base.php') script in my other scripts ( more.php ). Now
Respected All, I am newly working on android technology. I have use map view
I have use below below configuration without https. Now url changed to https .
Say I have use date = r.find('abbr') to get <abbr class="dtstart" title="2012-11-16T00:00:00-05:00">November 16, 2012</abbr>
I have use AVQueuePlayer to play two video at the same time, Now I
i have use the DateTime control that show only time in my design view
i have use AspxGridView which has FilterRow property. FilterRow property is working good in
To an intership, I have use the A* algorithm in the following case :
I have made a simple application in which i have use some buttons and
Hi i am developing android application, And now i have to use sqlite database

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.