I do not see your attempts to do so.octacone wrote:No hope. This is just impossible to solve.
[Solved] put pixel to get pixel and gui scroll
Re: put pixel to get pixel and gui scroll
Re: put pixel to get pixel and gui scroll
Why do you want intermediate buffer? Is not it easier to copy to the right place at once?octacone wrote:How do I capture 1600x900x32 area of pixels, save those pixels to a buffer and shift their y coordinate by wanted amount?
Code: Select all
void CopyMem(const DWORD* InBuf, DWORD* OutBuf, size_t Len, int Dir)
{
size_t i;
if(Dir == 0)
{
for(i = 0; i < Len; i++, OutBuf++, InBuf++)
*OutBuf = *InBuf;
}
else
{
for(i = 0; i < Len; i++, OutBuf--, InBuf--)
*OutBuf = *InBuf;
}
}
void CopyRectangle(const DWORD *InVideoBuffer, DWORD *OutVideoBuffer,
int X1, int Y1, int X2, int Y2, int Width, int Height,
int Buffer1_Pitch, int Buffer2_Pitch)
{
const DWORD* vbuf1;
DWORD* vbuf2;
int y = Height;
if(Y2 <= Y1)
{
if(X2 <= X1)
{
vbuf1 = InVideoBuffer + X1 + Y1 * Buffer1_Pitch;
vbuf2 = OutVideoBuffer + X2 + Y2 * Buffer2_Pitch;
while(y-- > 0)
{
CopyMem(vbuf1, vbuf2, Width, 0);
vbuf1 += Buffer1_Pitch;
vbuf2 += Buffer2_Pitch;
}
}
else
{
vbuf1 = InVideoBuffer + X1 + Width - 1 + Y1 * Buffer1_Pitch;
vbuf2 = OutVideoBuffer + X2 + Width - 1 + Y2 * Buffer2_Pitch;
while(y--)
{
CopyMem(vbuf1, vbuf2, Width, 1);
vbuf1 += Buffer1_Pitch;
vbuf2 += Buffer2_Pitch;
}
}
}
else
{
if(X2 <= X1)
{
vbuf1 = InVideoBuffer + X1 + (Y1 + Height - 1) * Buffer1_Pitch;
vbuf2 = OutVideoBuffer + X2 + (Y2 + Height - 1) * Buffer2_Pitch;
while(y--)
{
CopyMem(vbuf1, vbuf2, Width, 0);
vbuf1 -= Buffer1_Pitch;
vbuf2 -= Buffer2_Pitch;
}
}
else
{
vbuf1 = InVideoBuffer + X1 + Width - 1 + (Y1 + Height - 1) * Buffer1_Pitch;
vbuf2 = OutVideoBuffer + X2 + Width - 1 + (Y2 + Height - 1) * Buffer2_Pitch;
while(y--)
{
CopyMem(vbuf1, vbuf2, Width, 1);
vbuf1 -= Buffer1_Pitch;
vbuf2 -= Buffer2_Pitch;
}
}
}
}
Pitch - logical buffer width (may be more than simply width).
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: put pixel to get pixel and gui scroll
Just as a note, you should NEVER read from the VESA framebuffer. Writing is slow enough. Reading is even slower. Allocate a back buffer in normal RAM, and read from there and operate how you like on it. When all drawing is done, you memcpy() the back buffer to the hardware framebuffer.
Double Buffering
Double Buffering
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: put pixel to get pixel and gui scroll
I have to admit something... That was one of the easiest to understand tutorials I've ever seen. for the author.omarrx024 wrote:Just as a note, you should NEVER read from the VESA framebuffer. Writing is slow enough. Reading is even slower. Allocate a back buffer in normal RAM, and read from there and operate how you like on it. When all drawing is done, you memcpy() the back buffer to the hardware framebuffer.
Double Buffering
I did not know that it was that bad. I guess I will have to implement double buffering first and the get come in here.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
Is this how double buffering is supposed to look like?
Code: Select all
backVideoBuffer = ((uint32_t*) (Malloc(5760000))); //When I do this my mode does not get set
backVideoBuffer = ((uint32_t*) (Malloc(576000))); //When I do is with one less zero I get those artifacts
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
Looks like broken memory management if the usage of the buffer is right.
Anyways, you should clear the buffer before using it because memory is usually not 0
Anyways, you should clear the buffer before using it because memory is usually not 0
Re: put pixel to get pixel and gui scroll
Broken memory management. RIP!!!Ch4ozz wrote:Looks like broken memory management if the usage of the buffer is right.
Anyways, you should clear the buffer before using it because memory is usually not 0
What could it be: Malloc or MemoryCopy?
Here is my memory copy function:
Code: Select all
void MemoryCopy(string source, string destination, int bytes)
{
for(int i = 0; i < bytes; ++i)
*(destination + i) = *(source + i);
}
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
The probem is usually a wrong implementation of malloc.octacone wrote:Broken memory management. RIP!!!
What could it be: Malloc or MemoryCopy?
Here is my memory copy function:Code: Select all
void MemoryCopy(string source, string destination, int bytes) { for(int i = 0; i < bytes; ++i) *(destination + i) = *(source + i); }
Your memcpy is the slowest possible method btw (moving windows will lag like hell with this thing)
Re: put pixel to get pixel and gui scroll
I don't understand how you can possibly know how to plot pixels but not get them. You read the locations you would otherwise write.octacone wrote:I only know how to put pixels using:shmx wrote:It is simply copying memory. I do not understand what could be the problem.octacone wrote:The problem is: getting pixels from selected region.I don't know how to get specific pixels from wanted location.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;
Re: put pixel to get pixel and gui scroll
Yeah I know. I tweaked it up a bit.Ch4ozz wrote:The probem is usually a wrong implementation of malloc.octacone wrote:Broken memory management. RIP!!!
What could it be: Malloc or MemoryCopy?
Here is my memory copy function:Code: Select all
void MemoryCopy(string source, string destination, int bytes) { for(int i = 0; i < bytes; ++i) *(destination + i) = *(source + i); }
Your memcpy is the slowest possible method btw (moving windows will lag like hell with this thing)
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
[Solved] put pixel to get pixel and gui scroll
It is much more complex than that.azblue wrote: It is simply copying memory. I do not understand what could be the problem.
Does not matter any more, topic closed.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader