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

  • Home
  • SEARCH
  • 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 7686161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:25:02+00:00 2026-05-31T19:25:02+00:00

What I want to do is to draw a square where each vertex is

  • 0

What I want to do is to draw a square where each vertex is supposed to have a different color.
This should lead into a nice gradient within the square.
Here’s the code I’m using:

glBegin(GL_QUADS);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(((float)(winWidth-redLineWidth))/2.f,((float)(winHeight-redLineWidth))/2.f);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2f(((float)(winWidth+redLineWidth))/2.f,((float)(winHeight-redLineWidth))/2.f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(((float)(winWidth+redLineWidth))/2.f,((float)(winHeight+redLineWidth))/2.f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(((float)(winWidth-redLineWidth))/2.f,((float)(winHeight+redLineWidth))/2.f);
glEnd();

Please ignore the variables used.
I get a rectangle painted, but it has a solid color.
Where’s the error here?

I’m using GLUT on Mac OS X.

  • 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-31T19:25:03+00:00Added an answer on May 31, 2026 at 7:25 pm

    It seems unlikely that you’ve changed this, but you might try to add a glShadeModel(GL_SMOOTH) call before your drawing code. The default behavior should do as you expected though, so the problem is likely elsewhere.

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

Sidebar

Related Questions

I want to Draw multiple line Graph with each line have different color and
I have a Bitmap and I want to draw circle or square on it.
I have this 800x600square I want to draw to the screen. I want to
I want to draw a square in Assembly language. I have ridden something about
i want to draw line, i have two textfiled in which i enter some
I want to draw a widget (in this example, a canvas) and then remove
I want to draw a shape with square, diamond, and cross shape. The square
So I'm trying to work on a Canvas demo, and I want this square
I have overridden the drawRect: in my UIView and I want to draw several
I have the following code to draw a square outline with the following code.

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.