# No Transparent textures Using OpenGL 1.3 Inizialization

**URL:** https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558
**Category:** support
**Created:** [February 9, 2024, 12:28pm UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558 "2024-02-09T12:28:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![agustinvaquero](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@agustinvaquero](https://discourse.glfw.org/u/agustinvaquero)
#### Post date: [February 9, 2024, 12:28pm UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/1 "2024-02-09T12:28:02Z")

</div>

I have a very strange problem.  
This is my GLFW OpenGL inizialization.

```auto
 glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);// GLFW_OPENGL_CORE_PROFILE);// );
    glfwWindowHint(GLFW_SAMPLES, 8);
    glfwWindowHint(GLFW_ALPHA_BITS, 8);
    glfwWindowHint(GLFW_DEPTH_BITS, 24);
    glfwWindowHint(GLFW_STENCIL_BITS, 8);
    glfwWindowHint(GLFW_ALPHA_BITS, 8);
    glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
    g_Window = glfwCreateWindow(iw, ih, "APP", NULL, NULL);

    if (g_Window == NULL)
    {
        printf("Failed to create GLFW window\n");
        glfwTerminate();
        return -1;
    }
...

```

then My OpenGL configuration…

```auto
 glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, g_iWidthGL, 0, g_iHeightGL, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  
 glEnable(GL_BLEND);
 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

```

my load RGBA Tga Load File funtion…

```auto
void LoadTextureFromTga(uint32_t *uiTextureID, const char* caImg, int32_t* w, int32_t* h )
{
    if (!caImg)	return;

    struct tImageTGA* pImgData = 0;

    pImgData = Load_TGA(caImg);

    if (pImgData == 0) {
        printf("TGA_Texture\n ERROR\n: %s \n ERROR\n", caImg);
        return;
    }
    glGenTextures(1, uiTextureID);
    glBindTexture(GL_TEXTURE_2D, *uiTextureID);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    

    *w = pImgData->size_x;
    *h = pImgData->size_y;

    // Give the image to OpenGL // GL_RGBA
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pImgData->size_x, pImgData->size_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pImgData->data);
    

}

```

and my drawing texture function…

```auto
   glBindTexture(GL_TEXTURE_2D, uiTexture);

    glBindTexture(GL_TEXTURE_2D, uiTexture);
    glEnable(GL_TEXTURE_2D);
        glBegin(GL_QUADS);
            glTexCoord2d(0, 0);
            glVertex2i(v.x, v.y);
            glTexCoord2d(1, 0);
            glVertex2i(v.x + v.w, v.y);
            glTexCoord2d(1, 1);
            glVertex2i(v.x + v.w, v.y + v.h);
            glTexCoord2d(0, 1);
            glVertex2i(v.x, v.y + v.h);
        glEnd();
    glDisable(GL_TEXTURE_2D);

```

So the problem is… when I Draw a plygon with alpha is drawing with thwe correct transparency… but if draw a TGA with RGBA Channels… I Obtain a full white colour insted the tranparency.

I test the same code with glut and it works correwctly.

Any tip for that …!!!  
Thank you.

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [February 9, 2024, 1:07pm UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/2 "2024-02-09T13:07:31Z")

</div>

Hi and welcome to the GLFW forum,

this forum is more for help with using the GLFW API than OpenGL, and this is an OpenGL question.

I would first check that your texture is loaded correctly with alpha by inspecting it’s byte content, as I don’t know what `Load_TGA` does.

---

<div class="post-metadata">

### Author: ![agustinvaquero](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@agustinvaquero](https://discourse.glfw.org/u/agustinvaquero)
#### Post date: [February 9, 2024, 1:33pm UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/3 "2024-02-09T13:33:24Z")

</div>

I Know that is a GLFW forum but I Don´t know what´s happen with this issue  
The LoadTGA funcion load the TGA (without compression) (RGBA information inside the raw file as follows RGBA RGBA RGBA… for an image with 512x512 size… I´m sure that this work fine…

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [February 9, 2024, 2:01pm UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/4 "2024-02-09T14:01:17Z")

</div>

It has been 20 years while since I have used legacy OpenGL, but you may need to specify:

`glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );`

---

<div class="post-metadata">

### Author: ![agustinvaquero](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@agustinvaquero](https://discourse.glfw.org/u/agustinvaquero)
#### Post date: [February 10, 2024, 10:08am UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/5 "2024-02-10T10:08:04Z")

</div>

Thank you very mutch dougbinks…

I create another project form scratch (with the same code) and it works properly even without using …  
glTexEnvf(GL\_TEXTURE\_ENV, GL\_TEXTURE\_ENV\_MODE, GL\_MODULATE );  
So… I have some kind of problem at the big project…  
Sorry for the interruption and thank you for your tip !!  
I have to investigate more for discover the problem, but at the moment I don´t know what´s the problem… so frustrating…

By the way is possible with GLFW library capture to a log file all the instructions OpenGL for a later analysis.

Thank you in advance.

---

<div class="post-metadata">

### Author: ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)
#### Post date: [February 10, 2024, 10:25am UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/6 "2024-02-10T10:25:11Z")

</div>

> By the way is possible with GLFW library capture to a log file all the instructions OpenGL for a later analysis.

No, GLFW is a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. The majority of OpenGL functionality is via the system OpenGL libraries.

There are tools for OpenGL capture and replay but I’m not sure which ones will work with legacy OpenGL. For example [RenderDoc](https://renderdoc.org/) only [supports the core profile of OpenGL - from 3.2 up to 4.6 inclusive](https://renderdoc.org/docs/behind_scenes/opengl_support.html).

---

<div class="post-metadata">

### Author: ![agustinvaquero](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@agustinvaquero](https://discourse.glfw.org/u/agustinvaquero)
#### Post date: [February 10, 2024, 10:48am UTC](https://discourse.glfw.org/t/no-transparent-textures-using-opengl-1-3-inizialization/2558/7 "2024-02-10T10:48:23Z")

</div>

Ok, perfect, Thank you very much.
