Recent

Author Topic: How to determine the color depth of a monitor in Linux  (Read 2697 times)

KumurTash

  • Newbie
  • Posts: 2
How to determine the color depth of a monitor in Linux
« on: May 12, 2022, 03:47:11 pm »
for Windows, the color depth of the device can be determined using the winapi - GetDeviceCaps functi
Code: Pascal  [Select][+][-]
  1. var
  2.     dc:HDC;
  3.     depth:integer;    
  4. begin
  5.    dc := GetDC(0);  
  6.    depth := GetDeviceCaps(dc, PLANES) * GetDeviceCaps(dc, BITSPIXEL);
  7.    result:=depth;
  8. end;
  9.  


How to implement this in Linux?

PKTKS

  • New member
  • *
  • Posts: 9
Re: How to determine the color depth of a monitor in Linux
« Reply #1 on: May 23, 2022, 05:24:09 pm »
very simple and plain ...  using XLIB unit

Code: Pascal  [Select][+][-]
  1.  
  2.    PVisual = ^TVisual;
  3.    TVisual = record
  4.         ext_data : PXExtData;
  5.         visualid : TVisualID;
  6.         c_class : cint;
  7.         red_mask, green_mask, blue_mask : culong;
  8.         bits_per_rgb : cint;
  9.         map_entries : cint;
  10.      end;
  11.  
  12.  

Paul

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
Re: How to determine the color depth of a monitor in Linux
« Reply #2 on: May 23, 2022, 07:17:20 pm »
Use simply Lazarus TScreen....
Specialize a type, not a var.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: How to determine the color depth of a monitor in Linux
« Reply #3 on: May 23, 2022, 07:40:25 pm »
Use simply Lazarus TScreen....

Where exact??

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: How to determine the color depth of a monitor in Linux
« Reply #4 on: May 24, 2022, 04:33:38 pm »
Hi!

There is no info about the color depth in TScreen

Winni

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: How to determine the color depth of a monitor in Linux
« Reply #5 on: May 24, 2022, 05:19:59 pm »
very simple and plain ...  using XLIB unit

Does that report the properties of the monitor, or of the X11 server?

Does it work with Wayland?

Having said which... OP needs to give us /far/ more info about the system he expects to support. I had a nasty a few months ago where something ran fine on a Desktop Linux but not on an RPi because their homegrown window manager didn't report some metrics to Qt.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Seenkao

  • Hero Member
  • *****
  • Posts: 545
    • New ZenGL.
Re: How to determine the color depth of a monitor in Linux
« Reply #6 on: May 24, 2022, 09:26:19 pm »
Does it work with Wayland?
Вам нужно понять, что Wayland работает на OpenGL. Потому все запросы глубины цвета можно делать через OpenGL (не 100%, возможно Wayland ограничивает эту возможность).

google translate:
You need to understand that Wayland runs on OpenGL. Therefore, all color depth requests can be done through OpenGL (not 100%, perhaps Wayland limits this possibility).
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: How to determine the color depth of a monitor in Linux
« Reply #7 on: May 25, 2022, 09:05:54 am »
You need to understand that Wayland runs on OpenGL. Therefore, all color depth requests can be done through OpenGL (not 100%, perhaps Wayland limits this possibility).

It's not a requirement for Wayland to use OpenGL, neither for the clients nor the compositor.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: How to determine the color depth of a monitor in Linux
« Reply #8 on: May 25, 2022, 09:47:55 am »
It's not a requirement for Wayland to use OpenGL, neither for the clients nor the compositor.

Thanks for that.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Seenkao

  • Hero Member
  • *****
  • Posts: 545
    • New ZenGL.
Re: How to determine the color depth of a monitor in Linux
« Reply #9 on: May 25, 2022, 10:05:31 am »
It's not a requirement for Wayland to use OpenGL, neither for the clients nor the compositor.
I'm not talking about this, I'm talking about:
https://wayland.freedesktop.org/architecture.html#heading_toc_j_1
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: How to determine the color depth of a monitor in Linux
« Reply #10 on: May 25, 2022, 10:19:32 am »
It's not a requirement for Wayland to use OpenGL, neither for the clients nor the compositor.
I'm not talking about this, I'm talking about:
https://wayland.freedesktop.org/architecture.html#heading_toc_j_1

That says it uses DRI and

Quote
The client links to a rendering library such as OpenGL that knows how to program the hardware

Note the "such as" there, which is in line with what Sven said.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Seenkao

  • Hero Member
  • *****
  • Posts: 545
    • New ZenGL.
Re: How to determine the color depth of a monitor in Linux
« Reply #11 on: May 25, 2022, 10:46:03 am »
MarkMLl, я думаю что стоит читать полностью что пишут. Прочтите что написано в Hardware Enabling for Wayland.
Eng:
MarkMLl, I think it's worth reading in full what they write. Read what is written in Hardware Enabling for Wayland.

Quote
On the client side we've defined a Wayland EGL platform. In the EGL model, that consists of the native types (EGLNativeDisplayType, EGLNativeWindowType and EGLNativePixmapType) and a way to create those types. In other words, it's the glue code that binds the EGL stack and its buffer sharing mechanism to the generic Wayland API. The EGL stack is expected to provide an implementation of the Wayland EGL platform. The full API is in the wayland-egl.h header. The open source implementation in the mesa EGL stack is in platform_wayland.c.
same earlier
Quote
The client links to a rendering library such as OpenGL that knows how to program the hardware and renders directly into the buffer.
I think that everyone understands that an ordinary user is a client.

Думаю мне стоит извиниться! Это не отменяет сказанного вами!
Eng:
I think I should apologize! It doesn't change what you said!
« Last Edit: May 25, 2022, 10:50:52 am by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: How to determine the color depth of a monitor in Linux
« Reply #12 on: May 25, 2022, 10:58:54 am »
MarkMLl, I think it's worth reading in full what they write. Read what is written in Hardware Enabling for Wayland.

It says /typically/, in other words that's one of the possibilities and the one that the developers are using... or were using at the time that (undated) document was written. It then goes on to describe a client-side EGL stack and so on.

The Wp page says "EGL is an interface between Khronos rendering APIs (such as OpenGL, OpenGL ES or OpenVG) and the underlying native platform windowing system."

Again, I'd emphasise the "such as" there, and would point out that OpenGL is listed as one of the possibilities with- by implication- others being potentially usable.

I don't like saying this, but in English "typically" and "such as" do not imply any sort of definite relationship. "Pi is typically assumed to be 3.14159 in calculations, and approximations such as this don't detract from the accuracy of everyday maths" is an entirely correct statement.

Sven's right, as is usually the case.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: How to determine the color depth of a monitor in Linux
« Reply #13 on: May 25, 2022, 01:29:17 pm »
To quote from the Wayland FAQ:

Quote
What is the drawing API?

"Whatever you want it to be, honey". Wayland doesn't render on behalf of the clients, it expects the clients to use whatever means they prefer to render into a shareable buffer. When the client is done, it informs the Wayland server of the new contents. The current test clients use either Cairo software rendering, Cairo on OpenGL or hardware-accelerated OpenGL directly. Additionally, media frameworks can share their buffers directly with the server. As long as you have a userspace driver library that will let you render into a shareable buffer, you're good to go.

And further down:

Quote
Why does Wayland use EGL?

EGL is the only GL binding API that lets us avoid dependencies on existing window systems, in particular X. GLX obviously pulls in X dependencies and only lets us set up GL on X drawables. The alternative is to write a Wayland specific GL binding API, say, WaylandGL.

A more subtle point is that libGL.so includes the GLX symbols, so linking to that library will pull in all the X dependencies. This means that we can't link to full GL without pulling in the client side of X, so Weston uses OpenGL ES to render. This also enables Weston to run on GPUs which don't support the full OpenGL API.

As detailed above, clients are however free to use whichever rendering API they like.

My own, initial tests with Wayland (which were some years ago already) did not use any GL on the client side at all and used only what the Wayland protocol provided. See also this example.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6646
Re: How to determine the color depth of a monitor in Linux
« Reply #14 on: May 25, 2022, 02:57:47 pm »
Anyway, getting back to the original question: there's a field ColorDepth in TScreenInfo which appears to be applicable to AppInit() in multiple widget sets. I also don't know whether it applies to the entire screen (i.e. desktop etc.) or to a single monitor, and I don't know whether it reflects the properties of the card+driver or is updated in some way to describe the attached display device.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018