Page 1 of 2
Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 1:01 am
by abcdef4bfd
It displays me a black screen. Here's the code of the putpixel function:
Code: Select all
unsigned long pixindex=y*vbeMode.pitch+x*(vbeMode.bpp/8);
framebuffer[pixindex+0]=color;
framebuffer[pixindex+1]=color>>8;
framebuffer[pixindex+1]=color>>16;
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 2:05 am
by alexfru
I can come up with about 10 ways for how the above can be broken.
You need to debug your code to narrow down the problem.
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 2:13 am
by abcdef4bfd
alexfru wrote:I can come up with about 10 ways for how the above can be broken.
You need to debug your code to narrow down the problem.
OK, but can you see the problem in my code?
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 2:28 am
by alexfru
*The* problem? You're kidding, right? I just told you, there are many possible problems and you provided us with no information whatsoever to decide on which one it is. It can be bad values, bad memory mapping, code not even executing, etc. How can we know?
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 3:34 am
by abcdef4bfd
alexfru wrote:*The* problem? You're kidding, right? I just told you, there are many possible problems and you provided us with no information whatsoever to decide on which one it is. It can be bad values, bad memory mapping, code not even executing, etc. How can we know?
What info I need to provide?
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 5:32 am
by abcdef4bfd
Do not answer to me in 3 hours, I need to try to solve the problem myself.
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 7:10 am
by Ready4Dis
catnikita255 wrote:It displays me a black screen. Here's the code of the putpixel function:
Code: Select all
unsigned long pixindex=y*vbeMode.pitch+x*(vbeMode.bpp/8);
framebuffer[pixindex+0]=color;
framebuffer[pixindex+1]=color>>8;
framebuffer[pixindex+1]=color>>16;
Not very much info to go on, or any explanation of what's going wrong, but the most obvious thing is your doing pixindex+1 in both of the last two colors...
What is the address of framebuffer? Is it mapped in correctly (are you using virtual memory?) What is the value of color? There is a lot of missing information in order to give a real answer to this, but those are the first things I would check. Also, ensure you're creating a mode with LFB (linear frame buffer) otherwise this will not work very well.
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 10:24 am
by glauxosdever
Hi,
catnikita255 wrote:It displays me a black screen. Here's the code of the putpixel function:
Code: Select all
unsigned long pixindex=y*vbeMode.pitch+x*(vbeMode.bpp/8);
framebuffer[pixindex+0]=color;
framebuffer[pixindex+1]=color>>8;
framebuffer[pixindex+1]=color>>16;
Variable "framebuffer" is of what type? What does it equal? Where did you get it from? What does it represent? Please answer these questions for yourself and then try again to fix your code, when you have the answers you need.
Regards,
glauxosdever
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 11:55 am
by abcdef4bfd
Ready4Dis wrote:catnikita255 wrote:It displays me a black screen. Here's the code of the putpixel function:
Code: Select all
unsigned long pixindex=y*vbeMode.pitch+x*(vbeMode.bpp/8);
framebuffer[pixindex+0]=color;
framebuffer[pixindex+1]=color>>8;
framebuffer[pixindex+1]=color>>16;
Not very much info to go on, or any explanation of what's going wrong, but the most obvious thing is your doing pixindex+1 in both of the last two colors...
What is the address of framebuffer? Is it mapped in correctly (are you using virtual memory?) What is the value of color? There is a lot of missing information in order to give a real answer to this, but those are the first things I would check. Also, ensure you're creating a mode with LFB (linear frame buffer) otherwise this will not work very well.
THere's a old code, that's the new code.
Code: Select all
//This is from kmain
framebuffer=(uint32_t*)(*mbinfo).framebuffer_addr;
fbpitch=(*mbinfo).framebuffer_pitch;
fbbpp=(*mbinfo).framebuffer_bpp;
//and this is my putpixel
uint32_t fbpitch;
uint8_t fbbpp;
inline void putpixel(int x,int y,uint32_t color)
{
unsigned where = x*(fbbpp/8) + y*fbpitch;
framebuffer[where] = color & 255; // BLUE
framebuffer[where + 1] = (color >> 8) & 255; // GREEN
framebuffer[where + 2] = (color >> 16) & 255; // RED
}
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 11:59 am
by abcdef4bfd
glauxosdever wrote:Hi,
catnikita255 wrote:It displays me a black screen. Here's the code of the putpixel function:
Code: Select all
unsigned long pixindex=y*vbeMode.pitch+x*(vbeMode.bpp/8);
framebuffer[pixindex+0]=color;
framebuffer[pixindex+1]=color>>8;
framebuffer[pixindex+1]=color>>16;
Variable "framebuffer" is of what type? What does it equal? Where did you get it from? What does it represent? Please answer these questions for yourself and then try again to fix your code, when you have the answers you need.
Regards,
glauxosdever
1) uint32_t
2) Framebuffer address
3) From Multiboot info struct.
4) Framebuffer address
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 12:15 pm
by Roman
Why do you use uint32_t? Do you understand, what offset 'framebuffer[1]' will be from 'framebuffer[0]'?
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 12:46 pm
by abcdef4bfd
Roman wrote:Why do you use uint32_t? Do you understand, what offset 'framebuffer[1]' will be from 'framebuffer[0]'?
Is I need to use uint8_t?
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 1:15 pm
by glauxosdever
Hi,
You can use uint32_t only if you know that the width of each pixel is 32 bits. But you don't know it. GRUB may fall back to a 24-bit mode or a 16-bit mode or even a 8-bit palette mode if it can't find the desired mode. So uint8_t is the best solution, combined with other useful fields from multiboot info struct.
Regards,
glauxosdever
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 1:35 pm
by abcdef4bfd
Ok. And I fixed the problem, it was in the palette, it was old 16-color.
Re: Putting pixels in VBE 1024*768*32 mode is not working
Posted: Sun Oct 18, 2015 1:51 pm
by glauxosdever
Hi,
catnikita255 wrote:Ok. And I fixed the problem, it was in the palette, it was old 16-color.
Are the colors displayed correctly now?
16-color?! You were supposedly using VBE! Maybe you meant 16-bit?
Regards,
glauxosdever