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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:28:15+00:00 2026-05-14T15:28:15+00:00

I have a quad and I would like to use the gradient it produces

  • 0

I have a quad and I would like to use the gradient it produces as a texture for another polygon.

glPushMatrix();
glTranslatef(250,250,0);
    glBegin(GL_POLYGON);


    glColor3f(255,0,0);
glVertex2f(10,0);
glVertex2f(100,0);
glVertex2f(100,100);
glVertex2f(50,50);
glVertex2f(0,100);

    glEnd(); //End quadrilateral coordinates

    glPopMatrix();
    glBegin(GL_QUADS); //Begin quadrilateral coordinates

    glVertex2f(0,0);
glColor3f(0,255,0);
    glVertex2f(150,0);
    glVertex2f(150,150);
    glColor3f(255,0,0);
    glVertex2f(0,150);


    glEnd(); //End quadrilateral coordinates

My goal is to make the 5 vertex polygon have the gradient of the quad (maybe a texture is not the best bet)
Thanks

  • 1 1 Answer
  • 1 View
  • 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-14T15:28:16+00:00Added an answer on May 14, 2026 at 3:28 pm

    Keep it simple!

    It is very simple to create a gradient texture in code, e.g.:

    // gradient white -> black
    GLubyte gradient[2*3] = { 255,255,255, 0,0,0 };
    
    // WARNING: check documentation, I am not quite sure about syntax and order:
    glTexture1D( GL_TEXTURE_1D, 0,3, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, gradient );
    
    // setup texture parameters, draw your polygon etc.
    

    The graphics hardware and/or the GL will create a sweet looking gradient from color one to color two for you (remember: that’s one of the basic advantages of having hardware accelerated polygon drawing, you don’t have to do interpolation work in software).

    Your real problem is: which texture coordinates do you use on the 5 vertex polygon. But that was not your question… 😉

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

Sidebar

Related Questions

I have a quad core machine and would like to write some code to
I have an image with 2D projection(green one) of a 3D quad(blue one), like
If I have a class like this: typedef union { __m128 quad; float numbers[4];
I have an open GL quad that is rendered with a grayscale gradient. I
On top of a dual quad core physical host, I would like to run
I have a Visual Studio 2008 C++ application where I would like to convert
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a LAMP server (Quad Core Debian with 4GB RAM, Apache 2.2 and
I have a texture with a 3x9 repeating section. I don't want to store
When I run a single-threaded program that i have written on my quad core

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.