Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Last Attacker

AT LAST!

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

Hey, those who remebered my post about the incompatible program? I''ve found the problem! It was the Perspective procedure I wrote. I got code from NeHe about a Perspective function or something, well I "optimised" it a little but I guess that optimisation doesn''t work on all machines (or I probably done something wrong). Well here it is :
void SetPerspective(double fovY, double aspect, double zNear, double zFar)
{
	//Calculate the distance from 0 of the y clipping plane. 

	//Basically trig to calculate position of clipper at zNear.

	
	//Note:	tan( double ) uses radiants but OpenGL works in 

	//		degrees so we convert degrees to radiant by 

	//		dividing by 180 then multiplying by pi.

	//

	//I changed "fovy / 180.0 * pi" to "fovy * 0.0017683882565766148418764862596946"

	//and "/ 2.0" to "* 0.5"

	//This saves 2 divides!

	double fH = TAN(fovY * 0.017453292519943295769236907684886) * zNear * 0.5;
	
	//Calculate the distance from 0 of the x clipping plane based 

	//on the aspect ratio.

	double fW = fH * aspect;
	
	//Finally call glFrustum, this is all gluPerspective does anyway!

	//This is why we calculate half the distance between the clipping 

	//planes - glFrustum takes an offset from zero for each clipping 

	//planes distance. (Saves another 2 divides)

	glFrustum(-fW, fW, -fH, fH, zNear, zFar);
}
I guess the problem might lie in "0.017453292519943295769236907684886" // Last Attacker \\---=( LA )=---// LA Extreme \\

ICQ Number : 120585863

E-mail: laextr@icqmail.com

Share this post


Link to post
Share on other sites
Advertisement
the question is: why "optimize" a function thats called about once in a week and make it unreadable. why not use *(pi/180) and let the compiler do the math on the constants.

basically youre saying that you wasted a lot of time tracking down an error that''s the result of a completely pointless "optimization"?

Share this post


Link to post
Share on other sites
everybody needs such a phase sooner or later, even if its just to learn why not to do it ,-) wait til its running too slow, find out why, start optimizing. optimizing every single line no matter what will only cause headache and cost a lot of time.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you''re using a good compiler, then the compiler will (very often) optimise out constant expressions for you. Go to a release build, switch on assembly output and check what the compiler has come up with.

Share this post


Link to post
Share on other sites
Thanks for being so understanding. :D

BTW. Even the floating point consistancy problem has vanished when I compiled under release mode @ home.

I''m SO HAPPY!!!


// Last Attacker \\---=( LA )=---// LA Extreme \\

ICQ Number : 120585863

E-mail: laextr@icqmail.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!