oldSkool
oldSkool

Reputation: 1232

glBlendFunc() with 32-bit RGBA textures

I have a texture that is semi-transparent with varying opacity at different locations. I have the main texture bitmap, and a mask bitmap. When the program executes, the alpha values from the mask bitmap are loaded into the alpha values of the main texture bitmap. The areas that I want to be transparent have a value of 255 alpha, and the areas that I want to remain totally opaque have values of 0 alpha. There are in-between values also for mid-transparency.

I have tried all manner of glBlendFunc() settings, but it is either completely invisible or it acts on the RGB colors of the source texture.

Upvotes: 0

Views: 1691

Answers (2)

Gabe Coleman
Gabe Coleman

Reputation: 1

I had the same issue. I was using SDL_Image to load my images. I realized when I was converting the image I was using SDL_DisplayFormat instead of SDL_DisplayFormatAlpha. This solved my issue.

Upvotes: 0

Bahbar
Bahbar

Reputation: 18015

Typically in OpenGL, 0 means transparent and 255 opaque, which is the opposite that you have.

so something like:

glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);

Should work.

Upvotes: 4

Related Questions