flat assembler
Message board for the users of flat assembler.

Index > Linux > drawing in linux gui?

Author
Thread Post new topic Reply to topic
ginere



Joined: 15 Oct 2017
Posts: 12
ginere
What do you guys use to draw gui in assembly (64bit linux)?

I use SDL but dislike needing it to link to c library. Is there a pure assembly lib or something to draw in X?
Post 19 Mar 2019, 22:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18198
Location: In your JS exploiting you and your system
revolution
If you want to use the "standard" decorations that follow the user's preferences then using the lib is certainly the easiest path.

But it is also possible to use assembly to interact with X, the DRI driver, or the frame buffer..
Post 19 Mar 2019, 22:24
View user's profile Send private message Visit poster's website Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 124
FlierMate
I don't see any colors by typing the following command by @revolution :

Code:
dd if=/dev/urandom of=/dev/fb0 bs=4096 count=10        


As a beginner, how do I display a GUI message box like that from Windows , on Linux?


Description: How to display a simple message box like this on Linux?
Filesize: 4.41 KB
Viewed: 320 Time(s)

Screenshot from 2021-10-14 19-29-32.png


Description: Unfortunately " Dialog" package is not GUI
Filesize: 18.68 KB
Viewed: 320 Time(s)

Screenshot from 2021-10-14 19-26-09.png


Post 14 Oct 2021, 11:34
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 140
Location: Russia
macomics
ginere wrote:
I use SDL but dislike needing it to link to c library. Is there a pure assembly lib or something to draw in X?
I'm afraid you can't do without interacting with functions written in C. Most graphics libraries provide just such an interface.
FlierMate wrote:
Code:
dd if=/dev/urandom of=/dev/fb0 bs=4096 count=10    
It's just that the video buffer is redrawn by another process at a higher speed.

FlierMate wrote:
As a beginner, how do I display a GUI message box like that from Windows , on Linux?

There are only 3 elements in the dialog box. What prevents them from just drawing. But the choice of how to do it is entirely your task. Unlike Windows, in Linux, the GUI is an add-on. And at what level to interact with it is entirely your choice.
Quote:
Image
Post 14 Oct 2021, 13:34
View user's profile Send private message Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 124
FlierMate
I am much interested in the direct video rendering, or frame buffer instead of X11.... Razz

Running the following command succeeded:
Code:
cp /dev/fb0 myfile    


....but the hexdump of myfile is full of 4MB of following:
Code:
00000000  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000010  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000020  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000030  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000040  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000050  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000060  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000070  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000080  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000090  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000A0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000B0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000C0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000D0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000E0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
000000F0  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................
00000100  00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00   ................    


This is the output after running @revolution's code:
Code:
boo@debian:~/fasm$ ./fasm.x64 ~/x.asm
flat assembler  version 1.73.28  (16384 kilobytes memory, x64)
4 passes, 1384 bytes.
boo@debian:~/fasm$ cd ..
boo@debian:~$ ./x
Open /dev/fb0 okay (3)
Read fb_fix_screeninfo okay
Read fb_var_screeninfo okay
frame buff  0
frame len   4325376
mem start   0
mem len     0
line length 5632
x visible   1366
y visible   768
x virtual   1366
y virtual   768
x offset    0
y offset    0
pixel bits  32
Everything is okay
boo@debian:~$ 
    


Noted the 1366x768 (32-bit ARGB) screen resolution.

Am I missing anything because I don't see colors on screen nor I see any captured graphics pattern in "myfile".

Thanks @macomics for the helpful introduction, so now I know X11 is the display server API.
Post 14 Oct 2021, 14:20
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18198
Location: In your JS exploiting you and your system
revolution
You probably need to be in virtual console display mode.

If you see the X windowing then fb0 is not active so the output is not being displayed.

On my system I can use CTRL-ALT-F1 to open a virtual console. Then fb0 is active.
Post 14 Oct 2021, 14:26
View user's profile Send private message Visit poster's website Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 124
FlierMate
revolution wrote:
You probably need to be in virtual console display mode.

If you see the X windowing then fb0 is not active so the output is not being displayed.

On my system I can use CTRL-ALT-F1 to open a virtual console. Then fb0 is active.


You're right, on Debian 11 (my system), I press Ctrl-Alt-F3 for virtual console. And then Ctrl+Alt+F2 to return to desktop screen.

I managed to convert portion of raw image (screenshot) of /dev/fb0 while I was at virtual console, to JPG, using online converter. (Edit: I think that is a wrong image, but they look similar anyway Surprised )

Thanks for pointing at the right direction! [/b]


Description: Yes, I get random colors!
Filesize: 43.38 KB
Viewed: 284 Time(s)

fb.jpg


Post 14 Oct 2021, 14:45
View user's profile Send private message Visit poster's website Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 124
FlierMate
So this is it!

Using a utility called fbgrab: https://github.com/GunnarMonell/fbgrab

Credit: angch (not on this forum)


Description: Screenshot from frame buffer
Filesize: 408.56 KB
Viewed: 273 Time(s)

fb.png


Post 14 Oct 2021, 17:04
View user's profile Send private message Visit poster's website Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 462
Ali.Z
FlierMate wrote:
You're right, on Debian 11 (my system), I press Ctrl-Alt-F3 for virtual console. And then Ctrl+Alt+F2 to return to desktop screen.


I think something is wrong with your installation, unless you changed some of config files.
by default debian assign tty7 (ctrl-alt-f7) to whatever desktop environment installed, and tty1-tty6 just plain console. Rolling Eyes

_________________
Asm For Wise Humans
Post 14 Oct 2021, 21:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18198
Location: In your JS exploiting you and your system
revolution
FlierMate wrote:
Using a utility called fbgrab: https://github.com/GunnarMonell/fbgrab
You don't need any fancy tools.

dd can copy /dev/fb0 to a file.
Code:
dd if=/dev/fb0 of=/path/to/file bs=4096 count=10    
Post 14 Oct 2021, 21:08
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 140
Location: Russia
macomics
revolution wrote:
You don't need any fancy tools.
This utility seems to form an image file from the data immediately. I suspect that it is necessary to say about the very basics. You have all the help built into the operating system. Try each of these commands, for example:
Code:
man dd
info X    
Post 14 Oct 2021, 22:11
View user's profile Send private message Reply with quote
st



Joined: 12 Jul 2019
Posts: 49
Location: Russia
st
macomics wrote:
I'm afraid you can't do without interacting with functions written in C. Most graphics libraries provide just such an interface.

Perhaps it is possible to connect (via sys_connect) to "wayland-0" or X's socket but that would be reinventing libwayland-client.so or libxcb.so.
Post 16 Oct 2021, 14:16
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 140
Location: Russia
macomics
st wrote:
Perhaps it is possible to connect (via sys_connect) to "wayland-0" or X's socket but that would be reinventing libwayland-client.so or libxcb.so.

So if you really want to, then you can slurp soup with a fork.
Post 16 Oct 2021, 15:56
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1637
Furs
st wrote:
macomics wrote:
I'm afraid you can't do without interacting with functions written in C. Most graphics libraries provide just such an interface.

Perhaps it is possible to connect (via sys_connect) to "wayland-0" or X's socket but that would be reinventing libwayland-client.so or libxcb.so.
I mean they are open source. Nothing special or magical.
Post 17 Oct 2021, 19:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.