Jump to content
  • Advertisement
Sign in to follow this  
nto

Depth problem with Point Sprites

This topic is 4422 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

Hi everyone! I've been reading this forum for a while now and usually I find what I'm looking for. But I'm having a problem with my point sprite implementation for a particle engine and was hoping some of you can help me :) I found a good example tutorial of how to use point sprites and tried messing around with it using the NeHe base code. It draws the points, but whenever I try to zoom in and out on them, the size doesn't change at all. I was thinking maybe I need to glEnable some other states in my current Init function:
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glEnable(GL_TEXTURE_2D);
My current function for drawing the point sprites is this:
void DrawPoints()
{
	float quadric[] = {0.0f, 0.0f, 0.0f};
	glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadric);
	
	float maxSize = 0.0f;
	glGetFloatv(GL_POINT_SIZE_MAX_ARB, &maxSize);
	glPointSize(maxSize);

	glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
	glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 0.0f );

	glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE  );

	glEnable(GL_POINT_SPRITE_ARB);

	glBegin(GL_POINTS); //just a bunch of random points
            glColor4f( 0.0f, 
                       0.4f, 
                       0.0f, 
                       1.0f );
		glVertex3f(0.0f, 0.0f, -6.0f);
		glVertex3f(1.0f, 0.0f, -6.0f);
		glVertex3f(-1.0f, 0.0f, -6.0f);
		glVertex3f(0.0f, 1.0f, -6.0f);
		glVertex3f(0.0f, -1.0f, -6.0f);

	glEnd();

	glDisable(GL_POINT_SPRITE_ARB);
}
I would really appreciate if someone could point out why it doesn't alter the size of the points when I zoom in and out of the scene using glTranslatef. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
The size doesn't change bacause you set the attenuation factors to 0:


float quadric[] = {0.0f, 0.0f, 0.0f};
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadric);

Share this post


Link to post
Share on other sites
My final attenuation factors was {1.0f, 0.0f, 0.01f}, it works really well for my particle engine but I don't know if this is how the pros would normally do it :p

I found the tutorial at:
http://data.plok.be/ExNihilo/pages/Tutorialpointsprite.htm

but in the meantime I also found this one:

http://www.codesampler.com/oglsrc/oglsrc_6.htm#ogl_point_sprites

It's basically the same thing and I think the first mentioned tutorial is better but it's nice to have an example :)

Share this post


Link to post
Share on other sites
I'm using the same tutorial as above but I have found a weird problem...

When I'm using attenuation I can only get a max size of 63, but without attenuation I have "unlimited" size...

Does anyone know how to remedy this? Is this a graphics driver issue ?

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!