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;
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;
OK, but can you see the problem in my code?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.
What info I need to provide?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?
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...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.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;
THere's a old code, that's the new code.Ready4Dis wrote: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...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;
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.
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
}
1) uint32_tglauxosdever wrote:Hi,
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.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;
Regards,
glauxosdever
Is I need to use uint8_t?Roman wrote:Why do you use uint32_t? Do you understand, what offset 'framebuffer[1]' will be from 'framebuffer[0]'?
Are the colors displayed correctly now?catnikita255 wrote:Ok. And I fixed the problem, it was in the palette, it was old 16-color.