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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:35:24+00:00 2026-06-17T02:35:24+00:00

When I try to display texture on object it works but only with GL_BLEND

  • 0

When I try to display texture on object it works but only with GL_BLEND disabled. When I enable blending:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

The texture is just not visible anymore. Black screen.
I have really no idea whats going on. Its same for JPG and for PNG with alpha channel.

EDIT (more details):

Well, its hard to paste the code (objects, objects eveywhere and huge) but it goes something like this:

//initialization – i commented everything else

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//preparing texture

glEnable(GL_TEXTURE_2D);
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);

int Mode = GL_BGR;

int nOfColors = image->format->BytesPerPixel;
if (nOfColors == 4) {
    if (image->format->Rmask == 0x000000ff)
        Mode = GL_RGBA;
    else
        Mode = GL_BGRA;
} else if (nOfColors == 3) {
    if (image->format->Rmask == 0x000000ff)
        Mode = GL_RGB;
    else
        Mode = GL_BGR;
}

// glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, image->w, image->h, 0, Mode, GL_UNSIGNED_BYTE, image->pixels);
glDisable(GL_TEXTURE_2D);

//drawing

glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D, _i );

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(x, y);
glTexCoord2f(1, 0);
glVertex2f(x + width, y);
glTexCoord2f(1, 1);
glVertex2f(x + width, y + height);
glTexCoord2f(0, 1);
glVertex2f(x, y + height);
glEnd();

glBindTexture( GL_TEXTURE_2D, NULL );
glDisable(GL_TEXTURE_2D);

EDIT2

“black screen” may be little confusing – i meant that nothing is displayed (my background is black but it doesnt matter) – if i turn blending off i get nice texture on screen – with blending on nothing but background color

  • 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-17T02:35:26+00:00Added an answer on June 17, 2026 at 2:35 am

    So it finally started to work after i changed my image loading library to DevIL. Previous had problems with alpha channel it seems.

    Thanks all for your help

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

Sidebar

Related Questions

i try to display image in my web view background, but i got little
I try to use data raw texture using GL_TEXTURE_RECTANGLE_ARB: void Display::tex(){ GLubyte Texture[16] =
I try to display the Total sum() from a sqlStmt but all i got
When I try to display ImageIcon in JTable only description is rendered.The code is:
I'm try display data from column points , SELECT * from table ORDER by
I am using the following code to try and display in a time in
I am a total beginner to Objective C. Currently I try to display a
I try to get one data column from a MS-Access table and display it
I would like to display an ajax loader icon when user try to submit
Is it possible to display images next to items in FlyoutAnchor submenu? I try

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.