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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:41:25+00:00 2026-05-27T22:41:25+00:00

I have encountered a problem when simulation transparency in OpenGL. Here is the scenario:

  • 0

I have encountered a problem when simulation transparency in OpenGL.
Here is the scenario:

I have a ship which is represented by a sphere.
Now I though about adding a shield around the ship. I chose a sphere too, but with a larger radius and set the alpha factor 0.5 ( opacity ). However, the shield doesn’t appear and the colors don’t blend( as if it was not there ).

The camera is located in the center of the 1st sphere. I think the problem is that I’m inside the sphere, so opengl will just ignore it(not draw it).

The code looks like this:

//ship colors setup with alpha 1.0f
glutSolidSphere(1, 100, 100); original sphere ( ship )
//shield colors setup with alpha 0.5f
glutSolidSphere(3, 100, 100); //the shield whose colors should blend with the rest of  the scene

I have though to simulate the shield with a parallelepiped in front of the ship.
However this is not what I want…

EDIT: I have found the mistake. I was setting the near param of gluPerspective() too
high, so even though i was setting the alpha value correctly, the camera was in front of the object all the time so there was no way of seeing it.

  • 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-27T22:41:26+00:00Added an answer on May 27, 2026 at 10:41 pm

    Seems to work here:

    #include <GL/glut.h>
    
    void display()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0, 0, -5);
    
        glDisable(GL_BLEND); 
        glColor4ub(255,0,0,255);
        glutSolidCube(1.0);
    
        glEnable(GL_BLEND); 
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glColor4ub(0,255,0,64);
        glutSolidSphere(1.5, 100, 100);
    
        glFlush();
        glutSwapBuffers();
    }
    
    void reshape(int w, int h)
    {
        glViewport(0, 0, w, h);
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective( 60, (double)w / (double)h, 0.01, 100 );
    }
    
    int main(int argc, char **argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
    
        glutInitWindowSize(800,600);
        glutCreateWindow("Blending");
    
        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutMainLoop();
        return EXIT_SUCCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered a problem twice now whereby a producer thread produces N work
I have encountered a problem of placing data into the Table View. Here is
I am using ajaxForm. Now I have encountered a problem. My idea is when
I am writing a class. I have encountered the problem in the title. Here
I have encountered a problem that I have not come accross yet when setting
I have encountered a problem in my application. I have two forms, one that
I'm migrating a TSQL stored procedure to PL/SQL and have encountered a problem -
I've recently begun learning C# but have encountered an annoying problem. Every variable I
I have encountered a most annoying problem that occurs on the PWD variable when
I have encountered a rather nasty problem with the DataGridView control (Windows.Forms, .NET Framework

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.