PDA

View Full Version : Describing a 2d objects visible space



Spaceaholic
06-17-2011, 09:09 AM
I am new to opengl, and am trying to develop a game that runs on the android OS... I am using 2d graphics and displaying them in 3d space(almost paper mario-ish)... right now I am describing a plane and drawing a texture to it to display my character, this leaves black around the outlines of my character where transparencies are in the bitmap.. so I have come to the conclusion that I need to describe the outline of my character in some sort of vector list, so as to only draw the character(leaving out the rectangular planes edges)... does anyone know how I would go about doing this? is there a program that would allow me to make a 2d object straight from the bitmap(im running ubuntu)? If my question seams unclear please tell me and I'll try and specify....
Thanks in advance... I really appreciate your help...

Alfonse Reinheart
06-17-2011, 10:04 AM
right now I am describing a plane and drawing a texture to it to display my character, this leaves black around the outlines of my character where transparencies are in the bitmap.. so I have come to the conclusion that I need to describe the outline of my character in some sort of vector list, so as to only draw the character(leaving out the rectangular planes edges)...

That's not a good conclusion. It makes more sense to fix the actual problem: the outline around the texture. This sounds like you may be using GL_CLAMP instead of GL_CLAMP_TO_EDGE for wrap modes.

Spaceaholic
06-17-2011, 10:39 AM
I like the idea of not having to further define my coords, just to specify, i have a rectangle composed of 4 points, two triangles, I draw a .PNG to the surface of the plane. the png contains transparent pixels throughout... By using the GL_CLAMP_TO_EDGE it will leave these pixels transparent allowing you to see though my character into the world behind it?

ZbuffeR
06-18-2011, 02:49 AM
Nothing to do with texture clamping.


Sound like a job for premultipled alpha : you have a black background for transparent texels right ?


Then change the blending to this :
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);



The theory :
<a href=http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]]>Tom Forsyth on premultiplied alpha</a>

Spaceaholic
06-18-2011, 10:50 AM
Thanks took me a little bit to work it all out but the blending worked...