0

SFML allows the programmer to specify a 'bitsperpixel' value using sf::VideoMode.

It also allows the programmer to specify a 'depth' value using sf::ContextSettings.

What is the difference between these things, or are they the same?

FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225

2 Answers2

3

They are two distinct parameters.

bitsPerPixel represents the bit depth, also know as the color depth. Usually you would use a value of 32 here to have good rendering.

And the depth is defined as follow in the documentation:

All these settings have no impact on the regular SFML rendering (graphics module) – except the anti-aliasing level, so you may need to use this structure only if you're using SFML as a windowing system for custom OpenGL rendering.

The depthBits and stencilBits members define the number of bits per pixel requested for the (respectively) depth and stencil buffers.

So you don't have to care about this depth parameter if you don't directly use OpenGL.

Hiura
  • 3,500
  • 2
  • 20
  • 39
  • I am using OpenGL. What does it mean by depth then, if that is not the same as color depth? – FreelanceConsultant Jun 24 '13 at 09:44
  • 1
    As the documentation states, it's related to the depth buffer. If you don't do any kind of 3D you don't need that. Otherwise, have a look at this nice [tutorial](http://www.arcsynthesis.org/gltut/Positioning/Tut05%20Overlap%20and%20Depth%20Buffering.html). – Hiura Jun 24 '13 at 19:58
  • I forgot about this question, but the update I will now make is the depth buffer is not the same as the color buffer, which has what is often refereed to as "color depth". Search for OpenGL color depth and depth buffer. See also, stencil buffer, accumulation buffer etc. – FreelanceConsultant Jul 20 '13 at 23:33
  • 32 bits is intended for 8 bits * R,G,B,A, right? Is there an RGB that uses all of 32 bits? I loved the idea of using opacity in my window and seeing the desktop behind it, but I've never successfully done it. If I understand correctly, you'd have to capture the desktop somehow and composite them yourself. So, if you're not using the alpha channel, or you're using it but assigning the max value anyway, you shouldn't lose anything switching to 24 bits. Tight packing and a saved byte should help speed and memory, but factors like alignment could slow it down, I can't be sure. – John P Jun 11 '22 at 00:40
-1

I believe they are the same in SFML if I recall correctly, however I may be wrong. Look here for more info: http://sfml-dev.org/documentation/2.0/

hCon
  • 207
  • 1
  • 7
  • 19