PDA

View Full Version : "Transperent color" on the image and high quality textures



-=MadMan=-
05-11-2005, 07:49 AM
Hi to All.
I'm a newbie to OpenGL so please be patient to my question ;]
I'm trying to implement a simple crossplatform OpenGL based 2D-Canvas engine. Simply adding a plane and bindind texture to it.
The question is: how to make that the invisible color from the base image where absolutely transperent? I mean that: if there is a "transperent hole" on the image and I place another plane with texture behind it and it would be visible.
I tried using

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
but it works other way than I want.
And the other thing. How to make output more clear, not so blended, as if I used low quality textures? The perfect result would be to get 1 to 1 pixel match, without any interpolation.
Thanks a lot for your answers.
With best regards. Daniel.

CWiC
05-11-2005, 09:47 AM
If you wish to create holes (without shaders where you can discard fragments depending on their color) you must add alpha channel to the image and set value 'transparent' to pixels with key color. It's simply a matter of concerting RGB image to RGBA and then set appropriate alpha value (0 or 255). Then blending will start to work.
For the second part - you probably talking about filtering, not blending. If you wish to have 1 to 1 mapping your rendered primitive must be equal to texture size - it's obvious. If you render quad for full screen at 1600x1200 display with 256x256 texture - textels gets interpolated. Try to set nearest and linear filtering mode and see the difference.

-=MadMan=-
05-11-2005, 10:13 AM
The image contains Alpha channel and the transperent color is (0,0,0,0). I use gluBuild2DMipmaps with GL_RGBA key to create texture, since it can take tex with dimentions that are not power of 2.
May be this is my problem?
Now about the second question: I'm trying to view tex in its native size. I'm only not very shure about that. I use w,h parameters passed to the glViewport( 0, 0, (GLint)w, (GLint)h ); and glwidth, glheight passed to the glOrtho( 0, glwidth, 0, glheight, -10000.0, 10000.0 ); And then trying to calculate sutable size for the quad to be created.
Is that right?
10x. Daniel

CWiC
05-11-2005, 10:48 PM
gluBuild2DMipmaps should not be a problem. Don't your background have black color as well? You must draw 'far' object (if any) first in order the transparency work.
And sorry, I don't see your image, but you always can press 'Print Screen', put image into raster editor and compare sizes of you drawed image and source texture, don't you?