#### Archived

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

# AT LAST!

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

## 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 on other sites
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 on other sites
I''m sorry, it was when went through an Optimize "phase"! LOL!

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

ICQ Number : 120585863

E-mail: laextr@icqmail.com

##### 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 on other sites
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 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

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013300
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!