I wached Lesson 20 and managed to load the bmp, but the part with the PaddingBytes don't seem to change anything the dude is still fucked up and i have no idea where the error is.
Thanks in advance
P.S. thanks to Chili for the great tutorials.
need help with Lesson 20
need help with Lesson 20
- Attachments
-
- Sprites.zip
- (77.05 KiB) Downloaded 161 times
Re: need help with Lesson 20
Hey bro, welcome to the board. Nice to see someone who can follow the rules and post their cleaned solution when asking a question.
You have a bad habit of omitting the braces after control statements. For example:
In this case there is no problem, but it's not good practice at all. Want to see why?
Look at this other code snipped from your solution (LoadBmp).
In this case, the y loop will only repeat the following x loop, and the fseek function call will not be called until after the y loop has completed.
You don't get any bonus points for shaving a couple of lines off your code, so save yourself some headaches and use the braces everytime ({}).
You have a bad habit of omitting the braces after control statements. For example:
Code: Select all
void D3DGraphics::DrawSurface( int xoff,int yoff,int width,int height,const D3DCOLOR* surf )
{
for( int y = 0; y < height; y++ )
for( int x = 0; x < width; x++ )
PutPixel( x + xoff,y + yoff,surf[ x + y * width ] );
}
Look at this other code snipped from your solution (LoadBmp).
Code: Select all
for( int y = 0; y < infoHeader.height; y++ )
for( int x = 0; x < infoHeader.width; x++ )
{
Pixel24 pixel;
fread( &pixel,sizeof( pixel ),1,bmpFile );
surface[ x + y * infoHeader.width ] = D3DCOLOR_XRGB( pixel.red,pixel.green,pixel.blue );
}
fseek( bmpFile,nPaddingBytesPerRow,SEEK_CUR );
You don't get any bonus points for shaving a couple of lines off your code, so save yourself some headaches and use the braces everytime ({}).
Chili
Re: need help with Lesson 20
Thanks, this error was really unnecessary i will try to make the braces every time in the future