About ZBuffer ( probably a stupid question)

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
slavaxd
Posts: 1
Joined: January 26th, 2023, 1:35 pm

About ZBuffer ( probably a stupid question)

Post by slavaxd » January 26th, 2023, 1:38 pm

In the series the ZBuffer class has an overload for the At method:

Code: Select all

	float& At(int x, int y)
	{
		assert(x >= 0);
		assert(x < width);
		assert(y >= 0);
		assert(y < height);
		return pBuffer[y * width + x];
	}
	const float& At(int x, int y) const
	{
		return const_cast<ZBuffer*>(this)->At(x, y);
	}
My question is why is it using const_cast<Zbuffer> rather than const_cast<float*>? I mean, the point of this is to return a CONST reference to the pbuffer amiright?

Post Reply