LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-15-2017, 07:45 AM   #1
Peewe
LQ Newbie
 
Registered: May 2017
Posts: 8

Rep: Reputation: Disabled
How to write to the screen


I'm trying to display a red screen in all/part of the screen for 1 frame exactly and I didn't really understand how to do it in the GUI server.
I succeed to print on my screen only from Ctrl+Alt+F1 mode using this code but the problems with this code where :
1. Now working on the GUI server.
2. Slow as hell.
So what am I looking for ? A way to print red screen/picture on the screen for exactly 1 frame ( that part really important! ) in the GUI server.
Another important thing is that I want to write directly to the monitor without using any application such ( OpenGL ). I'm using Xubuntu with Intel graphics 530 ( if needed I can switch to other kind of linux in order make it work ).
Thank you and have a nice day

this =
Quote:
#include <linux/fb.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

/* for tty */
#include <linux/kd.h>
#include <linux/vt.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#include <signal.h>

/* for fbdev */
#include <linux/fb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


int main()
{
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;

int fb_fd = open("/dev/fb0",O_RDWR);

//Get variable screen information
ioctl(fb_fd, FBIOGET_VSCREENINFO, &vinfo);
vinfo.grayscale=0;
vinfo.bits_per_pixel=32;
ioctl(fb_fd, FBIOPUT_VSCREENINFO, &vinfo);
ioctl(fb_fd, FBIOGET_VSCREENINFO, &vinfo);

ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo);

printf("%d x %d" , vinfo.xres , vinfo.yres );

long screensize = vinfo.yres_virtual * finfo.line_length;

uint8_t *fbp = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, (off_t)0);

int x,y;

for (x=0;x<vinfo.xres;x++)
{
for (y=0;y<vinfo.yres;y++)
{
long location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) + (y+vinfo.yoffset) * finfo.line_length;
*((uint32_t*)(fbp + location)) = (0xFF<<vinfo.red.offset) | (0x00<<vinfo.green.offset) | (0xFF<<vinfo.blue.offset);
}

}
return 0;
}

Last edited by Peewe; 05-15-2017 at 08:39 AM.
 
Old 05-15-2017, 07:57 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
C Programming Tutorial Change Console Background and Font Color

C Programming Changing the background colour

How To Change Text Color of C/C++ Console Application in Code::Blocks


that is what google told me.

one frame - what is the frame rate - just curious if the brain will even consciously pick that up. 'write little subliminal messages in your program ''' bleep bleep bleep

Last edited by BW-userx; 05-15-2017 at 08:00 AM.
 
Old 05-15-2017, 08:01 AM   #3
Peewe
LQ Newbie
 
Registered: May 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Google is great when you know what to ask.. Have you read my question? I asked how to write to the screen *without any application* like directly to the gpu.
 
Old 05-15-2017, 08:15 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Peewe View Post
Google is great when you know what to ask.. Have you read my question? I asked how to write to the screen *without any application* like directly to the gpu.
whence you figure out how to do it within a cli program then the next step would be what?
no application is imposable. that is what programming does it writes applications to do things. Even without human interaction.

directly to the gpu -> high-level -> assembly - > machine language

try something like this using key words and phrases - that is how google is written to work.

GUI server how to change screen color using what ever language you're writing it with.

a GUI Server is just a server that is now using a desktop/window manager to manipulate it to do what you want it (the server) to do.

GUI = Graphical user interface

Last edited by BW-userx; 05-15-2017 at 08:24 AM.
 
Old 05-15-2017, 08:18 AM   #5
Peewe
LQ Newbie
 
Registered: May 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
whence you figure out how to do it within a cli program then the next step would be what?
no application is imposable. that is what programming does it writes applications to do things. Even without human interaction.

try something like this using key words and phrases - that is how google is written to work.

GUI server how to change screen color using what ever language you're writing it with.
I really appreciate your answer but you can't tell me it's impossible I ask for one thing and you answer about other, there is a reason why I don't want application so.. If you can't answer me, thanks and I'll wait for someone else.
 
Old 05-15-2017, 08:34 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Peewe View Post
I really appreciate your answer but you can't tell me it's impossible I ask for one thing and you answer about other, there is a reason why I don't want application so.. If you can't answer me, thanks and I'll wait for someone else.
you said:
"Another important thing is that I want to write directly to the monitor without using any application such ( OpenGL )."


meaning that you're going to have to use a language to write an application to change the monitor color other than OpenGL ---
I gave you C - not OpenGL

you are I do believe not having a full grasp of understanding on what an (the term) application really is.

You need to brush up on your jargon as well. along with the sequence of events that need to take place before your monitor color changes colors. where that actually takes place. It, the GPU still needs an API that with that an application is written to make it do what you want it to show up on the screen you are writing to.

Component: GPU


You wanting to use your GPU specificity you're going to have to get details of what GPU it is and the resources it has for it to make it change a screen color to whatever colors it is capable of. So you can access your GPU directly.

or rewrite your question and use code blocks for your code. nevertheless you are still going to end up writing an application to get this done.

Last edited by BW-userx; 05-15-2017 at 08:37 AM.
 
Old 05-15-2017, 08:43 AM   #7
Peewe
LQ Newbie
 
Registered: May 2017
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
you said:
"Another important thing is that I want to write directly to the monitor without using any application such ( OpenGL )."


meaning that you're going to have to use a language to write an application to change the monitor color other than OpenGL ---
I gave you C - not OpenGL

you are I do believe not having a full grasp of understanding on what an (the term) application really is.

You need to brush up on your jargon as well. along with the sequence of events that need to take place before your monitor color changes colors. where that actually takes place. It, the GPU still needs an API that with that an application is written to make it do what you want it to show up on the screen you are writing to.

Component: GPU


You wanting to use your GPU specificity you're going to have to get details of what GPU it is and the resources it has for it to make it change a screen color to whatever colors it is capable of. So you can access your GPU directly.

or rewrite your question and use code blocks for your code. nevertheless you are still going to end up writing an application to get this done.
OK maybe I miss understood the meaning of Application, I'll tell you clearly what I need : I want to actually draw pixels on the monitor regardless
what the user does now with the computer. From what I read and from the example above I need to write to the framebuffer but I can't get the framebuffer of te X server ...
And as I say I have only integrated GPU of my Intel i7-6700 which is Intel Graphics 530

Last edited by Peewe; 05-15-2017 at 08:44 AM.
 
Old 05-15-2017, 09:10 AM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
The method you are using IS AN APPLICATION, just one you wrote, instead of written by another. Perhaps look at existing applications for getting and putting the background.

$ scrot
(get)

$ xsetbg file.png
(put)

$ apt-get source scrot
$ apt-get source xloadimage
$ apt-get source x11-xserver-utils

For things like xsetroot which can change your background color and stuff

$ xsetroot -solid rgb:00/00/44

The code is already out there, aka open source. It's not illegal to look at it (depending on where you live). YMMV
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I want to write a C program that draws lines on the screen with Ubuntu 14.04 MarkWyz Ubuntu 16 12-16-2014 05:46 PM
Write in one line output for file and screen satin132 Linux - Newbie 4 10-17-2011 08:54 AM
How to write a Putty screen in a browser Gideon1a Programming 5 07-07-2011 12:59 AM
How to change keyboard to write in english on login screen mazen97 Linux - Newbie 2 07-08-2009 03:49 AM
Best way to write images to screen? MaTrIx709 Programming 1 07-16-2005 09:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration