Jump to content
  • Advertisement
Sign in to follow this  
milankoko

Rendering points using GL_POINT_SPRITE_ARB

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem while trying to render points with GL_POINT_SPRITE_ARB. I am using a simple texture that contains a white circle on black background and I cannot successfully blend these circles together to get proper color. I do not render pixels from back to front since there are too many to sort. Rendering is entirely point based. Here is the code(.NET, Tao framework): //texture loading Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB8, textureImage[0].Width, textureImage[0].Height, 0, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, bitmapData.Scan0); //right Z-order Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthMask(Gl.GL_FALSE); //blending Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_DST_COLOR); Gl.glPointParameterfvARB(Gl.GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic); Gl.glPointSize(100); Gl.glPointParameterfvARB(Gl.GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic); Gl.glPointParameterfARB(Gl.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f); float maxSize = 0.0f; Gl.glGetFloatv(Gl.GL_POINT_SIZE_MAX_ARB,out maxSize); Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MIN_ARB, 1.0f); Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MAX_ARB, maxSize); Gl.glTexEnvf(Gl.GL_POINT_SPRITE_ARB, Gl.GL_COORD_REPLACE_ARB, Gl.GL_TRUE); // Render point sprites... Gl.glEnable(Gl.GL_POINT_SPRITE_ARB); Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]); Gl.glCallList(myDisplList); Gl.glDisable(Gl.GL_POINT_SPRITE_ARB); Screenshot of application: http://img2.freeimagehosting.net/uploads/d940648d8d.png or http://img117.imageshack.us/my.php?image=screen1wi8.png Texture used: http://img2.freeimagehosting.net/uploads/3b01eaa8fa.jpg or http://img299.imageshack.us/my.php?image=circlete5.png What I want to achieve is that all circles will be of same shade of red, no matter if there are some circles behind it. I also do not want those nasty edges to show. What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
I guess it's because of the blend function you chose.
Try Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA) instead.

Share this post


Link to post
Share on other sites
It's actually worse using that blending option because it doesn't make black background transparrent. See for yourself:

http://img90.imageshack.us/my.php?image=screen2fu0.png

Share this post


Link to post
Share on other sites
Oh, sry, I didn't notice the texture has no alpha channel.

In that case you could try loading your texture using GL_ALPHA instead of GL_RGB8. That should tell OpenGL to only take the red channel of your texture data and treat it as alpha channel.
Although I don't know, if it works that way. It's been some time since I've done anything involving opengl textures [wink]

If that doesn't work, you could save your texture image as 8-bit-greyscale and replace both GL_RGB with GL_ALPHA.

Share this post


Link to post
Share on other sites
thanks! I really had a nasty bug in there so my loaded image was not recognized properly:

BitmapData bitmapData = textureImage[0].LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppArgb);

Yes, I locked it at 24bppArgb instead of 32 and therefore everything was messed up. Spent whole day butchering the code to finally find this one.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!