Near and far inconsistency

I iterate and refactor the code. I ended up changing the function:

void setPerspective(float nearP = 0.1f, float farP = 1000.0f);

to

void setPerspective(float near = 0.1f, float far = 1000.0f);

and started getting a lot of weird mistakes 'missing ;'and 'missing )'.

It seems that nearand far #defined in windef.h. Fair; I will not use them.

But then I noticed in another header file:

void setPerspective(float fov, float aspect, float near, float far);

But I have no problems. Both of these header files have the same #includes ...

Any idea why I am getting problems in one, but not in the other? These are apparently not default settings. Is this some sort of random order #includethat might cause problems with one header file and not another?

+5
source share
4 answers

near far, , null #define,

#define near
#define far

- , .

void setPerspective(float nearP = 0.1f, float farP = 1000.0f);

nearP farP float . nearP near farP far, , float... ... , :

void setPerspective(float  = 0.1f, float  = 1000.0f);

, , float near far, ...

void setPerspective(float fov, float aspect, float near, float far);

void setPerspective(float fov, float aspect, float , float );

( ).

+7

, Windows.

- , , , Intel 8086, 80186 80286. . 16- . , near far .

, , - . Sane (80386 ) near far, .

, near far; , .

+4

: Near Far

, , , .

, , nearP farP.:)

+2

#include, #include, .

/* foo.cpp */
#include "bar.h"
#include "foo.h" // foo.h is influenced by whatever is brought in by bar.h

far near ( ) - , , 8086/88 ( MS-DOS Windows 3.x). - Windows , , #define far ( ).

In another note, you should usually use doublefor floating point numbers. The type is floatdesigned to store storage in large arrays (it may or may not be less double). On platforms with floating point numbers, the IEEE 754 is floatusually a 32-bit number: it has a 7-bit exponent and a 24-bit mantissa, which is pretty bad. While it doubleis a 64-bit type with 11-bit exponent and 52-bit mantissa: significantly better range and accuracy.

+2
source

All Articles