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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:55:26+00:00 2026-05-27T05:55:26+00:00

I am making a texture in my environment that excludes all white pixels. I

  • 0

I am making a texture in my environment that excludes all white pixels. I read in a ppm file and the fourth value is always set to 0 if it is a white pixel. Everything seems to be in order, I have set up my view correctly and so forth. The texture image is visible with my current code, however the image as a whole is not fully opaque. It is highly see through. Is this a problem with how I am setting up my GL_Blend? Why is the entire texture not opaque as it should be only excluding the white pixels?

first three values are read in as rgb values and fourth value is not in file, it is selected depending on the total value of the three previous numbers from rgb. This texture is not loaded every time I render it is in a display list so only done once.

glPushMatrix();

    FILE *inFile3;
    char dump3[3];
    int max3, k3 = 0;

    inFile3 = fopen("tree.ppm", "r");
    int x3;
    int y3;

    fscanf(inFile3, "%s", dump3);
    fscanf(inFile3, "%d %d", &x3, &y3);


    fscanf(inFile3, "%d", &max3);
    int arraySize3 = y3*(4*x3);
    int pixel3, rgb = 0;
    GLubyte data3[arraySize3];

    for (int i = 0; i < x3; i++) {
        for (int j = 0; j < y3; j++) {
            fscanf(inFile3, "%d", &pixel3);
            data3[k3++] = pixel3;
            rgb += pixel3;

            fscanf(inFile3, "%d", &pixel3);
            data3[k3++] = pixel3;
            rgb += pixel3;

            fscanf(inFile3, "%d", &pixel3);
            data3[k3++] = pixel3;
            rgb += pixel3;

            data3[k3++] = ((rgb) > 760) ? 0 : 255;
            rgb = 0;
        }
    }


    fclose(inFile3);

    glGenTextures(1,&texture3);
    glBindTexture(GL_TEXTURE_2D,texture3);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);


    gluBuild2DMipmaps(GL_TEXTURE_2D,4,x3,y3,GL_RGBA,GL_UNSIGNED_BYTE,data3);


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

    glEnable( GL_TEXTURE_2D );
    glBindTexture( GL_TEXTURE_2D, texture3 );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

    glRotatef(180, 0, 0, 0);
    glTranslatef(0, -19, 0);

    glBegin(GL_QUADS);

    glTexCoord2d(0,0); glVertex3f(30,0,10);
    glTexCoord2d(0,1); glVertex3f(30,20,10);
    glTexCoord2d(1,1); glVertex3f(30,20,-10);
    glTexCoord2d(1,0); glVertex3f(30,0,-10);

    glEnd();

    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);
    glPopMatrix();

Screen shots:
Tree is not solid

enter image description here

  • 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-27T05:55:26+00:00Added an answer on May 27, 2026 at 5:55 am

    In addition to what @bernie pointed out about GluByte arrays and including glBegin/end, the problem was in..

    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

    GL_MODULATE needed to be replaced with GL_REPLACE. This fixed the issue. Thanks for your guys’ help.

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

Sidebar

Related Questions

I am making a game (obviously) and I noticed that my HelloWorldLayer.m file is
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
I'm making a 2D sidescrolling space shooter-type game, where I need a background that
I'm making an universal openGL based app that should work on ipod/iphone 2G/3G/3GS/4 and
I'm making a class that loads an image and calls its method after loading.
I'm making a little game framework that appends Canvas elements to a DIV but
So I'm making an Android 2.2 app that uses GLSurfaceView. My question is, since
I am trying to draw a partly-transparent texture above a coloured quad, so that
I am making application with OpenGL in IOS using PVR texture for making 3D

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.