Page 1 of 3
[Solved] put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 10:13 am
by Octacone
Hey people!
I am working on my graphical terminal. I need some help with terminal scrolling.
1.I need to create a temporary buffer
2.I need to copy selected area of pixels from my main linear frame buffer to my temporary frame buffer.
3.I need to repaint the entire screen with back color.
4.I need to copy my temporary buffer back to my main frame buffer minus wanted Y coordinate.
Now my problems are:
1.How do I reverse engineer this method to get pixel method. So I want to get selected area of pixels from my frame buffer and copy that to another buffer.
Code: Select all
unsigned location = (position.Y * screenWidthBGA * 4) + (position.X * 4);
linearFrameBufferBGA[location + 0] = 0;
linearFrameBufferBGA[location + 2] = color.R;
linearFrameBufferBGA[location + 1] = color.G;
linearFrameBufferBGA[location + 0] = color.B;
2.Once I get my get pixel method working how do I put all those pixels back minus wanted scroll up value?
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 10:21 am
by Octacone
Also I have SSE2 enabled.
Working memory copy and memory set.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 10:40 am
by Octacone
I tried something like this and it didn't work.
Code: Select all
unsigned location = (10 * screenWidthBGA * 4) + (10 * 4);
unsigned locationNew = (9 * screenWidthBGA * 4) + (9 * 4);
char nfb = linearFrameBufferBGA[location];
linearFrameBufferBGA[locationNew] = nfb;
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 10:42 am
by Octacone
Topic.BringToFront();
It did but the pixel is blue instead of white.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 10:57 am
by Octacone
Anybody??
Talking to myself in here.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:10 am
by Ch4ozz
Save only the text and redraw the text when scrolling.
For some better scrolling smoothness you *might* add 2 buffers (or enlarge the main buffer) to store some pixels there. (Instead of text only)
What you need for scrolling buffers is called "memmove"
EDIT: Your code in post 1 looks wrong, one of the colors should actually be at offset 3 (I guess alpha)
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:16 am
by Octacone
Ch4ozz wrote:Save only the text and redraw the text when scrolling.
For some better scrolling smoothness you *might* add 2 buffers (or enlarge the main buffer) to store some pixels there. (Instead of text only)
What you need for scrolling buffers is called "memmove"
EDIT: Your code in post 1 looks wrong, one of the colors should actually be at offset 3 (I guess alpha)
Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:23 am
by Octacone
Update: I have Memory Move function ready.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:28 am
by Ch4ozz
octacone wrote:Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
Of course your code works fine, because the alpha part is never rendered and the CPU/GPU does not care what value it is.
Your alpha value never gets set and is therefore simply random trash (Usually 0 on VMs).
Memmove is a function which can copy memory into the same region your copying from.
Im using something along this to copy a region from Buffer 1 into Buffer 2:
Code: Select all
for(i = center_y; i < center_y + new_h; i++)
blit(ctrl.buffer + (i*w*width + center_x*width), img_scaled->data + (i-center_y)*img_scaled->width*width + offset_x*width + offset_y*img_scaled->width*width, new_w*width);
blit() is a function like memcpy which also handles transparency
width is 4 bytes for 32 bit ARGB layout (4 colors)
center_x/y is the position where we copy into the new buffer
offset_x/y is the position we copy from
w/h is the width/height of the destination buffer
new_w/new_h is the width/height of the source buffer
@shmx
Already said that in first post but looks like octacone wants to copy memory that badly
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:32 am
by shmx
Make emulation of a text video memory. When scrolling completely redraw all text in the window from the text memory from the desired position. This is a very simple and effective method. I do not recommend copying video memory for these purposes, it is not optimized for reading.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:35 am
by Octacone
shmx wrote:Make emulation of a text video memory. When scrolling completely redraw all text in the window from the text memory from the desired position. This is a very simple and effective method. I do not recommend copying video memory for these purposes, it is not optimized for reading.
How do I do that? I only have a single linear frame buffer that contains all the pixels. I need to get all the pixels and copy them to the same location but different y coordinate.
The problem is: getting pixels from selected region.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:36 am
by Octacone
Ch4ozz wrote:octacone wrote:Code from my first post works just fine, it weird because of BGA.
I just want to know how to get a pixel from one specific location, not set pixel but get that pixel from coordinates.
Memory move you say, are you referring to: (source, destination, size) memory function?
Of course your code works fine, because the alpha part is never rendered and the CPU/GPU does not care what value it is.
Your alpha value never gets set and is therefore simply random trash (Usually 0 on VMs).
Memmove is a function which can copy memory into the same region your copying from.
Im using something along this to copy a region from Buffer 1 into Buffer 2:
Code: Select all
for(i = center_y; i < center_y + new_h; i++)
blit(ctrl.buffer + (i*w*width + center_x*width), img_scaled->data + (i-center_y)*img_scaled->width*width + offset_x*width + offset_y*img_scaled->width*width, new_w*width);
blit() is a function like memcpy which also handles transparency
width is 4 bytes for 32 bit ARGB layout (4 colors)
center_x/y is the position where we copy into the new buffer
offset_x/y is the position we copy from
w/h is the width/height of the destination buffer
new_w/new_h is the width/height of the source buffer
@shmx
Already said that in first post but looks like octacone wants to copy memory that badly
I don't have "blit". That design does not fit. I still can't read pixels from my buffer. I need to read all the pixels from selected area and then copy them to the same buffer but different y coordinate.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:47 am
by shmx
The terminal contains only text?
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:49 am
by Octacone
shmx wrote:The terminal contains only text?
Terminal contains only pixels, I might add some graphics later to it.
In my case text == bitmap arrays == pixels.
Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:53 am
by shmx
If only the text, then it is very simple.