Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 2:17 pm
I do not see your attempts to do so.octacone wrote:No hope. This is just impossible to solve.
The Place to Start for Operating System Developers
http://f.osdev.org/
I do not see your attempts to do so.octacone wrote:No hope. This is just impossible to solve.
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;
}
}
}
}
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
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
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
Code: Select all
void MemoryCopy(string source, string destination, int bytes)
{
for(int i = 0; i < bytes; ++i)
*(destination + i) = *(source + i);
}
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); }
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;
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)
It is much more complex than that.azblue wrote: It is simply copying memory. I do not understand what could be the problem.