Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: "Transperent color" on the image and high quality textures

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Saint-Petersburg, Russia
    Posts
    12

    "Transperent color" on the image and high quality textures

    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
    Code :
    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.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: "Transperent color" on the image and high quality textures

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Saint-Petersburg, Russia
    Posts
    12

    Re: "Transperent color" on the image and high quality textures

    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

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: "Transperent color" on the image and high quality textures

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •