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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:03:12+00:00 2026-06-01T14:03:12+00:00

I am completely new to opengl and need some help in drawing a texture

  • 0

I am completely new to opengl and need some help in drawing a texture with gradient applied over it.

Now I am drawing a texture with the following code:

glPushMatrix();
glBindTexture(GL_TEXTURE_2D,fcr.texture);
glTranslatef(trans, 0, 0);
glScalef(sc,sc,1.0);
glColor4f(1.0,1.0,1.0,0.4);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
glColor4f(1,1,1,1);

In the above code glColor4f(1.0,1.0,1.0,0.4); applies transparency to the drawn image. Now instead of a solid transparent color, I would like to apply a transparent gradient to the image so as to simulate the fading out effect.

Found this thread iPhone OpenGL – How to gradient fade out a texture?, which is the same as my question except I want the gradient to be applied to the main image itself instead of reflection. But I couldn’t figure out the solution from answers given.

I guess I should use glTexEnvi, but then how to draw another image with the gradient?

  • 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-01T14:03:13+00:00Added an answer on June 1, 2026 at 2:03 pm

    Instead of calling glColor4f before drawing the quad, can you set a glColorPointer (or glVertexAttribPointer), such that each of the four vertices of your quad get a different alpha value?

    i.e. RGBA values:

     (x,x,x,1)       (x,x,x,0)
         -----------------
         |               |
         |               |
         |               |
         |               |
         |               |
         |               |
         -----------------
      (x,x,x,1)      (x,x,x,0)
    

    This would give you an alpha gradient from right to left.

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

Sidebar

Related Questions

I'm completely new to Matlab and I need some help. I'm running a self-organising
I am completely new to flash. We need to load a binary file from
I'm completely new to Visual Studio and I'm having some trouble getting a project
I'm completely new to OpenGL so sorry if it's a silly question. Also no
I'm completely new in Open GL, so have a question. I need to apply
Completely new to Objective-C, trying to find out when I need to alloc and
I'm completely new to C++ and am breaking my head over a simple problem.
I am completely new to using code first for modeling databases. I've tried to
I'm completely new to sql and can't do that myself. So I need your
I am completely new to openGl. I have so far studied how to draw

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.