Recent

Author Topic: Getting Transparency to work in OpenGL. Also: Working with Texture Maps.  (Read 3930 times)

TomTech71

  • Newbie
  • Posts: 4
I have been pascal/Lazarus/OpenGL graphics based on the openglcontrol example (with the 'fountain of particles') that came with Lazarus. I reverse-engineered that code and rewrote it for what I wanted. I now have a 3D environment with thousands of particles in swarms having fun with gravity algorithms.

My main difficulty is transparency. I can't get Alpha-channel transparency to work. As an example, I want my particles to be round. I create a PNG image with a round circle on a square image background. I transparent all but my circle, so the background will show through the 'unused' sections of my square image. But it doesn't work. The round particle is great, but the unused portion of the square image renders solid black, not allowing the background to shine through. Can anyone shine a light on this?

I have tried a numbr of graphics libraries, but still can't get transparencies.


On, I expect, a related question: In the past, I did some programming for OpenGl using Java/Eclipse/OpenGL/libgdx. I was able create a PNG 'texture map' file, containing a grid of images. Through the libgdx graphics library functions, I was able to load up this texture map, and parse it into an array of 'sprites' containing the individual images contained in the texture map. AND, the transparencies of each of the individual resulting sprite images was intact. I want to be able to accomplish the same 'texture Map to Sprite array' in my current Pascal environment. Anyone have any advice on this as well.

Thanks for your help

Tom
« Last Edit: November 30, 2014, 07:58:03 pm by TomTech71 »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Getting Transparency to work in OpenGL. Also: Working with Texture Maps.
« Reply #1 on: November 29, 2014, 06:05:39 am »
It depends on how you setup your opengl and draw your texture. Have you enabled alpha blending? Do you draw your texture using GL_RGBA? etc.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Getting Transparency to work in OpenGL. Also: Working with Texture Maps.
« Reply #2 on: November 29, 2014, 06:33:09 am »
It migh an issue with png loading code. Try to make one of the pixels half-transparent, see if makes any difference

 

TinyPortal © 2005-2018