Sign in to follow this  
jake_Ghost

question about textures and rendering them

Recommended Posts

jake_Ghost    103
i am using some blizz UI textures for me UI cause i dont want to make my own, but i have a big problem with them. Sense all textures have to have certain resolutions, there are black spaces around what should be drawn, or this light green color. When i render these textures for my UI, i dont want to see the light green or the excess black around it. How do i do that? thx in advanced jake

Share this post


Link to post
Share on other sites
Kalidor    1087
Quote:
Original post by jake_Ghost
i am using some blizz UI textures for me UI cause i dont want to make my own, but i have a big problem with them. Sense all textures have to have certain resolutions, there are black spaces around what should be drawn, or this light green color. When i render these textures for my UI, i dont want to see the light green or the excess black around it. How do i do that?

thx in advanced jake


You can get around the power-of-two restriction by using the GL_ARB_texture_rectangle or GL_ARB_texture_non_power_of_two extensions. If you don't want to do that you would need to adjust your texture coordinates so that it fits to the part of the texture you need, or I suppose you could set the alpha for the unused part to 0 and alpha test them away, but that's probably not as efficient. The best way would most likely be using one of those extensions.

Share this post


Link to post
Share on other sites
jake_Ghost    103
ok thx ill try that for some of them but for the others i wont be able to. Lets say i have button thats like this...
_______
|/ |
| |
| |
|\ |
-------

lets say the parts to the left of the / and \ are ligh green space that i dont want rendered, how exactly would i find out those small points and either alpha them out or stencil them out. O and how would i get around doing that with rounded textures?

Share this post


Link to post
Share on other sites
MARS_999    1627
If you don't want to play around with extensions you can just use mipmaps. There is no restriction on POT with them. Just call gluBuild2DMipmaps instead of glTexImage2D. HTH

Share this post


Link to post
Share on other sites
jake_Ghost    103
i use mipmaps but the thing is that the textures have places on them that are black spaces that cannot be taken out because of the shape of it. So how do i not draw those places when rendering them?

Share this post


Link to post
Share on other sites
Kalidor    1087
Quote:
Original post by MARS_999
If you don't want to play around with extensions you can just use mipmaps. There is no restriction on POT with them. Just call gluBuild2DMipmaps instead of glTexImage2D. HTH


Ah yes, that should work, but it would also build all the mipmap levels and for a UI you only need one level since it will most likely not be moving relative to the camera. If you don't mind the wasted memory, which could get pretty large, than that is fine.

As for the circular buttons, you would need to use the alpha "trick" for that. It's commonly called color keying. OpenGL doesn't support it directly so you need to manually set an alpha value of zero for the color you specify to be transparent and then use alpha test to ignore zero alpha.

It's much easier to not bother with the color keying and just use an image format that includes alpha values. TGA and PNG are good ones. TGA is pretty simple to write your own loader but for PNG it's probably better to use an image loading library, many of which have been posted in threads all over these boards.

Share this post


Link to post
Share on other sites
MARS_999    1627
If I am reading what you are doing correctly you want a texture with lets say the right side is a button but the left side is nothing at all? and you want to get rid of that black space... You need to enable alpha testing and make sure you have a 32bit texture .tga or equivalent no .bmps, .jpgs ect... Then just add in this code..

//you may have to setup your glBlendFunc() to blend your images how you want
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glBindTexture(GL_TEXTURE_2D, texture[texture_index]);
//render here

glDisable(GL_ALPHA);
glDisable(GL_BLEND);







HTH

Share this post


Link to post
Share on other sites
jake_Ghost    103
well i got it to sort of work, but its not right. I can make the black disappear, but when the texture is over something else, it gets blended with it. How do i stop that from happening so that it will just get rid of the black, but not blend the rest of it.

Share this post


Link to post
Share on other sites
Kalidor    1087
You don't need blending enabled for simple transparency, only if you want something to look translucent. So you just enable alpha test, set alpha func to >0.0, and make sure the alpha where you don't want the texture to show is 0.0 and the alpha where you do want it to show is greater than 0.0

Share this post


Link to post
Share on other sites
zedzeek    529
* do NOT use mipmapping in a HUD
* as Kalidor saiz use alpha testing instead of blending
* create your textures with GL_NEAREST instead of linear
Quote:
there are black spaces around what should be drawn, or this light green color. When i render these textures for my UI, i dont want to see the light green or the excess black around it

* as others have said change the texture coords (with nearest + no mipmapping) + u will have no errors

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this